[Groonga-commit] groonga/groonga at 2cdaa6e [master] range_filter: support default min and max

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Nov 19 19:10:42 JST 2014


Kouhei Sutou	2014-11-19 19:10:42 +0900 (Wed, 19 Nov 2014)

  New Revision: 2cdaa6ea3f071147d305b36af3fa795a75e90967
  https://github.com/groonga/groonga/commit/2cdaa6ea3f071147d305b36af3fa795a75e90967

  Message:
    range_filter: support default min and max

  Added files:
    test/command/suite/range_filter/max/default.expected
    test/command/suite/range_filter/max/default.test
    test/command/suite/range_filter/min/default.expected
    test/command/suite/range_filter/min/default.test
  Modified files:
    lib/proc.c

  Modified: lib/proc.c (+6 -2)
===================================================================
--- lib/proc.c    2014-11-19 19:06:29 +0900 (7f4e377)
+++ lib/proc.c    2014-11-19 19:10:42 +0900 (66f1f4c)
@@ -6295,8 +6295,12 @@ proc_range_filter(grn_ctx *ctx, int nargs, grn_obj **args,
         }
         GRN_OBJ_INIT(&real_min, GRN_BULK, 0, lexicon->header.domain);
         GRN_OBJ_INIT(&real_max, GRN_BULK, 0, lexicon->header.domain);
-        grn_obj_cast(ctx, min, &real_min, GRN_FALSE);
-        grn_obj_cast(ctx, max, &real_max, GRN_FALSE);
+        if (GRN_TEXT_LEN(min) > 0) {
+          grn_obj_cast(ctx, min, &real_min, GRN_FALSE);
+        }
+        if (GRN_TEXT_LEN(max) > 0) {
+          grn_obj_cast(ctx, max, &real_max, GRN_FALSE);
+        }
         table_cursor = grn_table_cursor_open(ctx, lexicon,
                                              GRN_BULK_HEAD(&real_min),
                                              GRN_BULK_VSIZE(&real_min),

  Added: test/command/suite/range_filter/max/default.expected (+17 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/range_filter/max/default.expected    2014-11-19 19:10:42 +0900 (c35ad6f)
@@ -0,0 +1,17 @@
+table_create Memos TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Memos id COLUMN_SCALAR Int32
+[[0,0.0,0.0],true]
+column_create Memos text COLUMN_SCALAR Text
+[[0,0.0,0.0],true]
+table_create IDs TABLE_PAT_KEY Int32
+[[0,0.0,0.0],true]
+column_create IDs memos_id COLUMN_INDEX Memos id
+[[0,0.0,0.0],true]
+load --table Memos
+[
+{"id":   0, "text": "aaa"}
+]
+[[0,0.0,0.0],1]
+range_filter Memos id   --min 0 --min_border include   --max_border exclude
+[[0,0.0,0.0],[[["_id","UInt32"],["id","Int32"],["text","Text"]],[1,0,"aaa"]]]

  Added: test/command/suite/range_filter/max/default.test (+15 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/range_filter/max/default.test    2014-11-19 19:10:42 +0900 (771d108)
@@ -0,0 +1,15 @@
+table_create Memos TABLE_NO_KEY
+column_create Memos id COLUMN_SCALAR Int32
+column_create Memos text COLUMN_SCALAR Text
+
+table_create IDs TABLE_PAT_KEY Int32
+column_create IDs memos_id COLUMN_INDEX Memos id
+
+load --table Memos
+[
+{"id":   0, "text": "aaa"}
+]
+
+range_filter Memos id \
+  --min 0 --min_border include \
+  --max_border exclude

  Added: test/command/suite/range_filter/min/default.expected (+17 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/range_filter/min/default.expected    2014-11-19 19:10:42 +0900 (06c6583)
@@ -0,0 +1,17 @@
+table_create Memos TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Memos id COLUMN_SCALAR Int32
+[[0,0.0,0.0],true]
+column_create Memos text COLUMN_SCALAR Text
+[[0,0.0,0.0],true]
+table_create IDs TABLE_PAT_KEY Int32
+[[0,0.0,0.0],true]
+column_create IDs memos_id COLUMN_INDEX Memos id
+[[0,0.0,0.0],true]
+load --table Memos
+[
+{"id":   0, "text": "aaa"}
+]
+[[0,0.0,0.0],1]
+range_filter Memos id   --min_border include   --max 10 --max_border exclude
+[[0,0.0,0.0],[[["_id","UInt32"],["id","Int32"],["text","Text"]],[1,0,"aaa"]]]

  Added: test/command/suite/range_filter/min/default.test (+15 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/range_filter/min/default.test    2014-11-19 19:10:42 +0900 (cea3efa)
@@ -0,0 +1,15 @@
+table_create Memos TABLE_NO_KEY
+column_create Memos id COLUMN_SCALAR Int32
+column_create Memos text COLUMN_SCALAR Text
+
+table_create IDs TABLE_PAT_KEY Int32
+column_create IDs memos_id COLUMN_INDEX Memos id
+
+load --table Memos
+[
+{"id":   0, "text": "aaa"}
+]
+
+range_filter Memos id \
+  --min_border include \
+  --max 10 --max_border exclude
-------------- next part --------------
HTML����������������������������...
下載 



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