You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by sh...@apache.org on 2019/01/05 11:23:36 UTC
[arrow] branch master updated: ARROW-4154: [GLib] Add
GArrowDecimal128DataType
This is an automated email from the ASF dual-hosted git repository.
shiro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 857deae ARROW-4154: [GLib] Add GArrowDecimal128DataType
857deae is described below
commit 857deae933478970b4fc0ff55fab61f32a5c6e4f
Author: Kouhei Sutou <ko...@clear-code.com>
AuthorDate: Sat Jan 5 20:23:22 2019 +0900
ARROW-4154: [GLib] Add GArrowDecimal128DataType
garrow_decimal_data_type_new() is deprecated.
Author: Kouhei Sutou <ko...@clear-code.com>
Closes #3305 from kou/glib-decimal128-data-type and squashes the following commits:
b51b7a19 <Kouhei Sutou> Use decimal128
4823eea6 <Kouhei Sutou> Add GArrowDecimal128DataType
---
c_glib/arrow-glib/Makefile.am | 6 +--
c_glib/arrow-glib/array-builder.cpp | 6 +--
c_glib/arrow-glib/array-builder.h | 5 +-
c_glib/arrow-glib/basic-array.cpp | 4 +-
c_glib/arrow-glib/basic-data-type.cpp | 61 +++++++++++++++++-----
c_glib/arrow-glib/basic-data-type.h | 28 ++++++++--
c_glib/arrow-glib/{decimal.cpp => decimal128.cpp} | 2 +-
c_glib/arrow-glib/{decimal.h => decimal128.h} | 0
c_glib/arrow-glib/{decimal.hpp => decimal128.hpp} | 2 +-
c_glib/arrow-glib/meson.build | 6 +--
c_glib/arrow-glib/orc-file-reader.h | 2 +
c_glib/doc/arrow-glib/arrow-glib-docs.xml | 2 +-
...t-decimal-array.rb => test-decimal128-array.rb} | 6 +--
...l-data-type.rb => test-decimal128-data-type.rb} | 10 ++--
.../test/{test-decimal.rb => test-decimal128.rb} | 0
15 files changed, 99 insertions(+), 41 deletions(-)
diff --git a/c_glib/arrow-glib/Makefile.am b/c_glib/arrow-glib/Makefile.am
index bf97168..a296595 100644
--- a/c_glib/arrow-glib/Makefile.am
+++ b/c_glib/arrow-glib/Makefile.am
@@ -59,7 +59,7 @@ libarrow_glib_la_headers = \
composite-array.h \
composite-data-type.h \
data-type.h \
- decimal.h \
+ decimal128.h \
error.h \
field.h \
gobject-type.h \
@@ -110,7 +110,7 @@ libarrow_glib_la_sources = \
column.cpp \
composite-array.cpp \
composite-data-type.cpp \
- decimal.cpp \
+ decimal128.cpp \
error.cpp \
field.cpp \
record-batch.cpp \
@@ -155,7 +155,7 @@ libarrow_glib_la_cpp_headers = \
codec.hpp \
column.hpp \
data-type.hpp \
- decimal.hpp \
+ decimal128.hpp \
error.hpp \
field.hpp \
record-batch.hpp \
diff --git a/c_glib/arrow-glib/array-builder.cpp b/c_glib/arrow-glib/array-builder.cpp
index 4b61bfa..5f2d411 100644
--- a/c_glib/arrow-glib/array-builder.cpp
+++ b/c_glib/arrow-glib/array-builder.cpp
@@ -23,9 +23,9 @@
#include <arrow-glib/array-builder.hpp>
#include <arrow-glib/data-type.hpp>
+#include <arrow-glib/decimal128.hpp>
#include <arrow-glib/error.hpp>
#include <arrow-glib/type.hpp>
-#include <arrow-glib/decimal.hpp>
template <typename BUILDER, typename VALUE>
gboolean
@@ -3803,14 +3803,14 @@ garrow_decimal128_array_builder_class_init(GArrowDecimal128ArrayBuilderClass *kl
/**
* garrow_decimal128_array_builder_new:
- * @data_type: #GArrowDecimalDataType for the decimal.
+ * @data_type: #GArrowDecimal128DataType for the decimal.
*
* Returns: A newly created #GArrowDecimal128ArrayBuilder.
*
* Since: 0.10.0
*/
GArrowDecimal128ArrayBuilder *
-garrow_decimal128_array_builder_new(GArrowDecimalDataType *data_type)
+garrow_decimal128_array_builder_new(GArrowDecimal128DataType *data_type)
{
auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(data_type));
auto builder = garrow_array_builder_new(arrow_data_type,
diff --git a/c_glib/arrow-glib/array-builder.h b/c_glib/arrow-glib/array-builder.h
index 1ddc026..b2ad6f4 100644
--- a/c_glib/arrow-glib/array-builder.h
+++ b/c_glib/arrow-glib/array-builder.h
@@ -20,8 +20,7 @@
#pragma once
#include <arrow-glib/array.h>
-#include <arrow-glib/gobject-type.h>
-#include <arrow-glib/decimal.h>
+#include <arrow-glib/decimal128.h>
G_BEGIN_DECLS
@@ -1475,7 +1474,7 @@ struct _GArrowDecimal128ArrayBuilderClass
GArrowArrayBuilderClass parent_class;
};
-GArrowDecimal128ArrayBuilder *garrow_decimal128_array_builder_new(GArrowDecimalDataType *data_type);
+GArrowDecimal128ArrayBuilder *garrow_decimal128_array_builder_new(GArrowDecimal128DataType *data_type);
#ifndef GARROW_DISABLE_DEPRECATED
GARROW_DEPRECATED_IN_0_12_FOR(garrow_decimal128_array_builder_append_value)
diff --git a/c_glib/arrow-glib/basic-array.cpp b/c_glib/arrow-glib/basic-array.cpp
index fef43a0..9aebd9c 100644
--- a/c_glib/arrow-glib/basic-array.cpp
+++ b/c_glib/arrow-glib/basic-array.cpp
@@ -22,12 +22,12 @@
#endif
#include <arrow-glib/array.hpp>
+#include <arrow-glib/basic-data-type.hpp>
#include <arrow-glib/buffer.hpp>
#include <arrow-glib/compute.hpp>
-#include <arrow-glib/basic-data-type.hpp>
+#include <arrow-glib/decimal128.hpp>
#include <arrow-glib/error.hpp>
#include <arrow-glib/type.hpp>
-#include <arrow-glib/decimal.hpp>
#include <sstream>
diff --git a/c_glib/arrow-glib/basic-data-type.cpp b/c_glib/arrow-glib/basic-data-type.cpp
index cd3aa97..2a59996 100644
--- a/c_glib/arrow-glib/basic-data-type.cpp
+++ b/c_glib/arrow-glib/basic-data-type.cpp
@@ -85,7 +85,9 @@ G_BEGIN_DECLS
* #GArrowTime64DataType is a class for the number of microseconds or
* nanoseconds since midnight in 64-bit signed integer data type.
*
- * #GArrowDecimalDataType is a class for 128-bit decimal data type.
+ * #GArrowDecimalDataType is a base class for decimal data type.
+ *
+ * #GArrowDecimal128DataType is a class for 128-bit decimal data type.
*/
typedef struct GArrowDataTypePrivate_ {
@@ -1040,9 +1042,9 @@ garrow_time64_data_type_new(GArrowTimeUnit unit, GError **error)
}
-G_DEFINE_TYPE(GArrowDecimalDataType,
- garrow_decimal_data_type,
- GARROW_TYPE_DATA_TYPE)
+G_DEFINE_ABSTRACT_TYPE(GArrowDecimalDataType,
+ garrow_decimal_data_type,
+ GARROW_TYPE_DATA_TYPE)
static void
garrow_decimal_data_type_init(GArrowDecimalDataType *object)
@@ -1062,18 +1064,16 @@ garrow_decimal_data_type_class_init(GArrowDecimalDataTypeClass *klass)
* Returns: The newly created decimal data type.
*
* Since: 0.10.0
+ *
+ * Deprecate: 0.12.0:
+ * Use garrow_decimal128_data_type_new() instead.
*/
GArrowDecimalDataType *
garrow_decimal_data_type_new(gint32 precision,
gint32 scale)
{
- auto arrow_data_type = arrow::decimal(precision, scale);
-
- GArrowDecimalDataType *data_type =
- GARROW_DECIMAL_DATA_TYPE(g_object_new(GARROW_TYPE_DECIMAL_DATA_TYPE,
- "data-type", &arrow_data_type,
- NULL));
- return data_type;
+ auto decimal128_data_type = garrow_decimal128_data_type_new(precision, scale);
+ return GARROW_DECIMAL_DATA_TYPE(decimal128_data_type);
}
/**
@@ -1112,6 +1112,43 @@ garrow_decimal_data_type_get_scale(GArrowDecimalDataType *decimal_data_type)
return arrow_decimal_type->scale();
}
+
+G_DEFINE_TYPE(GArrowDecimal128DataType,
+ garrow_decimal128_data_type,
+ GARROW_TYPE_DECIMAL_DATA_TYPE)
+
+static void
+garrow_decimal128_data_type_init(GArrowDecimal128DataType *object)
+{
+}
+
+static void
+garrow_decimal128_data_type_class_init(GArrowDecimal128DataTypeClass *klass)
+{
+}
+
+/**
+ * garrow_decimal128_data_type_new:
+ * @precision: The precision of decimal data.
+ * @scale: The scale of decimal data.
+ *
+ * Returns: The newly created 128-bit decimal data type.
+ *
+ * Since: 0.12.0
+ */
+GArrowDecimal128DataType *
+garrow_decimal128_data_type_new(gint32 precision,
+ gint32 scale)
+{
+ auto arrow_data_type = arrow::decimal(precision, scale);
+
+ auto data_type =
+ GARROW_DECIMAL128_DATA_TYPE(g_object_new(GARROW_TYPE_DECIMAL128_DATA_TYPE,
+ "data-type", &arrow_data_type,
+ NULL));
+ return data_type;
+}
+
G_END_DECLS
GArrowDataType *
@@ -1199,7 +1236,7 @@ garrow_data_type_new_raw(std::shared_ptr<arrow::DataType> *arrow_data_type)
type = GARROW_TYPE_DICTIONARY_DATA_TYPE;
break;
case arrow::Type::type::DECIMAL:
- type = GARROW_TYPE_DECIMAL_DATA_TYPE;
+ type = GARROW_TYPE_DECIMAL128_DATA_TYPE;
break;
default:
type = GARROW_TYPE_DATA_TYPE;
diff --git a/c_glib/arrow-glib/basic-data-type.h b/c_glib/arrow-glib/basic-data-type.h
index 45fddba..ef41f1d 100644
--- a/c_glib/arrow-glib/basic-data-type.h
+++ b/c_glib/arrow-glib/basic-data-type.h
@@ -19,9 +19,9 @@
#pragma once
-#include <arrow-glib/gobject-type.h>
+#include <arrow-glib/decimal128.h>
#include <arrow-glib/type.h>
-#include <arrow-glib/decimal.h>
+#include <arrow-glib/version.h>
G_BEGIN_DECLS
@@ -651,6 +651,7 @@ GArrowTime64DataType *garrow_time64_data_type_new (GArrowTimeUnit unit,
#define GARROW_TYPE_DECIMAL_DATA_TYPE (garrow_decimal_data_type_get_type())
+/* TODO: Delivered from GArrowFixedSizeBinaryDataType. */
G_DECLARE_DERIVABLE_TYPE(GArrowDecimalDataType,
garrow_decimal_data_type,
GARROW,
@@ -661,9 +662,28 @@ struct _GArrowDecimalDataTypeClass
GArrowDataTypeClass parent_class;
};
-GArrowDecimalDataType *garrow_decimal_data_type_new (gint32 precision,
- gint32 scale);
+#ifndef GARROW_DISABLE_DEPRECATED
+GARROW_DEPRECATED_IN_0_12_FOR(garrow_decimal128_data_type_new)
+GArrowDecimalDataType *
+garrow_decimal_data_type_new(gint32 precision, gint32 scale);
+#endif
gint32 garrow_decimal_data_type_get_precision(GArrowDecimalDataType *decimal_data_type);
gint32 garrow_decimal_data_type_get_scale(GArrowDecimalDataType *decimal_data_type);
+
+#define GARROW_TYPE_DECIMAL128_DATA_TYPE (garrow_decimal128_data_type_get_type())
+G_DECLARE_DERIVABLE_TYPE(GArrowDecimal128DataType,
+ garrow_decimal128_data_type,
+ GARROW,
+ DECIMAL128_DATA_TYPE,
+ GArrowDecimalDataType)
+struct _GArrowDecimal128DataTypeClass
+{
+ GArrowDecimalDataTypeClass parent_class;
+};
+
+GARROW_AVAILABLE_IN_0_12
+GArrowDecimal128DataType *
+garrow_decimal128_data_type_new(gint32 precision, gint32 scale);
+
G_END_DECLS
diff --git a/c_glib/arrow-glib/decimal.cpp b/c_glib/arrow-glib/decimal128.cpp
similarity index 99%
rename from c_glib/arrow-glib/decimal.cpp
rename to c_glib/arrow-glib/decimal128.cpp
index 34eb417..e30eb7e 100644
--- a/c_glib/arrow-glib/decimal.cpp
+++ b/c_glib/arrow-glib/decimal128.cpp
@@ -21,7 +21,7 @@
# include <config.h>
#endif
-#include <arrow-glib/decimal.hpp>
+#include <arrow-glib/decimal128.hpp>
#include <arrow-glib/error.hpp>
G_BEGIN_DECLS
diff --git a/c_glib/arrow-glib/decimal.h b/c_glib/arrow-glib/decimal128.h
similarity index 100%
rename from c_glib/arrow-glib/decimal.h
rename to c_glib/arrow-glib/decimal128.h
diff --git a/c_glib/arrow-glib/decimal.hpp b/c_glib/arrow-glib/decimal128.hpp
similarity index 96%
rename from c_glib/arrow-glib/decimal.hpp
rename to c_glib/arrow-glib/decimal128.hpp
index ce56cfe..84bf47e 100644
--- a/c_glib/arrow-glib/decimal.hpp
+++ b/c_glib/arrow-glib/decimal128.hpp
@@ -23,7 +23,7 @@
#include <arrow/util/decimal.h>
-#include <arrow-glib/decimal.h>
+#include <arrow-glib/decimal128.h>
GArrowDecimal128 *garrow_decimal128_new_raw(std::shared_ptr<arrow::Decimal128> *arrow_decimal128);
std::shared_ptr<arrow::Decimal128> garrow_decimal128_get_raw(GArrowDecimal128 *decimal);
diff --git a/c_glib/arrow-glib/meson.build b/c_glib/arrow-glib/meson.build
index d962ec1..14126be 100644
--- a/c_glib/arrow-glib/meson.build
+++ b/c_glib/arrow-glib/meson.build
@@ -27,7 +27,7 @@ sources = files(
'column.cpp',
'composite-array.cpp',
'composite-data-type.cpp',
- 'decimal.cpp',
+ 'decimal128.cpp',
'error.cpp',
'field.cpp',
'record-batch.cpp',
@@ -77,7 +77,7 @@ c_headers = files(
'composite-array.h',
'composite-data-type.h',
'data-type.h',
- 'decimal.h',
+ 'decimal128.h',
'error.h',
'field.h',
'gobject-type.h',
@@ -128,7 +128,7 @@ cpp_headers = files(
'codec.hpp',
'column.hpp',
'data-type.hpp',
- 'decimal.hpp',
+ 'decimal128.hpp',
'error.hpp',
'field.hpp',
'record-batch.hpp',
diff --git a/c_glib/arrow-glib/orc-file-reader.h b/c_glib/arrow-glib/orc-file-reader.h
index 97cf1ef..9551d52 100644
--- a/c_glib/arrow-glib/orc-file-reader.h
+++ b/c_glib/arrow-glib/orc-file-reader.h
@@ -45,6 +45,7 @@ garrow_orc_file_reader_set_field_indexes(GArrowORCFileReader *reader,
const gint *field_indexes,
guint n_field_indexes);
#endif
+GARROW_AVAILABLE_IN_0_12
void
garrow_orc_file_reader_set_field_indices(GArrowORCFileReader *reader,
const gint *field_indices,
@@ -55,6 +56,7 @@ const gint *
garrow_orc_file_reader_get_field_indexes(GArrowORCFileReader *reader,
guint *n_field_indexes);
#endif
+GARROW_AVAILABLE_IN_0_12
const gint *
garrow_orc_file_reader_get_field_indices(GArrowORCFileReader *reader,
guint *n_field_indices);
diff --git a/c_glib/doc/arrow-glib/arrow-glib-docs.xml b/c_glib/doc/arrow-glib/arrow-glib-docs.xml
index 17b7500..f9f01fe 100644
--- a/c_glib/doc/arrow-glib/arrow-glib-docs.xml
+++ b/c_glib/doc/arrow-glib/arrow-glib-docs.xml
@@ -53,7 +53,7 @@
</chapter>
<chapter id="decimal">
<title>Decimal</title>
- <xi:include href="xml/decimal.xml"/>
+ <xi:include href="xml/decimal128.xml"/>
</chapter>
<chapter id="tensor">
<title>Tensor</title>
diff --git a/c_glib/test/test-decimal-array.rb b/c_glib/test/test-decimal128-array.rb
similarity index 89%
rename from c_glib/test/test-decimal-array.rb
rename to c_glib/test/test-decimal128-array.rb
index a5eb282..132ceb7 100644
--- a/c_glib/test/test-decimal-array.rb
+++ b/c_glib/test/test-decimal128-array.rb
@@ -15,9 +15,9 @@
# specific language governing permissions and limitations
# under the License.
-class TestDecimalArray < Test::Unit::TestCase
+class TestDecimal128Array < Test::Unit::TestCase
def test_format_value
- data_type = Arrow::DecimalDataType.new(8,2)
+ data_type = Arrow::Decimal128DataType.new(8, 2)
builder = Arrow::Decimal128ArrayBuilder.new(data_type)
decimal = Arrow::Decimal128.new("23423445")
builder.append_value(decimal)
@@ -26,7 +26,7 @@ class TestDecimalArray < Test::Unit::TestCase
end
def test_value
- data_type = Arrow::DecimalDataType.new(8,2)
+ data_type = Arrow::Decimal128DataType.new(8, 2)
builder = Arrow::Decimal128ArrayBuilder.new(data_type)
decimal = Arrow::Decimal128.new("23423445")
builder.append_value(decimal)
diff --git a/c_glib/test/test-decimal-data-type.rb b/c_glib/test/test-decimal128-data-type.rb
similarity index 80%
rename from c_glib/test/test-decimal-data-type.rb
rename to c_glib/test/test-decimal128-data-type.rb
index 04bfe78..27a31e2 100644
--- a/c_glib/test/test-decimal-data-type.rb
+++ b/c_glib/test/test-decimal128-data-type.rb
@@ -15,24 +15,24 @@
# specific language governing permissions and limitations
# under the License.
-class TestDecimalDataType < Test::Unit::TestCase
+class TestDecimal128DataType < Test::Unit::TestCase
def test_type
- data_type = Arrow::DecimalDataType.new(2, 0)
+ data_type = Arrow::Decimal128DataType.new(2, 0)
assert_equal(Arrow::Type::DECIMAL, data_type.id)
end
def test_to_s
- data_type = Arrow::DecimalDataType.new(2, 0)
+ data_type = Arrow::Decimal128DataType.new(2, 0)
assert_equal("decimal(2, 0)", data_type.to_s)
end
def test_precision
- data_type = Arrow::DecimalDataType.new(8, 2)
+ data_type = Arrow::Decimal128DataType.new(8, 2)
assert_equal(8, data_type.precision)
end
def test_scale
- data_type = Arrow::DecimalDataType.new(8, 2)
+ data_type = Arrow::Decimal128DataType.new(8, 2)
assert_equal(2, data_type.scale)
end
end
diff --git a/c_glib/test/test-decimal.rb b/c_glib/test/test-decimal128.rb
similarity index 100%
rename from c_glib/test/test-decimal.rb
rename to c_glib/test/test-decimal128.rb