[Groonga-commit] groonga/groonga at b8e1412 [master] Treat vector value as score "1"

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Jan 26 22:53:28 JST 2014


Kouhei Sutou	2014-01-26 22:53:28 +0900 (Sun, 26 Jan 2014)

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

  Message:
    Treat vector value as score "1"

  Added files:
    test/command/suite/select/filter/logical_operation/or/vector.expected
    test/command/suite/select/filter/logical_operation/or/vector.test
  Modified files:
    lib/expr.c

  Modified: lib/expr.c (+13 -3)
===================================================================
--- lib/expr.c    2014-01-26 22:29:42 +0900 (cd55c69)
+++ lib/expr.c    2014-01-26 22:53:28 +0900 (19ecfa5)
@@ -4319,11 +4319,21 @@ exec_result_to_score(grn_ctx *ctx, grn_obj *result, grn_obj *score_buffer)
     return 0;
   }
 
-  if (grn_obj_cast(ctx, result, score_buffer, GRN_FALSE) != GRN_SUCCESS) {
+  switch (result->header.type) {
+  case GRN_VOID :
     return 0;
+  case GRN_BULK :
+    if (grn_obj_cast(ctx, result, score_buffer, GRN_FALSE) != GRN_SUCCESS) {
+      return 1;
+    }
+    return GRN_INT32_VALUE(score_buffer);
+  case GRN_UVECTOR :
+  case GRN_PVECTOR :
+  case GRN_VECTOR :
+    return 1;
+  default :
+    return 1; /* TODO: 1 is reasonable? */
   }
-
-  return GRN_INT32_VALUE(score_buffer);
 }
 
 static void

  Added: test/command/suite/select/filter/logical_operation/or/vector.expected (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/logical_operation/or/vector.expected    2014-01-26 22:53:28 +0900 (6126565)
@@ -0,0 +1,11 @@
+table_create Records TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Records tags COLUMN_VECTOR ShortText
+[[0,0.0,0.0],true]
+load --table Records
+[
+{"_key": "empty", "tags": []}
+]
+[[0,0.0,0.0],1]
+select Records   --output_columns '_id, tags || "default"'   --command_version 2
+[[0,0.0,0.0],[[[1],[["_id","UInt32"],["tags","ShortText"]],[1,[]]]]]

  Added: test/command/suite/select/filter/logical_operation/or/vector.test (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/logical_operation/or/vector.test    2014-01-26 22:53:28 +0900 (f90caf8)
@@ -0,0 +1,11 @@
+table_create Records TABLE_HASH_KEY ShortText
+column_create Records tags COLUMN_VECTOR ShortText
+
+load --table Records
+[
+{"_key": "empty", "tags": []}
+]
+
+select Records \
+  --output_columns '_id, tags || "default"' \
+  --command_version 2
-------------- next part --------------
HTML����������������������������...
Download 



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