[Groonga-commit] groonga/groonga [master] [msgpack] partially support MessagePack on select

Back to archive index

null+****@clear***** null+****@clear*****
2011年 12月 28日 (水) 12:31:44 JST


Yoji SHIDARA	2011-12-28 12:31:44 +0900 (Wed, 28 Dec 2011)

  New Revision: a614f96faea991356bd1f42e6f83a72d8139e826

  Log:
    [msgpack] partially support MessagePack on select
    
    drilldown is not yet supported.
    
    refs #1215

  Modified files:
    lib/output.c
    lib/proc.c

  Modified: lib/output.c (+19 -3)
===================================================================
--- lib/output.c    2011-12-28 12:31:05 +0900 (3436c71)
+++ lib/output.c    2011-12-28 12:31:44 +0900 (01efb54)
@@ -939,16 +939,32 @@ grn_output_obj(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type,
       grn_table_cursor *tc = grn_table_cursor_open(ctx, obj, NULL, 0, NULL, 0,
                                                    format->offset, format->limit,
                                                    GRN_CURSOR_ASCENDING);
+      int resultset_size = -1;
       if (!tc) { ERRCLR(ctx); }
-      grn_output_array_open(ctx, outbuf, output_type, "RESULTSET", -1);
+#ifdef HAVE_MESSAGE_PACK
+      resultset_size = 1; /* [NHITS, (COLUMNS), (HITS)] */
+      if (format->flags & GRN_OBJ_FORMAT_WITH_COLUMN_NAMES) {
+        resultset_size++;
+      }
+      resultset_size += format->limit;
+#endif
+      grn_output_array_open(ctx, outbuf, output_type, "RESULTSET", resultset_size);
       grn_output_array_open(ctx, outbuf, output_type, "NHITS", 1);
+#ifdef HAVE_MESSAGE_PACK
+      if (output_type == GRN_CONTENT_MSGPACK) {
+        grn_output_int32(ctx, outbuf, output_type, format->nhits);
+      } else {
+        grn_text_itoa(ctx, outbuf, format->nhits);
+      }
+#else
       grn_text_itoa(ctx, outbuf, format->nhits);
+#endif
       grn_output_array_close(ctx, outbuf, output_type);
       if (format->flags & GRN_OBJ_FORMAT_WITH_COLUMN_NAMES) {
-        grn_output_array_open(ctx, outbuf, output_type, "COLUMNS", -1);
+        grn_output_array_open(ctx, outbuf, output_type, "COLUMNS", ncolumns);
         for (j = 0; j < ncolumns; j++) {
           grn_id range_id;
-          grn_output_array_open(ctx, outbuf, output_type, "COLUMN", -1);
+          grn_output_array_open(ctx, outbuf, output_type, "COLUMN", 2);
           GRN_BULK_REWIND(&buf);
           grn_column_name_(ctx, columns[j], &buf);
           grn_output_obj(ctx, outbuf, output_type, &buf, NULL);

  Modified: lib/proc.c (+1 -1)
===================================================================
--- lib/proc.c    2011-12-28 12:31:05 +0900 (bf12b9f)
+++ lib/proc.c    2011-12-28 12:31:44 +0900 (1b8fb2f)
@@ -405,7 +405,7 @@ grn_select(grn_ctx *ctx, const char *table, unsigned table_len,
     }
     nhits = res ? grn_table_size(ctx, res) : 0;
     LAP(":", "select(%d)", nhits);
-    GRN_OUTPUT_ARRAY_OPEN("RESULT", -1);
+    GRN_OUTPUT_ARRAY_OPEN("RESULT", res ? 1 : 0);
     if (res) {
       if (scorer && scorer_len) {
         grn_obj *v;




Groonga-commit メーリングリストの案内
Back to archive index