[Groonga-commit] ranguba/rroonga at 9c2c071 [master] Add :key_large option to Groonga::Hash.create

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Apr 18 18:17:36 JST 2016


Kouhei Sutou	2016-04-18 18:17:36 +0900 (Mon, 18 Apr 2016)

  New Revision: 9c2c071b3915e90cfa425d1df701e7a96b90564e
  https://github.com/ranguba/rroonga/commit/9c2c071b3915e90cfa425d1df701e7a96b90564e

  Message:
    Add :key_large option to Groonga::Hash.create

  Modified files:
    ext/groonga/rb-grn-hash.c
    test/test-hash.rb

  Modified: ext/groonga/rb-grn-hash.c (+14 -2)
===================================================================
--- ext/groonga/rb-grn-hash.c    2016-04-18 18:04:33 +0900 (8e93a6a)
+++ ext/groonga/rb-grn-hash.c    2016-04-18 18:17:36 +0900 (6526807)
@@ -1,6 +1,6 @@
 /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /*
-  Copyright (C) 2009-2012  Kouhei Sutou <kou �� clear-code.com>
+  Copyright (C) 2009-2016  Kouhei Sutou <kou �� clear-code.com>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -103,6 +103,12 @@ VALUE rb_cGrnHash;
  *
  *       @deprecated Use @:normalizer => "NormalizerAuto"@ instead.
  *
+ *     @option options [Boolean] :key_large (false)
+ *       It specifies whether total key size is large or not. The
+ *       default total key size is 4GiB. Large total key size is 1TiB.
+ *
+ *       @since 6.0.1
+ *
  *     @option options :key_type
  *       キーの種類を示すオブジェクトを指定する。キーの種類には型
  *       名("Int32"や"ShortText"など)または {Groonga::Type} または
@@ -161,7 +167,9 @@ rb_grn_hash_s_create (int argc, VALUE *argv, VALUE klass)
     grn_obj_flags flags = GRN_OBJ_TABLE_HASH_KEY;
     VALUE rb_table;
     VALUE options, rb_context, rb_name, rb_path, rb_persistent;
-    VALUE rb_key_normalize, rb_key_type, rb_value_type, rb_default_tokenizer;
+    VALUE rb_key_normalize;
+    VALUE rb_key_large;
+    VALUE rb_key_type, rb_value_type, rb_default_tokenizer;
     VALUE rb_token_filters;
     VALUE rb_sub_records;
     VALUE rb_normalizer;
@@ -174,6 +182,7 @@ rb_grn_hash_s_create (int argc, VALUE *argv, VALUE klass)
                         "path", &rb_path,
                         "persistent", &rb_persistent,
                         "key_normalize", &rb_key_normalize,
+                        "key_large", &rb_key_large,
                         "key_type", &rb_key_type,
                         "value_type", &rb_value_type,
                         "default_tokenizer", &rb_default_tokenizer,
@@ -201,6 +210,9 @@ rb_grn_hash_s_create (int argc, VALUE *argv, VALUE klass)
     if (RVAL2CBOOL(rb_key_normalize))
         flags |= GRN_OBJ_KEY_NORMALIZE;
 
+    if (RVAL2CBOOL(rb_key_large))
+        flags |= GRN_OBJ_KEY_LARGE;
+
     if (NIL_P(rb_key_type)) {
         key_type = grn_ctx_at(context, GRN_DB_SHORT_TEXT);
     } else {

  Modified: test/test-hash.rb (+22 -3)
===================================================================
--- test/test-hash.rb    2016-04-18 18:04:33 +0900 (3a4b27e)
+++ test/test-hash.rb    2016-04-18 18:17:36 +0900 (ab532bf)
@@ -1,7 +1,5 @@
-# -*- coding: utf-8 -*-
-#
 # Copyright (C) 2014  Masafumi Yokoyama <myokoym �� gmail.com>
-# Copyright (C) 2009-2014  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2009-2016  Kouhei Sutou <kou �� clear-code.com>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -443,4 +441,25 @@ class HashTest < Test::Unit::TestCase
     user_names = users.each.collect(&:key)
     assert_equal(["Alice", "Bob", "Carl"], user_names)
   end
+
+  class KeyLargeTest < self
+    def test_default
+      paths = Groonga::Hash.create(:name => "Paths",
+                                   :key_type => "ShortText")
+      inspected = context.execute_command("object_inspect",
+                                          :name => paths.name)
+      assert_equal((4 * 1024 * 1024 * 1024) - 1,
+                   inspected.body["key"]["max_total_size"])
+    end
+
+    def test_enable
+      paths = Groonga::Hash.create(:name => "Paths",
+                                   :key_type => "ShortText",
+                                   :key_large => true)
+      inspected = context.execute_command("object_inspect",
+                                          :name => paths.name)
+      assert_equal((1 * 1024 * 1024 * 1024 * 1024) - 1,
+                   inspected.body["key"]["max_total_size"])
+    end
+  end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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