[Groonga-commit] groonga/groonga at 263f166 [master] store lz4: pack raw value instead of error for too large value

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Nov 11 12:36:32 JST 2016


Kouhei Sutou	2016-11-11 12:36:32 +0900 (Fri, 11 Nov 2016)

  New Revision: 263f166529c2ef73c234d2a1951eb38f613a7d69
  https://github.com/groonga/groonga/commit/263f166529c2ef73c234d2a1951eb38f613a7d69

  Message:
    store lz4: pack raw value instead of error for too large value

  Modified files:
    lib/store.c

  Modified: lib/store.c (+27 -4)
===================================================================
--- lib/store.c    2016-11-11 12:31:25 +0900 (1917bff)
+++ lib/store.c    2016-11-11 12:36:32 +0900 (b010d60)
@@ -1686,10 +1686,33 @@ grn_ja_put_lz4(grn_ctx *ctx, grn_ja *ja, grn_id id,
   }
 
   if (value_len > (uint32_t)LZ4_MAX_INPUT_SIZE) {
-    ERR(GRN_INVALID_ARGUMENT,
-        "[ja][lz4] too large value size: <%u>: max: <%d>",
-        value_len, LZ4_MAX_INPUT_SIZE);
-    return ctx->rc;
+    uint64_t packed_value_meta;
+
+    packed_value_len_real = value_len + sizeof(uint64_t);
+    packed_value = GRN_MALLOC(packed_value_len_real);
+    if (!packed_value) {
+      grn_ja_compress_error(ctx,
+                            ja,
+                            id,
+                            GRN_LZ4_ERROR,
+                            "[lz4] failed to allocate packed buffer",
+                            NULL);
+      return ctx->rc;
+    }
+    packed_value_meta = value_len | COMPRESSED_VALUE_META_FLAG_RAW;
+    *((uint64_t *)packed_value) = packed_value_meta;
+    memcpy(((uint64_t *)packed_value) + 1,
+           value,
+           value_len);
+    rc = grn_ja_put_raw(ctx,
+                        ja,
+                        id,
+                        packed_value,
+                        packed_value_len_real,
+                        flags,
+                        cas);
+    GRN_FREE(packed_value);
+    return rc;
   }
 
   lz4_value_len_max = LZ4_compressBound(value_len);
-------------- next part --------------
HTML����������������������������...
下载 



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