Skip to content

Commit

Permalink
Make Make INDEX/2 more efficient
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugen authored and Eugen committed Apr 19, 2018
1 parent 7fd9e86 commit ec3c9ee
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/builtin.jq
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,7 @@ def walk(f):

# SQL-ish operators here:
def INDEX(stream; idx_expr):
reduce stream as $row ({};
.[$row|idx_expr|
if type != "string" then tojson
else .
end] |= $row);
reduce stream as $row ({}; .[($row|idx_expr|tostring)] |= $row);
def INDEX(idx_expr): INDEX(.[]; idx_expr);
def JOIN($idx; idx_expr):
[.[] | [., $idx[idx_expr]]];
Expand Down

0 comments on commit ec3c9ee

Please # to comment.