From 31c1994d2a6ccfcfca6bad927e7da0520b90e100 Mon Sep 17 00:00:00 2001 From: Michael Baird Date: Fri, 30 Jun 2017 13:46:52 -0500 Subject: [PATCH] API docs for input definition --- docs/api-reference.md | 95 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-) diff --git a/docs/api-reference.md b/docs/api-reference.md index 8c083d514..2a3c9686c 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -173,7 +173,7 @@ Response: ### Remove frame -`DELETE POST /index//frame/` +`DELETE /index//frame/` Removes the given frame. @@ -219,6 +219,99 @@ Response: {} ``` +### Create input definition + +`POST /index//input-definition/` + +Creates a input definition in the given index with the given name. + +The request payload is in JSON, and must contain the `frames` and `fields` field. `frames` is an array of a JSON specifying the frames to use used/created for this import. Each frame must contain a `name` and may contain the following options: + +* `rowLabel` (string): Row label of the frame. +* `timeQuantum` (string): [Time Quantum]({{< ref "data-model.md#time-quantum" >}}) for this frame. +* `inverseEnabled` (boolean): Enables [the inverted view]({{< ref "data-model.md#inverse" >}}) for this frame if `true`. +* `cacheType` (string): [ranked]({{< ref "data-model.md#ranked" >}}) or [LRU]({{< ref "data-model.md#lru" >}}) caching on this frame. Default is `lru`. +* `cacheSize` (int): Number of rows to keep in the cache. Default 50,000. + +The `fields` array contains series of json objects describing how to process each field in the JSON data. Each `field` object must contain a string `name` which maps to the source json field name. One field must be defined at the `primaryKey`. The `primarykey` source field must contain only non duplicated unsigned integer values, and the field name must equal the column label for the `Index`. The `primarykey` ID's will map directly to column ID's in Pilosa. + +* `name` (string): Maps the source data field to actions that process its value. +* `actions` (array): List of Actions that will process the field's value. + +The `action` describes how the field value will be processed. Each `action` may contain: + +* `frame` (string): The Frame that will contain this Action's set bits. +* `rowid` (int): The action can use this as a pre-defined SetBit rowID. The user is required to ensure this ID does not overlap with other rows in use per frame. +* `valueDestination` (string): The mapping rule used for this data. + - `value-to-row` The value should be an integer and will map directly to a RowID. + - `single-row-boolean` If the value is true set a bit using the `rowid`. + - `mapping` Map the value to a RowID in the `valueMap`. +* `valueMap` (object): string and integer pairs used to map field values to row ID's. + +Request: +``` +curl localhost:10101/index/user/input-definition/stargazer-input \ + -X POST \ + -d '{"frames":[{"name": "language", "options": {"rowLabel": "language_id"}}], "fields":[{"name": "repo_id", "primaryKey":true}, {"name": "language_id", "actions":[{"frame": "language", "valueDestination": "mapping", "valueMap": {"Go":5,"Python":17,"C++":10}}]}]}' +``` + +Response: +``` +{} +``` + +### Get input definition + +`GET /index//input-definition/` + +Returns the input definition in JSON. + +Request: +``` +curl -XGET localhost:10101/index/user/input-definition/stargazer-input +``` + +Response: +``` +{"frames":[{"name":"language","options":{"rowLabel":"language_id"}}],"fields":[{"name":"repo_id","primaryKey":true},{"name":"language_id","actions":[{"frame":"language","valueDestination":"mapping","valueMap":{"Go":5,"Python":17,"C++":10}}]}]} +``` + +### Remove input definition + +`DELETE /index//input-definition/` + +Removes the given input definition. + +Request: +``` +curl -XDELETE localhost:10101/index/user/input-definition/stargazer-input +``` + +Response: +``` +{} +``` + +### Process input data + +`POST /index//input/` + +Process JSON body with the given input definition and set bits. + +The request payload is a JSON array of objects containing one field for the primary key that corresponds to the column label, and other fields that will be handled by the actions in the input definition. + +Request: +``` +curl localhost:10101/index/user/input/stargazer-input \ + -X POST \ + -d '[{"language_id": "Go", "repo_id": 92274475, "stargazer_id": 513111}]' +``` + +Response: +``` +{} +``` + ### List hosts `GET /hosts`