[Groonga-commit] groonga/groonga [master] Support binary assign operation for UInt16 type

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Mar 4 18:23:27 JST 2013


Kouhei Sutou	2013-03-04 18:23:27 +0900 (Mon, 04 Mar 2013)

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

  Log:
    Support binary assign operation for UInt16 type
    
    Operation: X - Y

  Added files:
    test/command/suite/select/filter/arithmetic_operation/minus/uint16.expected
    test/command/suite/select/filter/arithmetic_operation/minus/uint16.test
  Modified files:
    lib/expr.c

  Modified: lib/expr.c (+22 -0)
===================================================================
--- lib/expr.c    2013-03-04 17:38:36 +0900 (c850e9d)
+++ lib/expr.c    2013-03-04 18:23:27 +0900 (1583031)
@@ -1942,6 +1942,14 @@ grn_proc_call(grn_ctx *ctx, grn_obj *proc, int nargs, grn_obj *caller)
       set(ctx, res, integer_operation(x_, y_));                         \
     }                                                                   \
     break;                                                              \
+  case GRN_DB_UINT16 :                                                  \
+    {                                                                   \
+      uint16_t y_;                                                      \
+      y_ = GRN_UINT16_VALUE(y);                                         \
+      right_expression_check(y_);                                       \
+      set(ctx, res, integer_operation(x_, y_));                         \
+    }                                                                   \
+    break;                                                              \
   case GRN_DB_INT32 :                                                   \
     {                                                                   \
       int y_;                                                           \
@@ -2063,6 +2071,20 @@ grn_proc_call(grn_ctx *ctx, grn_obj *proc, int nargs, grn_obj *caller)
                                             invalid_type_error);        \
     }                                                                   \
     break;                                                              \
+  case GRN_DB_UINT16 :                                                  \
+    {                                                                   \
+      uint16_t x_;                                                      \
+      x_ = GRN_UINT16_VALUE(x);                                         \
+      left_expression_check(x_);                                        \
+      NUMERIC_ARITHMETIC_OPERATION_DISPATCH(GRN_UINT16_SET,             \
+                                            GRN_UINT16_VALUE,           \
+                                            x_, y, res,                 \
+                                            integer16_operation,        \
+                                            float_operation,            \
+                                            right_expression_check,     \
+                                            invalid_type_error);        \
+    }                                                                   \
+    break;                                                              \
   case GRN_DB_INT32 :                                                   \
     {                                                                   \
       int x_;                                                           \

  Added: test/command/suite/select/filter/arithmetic_operation/minus/uint16.expected (+45 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/arithmetic_operation/minus/uint16.expected    2013-03-04 18:23:27 +0900 (860e217)
@@ -0,0 +1,45 @@
+table_create Values TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Values value1 COLUMN_SCALAR UInt16
+[[0,0.0,0.0],true]
+column_create Values value2 COLUMN_SCALAR UInt16
+[[0,0.0,0.0],true]
+load --table Values
+[
+{"value1": 5, "value2": 1}
+]
+[[0,0.0,0.0],1]
+select Values   --filter true   --scorer '_score = value1 - value2'   --output_columns 'value1, value2, _score'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "value1",
+          "UInt16"
+        ],
+        [
+          "value2",
+          "UInt16"
+        ],
+        [
+          "_score",
+          "Int32"
+        ]
+      ],
+      [
+        5,
+        1,
+        4
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/arithmetic_operation/minus/uint16.test (+13 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/arithmetic_operation/minus/uint16.test    2013-03-04 18:23:27 +0900 (8add56d)
@@ -0,0 +1,13 @@
+table_create Values TABLE_NO_KEY
+column_create Values value1 COLUMN_SCALAR UInt16
+column_create Values value2 COLUMN_SCALAR UInt16
+
+load --table Values
+[
+{"value1": 5, "value2": 1}
+]
+
+select Values \
+  --filter true \
+  --scorer '_score = value1 - value2' \
+  --output_columns 'value1, value2, _score'
-------------- next part --------------
HTML����������������������������...
Download 



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