Navigation Menu

Skip to content

Commit

Permalink
mrb: implement resolving index of accessor in expr on match by mruby
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 9, 2014
1 parent c9acbd4 commit 5c063fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
21 changes: 6 additions & 15 deletions lib/mrb/mrb_expr.c
Expand Up @@ -181,23 +181,14 @@ scan_info_build(grn_ctx *ctx, grn_obj *expr, int *n,
if (ec->value) {
switch (ec->value->header.type) {
case GRN_ACCESSOR :
if (grn_column_index(ctx, ec->value, c->op, &index, 1, &sid)) {
mrb_value mrb_ec = mrb_grn_expr_code_new(mrb, ec);
{
mrb_value mrb_accessor;
weight = mrb_fixnum(mrb_funcall(mrb, mrb_ec, "weight", 0));
grn_scan_info_set_flags(si, grn_scan_info_get_flags(si) | SCAN_ACCESSOR);
mrb_value mrb_ec;

mrb_accessor = grn_mrb_value_from_grn_obj(mrb, ec->value);
if (!mrb_nil_p(mrb_funcall(mrb, mrb_accessor, "next", 0))) {
mrb_funcall(mrb, mrb_si, "put_index", 3,
grn_mrb_value_from_grn_obj(mrb, ec->value),
mrb_fixnum_value(sid),
mrb_fixnum_value(weight));
} else {
mrb_funcall(mrb, mrb_si, "put_index", 3,
grn_mrb_value_from_grn_obj(mrb, index),
mrb_fixnum_value(sid),
mrb_fixnum_value(weight));
}
mrb_ec = mrb_grn_expr_code_new(mrb, ec);
mrb_funcall(mrb, mrb_si, "match_expr_resolve_index_accessor",
2, mrb_accessor, mrb_ec);
}
break;
case GRN_COLUMN_FIX_SIZE :
Expand Down
11 changes: 11 additions & 0 deletions lib/mrb/scripts/scan_info.rb
Expand Up @@ -18,6 +18,17 @@ def each_arg
nil
end

def match_expr_resolve_index_accessor(accessor, expr_code)
self.flags |= Flags::ACCESSOR
index_info = accessor.find_index(op)
return if index_info.nil?
if accessor.next
put_index(accessor, index_info.section_id, expr_code.weight)
else
put_index(index_info.index, index_info.section_id, expr_code.weight)
end
end

def match_resolve_index_db_obj(db_obj)
index_info = db_obj.find_index(op)
return if index_info.nil?
Expand Down

0 comments on commit 5c063fd

Please sign in to comment.