[Groonga-commit] groonga/groonga at b01eacd [master] logical_range_filter: support 'fixed_size_type_vector_column @ 1'

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Jun 30 18:07:33 JST 2015


Kouhei Sutou	2015-06-30 18:07:33 +0900 (Tue, 30 Jun 2015)

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

  Message:
    logical_range_filter: support 'fixed_size_type_vector_column @ 1'

  Added files:
    test/command/suite/sharding/logical_range_filter/no_index/condition/match/vector/int32.expected
    test/command/suite/sharding/logical_range_filter/no_index/condition/match/vector/int32.test
  Modified files:
    lib/mrb/mrb_index_column.c

  Modified: lib/mrb/mrb_index_column.c (+17 -4)
===================================================================
--- lib/mrb/mrb_index_column.c    2015-06-30 17:54:50 +0900 (eb85ff9)
+++ lib/mrb/mrb_index_column.c    2015-06-30 18:07:33 +0900 (2af198c)
@@ -24,6 +24,7 @@
 #include <mruby/class.h>
 #include <mruby/data.h>
 
+#include "mrb_ctx.h"
 #include "mrb_converter.h"
 #include "mrb_index_column.h"
 #include "mrb_operator.h"
@@ -77,14 +78,22 @@ mrb_grn_index_column_estimate_size_for_query(mrb_state *mrb, mrb_value self)
 {
   grn_ctx *ctx = (grn_ctx *)mrb->ud;
   grn_obj *index_column;
-  char *query;
-  mrb_int query_len;
+  grn_obj *lexicon;
+  mrb_value mrb_query;
+  void *query;
+  unsigned int query_size;
+  grn_mrb_value_to_raw_data_buffer buffer;
   mrb_value mrb_options = mrb_nil_value();
   grn_search_optarg optarg;
   unsigned int size;
 
   index_column = DATA_PTR(self);
-  mrb_get_args(mrb, "s|H", &query, &query_len, &mrb_options);
+  mrb_get_args(mrb, "o|H", &mrb_query, &mrb_options);
+
+  lexicon = grn_ctx_at(ctx, index_column->header.domain);
+  grn_mrb_value_to_raw_data_buffer_init(mrb, &buffer);
+  grn_mrb_value_to_raw_data(mrb, "query", mrb_query, lexicon->header.domain,
+                            &buffer, &query, &query_size);
 
   memset(&optarg, 0, sizeof(grn_search_optarg));
   optarg.mode = GRN_OP_EXACT;
@@ -99,7 +108,11 @@ mrb_grn_index_column_estimate_size_for_query(mrb_state *mrb, mrb_value self)
   }
 
   size = grn_ii_estimate_size_for_query(ctx, (grn_ii *)index_column,
-                                        query, query_len, &optarg);
+                                        query, query_size, &optarg);
+  grn_mrb_value_to_raw_data_buffer_fin(mrb, &buffer);
+
+  grn_mrb_ctx_check(mrb);
+
   return mrb_fixnum_value(size);
 }
 

  Added: test/command/suite/sharding/logical_range_filter/no_index/condition/match/vector/int32.expected (+130 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/no_index/condition/match/vector/int32.expected    2015-06-30 18:07:33 +0900 (6b3920c)
@@ -0,0 +1,130 @@
+register sharding
+[[0,0.0,0.0],true]
+table_create Logs_20150203 TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Logs_20150203 timestamp COLUMN_SCALAR Time
+[[0,0.0,0.0],true]
+column_create Logs_20150203 memo COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+column_create Logs_20150203 numbers COLUMN_VECTOR Int32
+[[0,0.0,0.0],true]
+table_create Logs_20150204 TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Logs_20150204 timestamp COLUMN_SCALAR Time
+[[0,0.0,0.0],true]
+column_create Logs_20150204 memo COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+column_create Logs_20150204 numbers COLUMN_VECTOR Int32
+[[0,0.0,0.0],true]
+table_create Logs_20150205 TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Logs_20150205 timestamp COLUMN_SCALAR Time
+[[0,0.0,0.0],true]
+column_create Logs_20150205 memo COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+column_create Logs_20150205 numbers COLUMN_VECTOR Int32
+[[0,0.0,0.0],true]
+load --table Logs_20150203
+[
+{
+  "timestamp": "2015-02-03 12:49:00",
+       "memo": "2015-02-03 12:49:00",
+    "numbers": [2, 0, 1, 5, 3, 4, 9]
+}
+]
+[[0,0.0,0.0],1]
+load --table Logs_20150204
+[
+{
+  "timestamp": "2015-02-04 13:49:00",
+       "memo": "2015-02-04 13:49:00",
+    "numbers": [2, 0, 1, 5, 4, 3, 9]
+},
+{
+  "timestamp": "2015-02-04 13:50:00",
+       "memo": "2015-02-04 13:50:00",
+    "numbers": [2, 0, 1, 5, 4, 3]
+}
+]
+[[0,0.0,0.0],2]
+load --table Logs_20150205
+[
+{
+  "timestamp": "2015-02-05 13:49:00",
+       "memo": "2015-02-05 13:49:00",
+    "numbers": [2, 0, 1, 5, 4, 9]
+},
+{
+  "timestamp": "2015-02-05 13:50:00",
+       "memo": "2015-02-05 13:50:00",
+    "numbers": [2, 0, 1, 5, 3]
+},
+{
+  "timestamp": "2015-02-05 13:51:00",
+       "memo": "2015-02-05 13:51:00",
+    "numbers": [2, 0, 1, 5, 3]
+}
+]
+[[0,0.0,0.0],3]
+logical_range_filter Logs timestamp --filter 'numbers @ 9'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        "memo",
+        "ShortText"
+      ],
+      [
+        "numbers",
+        "Int32"
+      ],
+      [
+        "timestamp",
+        "Time"
+      ]
+    ],
+    [
+      "2015-02-03 12:49:00",
+      [
+        2,
+        0,
+        1,
+        5,
+        3,
+        4,
+        9
+      ],
+      1422935340.0
+    ],
+    [
+      "2015-02-04 13:49:00",
+      [
+        2,
+        0,
+        1,
+        5,
+        4,
+        3,
+        9
+      ],
+      1423025340.0
+    ],
+    [
+      "2015-02-05 13:49:00",
+      [
+        2,
+        0,
+        1,
+        5,
+        4,
+        9
+      ],
+      1423111740.0
+    ]
+  ]
+]

  Added: test/command/suite/sharding/logical_range_filter/no_index/condition/match/vector/int32.test (+62 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/no_index/condition/match/vector/int32.test    2015-06-30 18:07:33 +0900 (a49f8d4)
@@ -0,0 +1,62 @@
+#@on-error omit
+register sharding
+#@on-error default
+
+table_create Logs_20150203 TABLE_NO_KEY
+column_create Logs_20150203 timestamp COLUMN_SCALAR Time
+column_create Logs_20150203 memo COLUMN_SCALAR ShortText
+column_create Logs_20150203 numbers COLUMN_VECTOR Int32
+
+table_create Logs_20150204 TABLE_NO_KEY
+column_create Logs_20150204 timestamp COLUMN_SCALAR Time
+column_create Logs_20150204 memo COLUMN_SCALAR ShortText
+column_create Logs_20150204 numbers COLUMN_VECTOR Int32
+
+table_create Logs_20150205 TABLE_NO_KEY
+column_create Logs_20150205 timestamp COLUMN_SCALAR Time
+column_create Logs_20150205 memo COLUMN_SCALAR ShortText
+column_create Logs_20150205 numbers COLUMN_VECTOR Int32
+
+load --table Logs_20150203
+[
+{
+  "timestamp": "2015-02-03 12:49:00",
+       "memo": "2015-02-03 12:49:00",
+    "numbers": [2, 0, 1, 5, 3, 4, 9]
+}
+]
+
+load --table Logs_20150204
+[
+{
+  "timestamp": "2015-02-04 13:49:00",
+       "memo": "2015-02-04 13:49:00",
+    "numbers": [2, 0, 1, 5, 4, 3, 9]
+},
+{
+  "timestamp": "2015-02-04 13:50:00",
+       "memo": "2015-02-04 13:50:00",
+    "numbers": [2, 0, 1, 5, 4, 3]
+}
+]
+
+load --table Logs_20150205
+[
+{
+  "timestamp": "2015-02-05 13:49:00",
+       "memo": "2015-02-05 13:49:00",
+    "numbers": [2, 0, 1, 5, 4, 9]
+},
+{
+  "timestamp": "2015-02-05 13:50:00",
+       "memo": "2015-02-05 13:50:00",
+    "numbers": [2, 0, 1, 5, 3]
+},
+{
+  "timestamp": "2015-02-05 13:51:00",
+       "memo": "2015-02-05 13:51:00",
+    "numbers": [2, 0, 1, 5, 3]
+}
+]
+
+logical_range_filter Logs timestamp --filter 'numbers @ 9'
-------------- next part --------------
HTML����������������������������...
下載 



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