From 0e30af37b23fe4fff4851359fb8a1c472ab3f638 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Fri, 31 Mar 2017 17:02:10 -0400 Subject: [PATCH] Rename FixedWidthBinary to FixedSizeBinary for consistency with FixedSizeList type Change-Id: I4f0f8f0d45366da4d6405c4d9be21a38c7e65aeb --- cpp/src/arrow/array-test.cc | 34 ++++++++++---------- cpp/src/arrow/array.cc | 11 +++---- cpp/src/arrow/array.h | 6 ++-- cpp/src/arrow/builder.cc | 24 +++++++------- cpp/src/arrow/builder.h | 6 ++-- cpp/src/arrow/compare.cc | 8 ++--- cpp/src/arrow/ipc/json-internal.cc | 24 +++++++------- cpp/src/arrow/ipc/metadata.cc | 14 ++++---- cpp/src/arrow/ipc/test-common.h | 8 ++--- cpp/src/arrow/ipc/writer.cc | 2 +- cpp/src/arrow/loader.cc | 6 ++-- cpp/src/arrow/pretty_print-test.cc | 6 ++-- cpp/src/arrow/pretty_print.cc | 7 ++-- cpp/src/arrow/python/builtin_convert.cc | 6 ++-- cpp/src/arrow/python/pandas_convert.cc | 30 ++++++++--------- cpp/src/arrow/type-test.cc | 16 ++++----- cpp/src/arrow/type.cc | 14 ++++---- cpp/src/arrow/type.h | 14 ++++---- cpp/src/arrow/type_fwd.h | 6 ++-- cpp/src/arrow/type_traits.h | 6 ++-- cpp/src/arrow/visitor.cc | 4 +-- cpp/src/arrow/visitor.h | 4 +-- cpp/src/arrow/visitor_inline.h | 4 +-- format/Schema.fbs | 4 +-- python/pyarrow/__init__.py | 4 +-- python/pyarrow/array.pxd | 2 +- python/pyarrow/array.pyx | 6 ++-- python/pyarrow/includes/libarrow.pxd | 8 ++--- python/pyarrow/scalar.pxd | 2 +- python/pyarrow/scalar.pyx | 12 +++---- python/pyarrow/schema.pxd | 6 ++-- python/pyarrow/schema.pyx | 22 ++++++------- python/pyarrow/tests/test_convert_builtin.py | 4 +-- python/pyarrow/tests/test_convert_pandas.py | 4 +-- python/pyarrow/tests/test_scalars.py | 4 +-- 35 files changed, 168 insertions(+), 170 deletions(-) diff --git a/cpp/src/arrow/array-test.cc b/cpp/src/arrow/array-test.cc index 52f3727d46a..68b9864301d 100644 --- a/cpp/src/arrow/array-test.cc +++ b/cpp/src/arrow/array-test.cc @@ -1080,19 +1080,19 @@ TEST_F(TestBinaryArray, LengthZeroCtor) { } // ---------------------------------------------------------------------- -// FixedWidthBinary tests +// FixedSizeBinary tests class TestFWBinaryArray : public ::testing::Test { public: void SetUp() {} void InitBuilder(int byte_width) { - auto type = fixed_width_binary(byte_width); - builder_.reset(new FixedWidthBinaryBuilder(default_memory_pool(), type)); + auto type = fixed_size_binary(byte_width); + builder_.reset(new FixedSizeBinaryBuilder(default_memory_pool(), type)); } protected: - std::unique_ptr builder_; + std::unique_ptr builder_; }; TEST_F(TestFWBinaryArray, Builder) { @@ -1114,7 +1114,7 @@ TEST_F(TestFWBinaryArray, Builder) { auto CheckResult = [this, &length, &is_valid, &raw_data, &byte_width]( const Array& result) { // Verify output - const auto& fw_result = static_cast(result); + const auto& fw_result = static_cast(result); ASSERT_EQ(length, result.length()); @@ -1169,9 +1169,9 @@ TEST_F(TestFWBinaryArray, Builder) { TEST_F(TestFWBinaryArray, EqualsRangeEquals) { // Check that we don't compare data in null slots - auto type = fixed_width_binary(4); - FixedWidthBinaryBuilder builder1(default_memory_pool(), type); - FixedWidthBinaryBuilder builder2(default_memory_pool(), type); + auto type = fixed_size_binary(4); + FixedSizeBinaryBuilder builder1(default_memory_pool(), type); + FixedSizeBinaryBuilder builder2(default_memory_pool(), type); ASSERT_OK(builder1.Append("foo1")); ASSERT_OK(builder1.AppendNull()); @@ -1183,19 +1183,19 @@ TEST_F(TestFWBinaryArray, EqualsRangeEquals) { ASSERT_OK(builder1.Finish(&array1)); ASSERT_OK(builder2.Finish(&array2)); - const auto& a1 = static_cast(*array1); - const auto& a2 = static_cast(*array2); + const auto& a1 = static_cast(*array1); + const auto& a2 = static_cast(*array2); - FixedWidthBinaryArray equal1(type, 2, a1.data(), a1.null_bitmap(), 1); - FixedWidthBinaryArray equal2(type, 2, a2.data(), a1.null_bitmap(), 1); + FixedSizeBinaryArray equal1(type, 2, a1.data(), a1.null_bitmap(), 1); + FixedSizeBinaryArray equal2(type, 2, a2.data(), a1.null_bitmap(), 1); ASSERT_TRUE(equal1.Equals(equal2)); ASSERT_TRUE(equal1.RangeEquals(equal2, 0, 2, 0)); } TEST_F(TestFWBinaryArray, ZeroSize) { - auto type = fixed_width_binary(0); - FixedWidthBinaryBuilder builder(default_memory_pool(), type); + auto type = fixed_size_binary(0); + FixedSizeBinaryBuilder builder(default_memory_pool(), type); ASSERT_OK(builder.Append(nullptr)); ASSERT_OK(builder.Append(nullptr)); @@ -1207,7 +1207,7 @@ TEST_F(TestFWBinaryArray, ZeroSize) { std::shared_ptr array; ASSERT_OK(builder.Finish(&array)); - const auto& fw_array = static_cast(*array); + const auto& fw_array = static_cast(*array); // data is never allocated ASSERT_TRUE(fw_array.data() == nullptr); @@ -1218,8 +1218,8 @@ TEST_F(TestFWBinaryArray, ZeroSize) { } TEST_F(TestFWBinaryArray, Slice) { - auto type = fixed_width_binary(4); - FixedWidthBinaryBuilder builder(default_memory_pool(), type); + auto type = fixed_size_binary(4); + FixedSizeBinaryBuilder builder(default_memory_pool(), type); vector strings = {"foo1", "foo2", "foo3", "foo4", "foo5"}; vector is_null = {0, 1, 0, 0, 0}; diff --git a/cpp/src/arrow/array.cc b/cpp/src/arrow/array.cc index b25411a1c59..bd20654bc87 100644 --- a/cpp/src/arrow/array.cc +++ b/cpp/src/arrow/array.cc @@ -280,18 +280,17 @@ std::shared_ptr StringArray::Slice(int64_t offset, int64_t length) const // ---------------------------------------------------------------------- // Fixed width binary -FixedWidthBinaryArray::FixedWidthBinaryArray(const std::shared_ptr& type, +FixedSizeBinaryArray::FixedSizeBinaryArray(const std::shared_ptr& type, int64_t length, const std::shared_ptr& data, const std::shared_ptr& null_bitmap, int64_t null_count, int64_t offset) : PrimitiveArray(type, length, data, null_bitmap, null_count, offset) { - DCHECK(type->type == Type::FIXED_WIDTH_BINARY); - byte_width_ = static_cast(*type).byte_width(); + DCHECK(type->type == Type::FIXED_SIZE_BINARY); + byte_width_ = static_cast(*type).byte_width(); } -std::shared_ptr FixedWidthBinaryArray::Slice( - int64_t offset, int64_t length) const { +std::shared_ptr FixedSizeBinaryArray::Slice(int64_t offset, int64_t length) const { ConformSliceParams(offset_, length_, &offset, &length); - return std::make_shared( + return std::make_shared( type_, length, data_, null_bitmap_, kUnknownNullCount, offset); } diff --git a/cpp/src/arrow/array.h b/cpp/src/arrow/array.h index 53b640853d5..9f0e73914da 100644 --- a/cpp/src/arrow/array.h +++ b/cpp/src/arrow/array.h @@ -347,11 +347,11 @@ class ARROW_EXPORT StringArray : public BinaryArray { // ---------------------------------------------------------------------- // Fixed width binary -class ARROW_EXPORT FixedWidthBinaryArray : public PrimitiveArray { +class ARROW_EXPORT FixedSizeBinaryArray : public PrimitiveArray { public: - using TypeClass = FixedWidthBinaryType; + using TypeClass = FixedSizeBinaryType; - FixedWidthBinaryArray(const std::shared_ptr& type, int64_t length, + FixedSizeBinaryArray(const std::shared_ptr& type, int64_t length, const std::shared_ptr& data, const std::shared_ptr& null_bitmap = nullptr, int64_t null_count = 0, int64_t offset = 0); diff --git a/cpp/src/arrow/builder.cc b/cpp/src/arrow/builder.cc index 82b62146b0f..40b81cf015a 100644 --- a/cpp/src/arrow/builder.cc +++ b/cpp/src/arrow/builder.cc @@ -438,51 +438,51 @@ Status StringBuilder::Finish(std::shared_ptr* out) { // ---------------------------------------------------------------------- // Fixed width binary -FixedWidthBinaryBuilder::FixedWidthBinaryBuilder( +FixedSizeBinaryBuilder::FixedSizeBinaryBuilder( MemoryPool* pool, const std::shared_ptr& type) : ArrayBuilder(pool, type), byte_builder_(pool) { - DCHECK(type->type == Type::FIXED_WIDTH_BINARY); - byte_width_ = static_cast(*type).byte_width(); + DCHECK(type->type == Type::FIXED_SIZE_BINARY); + byte_width_ = static_cast(*type).byte_width(); } -Status FixedWidthBinaryBuilder::Append(const uint8_t* value) { +Status FixedSizeBinaryBuilder::Append(const uint8_t* value) { RETURN_NOT_OK(Reserve(1)); UnsafeAppendToBitmap(true); return byte_builder_.Append(value, byte_width_); } -Status FixedWidthBinaryBuilder::Append( +Status FixedSizeBinaryBuilder::Append( const uint8_t* data, int64_t length, const uint8_t* valid_bytes) { RETURN_NOT_OK(Reserve(length)); UnsafeAppendToBitmap(valid_bytes, length); return byte_builder_.Append(data, length * byte_width_); } -Status FixedWidthBinaryBuilder::Append(const std::string& value) { +Status FixedSizeBinaryBuilder::Append(const std::string& value) { return Append(reinterpret_cast(value.c_str())); } -Status FixedWidthBinaryBuilder::AppendNull() { +Status FixedSizeBinaryBuilder::AppendNull() { RETURN_NOT_OK(Reserve(1)); UnsafeAppendToBitmap(false); return byte_builder_.Advance(byte_width_); } -Status FixedWidthBinaryBuilder::Init(int64_t elements) { +Status FixedSizeBinaryBuilder::Init(int64_t elements) { DCHECK_LT(elements, std::numeric_limits::max()); RETURN_NOT_OK(ArrayBuilder::Init(elements)); return byte_builder_.Resize(elements * byte_width_); } -Status FixedWidthBinaryBuilder::Resize(int64_t capacity) { +Status FixedSizeBinaryBuilder::Resize(int64_t capacity) { DCHECK_LT(capacity, std::numeric_limits::max()); RETURN_NOT_OK(byte_builder_.Resize(capacity * byte_width_)); return ArrayBuilder::Resize(capacity); } -Status FixedWidthBinaryBuilder::Finish(std::shared_ptr* out) { +Status FixedSizeBinaryBuilder::Finish(std::shared_ptr* out) { std::shared_ptr data = byte_builder_.Finish(); - *out = std::make_shared( + *out = std::make_shared( type_, length_, data, null_bitmap_, null_count_); return Status::OK(); } @@ -542,7 +542,7 @@ Status MakeBuilder(MemoryPool* pool, const std::shared_ptr& type, BUILDER_CASE(DOUBLE, DoubleBuilder); BUILDER_CASE(STRING, StringBuilder); BUILDER_CASE(BINARY, BinaryBuilder); - BUILDER_CASE(FIXED_WIDTH_BINARY, FixedWidthBinaryBuilder); + BUILDER_CASE(FIXED_SIZE_BINARY, FixedSizeBinaryBuilder); case Type::LIST: { std::shared_ptr value_builder; std::shared_ptr value_type = diff --git a/cpp/src/arrow/builder.h b/cpp/src/arrow/builder.h index bd957b38280..61207a334db 100644 --- a/cpp/src/arrow/builder.h +++ b/cpp/src/arrow/builder.h @@ -390,11 +390,11 @@ class ARROW_EXPORT StringBuilder : public BinaryBuilder { }; // ---------------------------------------------------------------------- -// FixedWidthBinaryBuilder +// FixedSizeBinaryBuilder -class ARROW_EXPORT FixedWidthBinaryBuilder : public ArrayBuilder { +class ARROW_EXPORT FixedSizeBinaryBuilder : public ArrayBuilder { public: - FixedWidthBinaryBuilder(MemoryPool* pool, const std::shared_ptr& type); + FixedSizeBinaryBuilder(MemoryPool* pool, const std::shared_ptr& type); Status Append(const uint8_t* value); Status Append( diff --git a/cpp/src/arrow/compare.cc b/cpp/src/arrow/compare.cc index 4cd617e6021..7451439a875 100644 --- a/cpp/src/arrow/compare.cc +++ b/cpp/src/arrow/compare.cc @@ -202,8 +202,8 @@ class RangeEqualsVisitor { return Status::OK(); } - Status Visit(const FixedWidthBinaryArray& left) { - const auto& right = static_cast(right_); + Status Visit(const FixedSizeBinaryArray& left) { + const auto& right = static_cast(right_); int32_t width = left.byte_width(); @@ -648,8 +648,8 @@ class TypeEqualsVisitor { return Status::OK(); } - Status Visit(const FixedWidthBinaryType& left) { - const auto& right = static_cast(right_); + Status Visit(const FixedSizeBinaryType& left) { + const auto& right = static_cast(right_); result_ = left.byte_width() == right.byte_width(); return Status::OK(); } diff --git a/cpp/src/arrow/ipc/json-internal.cc b/cpp/src/arrow/ipc/json-internal.cc index 9572a0a8189..1e2385b73f8 100644 --- a/cpp/src/arrow/ipc/json-internal.cc +++ b/cpp/src/arrow/ipc/json-internal.cc @@ -189,7 +189,7 @@ class JsonSchemaWriter { } } - void WriteTypeMetadata(const FixedWidthBinaryType& type) { + void WriteTypeMetadata(const FixedSizeBinaryType& type) { writer_->Key("byteWidth"); writer_->Int(type.byte_width()); } @@ -297,8 +297,8 @@ class JsonSchemaWriter { Status Visit(const BinaryType& type) { return WriteVarBytes("binary", type); } - Status Visit(const FixedWidthBinaryType& type) { - return WritePrimitive("fixedwidthbinary", type); + Status Visit(const FixedSizeBinaryType& type) { + return WritePrimitive("fixedsizebinary", type); } Status Visit(const TimestampType& type) { return WritePrimitive("timestamp", type); } @@ -401,7 +401,7 @@ class JsonArrayWriter { } } - void WriteDataValues(const FixedWidthBinaryArray& arr) { + void WriteDataValues(const FixedSizeBinaryArray& arr) { int32_t width = arr.byte_width(); for (int64_t i = 0; i < arr.length(); ++i) { const char* buf = reinterpret_cast(arr.GetValue(i)); @@ -576,13 +576,13 @@ static Status GetFloatingPoint( return Status::OK(); } -static Status GetFixedWidthBinary( +static Status GetFixedSizeBinary( const RjObject& json_type, std::shared_ptr* type) { const auto& json_byte_width = json_type.FindMember("byteWidth"); RETURN_NOT_INT("byteWidth", json_byte_width, json_type); int32_t byte_width = json_byte_width->value.GetInt(); - *type = fixed_width_binary(byte_width); + *type = fixed_size_binary(byte_width); return Status::OK(); } @@ -709,8 +709,8 @@ static Status GetType(const RjObject& json_type, *type = utf8(); } else if (type_name == "binary") { *type = binary(); - } else if (type_name == "fixedwidthbinary") { - return GetFixedWidthBinary(json_type, type); + } else if (type_name == "fixedsizebinary") { + return GetFixedSizeBinary(json_type, type); } else if (type_name == "null") { *type = null(); } else if (type_name == "date") { @@ -896,10 +896,10 @@ class JsonArrayReader { } template - typename std::enable_if::value, Status>::type + typename std::enable_if::value, Status>::type ReadArray(const RjObject& json_array, int32_t length, const std::vector& is_valid, const std::shared_ptr& type, std::shared_ptr* array) { - FixedWidthBinaryBuilder builder(pool_, type); + FixedSizeBinaryBuilder builder(pool_, type); const auto& json_data = json_array.FindMember("DATA"); RETURN_NOT_ARRAY("DATA", json_data, json_array); @@ -908,7 +908,7 @@ class JsonArrayReader { DCHECK_EQ(static_cast(json_data_arr.Size()), length); - int32_t byte_width = static_cast(*type).byte_width(); + int32_t byte_width = static_cast(*type).byte_width(); // Allocate space for parsed values std::shared_ptr byte_buffer; @@ -1112,7 +1112,7 @@ class JsonArrayReader { TYPE_CASE(DoubleType); TYPE_CASE(StringType); TYPE_CASE(BinaryType); - TYPE_CASE(FixedWidthBinaryType); + TYPE_CASE(FixedSizeBinaryType); TYPE_CASE(Date32Type); TYPE_CASE(Date64Type); TYPE_CASE(TimestampType); diff --git a/cpp/src/arrow/ipc/metadata.cc b/cpp/src/arrow/ipc/metadata.cc index 076a6e792ba..5007f130908 100644 --- a/cpp/src/arrow/ipc/metadata.cc +++ b/cpp/src/arrow/ipc/metadata.cc @@ -230,9 +230,9 @@ static Status TypeFromFlatbuffer(flatbuf::Type type, const void* type_data, case flatbuf::Type_Binary: *out = binary(); return Status::OK(); - case flatbuf::Type_FixedWidthBinary: { - auto fw_binary = static_cast(type_data); - *out = fixed_width_binary(fw_binary->byteWidth()); + case flatbuf::Type_FixedSizeBinary: { + auto fw_binary = static_cast(type_data); + *out = fixed_size_binary(fw_binary->byteWidth()); return Status::OK(); } case flatbuf::Type_Utf8: @@ -362,10 +362,10 @@ static Status TypeToFlatbuffer(FBB& fbb, const std::shared_ptr& type, *out_type = flatbuf::Type_FloatingPoint; *offset = FloatToFlatbuffer(fbb, flatbuf::Precision_DOUBLE); break; - case Type::FIXED_WIDTH_BINARY: { - const auto& fw_type = static_cast(*type); - *out_type = flatbuf::Type_FixedWidthBinary; - *offset = flatbuf::CreateFixedWidthBinary(fbb, fw_type.byte_width()).Union(); + case Type::FIXED_SIZE_BINARY: { + const auto& fw_type = static_cast(*type); + *out_type = flatbuf::Type_FixedSizeBinary; + *offset = flatbuf::CreateFixedSizeBinary(fbb, fw_type.byte_width()).Union(); } break; case Type::BINARY: *out_type = flatbuf::Type_Binary; diff --git a/cpp/src/arrow/ipc/test-common.h b/cpp/src/arrow/ipc/test-common.h index 134a5caee8e..d113531822c 100644 --- a/cpp/src/arrow/ipc/test-common.h +++ b/cpp/src/arrow/ipc/test-common.h @@ -599,14 +599,14 @@ void AppendValues(const std::vector& is_valid, const std::vector& value Status MakeFWBinary(std::shared_ptr* out) { std::vector is_valid = {true, true, true, false}; - auto f0 = field("f0", fixed_width_binary(4)); - auto f1 = field("f1", fixed_width_binary(0)); + auto f0 = field("f0", fixed_size_binary(4)); + auto f1 = field("f1", fixed_size_binary(0)); std::shared_ptr schema(new Schema({f0, f1})); std::shared_ptr a1, a2; - FixedWidthBinaryBuilder b1(default_memory_pool(), f0->type); - FixedWidthBinaryBuilder b2(default_memory_pool(), f1->type); + FixedSizeBinaryBuilder b1(default_memory_pool(), f0->type); + FixedSizeBinaryBuilder b2(default_memory_pool(), f1->type); std::vector values1 = {"foo1", "foo2", "foo3", "foo4"}; AppendValues(is_valid, values1, &b1); diff --git a/cpp/src/arrow/ipc/writer.cc b/cpp/src/arrow/ipc/writer.cc index 0867382e6b1..53302064809 100644 --- a/cpp/src/arrow/ipc/writer.cc +++ b/cpp/src/arrow/ipc/writer.cc @@ -269,7 +269,7 @@ class RecordBatchWriter : public ArrayVisitor { return Status::OK(); } - Status Visit(const FixedWidthBinaryArray& array) override { + Status Visit(const FixedSizeBinaryArray& array) override { auto data = array.data(); int32_t width = array.byte_width(); diff --git a/cpp/src/arrow/loader.cc b/cpp/src/arrow/loader.cc index cc64c4d8264..f3347f92e6d 100644 --- a/cpp/src/arrow/loader.cc +++ b/cpp/src/arrow/loader.cc @@ -139,7 +139,7 @@ class ArrayLoader { template typename std::enable_if::value && - !std::is_base_of::value && + !std::is_base_of::value && !std::is_base_of::value, Status>::type Visit(const T& type) { @@ -152,14 +152,14 @@ class ArrayLoader { return LoadBinary(); } - Status Visit(const FixedWidthBinaryType& type) { + Status Visit(const FixedSizeBinaryType& type) { FieldMetadata field_meta; std::shared_ptr null_bitmap, data; RETURN_NOT_OK(LoadCommon(&field_meta, &null_bitmap)); RETURN_NOT_OK(GetBuffer(context_->buffer_index++, &data)); - result_ = std::make_shared( + result_ = std::make_shared( type_, field_meta.length, data, null_bitmap, field_meta.null_count); return Status::OK(); } diff --git a/cpp/src/arrow/pretty_print-test.cc b/cpp/src/arrow/pretty_print-test.cc index f21383f0cb0..80cd9cfe6ac 100644 --- a/cpp/src/arrow/pretty_print-test.cc +++ b/cpp/src/arrow/pretty_print-test.cc @@ -78,14 +78,14 @@ TEST_F(TestPrettyPrint, BinaryType) { CheckPrimitive(0, is_valid, values, ex); } -TEST_F(TestPrettyPrint, FixedWidthBinaryType) { +TEST_F(TestPrettyPrint, FixedSizeBinaryType) { std::vector is_valid = {true, true, false, true, false}; std::vector values = {"foo", "bar", "baz"}; static const char* ex = R"expected([666F6F, 626172, 62617A])expected"; std::shared_ptr array; - auto type = fixed_width_binary(3); - FixedWidthBinaryBuilder builder(default_memory_pool(), type); + auto type = fixed_size_binary(3); + FixedSizeBinaryBuilder builder(default_memory_pool(), type); builder.Append(values[0]); builder.Append(values[1]); diff --git a/cpp/src/arrow/pretty_print.cc b/cpp/src/arrow/pretty_print.cc index 0f67fe5bc52..0f46f0306fe 100644 --- a/cpp/src/arrow/pretty_print.cc +++ b/cpp/src/arrow/pretty_print.cc @@ -97,9 +97,8 @@ class ArrayPrinter { } template - inline - typename std::enable_if::value, void>::type - WriteDataValues(const T& array) { + inline typename std::enable_if::value, void>::type + WriteDataValues(const T& array) { int32_t width = array.byte_width(); for (int i = 0; i < array.length(); ++i) { if (i > 0) { (*sink_) << ", "; } @@ -136,7 +135,7 @@ class ArrayPrinter { template typename std::enable_if::value || - std::is_base_of::value || + std::is_base_of::value || std::is_base_of::value, Status>::type Visit(const T& array) { diff --git a/cpp/src/arrow/python/builtin_convert.cc b/cpp/src/arrow/python/builtin_convert.cc index 72e86774fcc..6a13fdccdea 100644 --- a/cpp/src/arrow/python/builtin_convert.cc +++ b/cpp/src/arrow/python/builtin_convert.cc @@ -406,13 +406,13 @@ class BytesConverter : public TypedConverter { } }; -class FixedWidthBytesConverter : public TypedConverter { +class FixedWidthBytesConverter : public TypedConverter { public: Status AppendData(PyObject* seq) override { PyObject* item; PyObject* bytes_obj; OwnedRef tmp; - Py_ssize_t expected_length = std::dynamic_pointer_cast( + Py_ssize_t expected_length = std::dynamic_pointer_cast( typed_builder_->type())->byte_width(); Py_ssize_t size = PySequence_Size(seq); for (int64_t i = 0; i < size; ++i) { @@ -510,7 +510,7 @@ std::shared_ptr GetConverter(const std::shared_ptr& type return std::make_shared(); case Type::BINARY: return std::make_shared(); - case Type::FIXED_WIDTH_BINARY: + case Type::FIXED_SIZE_BINARY: return std::make_shared(); case Type::STRING: return std::make_shared(); diff --git a/cpp/src/arrow/python/pandas_convert.cc b/cpp/src/arrow/python/pandas_convert.cc index 68a8d7d7afc..864d9710c5c 100644 --- a/cpp/src/arrow/python/pandas_convert.cc +++ b/cpp/src/arrow/python/pandas_convert.cc @@ -176,7 +176,7 @@ Status AppendObjectStrings(int64_t objects_length, StringBuilder* builder, } static Status AppendObjectFixedWidthBytes(int64_t objects_length, int byte_width, - FixedWidthBinaryBuilder* builder, PyObject** objects) { + FixedSizeBinaryBuilder* builder, PyObject** objects) { PyObject* obj; for (int64_t i = 0; i < objects_length; ++i) { @@ -223,7 +223,7 @@ struct WrapBytes { }; template <> -struct WrapBytes { +struct WrapBytes { static inline PyObject* Wrap(const uint8_t* data, int64_t length) { return PyBytes_FromStringAndSize(reinterpret_cast(data), length); } @@ -462,10 +462,10 @@ Status PandasConverter::ConvertObjectFixedWidthBytes( PyAcquireGIL lock; PyObject** objects = reinterpret_cast(PyArray_DATA(arr_)); - FixedWidthBinaryBuilder builder(pool_, type); + FixedSizeBinaryBuilder builder(pool_, type); RETURN_NOT_OK(builder.Resize(length_)); RETURN_NOT_OK(AppendObjectFixedWidthBytes(length_, - std::dynamic_pointer_cast(builder.type())->byte_width(), + std::dynamic_pointer_cast(builder.type())->byte_width(), &builder, objects)); RETURN_NOT_OK(builder.Finish(out)); return Status::OK(); @@ -527,7 +527,7 @@ Status PandasConverter::ConvertObjects(std::shared_ptr* out) { switch (type_->type) { case Type::STRING: return ConvertObjectStrings(out); - case Type::FIXED_WIDTH_BINARY: + case Type::FIXED_SIZE_BINARY: return ConvertObjectFixedWidthBytes(type_, out); case Type::BOOL: return ConvertBooleans(out); @@ -979,14 +979,14 @@ inline Status ConvertBinaryLike(const ChunkedArray& data, PyObject** out_values) return Status::OK(); } -inline Status ConvertFixedWidthBinary(const ChunkedArray& data, PyObject** out_values) { +inline Status ConvertFixedSizeBinary(const ChunkedArray& data, PyObject** out_values) { PyAcquireGIL lock; for (int c = 0; c < data.num_chunks(); c++) { - auto arr = static_cast(data.chunk(c).get()); + auto arr = static_cast(data.chunk(c).get()); const uint8_t* data_ptr; int32_t length = - std::dynamic_pointer_cast(arr->type())->byte_width(); + std::dynamic_pointer_cast(arr->type())->byte_width(); const bool has_nulls = data.null_count() > 0; for (int64_t i = 0; i < arr->length(); ++i) { if (has_nulls && arr->IsNull(i)) { @@ -994,7 +994,7 @@ inline Status ConvertFixedWidthBinary(const ChunkedArray& data, PyObject** out_v *out_values = Py_None; } else { data_ptr = arr->GetValue(i); - *out_values = WrapBytes::Wrap(data_ptr, length); + *out_values = WrapBytes::Wrap(data_ptr, length); if (*out_values == nullptr) { PyErr_Clear(); std::stringstream ss; @@ -1143,8 +1143,8 @@ class ObjectBlock : public PandasBlock { RETURN_NOT_OK(ConvertBinaryLike(data, out_buffer)); } else if (type == Type::STRING) { RETURN_NOT_OK(ConvertBinaryLike(data, out_buffer)); - } else if (type == Type::FIXED_WIDTH_BINARY) { - RETURN_NOT_OK(ConvertFixedWidthBinary(data, out_buffer)); + } else if (type == Type::FIXED_SIZE_BINARY) { + RETURN_NOT_OK(ConvertFixedSizeBinary(data, out_buffer)); } else if (type == Type::LIST) { auto list_type = std::static_pointer_cast(col->type()); switch (list_type->value_type()->type) { @@ -1574,7 +1574,7 @@ class DataFrameBlockCreator { break; case Type::STRING: case Type::BINARY: - case Type::FIXED_WIDTH_BINARY: + case Type::FIXED_SIZE_BINARY: output_type = PandasBlock::OBJECT; break; case Type::DATE64: @@ -1839,7 +1839,7 @@ class ArrowDeserializer { CONVERT_CASE(DOUBLE); CONVERT_CASE(BINARY); CONVERT_CASE(STRING); - CONVERT_CASE(FIXED_WIDTH_BINARY); + CONVERT_CASE(FIXED_SIZE_BINARY); CONVERT_CASE(DATE64); CONVERT_CASE(TIMESTAMP); CONVERT_CASE(DICTIONARY); @@ -1944,11 +1944,11 @@ class ArrowDeserializer { // Fixed length binary strings template - inline typename std::enable_if::type + inline typename std::enable_if::type ConvertValues() { RETURN_NOT_OK(AllocateOutput(NPY_OBJECT)); auto out_values = reinterpret_cast(PyArray_DATA(arr_)); - return ConvertFixedWidthBinary(data_, out_values); + return ConvertFixedSizeBinary(data_, out_values); } #define CONVERTVALUES_LISTSLIKE_CASE(ArrowType, ArrowEnum) \ diff --git a/cpp/src/arrow/type-test.cc b/cpp/src/arrow/type-test.cc index b221c80391c..dafadc168c1 100644 --- a/cpp/src/arrow/type-test.cc +++ b/cpp/src/arrow/type-test.cc @@ -155,16 +155,16 @@ TEST(TestStringType, ToString) { ASSERT_EQ(str.ToString(), std::string("string")); } -TEST(TestFixedWidthBinaryType, ToString) { - auto t = fixed_width_binary(10); - ASSERT_EQ(t->type, Type::FIXED_WIDTH_BINARY); - ASSERT_EQ("fixed_width_binary[10]", t->ToString()); +TEST(TestFixedSizeBinaryType, ToString) { + auto t = fixed_size_binary(10); + ASSERT_EQ(t->type, Type::FIXED_SIZE_BINARY); + ASSERT_EQ("fixed_size_binary[10]", t->ToString()); } -TEST(TestFixedWidthBinaryType, Equals) { - auto t1 = fixed_width_binary(10); - auto t2 = fixed_width_binary(10); - auto t3 = fixed_width_binary(3); +TEST(TestFixedSizeBinaryType, Equals) { + auto t1 = fixed_size_binary(10); + auto t2 = fixed_size_binary(10); + auto t3 = fixed_size_binary(3); ASSERT_TRUE(t1->Equals(t1)); ASSERT_TRUE(t1->Equals(t2)); diff --git a/cpp/src/arrow/type.cc b/cpp/src/arrow/type.cc index e6e6f5c3e8b..d99551d661d 100644 --- a/cpp/src/arrow/type.cc +++ b/cpp/src/arrow/type.cc @@ -90,13 +90,13 @@ std::string BinaryType::ToString() const { return std::string("binary"); } -int FixedWidthBinaryType::bit_width() const { +int FixedSizeBinaryType::bit_width() const { return 8 * byte_width(); } -std::string FixedWidthBinaryType::ToString() const { +std::string FixedSizeBinaryType::ToString() const { std::stringstream ss; - ss << "fixed_width_binary[" << byte_width_ << "]"; + ss << "fixed_size_binary[" << byte_width_ << "]"; return ss.str(); } @@ -286,7 +286,7 @@ std::string Schema::ToString() const { ACCEPT_VISITOR(NullType); ACCEPT_VISITOR(BooleanType); ACCEPT_VISITOR(BinaryType); -ACCEPT_VISITOR(FixedWidthBinaryType); +ACCEPT_VISITOR(FixedSizeBinaryType); ACCEPT_VISITOR(StringType); ACCEPT_VISITOR(ListType); ACCEPT_VISITOR(StructType); @@ -324,8 +324,8 @@ TYPE_FACTORY(binary, BinaryType); TYPE_FACTORY(date64, Date64Type); TYPE_FACTORY(date32, Date32Type); -std::shared_ptr fixed_width_binary(int32_t byte_width) { - return std::make_shared(byte_width); +std::shared_ptr fixed_size_binary(int32_t byte_width) { + return std::make_shared(byte_width); } std::shared_ptr timestamp(TimeUnit unit) { @@ -392,7 +392,7 @@ std::vector BinaryType::GetBufferLayout() const { return {kValidityBuffer, kOffsetBuffer, kValues8}; } -std::vector FixedWidthBinaryType::GetBufferLayout() const { +std::vector FixedSizeBinaryType::GetBufferLayout() const { return {kValidityBuffer, BufferDescr(BufferType::DATA, byte_width_ * 8)}; } diff --git a/cpp/src/arrow/type.h b/cpp/src/arrow/type.h index 4f931907ee7..6b936f348d4 100644 --- a/cpp/src/arrow/type.h +++ b/cpp/src/arrow/type.h @@ -70,8 +70,8 @@ struct Type { // Variable-length bytes (no guarantee of UTF8-ness) BINARY, - // Fixed-width binary. Each value occupies the same number of bytes - FIXED_WIDTH_BINARY, + // Fixed-size binary. Each value occupies the same number of bytes + FIXED_SIZE_BINARY, // int32_t days since the UNIX epoch DATE32, @@ -353,12 +353,12 @@ struct ARROW_EXPORT BinaryType : public DataType, public NoExtraMeta { }; // BinaryType type is represents lists of 1-byte values. -class ARROW_EXPORT FixedWidthBinaryType : public FixedWidthType { +class ARROW_EXPORT FixedSizeBinaryType : public FixedWidthType { public: - static constexpr Type::type type_id = Type::FIXED_WIDTH_BINARY; + static constexpr Type::type type_id = Type::FIXED_SIZE_BINARY; - explicit FixedWidthBinaryType(int32_t byte_width) - : FixedWidthType(Type::FIXED_WIDTH_BINARY), byte_width_(byte_width) {} + explicit FixedSizeBinaryType(int32_t byte_width) + : FixedWidthType(Type::FIXED_SIZE_BINARY), byte_width_(byte_width) {} Status Accept(TypeVisitor* visitor) const override; std::string ToString() const override; @@ -630,7 +630,7 @@ class ARROW_EXPORT Schema { // ---------------------------------------------------------------------- // Factory functions -std::shared_ptr ARROW_EXPORT fixed_width_binary(int32_t byte_width); +std::shared_ptr ARROW_EXPORT fixed_size_binary(int32_t byte_width); std::shared_ptr ARROW_EXPORT list(const std::shared_ptr& value_type); std::shared_ptr ARROW_EXPORT list(const std::shared_ptr& value_type); diff --git a/cpp/src/arrow/type_fwd.h b/cpp/src/arrow/type_fwd.h index 04ddf7e74dd..2e27ce98589 100644 --- a/cpp/src/arrow/type_fwd.h +++ b/cpp/src/arrow/type_fwd.h @@ -51,9 +51,9 @@ struct BinaryType; class BinaryArray; class BinaryBuilder; -class FixedWidthBinaryType; -class FixedWidthBinaryArray; -class FixedWidthBinaryBuilder; +class FixedSizeBinaryType; +class FixedSizeBinaryArray; +class FixedSizeBinaryBuilder; struct StringType; class StringArray; diff --git a/cpp/src/arrow/type_traits.h b/cpp/src/arrow/type_traits.h index b73d5a68d25..353b638fed8 100644 --- a/cpp/src/arrow/type_traits.h +++ b/cpp/src/arrow/type_traits.h @@ -257,9 +257,9 @@ struct TypeTraits { }; template <> -struct TypeTraits { - using ArrayType = FixedWidthBinaryArray; - using BuilderType = FixedWidthBinaryBuilder; +struct TypeTraits { + using ArrayType = FixedSizeBinaryArray; + using BuilderType = FixedSizeBinaryBuilder; constexpr static bool is_parameter_free = false; }; diff --git a/cpp/src/arrow/visitor.cc b/cpp/src/arrow/visitor.cc index 9200e0ff228..117578965cc 100644 --- a/cpp/src/arrow/visitor.cc +++ b/cpp/src/arrow/visitor.cc @@ -43,7 +43,7 @@ ARRAY_VISITOR_DEFAULT(FloatArray); ARRAY_VISITOR_DEFAULT(DoubleArray); ARRAY_VISITOR_DEFAULT(BinaryArray); ARRAY_VISITOR_DEFAULT(StringArray); -ARRAY_VISITOR_DEFAULT(FixedWidthBinaryArray); +ARRAY_VISITOR_DEFAULT(FixedSizeBinaryArray); ARRAY_VISITOR_DEFAULT(Date32Array); ARRAY_VISITOR_DEFAULT(Date64Array); ARRAY_VISITOR_DEFAULT(Time32Array); @@ -82,7 +82,7 @@ TYPE_VISITOR_DEFAULT(FloatType); TYPE_VISITOR_DEFAULT(DoubleType); TYPE_VISITOR_DEFAULT(StringType); TYPE_VISITOR_DEFAULT(BinaryType); -TYPE_VISITOR_DEFAULT(FixedWidthBinaryType); +TYPE_VISITOR_DEFAULT(FixedSizeBinaryType); TYPE_VISITOR_DEFAULT(Date64Type); TYPE_VISITOR_DEFAULT(Date32Type); TYPE_VISITOR_DEFAULT(Time32Type); diff --git a/cpp/src/arrow/visitor.h b/cpp/src/arrow/visitor.h index d44dcf6b976..6c36e465ec4 100644 --- a/cpp/src/arrow/visitor.h +++ b/cpp/src/arrow/visitor.h @@ -43,7 +43,7 @@ class ARROW_EXPORT ArrayVisitor { virtual Status Visit(const DoubleArray& array); virtual Status Visit(const StringArray& array); virtual Status Visit(const BinaryArray& array); - virtual Status Visit(const FixedWidthBinaryArray& array); + virtual Status Visit(const FixedSizeBinaryArray& array); virtual Status Visit(const Date32Array& array); virtual Status Visit(const Date64Array& array); virtual Status Visit(const Time32Array& array); @@ -76,7 +76,7 @@ class ARROW_EXPORT TypeVisitor { virtual Status Visit(const DoubleType& type); virtual Status Visit(const StringType& type); virtual Status Visit(const BinaryType& type); - virtual Status Visit(const FixedWidthBinaryType& type); + virtual Status Visit(const FixedSizeBinaryType& type); virtual Status Visit(const Date64Type& type); virtual Status Visit(const Date32Type& type); virtual Status Visit(const Time32Type& type); diff --git a/cpp/src/arrow/visitor_inline.h b/cpp/src/arrow/visitor_inline.h index cbc4d5acdb8..c61c9f59f7a 100644 --- a/cpp/src/arrow/visitor_inline.h +++ b/cpp/src/arrow/visitor_inline.h @@ -48,7 +48,7 @@ inline Status VisitTypeInline(const DataType& type, VISITOR* visitor) { TYPE_VISIT_INLINE(DoubleType); TYPE_VISIT_INLINE(StringType); TYPE_VISIT_INLINE(BinaryType); - TYPE_VISIT_INLINE(FixedWidthBinaryType); + TYPE_VISIT_INLINE(FixedSizeBinaryType); TYPE_VISIT_INLINE(Date32Type); TYPE_VISIT_INLINE(Date64Type); TYPE_VISIT_INLINE(TimestampType); @@ -87,7 +87,7 @@ inline Status VisitArrayInline(const Array& array, VISITOR* visitor) { ARRAY_VISIT_INLINE(DoubleType); ARRAY_VISIT_INLINE(StringType); ARRAY_VISIT_INLINE(BinaryType); - ARRAY_VISIT_INLINE(FixedWidthBinaryType); + ARRAY_VISIT_INLINE(FixedSizeBinaryType); ARRAY_VISIT_INLINE(Date32Type); ARRAY_VISIT_INLINE(Date64Type); ARRAY_VISIT_INLINE(TimestampType); diff --git a/format/Schema.fbs b/format/Schema.fbs index 5268bf95cfd..958f09181bf 100644 --- a/format/Schema.fbs +++ b/format/Schema.fbs @@ -67,7 +67,7 @@ table Utf8 { table Binary { } -table FixedWidthBinary { +table FixedSizeBinary { /// Number of bytes per value byteWidth: int; } @@ -156,7 +156,7 @@ union Type { List, Struct_, Union, - FixedWidthBinary + FixedSizeBinary } /// ---------------------------------------------------------------------- diff --git a/python/pyarrow/__init__.py b/python/pyarrow/__init__.py index 66b60386179..3df2a1d4455 100644 --- a/python/pyarrow/__init__.py +++ b/python/pyarrow/__init__.py @@ -55,7 +55,7 @@ Int8Value, Int16Value, Int32Value, Int64Value, UInt8Value, UInt16Value, UInt32Value, UInt64Value, FloatValue, DoubleValue, ListValue, - BinaryValue, StringValue, FixedWidthBinaryValue) + BinaryValue, StringValue, FixedSizeBinaryValue) import pyarrow.schema as _schema @@ -65,7 +65,7 @@ timestamp, date32, date64, float_, double, binary, string, list_, struct, dictionary, field, - DataType, FixedWidthBinaryType, + DataType, FixedSizeBinaryType, Field, Schema, schema) diff --git a/python/pyarrow/array.pxd b/python/pyarrow/array.pxd index a7241c6a47e..0b5f33d0d2d 100644 --- a/python/pyarrow/array.pxd +++ b/python/pyarrow/array.pxd @@ -100,7 +100,7 @@ cdef class DoubleArray(FloatingPointArray): pass -cdef class FixedWidthBinaryArray(Array): +cdef class FixedSizeBinaryArray(Array): pass diff --git a/python/pyarrow/array.pyx b/python/pyarrow/array.pyx index 289baf29930..b9799f15bf3 100644 --- a/python/pyarrow/array.pyx +++ b/python/pyarrow/array.pyx @@ -37,7 +37,7 @@ cimport pyarrow.scalar as scalar from pyarrow.scalar import NA from pyarrow.schema cimport (DataType, Field, Schema, DictionaryType, - FixedWidthBinaryType, + FixedSizeBinaryType, box_data_type) import pyarrow.schema as schema @@ -407,7 +407,7 @@ cdef class DoubleArray(FloatingPointArray): pass -cdef class FixedWidthBinaryArray(Array): +cdef class FixedSizeBinaryArray(Array): pass @@ -518,7 +518,7 @@ cdef dict _array_classes = { Type_BINARY: BinaryArray, Type_STRING: StringArray, Type_DICTIONARY: DictionaryArray, - Type_FIXED_WIDTH_BINARY: FixedWidthBinaryArray, + Type_FIXED_SIZE_BINARY: FixedSizeBinaryArray, } cdef object box_array(const shared_ptr[CArray]& sp_array): diff --git a/python/pyarrow/includes/libarrow.pxd b/python/pyarrow/includes/libarrow.pxd index b44ade5298e..f549884d175 100644 --- a/python/pyarrow/includes/libarrow.pxd +++ b/python/pyarrow/includes/libarrow.pxd @@ -45,7 +45,7 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil: Type_TIME64" arrow::Type::TIME64" Type_BINARY" arrow::Type::BINARY" Type_STRING" arrow::Type::STRING" - Type_FIXED_WIDTH_BINARY" arrow::Type::FIXED_WIDTH_BINARY" + Type_FIXED_SIZE_BINARY" arrow::Type::FIXED_SIZE_BINARY" Type_LIST" arrow::Type::LIST" Type_STRUCT" arrow::Type::STRUCT" @@ -140,8 +140,8 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil: cdef cppclass CStringType" arrow::StringType"(CDataType): pass - cdef cppclass CFixedWidthBinaryType" arrow::FixedWidthBinaryType"(CFixedWidthType): - CFixedWidthBinaryType(int byte_width) + cdef cppclass CFixedSizeBinaryType" arrow::FixedSizeBinaryType"(CFixedWidthType): + CFixedSizeBinaryType(int byte_width) int byte_width() cdef cppclass CField" arrow::Field": @@ -208,7 +208,7 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil: cdef cppclass CDoubleArray" arrow::DoubleArray"(CArray): double Value(int i) - cdef cppclass CFixedWidthBinaryArray" arrow::FixedWidthBinaryArray"(CArray): + cdef cppclass CFixedSizeBinaryArray" arrow::FixedSizeBinaryArray"(CArray): const uint8_t* GetValue(int i) cdef cppclass CListArray" arrow::ListArray"(CArray): diff --git a/python/pyarrow/scalar.pxd b/python/pyarrow/scalar.pxd index e9cc3cb487c..d6c3b35160c 100644 --- a/python/pyarrow/scalar.pxd +++ b/python/pyarrow/scalar.pxd @@ -62,7 +62,7 @@ cdef class StringValue(ArrayValue): pass -cdef class FixedWidthBinaryValue(ArrayValue): +cdef class FixedSizeBinaryValue(ArrayValue): pass diff --git a/python/pyarrow/scalar.pyx b/python/pyarrow/scalar.pyx index f4a1c9e08eb..983a9a73340 100644 --- a/python/pyarrow/scalar.pyx +++ b/python/pyarrow/scalar.pyx @@ -224,16 +224,16 @@ cdef class ListValue(ArrayValue): return result -cdef class FixedWidthBinaryValue(ArrayValue): +cdef class FixedSizeBinaryValue(ArrayValue): def as_py(self): cdef: - CFixedWidthBinaryArray* ap - CFixedWidthBinaryType* ap_type + CFixedSizeBinaryArray* ap + CFixedSizeBinaryType* ap_type int32_t length const char* data - ap = self.sp_array.get() - ap_type = ap.type().get() + ap = self.sp_array.get() + ap_type = ap.type().get() length = ap_type.byte_width() data = ap.GetValue(self.index) return cp.PyBytes_FromStringAndSize(data, length) @@ -258,7 +258,7 @@ cdef dict _scalar_classes = { Type_LIST: ListValue, Type_BINARY: BinaryValue, Type_STRING: StringValue, - Type_FIXED_WIDTH_BINARY: FixedWidthBinaryValue, + Type_FIXED_SIZE_BINARY: FixedSizeBinaryValue, } cdef object box_scalar(DataType type, const shared_ptr[CArray]& sp_array, diff --git a/python/pyarrow/schema.pxd b/python/pyarrow/schema.pxd index c0c2c709b27..94d65bfc157 100644 --- a/python/pyarrow/schema.pxd +++ b/python/pyarrow/schema.pxd @@ -19,7 +19,7 @@ from pyarrow.includes.common cimport * from pyarrow.includes.libarrow cimport (CDataType, CDictionaryType, CTimestampType, - CFixedWidthBinaryType, + CFixedSizeBinaryType, CField, CSchema) cdef class DataType: @@ -40,9 +40,9 @@ cdef class TimestampType(DataType): const CTimestampType* ts_type -cdef class FixedWidthBinaryType(DataType): +cdef class FixedSizeBinaryType(DataType): cdef: - const CFixedWidthBinaryType* fixed_width_binary_type + const CFixedSizeBinaryType* fixed_size_binary_type cdef class Field: diff --git a/python/pyarrow/schema.pyx b/python/pyarrow/schema.pyx index 532a318840c..06df64461ae 100644 --- a/python/pyarrow/schema.pyx +++ b/python/pyarrow/schema.pyx @@ -28,7 +28,7 @@ from pyarrow.compat import frombytes, tobytes from pyarrow.array cimport Array from pyarrow.error cimport check_status from pyarrow.includes.libarrow cimport (CDataType, CStructType, CListType, - CFixedWidthBinaryType, + CFixedSizeBinaryType, TimeUnit_SECOND, TimeUnit_MILLI, TimeUnit_MICRO, TimeUnit_NANO, Type, TimeUnit) @@ -91,16 +91,16 @@ cdef class TimestampType(DataType): return None -cdef class FixedWidthBinaryType(DataType): +cdef class FixedSizeBinaryType(DataType): cdef init(self, const shared_ptr[CDataType]& type): DataType.init(self, type) - self.fixed_width_binary_type = type.get() + self.fixed_size_binary_type = type.get() property byte_width: def __get__(self): - return self.fixed_width_binary_type.byte_width() + return self.fixed_size_binary_type.byte_width() cdef class Field: @@ -362,16 +362,16 @@ def binary(int length=-1): ---------- length : int, optional, default -1 If length == -1 then return a variable length binary type. If length is - greater than or equal to 0 then return a fixed width binary type of + greater than or equal to 0 then return a fixed size binary type of width `length`. """ if length == -1: return primitive_type(la.Type_BINARY) - cdef FixedWidthBinaryType out = FixedWidthBinaryType() - cdef shared_ptr[CDataType] fixed_width_binary_type - fixed_width_binary_type.reset(new CFixedWidthBinaryType(length)) - out.init(fixed_width_binary_type) + cdef FixedSizeBinaryType out = FixedSizeBinaryType() + cdef shared_ptr[CDataType] fixed_size_binary_type + fixed_size_binary_type.reset(new CFixedSizeBinaryType(length)) + out.init(fixed_size_binary_type) return out @@ -428,8 +428,8 @@ cdef DataType box_data_type(const shared_ptr[CDataType]& type): out = DictionaryType() elif type.get().type == la.Type_TIMESTAMP: out = TimestampType() - elif type.get().type == la.Type_FIXED_WIDTH_BINARY: - out = FixedWidthBinaryType() + elif type.get().type == la.Type_FIXED_SIZE_BINARY: + out = FixedSizeBinaryType() else: out = DataType() diff --git a/python/pyarrow/tests/test_convert_builtin.py b/python/pyarrow/tests/test_convert_builtin.py index 99251250499..2d5014375b9 100644 --- a/python/pyarrow/tests/test_convert_builtin.py +++ b/python/pyarrow/tests/test_convert_builtin.py @@ -92,7 +92,7 @@ def test_bytes(self): assert arr.type == pyarrow.binary() assert arr.to_pylist() == [b'foo', u1, None] - def test_fixed_width_bytes(self): + def test_fixed_size_bytes(self): data = [b'foof', None, b'barb', b'2346'] arr = pyarrow.from_pylist(data, type=pyarrow.binary(4)) assert len(arr) == 4 @@ -100,7 +100,7 @@ def test_fixed_width_bytes(self): assert arr.type == pyarrow.binary(4) assert arr.to_pylist() == data - def test_fixed_width_bytes_does_not_accept_varying_lengths(self): + def test_fixed_size_bytes_does_not_accept_varying_lengths(self): data = [b'foo', None, b'barb', b'2346'] with self.assertRaises(pyarrow.error.ArrowException): pyarrow.from_pylist(data, type=pyarrow.binary(4)) diff --git a/python/pyarrow/tests/test_convert_pandas.py b/python/pyarrow/tests/test_convert_pandas.py index f7cb47f6855..3c6ad0a05b2 100644 --- a/python/pyarrow/tests/test_convert_pandas.py +++ b/python/pyarrow/tests/test_convert_pandas.py @@ -244,7 +244,7 @@ def test_bytes_to_binary(self): expected = pd.DataFrame({'strings': values2}) self._check_pandas_roundtrip(df, expected) - def test_fixed_width_bytes(self): + def test_fixed_size_bytes(self): values = [b'foo', None, b'bar', None, None, b'hey'] df = pd.DataFrame({'strings': values}) schema = A.Schema.from_fields([A.field('strings', A.binary(3))]) @@ -254,7 +254,7 @@ def test_fixed_width_bytes(self): result = table.to_pandas() tm.assert_frame_equal(result, df) - def test_fixed_width_bytes_does_not_accept_varying_lengths(self): + def test_fixed_size_bytes_does_not_accept_varying_lengths(self): values = [b'foo', None, b'ba', None, None, b'hey'] df = pd.DataFrame({'strings': values}) schema = A.Schema.from_fields([A.field('strings', A.binary(3))]) diff --git a/python/pyarrow/tests/test_scalars.py b/python/pyarrow/tests/test_scalars.py index 265ce8d3a58..a5db7e08356 100644 --- a/python/pyarrow/tests/test_scalars.py +++ b/python/pyarrow/tests/test_scalars.py @@ -87,12 +87,12 @@ def test_bytes(self): assert v == b'bar' assert isinstance(v, bytes) - def test_fixed_width_bytes(self): + def test_fixed_size_bytes(self): data = [b'foof', None, b'barb'] arr = A.from_pylist(data, type=A.binary(4)) v = arr[0] - assert isinstance(v, A.FixedWidthBinaryValue) + assert isinstance(v, A.FixedSizeBinaryValue) assert v.as_py() == b'foof' assert arr[1] is A.NA