[Groonga-commit] groonga/groonga [master] Support unary minus operation (-X) for UInt8 type

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Mar 2 15:34:49 JST 2013


Kouhei Sutou	2013-03-02 15:34:49 +0900 (Sat, 02 Mar 2013)

  New Revision: 8951fb3553e989f2b923ea89b600c070b3daf41a
  https://github.com/groonga/groonga/commit/8951fb3553e989f2b923ea89b600c070b3daf41a

  Log:
    Support unary minus operation (-X) for UInt8 type

  Added files:
    test/command/suite/select/operation/unary_minus/uint8.expected
    test/command/suite/select/operation/unary_minus/uint8.test
  Modified files:
    lib/expr.c

  Modified: lib/expr.c (+10 -0)
===================================================================
--- lib/expr.c    2013-03-02 15:27:58 +0900 (2f6c539)
+++ lib/expr.c    2013-03-02 15:34:49 +0900 (be3c12f)
@@ -2175,6 +2175,16 @@ grn_proc_call(grn_ctx *ctx, grn_obj *proc, int nargs, grn_obj *caller)
       GRN_INT8_SET(ctx, res, integer_operation(x_));                    \
     }                                                                   \
     break;                                                              \
+  case GRN_DB_UINT8 :                                                   \
+    {                                                                   \
+      uint8_t x_;                                                       \
+      x_ = GRN_UINT8_VALUE(x);                                          \
+      left_expression_check(x_);                                        \
+      GRN_INT16_SET(ctx, res, integer_operation(x_));                   \
+      res->header.type = GRN_BULK;                                      \
+      res->header.domain = GRN_DB_INT16;                                \
+    }                                                                   \
+    break;                                                              \
   case GRN_DB_INT32 :                                                   \
     {                                                                   \
       int x_;                                                           \

  Added: test/command/suite/select/operation/unary_minus/uint8.expected (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/operation/unary_minus/uint8.expected    2013-03-02 15:34:49 +0900 (a6ee596)
@@ -0,0 +1,11 @@
+table_create Values TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Values value COLUMN_SCALAR UInt8
+[[0,0.0,0.0],true]
+load --table Values
+[
+{"value": 1}
+]
+[[0,0.0,0.0],1]
+select Values   --filter true   --scorer '_score = -value'   --output_columns 'value, _score'
+[[0,0.0,0.0],[[[1],[["value","UInt8"],["_score","Int32"]],[1,-1]]]]

  Added: test/command/suite/select/operation/unary_minus/uint8.test (+12 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/operation/unary_minus/uint8.test    2013-03-02 15:34:49 +0900 (7e4677a)
@@ -0,0 +1,12 @@
+table_create Values TABLE_NO_KEY
+column_create Values value COLUMN_SCALAR UInt8
+
+load --table Values
+[
+{"value": 1}
+]
+
+select Values \
+  --filter true \
+  --scorer '_score = -value' \
+  --output_columns 'value, _score'
-------------- next part --------------
HTML����������������������������...
Download 



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