Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: build Mango indexes from dynamic expressions #3912

Open
wants to merge 6 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
NIF bindings for jq
Here we add a module named `couch_jq` which exports an interface to the
jq [1] library, letting us run jq programs against CouchDB docs held in
memory as Erlang terms. The exported functions are:

- `couch_jq:compile/1`: takes a binary containing a jq expression, and
  compiles it. Returns a resource object holding the resulting struct
  that stored the parsed expression.

- `couch_jq:eval/2`: takes a compiled jq program and a JSON document and
  returns the results of evaluating the program against the doc, as a
  list.

Both functions return either `{ok, Result}` or `{error, Message}`.

This assumes that jq programs will in general return multiple results.
Because the Erlang list is built from the tail, the results are returned
in the reverse order that they're emitted by jq. We're going to put
these values into an index where they'll get re-sorted so the order is
not important.

Most of the native code here is concerned with translating between
Erlang and jq representations of JSON values. Erlang terms are checked
to make sure they conform to the Couch document representation, and
anything else is rejected.

[1]: https://stedolan.github.io/jq/
  • Loading branch information
jcoglan committed Jan 25, 2022
commit 783dcc7572fdb145474f07a5d440ffd7c2510d8e
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ src/couch/priv/couch_js/**/config.h
src/couch/priv/couchjs
src/couch/priv/couchspawnkillable
src/couch/priv/couch_ejson_compare/couch_ejson_compare.d
src/couch/priv/couch_jq/*.d
src/couch/priv/couch_js/**/*.d
src/couch/priv/icu_driver/couch_icu_driver.d
src/mango/src/mango_cursor_text.nocompile
Expand Down
Loading