2016-07-13 1 views
1

etcd 3.0.xでは、新しいAPIが導入されました。一つのことは、RangeRequestオブジェクトで私には不明です。 description of the property range_endでは、それは言う:etcd v3.0.xでは、どのプレフィックスを持つすべてのキーを要求するのですか?

RANGE_ENDが指定されたキーより1ビット大きい場合、 その後、範囲要求は、プレフィックス(指定したキー)を持つすべてのキーを取得します。ここで

いくつかのコンテキストを提供するための完全なテキストです:

// key is the first key for the range. If range_end is not given, the request only looks up key. 
bytes key = 1; 
// range_end is the upper bound on the requested range [key, range_end). 
// If range_end is '\0', the range is all keys >= key. 
// If the range_end is one bit larger than the given key, 
// then the range requests get the all keys with the prefix (the given key). 
// If both key and range_end are '\0', then range requests returns all keys. 
bytes range_end = 2; 

私の質問は:RANGE_ENDが指定されたキーより1ビット大きい場合

とはどういう意味ですか

range_endkeyよりも1ビット長くなっていますか?整数として解釈されるとき、それはkey+1でなければならないのでしょうか?後者の場合は、どのエンコーディングですか?

答えて

0

keyの最後のバイトよりも1ビット大きい。
たとえば、keyが「09903x」の場合、range_endは「09903y」になります。
etcdサーバーに送信するときには、のバイトストリームしかないので、ドライバのシリアル化に注意して、range_endの値を決定してください。

0

この混乱を解決するPRがあります。

RANGE_ENDがキープラス1である場合(例えば、 "AA" 1 == "AB"、 "\のXFF" 1 == "B")、 は、範囲の要求がで始まるすべてのキーを取得しますキー。

UPDATE:

var key = "/aaa" 
var range_end = "/aa" + String.fromCharCode("a".charCodeAt(2) + 1); 
関連する問題