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

Keep and expose pretty-printed index functions #3231

Closed
AtnNn opened this issue Oct 23, 2014 · 7 comments
Closed

Keep and expose pretty-printed index functions #3231

AtnNn opened this issue Oct 23, 2014 · 7 comments
Milestone

Comments

@AtnNn
Copy link
Member

AtnNn commented Oct 23, 2014

There could be a "source" optarg to indexCreate that is kept by the server and exposed as-is through indexStatus.

The drivers could automatically populate the optarg with the pretty-printed index function.

If the field is missing, the server could set it to a basic representation of the query (perhaps as an s-expression).

@mlucy mlucy added this to the subsequent milestone Oct 23, 2014
@thelinuxlich
Copy link

Thank you @AtnNn !

@nviennot
Copy link
Contributor

That's a good idea. In NoBrainer, I'm planning to store the index definitions in a separate table so that I can check if index definitions have changed. I'd much rather populate that "source" thing.

👍

@danielmewes
Copy link
Member

This will become pretty easy once we have #3636

@danielmewes
Copy link
Member

Just needed this again when debugging something that a user ran into.
It turns out @Tryneus had actually already implemented a print_source() method on func_t, so I just went ahead and hooked that into index_status().

The output isn't perfect, but I think it's worth shipping this even if we later redo it in a nicer way. Sorry for not adhering to the ReQL_proposal standards, but I think the absence of this feature is sufficiently annoying for debugging that we should just ship it.

The indexStatus() output looks like this (note the new source field):

{
    "function": <binary, 127 bytes, "24 72 65 71 6c 5f..."> ,
    "geo": false ,
    "index": "parent_folder_id" ,
    "multi": false ,
    "outdated": true ,
    "ready": true ,
    "source": 'function (captures = [(no implicit)]) (args = [1]) var1("data")("parent_folder_id")'
}

@danielmewes danielmewes modified the milestones: 2.2, subsequent Oct 21, 2015
@danielmewes
Copy link
Member

In CR 3288. It's just a two-line addition.

@danielmewes
Copy link
Member

We decided to redo this a bit and actually generate the JS query that you can use to re-create the index (and call the field "query").

@danielmewes
Copy link
Member

Merged into next with the following format:

r.table('t1').indexStatus().pluck("query")
[
    {
        "query": "indexCreate('a', function(_var19) { return _var19.getField("a"); })" 
    } ,
    {
        "query": "indexCreate('b', function(_var19) { return _var19.getField("b"); }, {geo: true})" 
    } ,
    {
        "query": "indexCreate('c', function(_var19) { return _var19.getField("c"); }, {multi: true, geo: true})" 
    } ,
    {
        "query": "indexCreate('d', function(var24) { return r.expr([var24("a"), var24("b").count()]); })" 
    }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants