[Groonga-commit] ranguba/rroonga at 0538cff [master] Add Groonga::Context#support_zstd?

Back to archive index

Masafumi Yokoyama null+****@clear*****
Mon Dec 12 16:15:56 JST 2016


Masafumi Yokoyama	2016-12-12 16:15:56 +0900 (Mon, 12 Dec 2016)

  New Revision: 0538cff1ceb987d54463bfb0ca4f00a37beeacf1
  https://github.com/ranguba/rroonga/commit/0538cff1ceb987d54463bfb0ca4f00a37beeacf1

  Message:
    Add Groonga::Context#support_zstd?

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

  Modified: ext/groonga/rb-grn-context.c (+25 -0)
===================================================================
--- ext/groonga/rb-grn-context.c    2016-12-06 01:23:25 +0900 (1819c89)
+++ ext/groonga/rb-grn-context.c    2016-12-12 16:15:56 +0900 (11ead8a)
@@ -1,6 +1,7 @@
 /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /*
   Copyright (C) 2010-2015  Kouhei Sutou <kou �� clear-code.com>
+  Copyright (C) 2016  Masafumi Yokoyama <yokoyama �� 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
@@ -699,6 +700,28 @@ rb_grn_context_support_lz4_p (VALUE self)
 }
 
 /*
+ * If Groonga supports Zstandard compression, it returns +true+,
+ * otherwise it returns +false+.
+ *
+ * @overload support_zstd?
+ */
+static VALUE
+rb_grn_context_support_zstd_p (VALUE self)
+{
+    VALUE rb_support_p;
+    grn_ctx *context;
+    grn_obj support_p;
+
+    context = SELF(self);
+    GRN_BOOL_INIT(&support_p, 0);
+    grn_obj_get_info(context, NULL, GRN_INFO_SUPPORT_ZSTD, &support_p);
+    rb_support_p = CBOOL2RVAL(GRN_BOOL_VALUE(&support_p));
+    GRN_OBJ_FIN(context, &support_p);
+
+    return rb_support_p;
+}
+
+/*
  * コンテキストが使うデータベースを返す。
  *
  * @overload database
@@ -1005,6 +1028,8 @@ rb_grn_init_context (VALUE mGrn)
                      rb_grn_context_support_lzo_p, 0);
     rb_define_method(cGrnContext, "support_lz4?",
                      rb_grn_context_support_lz4_p, 0);
+    rb_define_method(cGrnContext, "support_zstd?",
+                     rb_grn_context_support_zstd_p, 0);
 
     rb_define_method(cGrnContext, "database", rb_grn_context_get_database, 0);
 

  Modified: test/test-context.rb (+5 -0)
===================================================================
--- test/test-context.rb    2016-12-06 01:23:25 +0900 (3f4db4f)
+++ test/test-context.rb    2016-12-12 16:15:56 +0900 (e16ab3d)
@@ -1,4 +1,5 @@
 # Copyright (C) 2009-2015  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2016  Masafumi Yokoyama <yokoyama �� 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
@@ -122,6 +123,10 @@ class ContextTest < Test::Unit::TestCase
     assert_boolean(Groonga::Context.default.support_lz4?)
   end
 
+  def test_support_zstd?
+    assert_boolean(Groonga::Context.default.support_zstd?)
+  end
+
   def test_match_escalation_threshold
     assert_equal(0, context.match_escalation_threshold)
     context.match_escalation_threshold = -1
-------------- next part --------------
HTML����������������������������...
下載 



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