Skip to content
Browse files

Update to new format of primary index keys

Change-Id: I346a96c25ef51d09539a4ebdbc84c1a1f5683ad9
Reviewed-on: http://review.couchbase.org/19122
Tested-by: Aaron Miller <apage43@ninjawhale.com>
Reviewed-by: Aaron Miller <apage43@ninjawhale.com>
  • Loading branch information...
1 parent ed238f0 commit 8b33a414af0de5f8d884e40e15daba548dd97cbc @snej snej committed with apage43
Showing with 12 additions and 5 deletions.
  1. +8 −1 src/view_indexer.c
  2. +4 −4 view_format.md
View
9 src/view_indexer.c
@@ -14,8 +14,15 @@ static void view_reduce(char *dst, size_t *size_r, nodelist *leaflist, int count
static void view_rereduce(char *dst, size_t *size_r, nodelist *leaflist, int count);
+static inline sized_buf getJSONKey(sized_buf buf) {
+ assert(buf.size >= 2);
+ sized_buf key = {buf.buf + 2, get_16(buf.buf)};
+ assert(key.size > 0 && key.size < buf.size - 2);
+ return key;
+}
+
static int keyCompare(const sized_buf *k1, const sized_buf *k2) {
- return CollateJSON(*k1, *k2, kCollateJSON_Unicode);
+ return CollateJSON(getJSONKey(*k1), getJSONKey(*k2), kCollateJSON_Unicode);
}
View
8 view_format.md
@@ -16,11 +16,11 @@ The underlying b-tree format is the same as already used in CouchStore.
In leaf nodes, `KeyValues` have the following format:
* `Key`:
- * `KeyId` -- A JSON string -- The JSON is the format of `[EmittedJSONKey, JSONQuotedDocId]`.
- The `EmittedJSONKey` is the JSON value emitted by the emit function. The `JSONQuotedDocId` is the docId JSON-quoted and escaped.
-
+ * `EmittedJsonKeyLength` -- 16bit integer
+ * `EmittedJSONKey` -– JSON -– The key emitted by the map function
+ * `UnquotedDocId` –- String -– The raw doc ID (occupies the remaining bytes)
* Value:
- * `PartitionId` -- 16bit Integer -- This is the partitionId (vbucket) from which this document id maps to.
+ * `PartitionId` -- 16bit integer -- This is the partitionId (vbucket) from which this document id maps to.
* 1 to infinity `JSONStringValue`s -- These are all the values that were emitted for this `EmittedJSONKey`.
Each `JSONStringValue` is of the form:
* `ValueLength` -- 24bit unsigned integer

0 comments on commit 8b33a41

Please sign in to comment.
Something went wrong with that request. Please try again.