Navigation Menu

Skip to content

Commit

Permalink
mrb: implement index resolution for accessor by mruby
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 8, 2014
1 parent e29f320 commit a717bd4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 1 addition & 10 deletions lib/mrb/mrb_expr.c
Expand Up @@ -362,17 +362,8 @@ scan_info_build(grn_ctx *ctx, grn_obj *expr, int *n,
mrb_funcall(mrb, mrb_si, "resolve_index_db_obj", 1, mrb_target);
} else if (GRN_ACCESSORP(*p)) {
mrb_value mrb_target;
mrb_value mrb_index_info;
mrb_target = mrb_grn_accessor_new(mrb, (grn_accessor *)(*p));
grn_scan_info_set_flags(si, grn_scan_info_get_flags(si) | SCAN_ACCESSOR);
mrb_index_info = mrb_funcall(mrb, mrb_target, "find_index", 1,
mrb_fixnum_value(c->op));
if (!mrb_nil_p(mrb_index_info)) {
mrb_funcall(mrb, mrb_si, "put_index", 3,
mrb_funcall(mrb, mrb_index_info, "index", 0),
mrb_funcall(mrb, mrb_index_info, "section_id", 0),
mrb_fixnum_value(1));
}
mrb_funcall(mrb, mrb_si, "resolve_index_accessor", 1, mrb_target);
} else {
mrb_funcall(mrb, mrb_si, "query=", 1, mrb_cptr_value(mrb, *p));
}
Expand Down
14 changes: 14 additions & 0 deletions lib/mrb/scripts/scan_info.rb
@@ -1,9 +1,23 @@
module Groonga
class ScanInfo
module Flags
ACCESSOR = 0x01
PUSH = 0x02
POP = 0x04
PRE_CONST = 0x08
end

def resolve_index_db_obj(db_obj)
index_info = db_obj.find_index(op)
return if index_info.nil?
put_index(index_info.index, index_info.section_id, 1)
end

def resolve_index_accessor(accessor)
self.flags |= Flags::ACCESSOR
index_info = accessor.find_index(op)
return if index_info.nil?
put_index(index_info.index, index_info.section_id, 1)
end
end
end

0 comments on commit a717bd4

Please sign in to comment.