[Groonga-commit] groonga/groonga at fdbdd9d [master] Add position information to scan_info

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Feb 6 00:05:12 JST 2016


Kouhei Sutou	2016-02-06 00:05:12 +0900 (Sat, 06 Feb 2016)

  New Revision: fdbdd9dbc5db84e3309d872bbf616364c63d58c6
  https://github.com/groonga/groonga/commit/fdbdd9dbc5db84e3309d872bbf616364c63d58c6

  Message:
    Add position information to scan_info

  Modified files:
    lib/expr.c
    lib/grn_expr.h
    lib/mrb/mrb_expr.c

  Modified: lib/expr.c (+25 -0)
===================================================================
--- lib/expr.c    2016-02-05 22:41:43 +0900 (ee2d5a7)
+++ lib/expr.c    2016-02-06 00:05:12 +0900 (069c92d)
@@ -3642,6 +3642,10 @@ struct _grn_scan_info {
   grn_obj scorers;
   grn_obj scorer_args_exprs;
   grn_obj scorer_args_expr_offsets;
+  struct {
+    grn_bool specified;
+    int start;
+  } position;
 };
 
 #define SI_FREE(si) do {\
@@ -3976,6 +3980,8 @@ grn_scan_info_open(grn_ctx *ctx, int start)
   GRN_PTR_INIT(&si->scorers, GRN_OBJ_VECTOR, GRN_ID_NIL);
   GRN_PTR_INIT(&si->scorer_args_exprs, GRN_OBJ_VECTOR, GRN_ID_NIL);
   GRN_UINT32_INIT(&si->scorer_args_expr_offsets, GRN_OBJ_VECTOR);
+  si->position.specified = GRN_FALSE;
+  si->position.start = 0;
 
   return si;
 }
@@ -4104,6 +4110,25 @@ grn_scan_info_get_arg(grn_ctx *ctx, scan_info *si, int i)
   return si->args[i];
 }
 
+int
+grn_scan_info_get_start_position(scan_info *si)
+{
+  return si->position.start;
+}
+
+void
+grn_scan_info_set_start_position(scan_info *si, int start)
+{
+  si->position.specified = GRN_TRUE;
+  si->position.start = start;
+}
+
+void
+grn_scan_info_reset_position(scan_info *si)
+{
+  si->position.specified = GRN_FALSE;
+}
+
 static uint32_t
 scan_info_build_match_expr_codes_find_index(grn_ctx *ctx, scan_info *si,
                                             grn_expr *expr, uint32_t i,

  Modified: lib/grn_expr.h (+3 -0)
===================================================================
--- lib/grn_expr.h    2016-02-05 22:41:43 +0900 (7a0f3f0)
+++ lib/grn_expr.h    2016-02-06 00:05:12 +0900 (efa46e6)
@@ -66,6 +66,9 @@ int grn_scan_info_get_similarity_threshold(scan_info *si);
 void grn_scan_info_set_similarity_threshold(scan_info *si, int similarity_threshold);
 grn_bool grn_scan_info_push_arg(scan_info *si, grn_obj *arg);
 grn_obj *grn_scan_info_get_arg(grn_ctx *ctx, scan_info *si, int i);
+int grn_scan_info_get_start_position(scan_info *si);
+void grn_scan_info_set_start_position(scan_info *si, int start);
+void grn_scan_info_reset_position(scan_info *si);
 
 int32_t grn_expr_code_get_weight(grn_ctx *ctx, grn_expr_code *ec, uint32_t *offset);
 grn_rc grn_expr_code_inspect_indented(grn_ctx *ctx,

  Modified: lib/mrb/mrb_expr.c (+40 -1)
===================================================================
--- lib/mrb/mrb_expr.c    2016-02-05 22:41:43 +0900 (0b4e775)
+++ lib/mrb/mrb_expr.c    2016-02-06 00:05:12 +0900 (f8fe1b6)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
-  Copyright(C) 2013-2015 Brazil
+  Copyright(C) 2013-2016 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -312,6 +312,39 @@ mrb_grn_scan_info_push_arg(mrb_state *mrb, mrb_value self)
 }
 
 static mrb_value
+mrb_grn_scan_info_get_start_position(mrb_state *mrb, mrb_value self)
+{
+  scan_info *si;
+  int start_position;
+
+  si = DATA_PTR(self);
+  start_position = grn_scan_info_get_start_position(si);
+  return mrb_fixnum_value(start_position);
+}
+
+static mrb_value
+mrb_grn_scan_info_set_start_position(mrb_state *mrb, mrb_value self)
+{
+  scan_info *si;
+  int start_position;
+
+  mrb_get_args(mrb, "i", &start_position);
+  si = DATA_PTR(self);
+  grn_scan_info_set_start_position(si, start_position);
+  return self;
+}
+
+static mrb_value
+mrb_grn_scan_info_reset_position(mrb_state *mrb, mrb_value self)
+{
+  scan_info *si;
+
+  si = DATA_PTR(self);
+  grn_scan_info_reset_position(si);
+  return self;
+}
+
+static mrb_value
 mrb_grn_expr_code_inspect(mrb_state *mrb, mrb_value self)
 {
   grn_ctx *ctx = (grn_ctx *)mrb->ud;
@@ -778,6 +811,12 @@ grn_mrb_expr_init(grn_ctx *ctx)
                     mrb_grn_scan_info_get_arg, MRB_ARGS_REQ(1));
   mrb_define_method(mrb, klass, "push_arg",
                     mrb_grn_scan_info_push_arg, MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, klass, "start_position",
+                    mrb_grn_scan_info_get_start_position, MRB_ARGS_NONE());
+  mrb_define_method(mrb, klass, "start_position=",
+                    mrb_grn_scan_info_set_start_position, MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, klass, "reset_position",
+                    mrb_grn_scan_info_reset_position, MRB_ARGS_NONE());
 
   klass = mrb_define_class_under(mrb, module,
                                  "ExpressionCode", mrb->object_class);
-------------- next part --------------
HTML����������������������������...
Télécharger 



More information about the Groonga-commit mailing list
Back to archive index