[Groonga-commit] ranguba/rroonga at 92fbf69 [master] Support Apache Arrow

Back to archive index

Kouhei Sutou null+****@clear*****
Mon May 15 12:16:24 JST 2017


Kouhei Sutou	2017-05-15 12:16:24 +0900 (Mon, 15 May 2017)

  New Revision: 92fbf692af80adc833758ff4df4de341494e622f
  https://github.com/ranguba/rroonga/commit/92fbf692af80adc833758ff4df4de341494e622f

  Message:
    Support Apache Arrow
    
    New API:
    
      * Table#load_arrow
      * Table#dump_arrow

  Modified files:
    .travis.yml
    ext/groonga/rb-grn-table.c
    ext/groonga/rb-grn-utils.c
    ext/groonga/rb-grn.h
    rroonga-build.rb

  Modified: .travis.yml (+2 -2)
===================================================================
--- .travis.yml    2017-04-29 11:53:26 +0900 (9af44bb)
+++ .travis.yml    2017-05-15 12:16:24 +0900 (a359ed4)
@@ -9,8 +9,8 @@ rvm:
   - 2.2
   - 2.3.3
   - 2.4.0
-# env:
-#   - GROONGA_MASTER=yes
+env:
+  - GROONGA_MASTER=yes
 # matrix:
 #   allow_failures:
 #     - rvm: ruby-head

  Modified: ext/groonga/rb-grn-table.c (+93 -1)
===================================================================
--- ext/groonga/rb-grn-table.c    2017-04-29 11:53:26 +0900 (0325c74)
+++ ext/groonga/rb-grn-table.c    2017-05-15 12:16:24 +0900 (c6349db)
@@ -1,6 +1,6 @@
 /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /*
-  Copyright (C) 2009-2015  Kouhei Sutou <kou �� clear-code.com>
+  Copyright (C) 2009-2017  Kouhei Sutou <kou �� clear-code.com>
   Copyright (C) 2014-2016  Masafumi Yokoyama <yokoyama �� clear-code.com>
 
   This library is free software; you can redistribute it and/or
@@ -2646,6 +2646,95 @@ rb_grn_table_rename (VALUE self, VALUE rb_name)
     return self;
 }
 
+/*
+ * @overload load_arrow(path)
+ *
+ *   Loads records from Apache Arrow file format file.
+ *
+ *   @param path [String, #to_path] the path of file in Apache Arrow
+ *     file format.
+ *
+ *   @return [void]
+ *
+ *   @since 7.0.3
+ */
+static VALUE
+rb_grn_table_load_arrow (VALUE self, VALUE rb_path)
+{
+    int rc;
+    grn_ctx *context;
+    grn_obj *table;
+
+    rb_grn_table_deconstruct(SELF(self), &table, &context,
+                             NULL, NULL, NULL,
+                             NULL, NULL,
+                             NULL);
+
+    {
+        VALUE rb_path_string;
+        rb_path_string = rb_grn_check_convert_to_string(rb_path);
+        if (NIL_P(rb_path_string)) {
+            ID to_path;
+            CONST_ID(to_path, "to_path");
+            rb_path_string = rb_check_funcall(rb_path, to_path, 0, 0);
+            if (rb_path_string == Qundef) {
+                rb_path_string = rb_path;
+            }
+            rb_path = rb_grn_convert_to_string(rb_path_string);
+        }
+    }
+
+    rc = grn_arrow_load(context, table, StringValueCStr(rb_path));
+    rb_grn_context_check(context, self);
+    rb_grn_rc_check(rc, self);
+
+    return self;
+}
+
+/*
+ * @overload dump_arrow(path)
+ *
+ *   Dump records to file in Apache Arrow file format.
+ *
+ *   @param path [String, #to_path] the output file path.
+ *
+ *   @return [void]
+ *
+ *   @since 7.0.3
+ */
+static VALUE
+rb_grn_table_dump_arrow (VALUE self, VALUE rb_path)
+{
+    int rc;
+    grn_ctx *context;
+    grn_obj *table;
+
+    rb_grn_table_deconstruct(SELF(self), &table, &context,
+                             NULL, NULL, NULL,
+                             NULL, NULL,
+                             NULL);
+
+    {
+        VALUE rb_path_string;
+        rb_path_string = rb_grn_check_convert_to_string(rb_path);
+        if (NIL_P(rb_path_string)) {
+            ID to_path;
+            CONST_ID(to_path, "to_path");
+            rb_path_string = rb_check_funcall(rb_path, to_path, 0, 0);
+            if (rb_path_string == Qundef) {
+                rb_path_string = rb_path;
+            }
+            rb_path = rb_grn_convert_to_string(rb_path_string);
+        }
+    }
+
+    rc = grn_arrow_dump(context, table, StringValueCStr(rb_path));
+    rb_grn_context_check(context, self);
+    rb_grn_rc_check(rc, self);
+
+    return self;
+}
+
 void
 rb_grn_init_table (VALUE mGrn)
 {
@@ -2733,6 +2822,9 @@ rb_grn_init_table (VALUE mGrn)
 
     rb_define_method(rb_cGrnTable, "rename", rb_grn_table_rename, 1);
 
+    rb_define_method(rb_cGrnTable, "load_arrow", rb_grn_table_load_arrow, 1);
+    rb_define_method(rb_cGrnTable, "dump_arrow", rb_grn_table_dump_arrow, 1);
+
     rb_grn_init_table_key_support(mGrn);
     rb_grn_init_array(mGrn);
     rb_grn_init_hash(mGrn);

  Modified: ext/groonga/rb-grn-utils.c (+21 -2)
===================================================================
--- ext/groonga/rb-grn-utils.c    2017-04-29 11:53:26 +0900 (a55cace)
+++ ext/groonga/rb-grn-utils.c    2017-05-15 12:16:24 +0900 (07b5bd4)
@@ -1,7 +1,7 @@
-/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* vim: set sts=4 sw=4 ts=8 noet: */
 /*
-  Copyright (C) 2009-2013  Kouhei Sutou <kou �� clear-code.com>
+  Copyright (C) 2009-2017  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
@@ -127,6 +127,25 @@ rb_grn_convert_to_array (VALUE object)
 }
 
 VALUE
+rb_grn_convert_to_path (VALUE object)
+{
+    VALUE path;
+
+    path = rb_grn_check_convert_to_string(object);
+    if (NIL_P(path)) {
+        ID to_path;
+        CONST_ID(to_path, "to_path");
+        path = rb_check_funcall(object, to_path, 0, 0);
+        if (path == Qundef) {
+            path = object;
+        }
+        path = rb_grn_convert_to_string(path);
+    }
+
+    return path;
+}
+
+VALUE
 rb_grn_check_convert_to_string (VALUE object)
 {
     return rb_check_string_type(object);

  Modified: ext/groonga/rb-grn.h (+1 -0)
===================================================================
--- ext/groonga/rb-grn.h    2017-04-29 11:53:26 +0900 (3a05dc9)
+++ ext/groonga/rb-grn.h    2017-05-15 12:16:24 +0900 (14e3d96)
@@ -404,6 +404,7 @@ grn_bool       rb_grn_equal_string                  (const char *string1,
                                                      const char *string2);
 VALUE          rb_grn_convert_to_string             (VALUE object);
 VALUE          rb_grn_convert_to_array              (VALUE object);
+VALUE          rb_grn_convert_to_path               (VALUE object);
 VALUE          rb_grn_check_convert_to_string       (VALUE object);
 VALUE          rb_grn_check_convert_to_array        (VALUE object);
 VALUE          rb_grn_check_convert_to_hash         (VALUE object);

  Modified: rroonga-build.rb (+3 -3)
===================================================================
--- rroonga-build.rb    2017-04-29 11:53:26 +0900 (0dd730c)
+++ rroonga-build.rb    2017-05-15 12:16:24 +0900 (1e2e59b)
@@ -18,15 +18,15 @@ module RroongaBuild
   module RequiredGroongaVersion
     MAJOR = 7
     MINOR = 0
-    MICRO = 2
+    MICRO = 3
     VERSION = [MAJOR, MINOR, MICRO]
-    RELEASED_DATE = Time.utc(2017, 4, 29)
+    RELEASED_DATE = Time.utc(2017, 5, 29)
   end
 
   module LatestGroongaVersion
     MAJOR = 7
     MINOR = 0
-    MICRO = 2
+    MICRO = 3
     VERSION = [MAJOR, MINOR, MICRO]
   end
 
-------------- next part --------------
HTML����������������������������...
下载 



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