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/05/13 18:39:57 UTC

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

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

 ##########
 File path: rfcs/008-map-indexes.md
 ##########
 @@ -0,0 +1,159 @@
+# 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 own data model stored in FoundationDB. The model includes grouping map indexes via their design doc's view signature. Each 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 use the changes feed and be updated via the background tasks queue. If the index only needs a very small update, the update can happen in the request instead of via the background job queue.
+
+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 for the documents stored in a CouchDB database. An index is defined by creating a map/reduce functions in a design document. This document describes building the map indexes on top of FoundationDB (FDB).
+
+### Data model
+
+A map index is created via a design document, an example 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"
+}
+```
+
+The view’s map function will be used to generate keys and values which will be stored in FDB as the secondary index. Format for storing the key/values is:
+
+```json
+{<database>, ?VIEWS, <view_signature>, ?VIEWS, <view_id>, ?MAP, <keys>, <_id>} -> <emitted_value>
+```
+
+Where each field is defined as:
+
+* `<database>` is the specific database namespace
+* `?VIEWS` is the standard views namespace.
+* `view_signature` is the design documents `View Signature`
+* `view_id` name of a view defined in the design document
+* `?MAP` is the standard map namespace
+* `keys` are the emitted keys from the map function
 
 Review comment:
   The plurality of `keys` here is confusing to me. Certainly you mean that there's a row per key emitted?

----------------------------------------------------------------
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