You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2019/10/28 12:24:56 UTC

[GitHub] [couchdb-documentation] garrensmith commented on a change in pull request #410: add rfc for map indexes

garrensmith commented on a change in pull request #410: add rfc for map indexes
URL: https://github.com/apache/couchdb-documentation/pull/410#discussion_r339534607
 
 

 ##########
 File path: rfcs/008-map-indexes.md
 ##########
 @@ -0,0 +1,202 @@
+# Map indexes RFC
+
+---
+
+name: Formal RFC
+about: Submit a formal Request For Comments for consideration by the team.
+title: ‘Map indexes on FoundationDB’
+labels: rfc, discussion
+assignees: ''
+
+---
+
+## Introduction
+
+This document describes the data model and index management for building and querying map indexes.
+
+## Abstract
+
+Map indexes will have their data model stored in FoundationDB. Each index is grouped via its design doc's view signature. An index will have the index key/value pairs stored, along with the last sequence number from the changes feed used to update the index.
+
+Indexes will be build using the background jobs api, `couch_jobs`, and will use the changes feed. There will be new size limitations on keys (10KB) and values (100KB) that are emitted from a map function.
+
+## Requirements Language
+
+[note]: # " Do not alter the section below. Follow its instructions. "
+
+The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
+"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
+document are to be interpreted as described in
+[RFC 2119](https://www.rfc-editor.org/rfc/rfc2119.txt).
+
+## Terminology
+
+`Sequence`: a 13-byte value formed by combining the current `Incarnation` of the database and the `Versionstamp` of the transaction. Sequences are monotonically increasing even when a database is relocated across FoundationDB clusters. See (RFC002)[LINK TBD] for a full explanation.
+
+`View Signature`: A md5 hash of the views, options, view language defined in a design document.
+
+---
+
+## Detailed Description
+
+CouchDB views are used to create secondary indexes in a database. An index is defined by creating map/reduce functions in a design document. This document describes building the map indexes on top of FoundationDB (FDB).
+
+An example map function is shown below:
+
+```json
+{
+  "_id": "_design/design-doc-id",
+  "_rev": "1-8d361a23b4cb8e213f0868ea3d2742c2",
+  "views": {
+    "map-view": {
+      "map": "function (doc) {\n  emit(doc._id, 1);\n}"
+    }
+  },
+  "language": "javascript"
+}
+```
+
+### Data model
+
+The data model for a map indexed is:
+
+```
+(<database>, ?DB_VIEWS, <view_signature>, ?VIEW_UPDATE_SEQ) = Sequence
+{<database>, ?DB_VIEWS, <view_signature>, ?VIEW_ID_INFO, view_id, ?VIEW_ROW_COUNT} = <row_count>
+{<database>, ?DB_VIEWS, <view_signature>, ?VIEW_ID_INFO, view_id, ?VIEW_KV_SIZE} = <kv_size>
+(<database>, ?DB_VIEWS, <view_signature>, ?VIEW_ID_RANGE, <_id>, <view_id>) = [total_keys, total_size, unique_keys]
+(<database>, ?DB_VIEWS, <view_signature>, ?VIEW_MAP_RANGE, <view_id>, <key>, <_id>, ?ROW_KEYS <count>) = <emitted_keys>
+(<database>, ?DB_VIEWS, <view_signature>, ?VIEW_MAP_RANGE, <view_id>, {<key>, <_id>}, <count>, ?ROW_VALUE) = <emitted_value>
+```
+
+Each field is defined as:
+
+- `<database>` is the specific database namespace
+- `?DB_VIEWS` is the views namespace.
+- `view_signature` is the design documents `View Signature`
+- `?VIEW_UPDATE_SEQ` is the change sequence namespace
+- `?VIEW_ID_RANGE` is the map id index namespace
+- `?VIEW_MAP_RANGE` is the map namespace
+- `?ROW_KEYS` is the namespace for a row where the value is the emitted keys from a map function
+- `?ROW_VALUE` is the namespace for a row where the value is the emitted value from a map function
+- `_id` is the document id
+- `view_id` id of a view defined in the design document
+- `key` is the encoded emitted row key from a map function
+- `count` is a value that is incremented to allow duplicate keys to be emitted for a document
+- `emitted_key` is the emitted key from the map function
 
 Review comment:
   It should be `emitted_keys`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services