Browse Source

Merge pull request #5454 from gyuho/document_issue_5401

etcdserverpb: document how to prefix, range query
Gyu-Ho Lee 9 years ago
parent
commit
5ab27e99f2

+ 1 - 1
Documentation/dev-guide/api_reference_v3.md

@@ -553,7 +553,7 @@ Empty field.
 | Field | Description | Type |
 | Field | Description | Type |
 | ----- | ----------- | ---- |
 | ----- | ----------- | ---- |
 | key | key is the first key for the range. If range_end is not given, the request only looks up key. | bytes |
 | key | key is the first key for the range. If range_end is not given, the request only looks up key. | bytes |
-| range_end | range_end is the upper bound on the requested range [key, range_end). If range_end is '\0', the range is all keys >= key. | bytes |
+| range_end | 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 |
 | limit | limit is a limit on the number of keys returned for the request. | int64 |
 | limit | limit is a limit on the number of keys returned for the request. | int64 |
 | revision | revision is the point-in-time of the key-value store to use for the range. If revision is less or equal to zero, the range is over the newest key-value store. If the revision has been compacted, ErrCompaction is returned as a response. | int64 |
 | revision | revision is the point-in-time of the key-value store to use for the range. If revision is less or equal to zero, the range is over the newest key-value store. If the revision has been compacted, ErrCompaction is returned as a response. | int64 |
 | sort_order | sort_order is the order for returned sorted results. | SortOrder |
 | sort_order | sort_order is the order for returned sorted results. | SortOrder |

+ 3 - 0
etcdserver/etcdserverpb/rpc.pb.go

@@ -201,6 +201,9 @@ type RangeRequest struct {
 	Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
 	Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
 	// range_end is the upper bound on the requested range [key, range_end).
 	// 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 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.
 	RangeEnd []byte `protobuf:"bytes,2,opt,name=range_end,json=rangeEnd,proto3" json:"range_end,omitempty"`
 	RangeEnd []byte `protobuf:"bytes,2,opt,name=range_end,json=rangeEnd,proto3" json:"range_end,omitempty"`
 	// limit is a limit on the number of keys returned for the request.
 	// limit is a limit on the number of keys returned for the request.
 	Limit int64 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"`
 	Limit int64 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"`

+ 3 - 0
etcdserver/etcdserverpb/rpc.proto

@@ -166,6 +166,9 @@ message RangeRequest {
   bytes key = 1;
   bytes key = 1;
   // range_end is the upper bound on the requested range [key, range_end).
   // 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 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;
   bytes range_end = 2;
   // limit is a limit on the number of keys returned for the request.
   // limit is a limit on the number of keys returned for the request.
   int64 limit = 3;
   int64 limit = 3;