Navigation Menu

Skip to content

Commit

Permalink
mrb: implement resolving index for match in mruby
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 11, 2014
1 parent 434c145 commit 2925361
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
23 changes: 1 addition & 22 deletions lib/mrb/mrb_expr.c
Expand Up @@ -173,28 +173,7 @@ scan_info_build(grn_ctx *ctx, grn_obj *expr, int *n,
mrb_funcall(mrb, mrb_si, "op=", 1, mrb_fixnum_value(c->op));
mrb_funcall(mrb, mrb_si, "end=", 1, mrb_fixnum_value(c - e->codes));
sis[i++] = si;
{
int k;
grn_obj *arg, **p = &arg;
for (k = 0; (arg = grn_scan_info_get_arg(ctx, si, k)) ; k++) {
if ((*p)->header.type == GRN_EXPR) {
mrb_value mrb_expr;
mrb_expr = grn_mrb_value_from_grn_obj(mrb, *p);
mrb_funcall(mrb, mrb_si, "match_resolve_index_expression",
1, mrb_expr);
} else if (GRN_DB_OBJP(*p)) {
mrb_value mrb_db_obj = grn_mrb_value_from_grn_obj(mrb, *p);
mrb_funcall(mrb, mrb_si, "match_resolve_index_db_obj", 1, mrb_db_obj);
} else if (GRN_ACCESSORP(*p)) {
mrb_value mrb_accessor = grn_mrb_value_from_grn_obj(mrb, *p);
mrb_funcall(mrb, mrb_si, "match_resolve_index_accessor", 1, mrb_accessor);
} else {
mrb_value mrb_query;
mrb_query = grn_mrb_value_from_grn_obj(mrb, *p);
mrb_funcall(mrb, mrb_si, "query=", 1, mrb_query);
}
}
}
mrb_funcall(mrb, mrb_si, "match_resolve_index", 0);
si = NULL;
break;
case GRN_OP_AND :
Expand Down
15 changes: 15 additions & 0 deletions lib/mrb/scripts/scan_info.rb
Expand Up @@ -18,6 +18,21 @@ def each_arg
nil
end

def match_resolve_index
each_arg do |arg|
case arg
when Expression
match_resolve_index_expression(arg)
when Accessor
match_resolve_index_accessor(arg)
when Object
match_resolve_index_db_obj(arg)
else
self.query = arg
end
end
end

def match_resolve_index_expression(expression)
codes = expression.codes
n_codes = codes.size
Expand Down

0 comments on commit 2925361

Please sign in to comment.