Repository: arrow Updated Branches: refs/heads/master d75d7a96c -> 9f5e17448
ARROW-733: [C++/Python] Rename FixedWidthBinary to FixedSizeBinary for consistency with FixedSizeList As discussed on JIRA Author: Wes McKinney <wes.mckin...@twosigma.com> Closes #473 from wesm/ARROW-733 and squashes the following commits: 0e30af3 [Wes McKinney] Rename FixedWidthBinary to FixedSizeBinary for consistency with FixedSizeList type Project: http://git-wip-us.apache.org/repos/asf/arrow/repo Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/9f5e1744 Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/9f5e1744 Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/9f5e1744 Branch: refs/heads/master Commit: 9f5e17448f984a709be36bfd6f731852a775e1b0 Parents: d75d7a9 Author: Wes McKinney <wes.mckin...@twosigma.com> Authored: Sat Apr 1 11:18:30 2017 -0400 Committer: Wes McKinney <wes.mckin...@twosigma.com> Committed: Sat Apr 1 11:18:30 2017 -0400 ---------------------------------------------------------------------- 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(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/array-test.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/array-test.cc b/cpp/src/arrow/array-test.cc index 52f3727..68b9864 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<FixedWidthBinaryBuilder> builder_; + std::unique_ptr<FixedSizeBinaryBuilder> 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<const FixedWidthBinaryArray&>(result); + const auto& fw_result = static_cast<const FixedSizeBinaryArray&>(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<const FixedWidthBinaryArray&>(*array1); - const auto& a2 = static_cast<const FixedWidthBinaryArray&>(*array2); + const auto& a1 = static_cast<const FixedSizeBinaryArray&>(*array1); + const auto& a2 = static_cast<const FixedSizeBinaryArray&>(*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> array; ASSERT_OK(builder.Finish(&array)); - const auto& fw_array = static_cast<const FixedWidthBinaryArray&>(*array); + const auto& fw_array = static_cast<const FixedSizeBinaryArray&>(*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<string> strings = {"foo1", "foo2", "foo3", "foo4", "foo5"}; vector<uint8_t> is_null = {0, 1, 0, 0, 0}; http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/array.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/array.cc b/cpp/src/arrow/array.cc index b25411a..bd20654 100644 --- a/cpp/src/arrow/array.cc +++ b/cpp/src/arrow/array.cc @@ -280,18 +280,17 @@ std::shared_ptr<Array> StringArray::Slice(int64_t offset, int64_t length) const // ---------------------------------------------------------------------- // Fixed width binary -FixedWidthBinaryArray::FixedWidthBinaryArray(const std::shared_ptr<DataType>& type, +FixedSizeBinaryArray::FixedSizeBinaryArray(const std::shared_ptr<DataType>& type, int64_t length, const std::shared_ptr<Buffer>& data, const std::shared_ptr<Buffer>& 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<const FixedWidthBinaryType&>(*type).byte_width(); + DCHECK(type->type == Type::FIXED_SIZE_BINARY); + byte_width_ = static_cast<const FixedSizeBinaryType&>(*type).byte_width(); } -std::shared_ptr<Array> FixedWidthBinaryArray::Slice( - int64_t offset, int64_t length) const { +std::shared_ptr<Array> FixedSizeBinaryArray::Slice(int64_t offset, int64_t length) const { ConformSliceParams(offset_, length_, &offset, &length); - return std::make_shared<FixedWidthBinaryArray>( + return std::make_shared<FixedSizeBinaryArray>( type_, length, data_, null_bitmap_, kUnknownNullCount, offset); } http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/array.h ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/array.h b/cpp/src/arrow/array.h index 53b6408..9f0e739 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<DataType>& type, int64_t length, + FixedSizeBinaryArray(const std::shared_ptr<DataType>& type, int64_t length, const std::shared_ptr<Buffer>& data, const std::shared_ptr<Buffer>& null_bitmap = nullptr, int64_t null_count = 0, int64_t offset = 0); http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/builder.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/builder.cc b/cpp/src/arrow/builder.cc index 82b6214..40b81cf 100644 --- a/cpp/src/arrow/builder.cc +++ b/cpp/src/arrow/builder.cc @@ -438,51 +438,51 @@ Status StringBuilder::Finish(std::shared_ptr<Array>* out) { // ---------------------------------------------------------------------- // Fixed width binary -FixedWidthBinaryBuilder::FixedWidthBinaryBuilder( +FixedSizeBinaryBuilder::FixedSizeBinaryBuilder( MemoryPool* pool, const std::shared_ptr<DataType>& type) : ArrayBuilder(pool, type), byte_builder_(pool) { - DCHECK(type->type == Type::FIXED_WIDTH_BINARY); - byte_width_ = static_cast<const FixedWidthBinaryType&>(*type).byte_width(); + DCHECK(type->type == Type::FIXED_SIZE_BINARY); + byte_width_ = static_cast<const FixedSizeBinaryType&>(*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<const uint8_t*>(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<int64_t>::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<int64_t>::max()); RETURN_NOT_OK(byte_builder_.Resize(capacity * byte_width_)); return ArrayBuilder::Resize(capacity); } -Status FixedWidthBinaryBuilder::Finish(std::shared_ptr<Array>* out) { +Status FixedSizeBinaryBuilder::Finish(std::shared_ptr<Array>* out) { std::shared_ptr<Buffer> data = byte_builder_.Finish(); - *out = std::make_shared<FixedWidthBinaryArray>( + *out = std::make_shared<FixedSizeBinaryArray>( type_, length_, data, null_bitmap_, null_count_); return Status::OK(); } @@ -542,7 +542,7 @@ Status MakeBuilder(MemoryPool* pool, const std::shared_ptr<DataType>& 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<ArrayBuilder> value_builder; std::shared_ptr<DataType> value_type = http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/builder.h ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/builder.h b/cpp/src/arrow/builder.h index bd957b3..61207a3 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<DataType>& type); + FixedSizeBinaryBuilder(MemoryPool* pool, const std::shared_ptr<DataType>& type); Status Append(const uint8_t* value); Status Append( http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/compare.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/compare.cc b/cpp/src/arrow/compare.cc index 4cd617e..7451439 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<const FixedWidthBinaryArray&>(right_); + Status Visit(const FixedSizeBinaryArray& left) { + const auto& right = static_cast<const FixedSizeBinaryArray&>(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<const FixedWidthBinaryType&>(right_); + Status Visit(const FixedSizeBinaryType& left) { + const auto& right = static_cast<const FixedSizeBinaryType&>(right_); result_ = left.byte_width() == right.byte_width(); return Status::OK(); } http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/ipc/json-internal.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/ipc/json-internal.cc b/cpp/src/arrow/ipc/json-internal.cc index 9572a0a..1e2385b 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<const char*>(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<DataType>* 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 T> - typename std::enable_if<std::is_base_of<FixedWidthBinaryType, T>::value, Status>::type + typename std::enable_if<std::is_base_of<FixedSizeBinaryType, T>::value, Status>::type ReadArray(const RjObject& json_array, int32_t length, const std::vector<bool>& is_valid, const std::shared_ptr<DataType>& type, std::shared_ptr<Array>* 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<int32_t>(json_data_arr.Size()), length); - int32_t byte_width = static_cast<const FixedWidthBinaryType&>(*type).byte_width(); + int32_t byte_width = static_cast<const FixedSizeBinaryType&>(*type).byte_width(); // Allocate space for parsed values std::shared_ptr<MutableBuffer> 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); http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/ipc/metadata.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/ipc/metadata.cc b/cpp/src/arrow/ipc/metadata.cc index 076a6e7..5007f13 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<const flatbuf::FixedWidthBinary*>(type_data); - *out = fixed_width_binary(fw_binary->byteWidth()); + case flatbuf::Type_FixedSizeBinary: { + auto fw_binary = static_cast<const flatbuf::FixedSizeBinary*>(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<DataType>& type, *out_type = flatbuf::Type_FloatingPoint; *offset = FloatToFlatbuffer(fbb, flatbuf::Precision_DOUBLE); break; - case Type::FIXED_WIDTH_BINARY: { - const auto& fw_type = static_cast<const FixedWidthBinaryType&>(*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<const FixedSizeBinaryType&>(*type); + *out_type = flatbuf::Type_FixedSizeBinary; + *offset = flatbuf::CreateFixedSizeBinary(fbb, fw_type.byte_width()).Union(); } break; case Type::BINARY: *out_type = flatbuf::Type_Binary; http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/ipc/test-common.h ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/ipc/test-common.h b/cpp/src/arrow/ipc/test-common.h index 134a5ca..d113531 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<bool>& is_valid, const std::vector<T>& value Status MakeFWBinary(std::shared_ptr<RecordBatch>* out) { std::vector<bool> 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> schema(new Schema({f0, f1})); std::shared_ptr<Array> 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<std::string> values1 = {"foo1", "foo2", "foo3", "foo4"}; AppendValues(is_valid, values1, &b1); http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/ipc/writer.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/ipc/writer.cc b/cpp/src/arrow/ipc/writer.cc index 0867382..5330206 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(); http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/loader.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/loader.cc b/cpp/src/arrow/loader.cc index cc64c4d..f3347f9 100644 --- a/cpp/src/arrow/loader.cc +++ b/cpp/src/arrow/loader.cc @@ -139,7 +139,7 @@ class ArrayLoader { template <typename T> typename std::enable_if<std::is_base_of<FixedWidthType, T>::value && - !std::is_base_of<FixedWidthBinaryType, T>::value && + !std::is_base_of<FixedSizeBinaryType, T>::value && !std::is_base_of<DictionaryType, T>::value, Status>::type Visit(const T& type) { @@ -152,14 +152,14 @@ class ArrayLoader { return LoadBinary<T>(); } - Status Visit(const FixedWidthBinaryType& type) { + Status Visit(const FixedSizeBinaryType& type) { FieldMetadata field_meta; std::shared_ptr<Buffer> null_bitmap, data; RETURN_NOT_OK(LoadCommon(&field_meta, &null_bitmap)); RETURN_NOT_OK(GetBuffer(context_->buffer_index++, &data)); - result_ = std::make_shared<FixedWidthBinaryArray>( + result_ = std::make_shared<FixedSizeBinaryArray>( type_, field_meta.length, data, null_bitmap, field_meta.null_count); return Status::OK(); } http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/pretty_print-test.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/pretty_print-test.cc b/cpp/src/arrow/pretty_print-test.cc index f21383f..80cd9cf 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<BinaryType, std::string>(0, is_valid, values, ex); } -TEST_F(TestPrettyPrint, FixedWidthBinaryType) { +TEST_F(TestPrettyPrint, FixedSizeBinaryType) { std::vector<bool> is_valid = {true, true, false, true, false}; std::vector<std::string> values = {"foo", "bar", "baz"}; static const char* ex = R"expected([666F6F, 626172, 62617A])expected"; std::shared_ptr<Array> 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]); http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/pretty_print.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/pretty_print.cc b/cpp/src/arrow/pretty_print.cc index 0f67fe5..0f46f03 100644 --- a/cpp/src/arrow/pretty_print.cc +++ b/cpp/src/arrow/pretty_print.cc @@ -97,9 +97,8 @@ class ArrayPrinter { } template <typename T> - inline - typename std::enable_if<std::is_same<FixedWidthBinaryArray, T>::value, void>::type - WriteDataValues(const T& array) { + inline typename std::enable_if<std::is_same<FixedSizeBinaryArray, T>::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 T> typename std::enable_if<std::is_base_of<PrimitiveArray, T>::value || - std::is_base_of<FixedWidthBinaryArray, T>::value || + std::is_base_of<FixedSizeBinaryArray, T>::value || std::is_base_of<BinaryArray, T>::value, Status>::type Visit(const T& array) { http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/python/builtin_convert.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/python/builtin_convert.cc b/cpp/src/arrow/python/builtin_convert.cc index 72e8677..6a13fdc 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<BinaryBuilder> { } }; -class FixedWidthBytesConverter : public TypedConverter<FixedWidthBinaryBuilder> { +class FixedWidthBytesConverter : public TypedConverter<FixedSizeBinaryBuilder> { public: Status AppendData(PyObject* seq) override { PyObject* item; PyObject* bytes_obj; OwnedRef tmp; - Py_ssize_t expected_length = std::dynamic_pointer_cast<FixedWidthBinaryType>( + Py_ssize_t expected_length = std::dynamic_pointer_cast<FixedSizeBinaryType>( 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<SeqConverter> GetConverter(const std::shared_ptr<DataType>& type return std::make_shared<DoubleConverter>(); case Type::BINARY: return std::make_shared<BytesConverter>(); - case Type::FIXED_WIDTH_BINARY: + case Type::FIXED_SIZE_BINARY: return std::make_shared<FixedWidthBytesConverter>(); case Type::STRING: return std::make_shared<UTF8Converter>(); http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/python/pandas_convert.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/python/pandas_convert.cc b/cpp/src/arrow/python/pandas_convert.cc index ae9b17c..ddfec1b 100644 --- a/cpp/src/arrow/python/pandas_convert.cc +++ b/cpp/src/arrow/python/pandas_convert.cc @@ -179,7 +179,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) { @@ -228,7 +228,7 @@ struct WrapBytes<BinaryArray> { }; template <> -struct WrapBytes<FixedWidthBinaryArray> { +struct WrapBytes<FixedSizeBinaryArray> { static inline PyObject* Wrap(const uint8_t* data, int64_t length) { return PyBytes_FromStringAndSize(reinterpret_cast<const char*>(data), length); } @@ -495,10 +495,10 @@ Status PandasConverter::ConvertObjectFixedWidthBytes( PyAcquireGIL lock; PyObject** objects = reinterpret_cast<PyObject**>(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<FixedWidthBinaryType>(builder.type())->byte_width(), + std::dynamic_pointer_cast<FixedSizeBinaryType>(builder.type())->byte_width(), &builder, objects)); RETURN_NOT_OK(builder.Finish(out)); return Status::OK(); @@ -564,7 +564,7 @@ Status PandasConverter::ConvertObjects(std::shared_ptr<Array>* 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); @@ -1017,14 +1017,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<FixedWidthBinaryArray*>(data.chunk(c).get()); + auto arr = static_cast<FixedSizeBinaryArray*>(data.chunk(c).get()); const uint8_t* data_ptr; int32_t length = - std::dynamic_pointer_cast<FixedWidthBinaryType>(arr->type())->byte_width(); + std::dynamic_pointer_cast<FixedSizeBinaryType>(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)) { @@ -1032,7 +1032,7 @@ inline Status ConvertFixedWidthBinary(const ChunkedArray& data, PyObject** out_v *out_values = Py_None; } else { data_ptr = arr->GetValue(i); - *out_values = WrapBytes<FixedWidthBinaryArray>::Wrap(data_ptr, length); + *out_values = WrapBytes<FixedSizeBinaryArray>::Wrap(data_ptr, length); if (*out_values == nullptr) { PyErr_Clear(); std::stringstream ss; @@ -1181,8 +1181,8 @@ class ObjectBlock : public PandasBlock { RETURN_NOT_OK(ConvertBinaryLike<BinaryArray>(data, out_buffer)); } else if (type == Type::STRING) { RETURN_NOT_OK(ConvertBinaryLike<StringArray>(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<ListType>(col->type()); switch (list_type->value_type()->type) { @@ -1612,7 +1612,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: @@ -1877,7 +1877,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); @@ -1982,11 +1982,11 @@ class ArrowDeserializer { // Fixed length binary strings template <int TYPE> - inline typename std::enable_if<TYPE == Type::FIXED_WIDTH_BINARY, Status>::type + inline typename std::enable_if<TYPE == Type::FIXED_SIZE_BINARY, Status>::type ConvertValues() { RETURN_NOT_OK(AllocateOutput(NPY_OBJECT)); auto out_values = reinterpret_cast<PyObject**>(PyArray_DATA(arr_)); - return ConvertFixedWidthBinary(data_, out_values); + return ConvertFixedSizeBinary(data_, out_values); } #define CONVERTVALUES_LISTSLIKE_CASE(ArrowType, ArrowEnum) \ http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/type-test.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/type-test.cc b/cpp/src/arrow/type-test.cc index b221c80..dafadc1 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)); http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/type.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/type.cc b/cpp/src/arrow/type.cc index e6e6f5c..d99551d 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<DataType> fixed_width_binary(int32_t byte_width) { - return std::make_shared<FixedWidthBinaryType>(byte_width); +std::shared_ptr<DataType> fixed_size_binary(int32_t byte_width) { + return std::make_shared<FixedSizeBinaryType>(byte_width); } std::shared_ptr<DataType> timestamp(TimeUnit unit) { @@ -392,7 +392,7 @@ std::vector<BufferDescr> BinaryType::GetBufferLayout() const { return {kValidityBuffer, kOffsetBuffer, kValues8}; } -std::vector<BufferDescr> FixedWidthBinaryType::GetBufferLayout() const { +std::vector<BufferDescr> FixedSizeBinaryType::GetBufferLayout() const { return {kValidityBuffer, BufferDescr(BufferType::DATA, byte_width_ * 8)}; } http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/type.h ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/type.h b/cpp/src/arrow/type.h index 4f93190..6b936f3 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<DataType> ARROW_EXPORT fixed_width_binary(int32_t byte_width); +std::shared_ptr<DataType> ARROW_EXPORT fixed_size_binary(int32_t byte_width); std::shared_ptr<DataType> ARROW_EXPORT list(const std::shared_ptr<Field>& value_type); std::shared_ptr<DataType> ARROW_EXPORT list(const std::shared_ptr<DataType>& value_type); http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/type_fwd.h ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/type_fwd.h b/cpp/src/arrow/type_fwd.h index 04ddf7e..2e27ce9 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; http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/type_traits.h ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/type_traits.h b/cpp/src/arrow/type_traits.h index b73d5a6..353b638 100644 --- a/cpp/src/arrow/type_traits.h +++ b/cpp/src/arrow/type_traits.h @@ -257,9 +257,9 @@ struct TypeTraits<BinaryType> { }; template <> -struct TypeTraits<FixedWidthBinaryType> { - using ArrayType = FixedWidthBinaryArray; - using BuilderType = FixedWidthBinaryBuilder; +struct TypeTraits<FixedSizeBinaryType> { + using ArrayType = FixedSizeBinaryArray; + using BuilderType = FixedSizeBinaryBuilder; constexpr static bool is_parameter_free = false; }; http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/visitor.cc ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/visitor.cc b/cpp/src/arrow/visitor.cc index 9200e0f..1175789 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); http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/visitor.h ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/visitor.h b/cpp/src/arrow/visitor.h index d44dcf6..6c36e46 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); http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/cpp/src/arrow/visitor_inline.h ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/visitor_inline.h b/cpp/src/arrow/visitor_inline.h index cbc4d5a..c61c9f5 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); http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/format/Schema.fbs ---------------------------------------------------------------------- diff --git a/format/Schema.fbs b/format/Schema.fbs index 5268bf9..958f091 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 } /// ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/python/pyarrow/__init__.py ---------------------------------------------------------------------- diff --git a/python/pyarrow/__init__.py b/python/pyarrow/__init__.py index 66b6038..3df2a1d 100644 --- a/python/pyarrow/__init__.py +++ b/python/pyarrow/__init__.py @@ -55,7 +55,7 @@ from pyarrow.scalar import (ArrayValue, Scalar, NA, NAType, 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 @@ from pyarrow.schema import (null, bool_, timestamp, date32, date64, float_, double, binary, string, list_, struct, dictionary, field, - DataType, FixedWidthBinaryType, + DataType, FixedSizeBinaryType, Field, Schema, schema) http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/python/pyarrow/array.pxd ---------------------------------------------------------------------- diff --git a/python/pyarrow/array.pxd b/python/pyarrow/array.pxd index a7241c6..0b5f33d 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 http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/python/pyarrow/array.pyx ---------------------------------------------------------------------- diff --git a/python/pyarrow/array.pyx b/python/pyarrow/array.pyx index 289baf2..b9799f1 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): http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/python/pyarrow/includes/libarrow.pxd ---------------------------------------------------------------------- diff --git a/python/pyarrow/includes/libarrow.pxd b/python/pyarrow/includes/libarrow.pxd index b44ade5..f549884 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): http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/python/pyarrow/scalar.pxd ---------------------------------------------------------------------- diff --git a/python/pyarrow/scalar.pxd b/python/pyarrow/scalar.pxd index e9cc3cb..d6c3b35 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 http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/python/pyarrow/scalar.pyx ---------------------------------------------------------------------- diff --git a/python/pyarrow/scalar.pyx b/python/pyarrow/scalar.pyx index f4a1c9e..983a9a7 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 = <CFixedWidthBinaryArray*> self.sp_array.get() - ap_type = <CFixedWidthBinaryType*> ap.type().get() + ap = <CFixedSizeBinaryArray*> self.sp_array.get() + ap_type = <CFixedSizeBinaryType*> ap.type().get() length = ap_type.byte_width() data = <const char*> 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, http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/python/pyarrow/schema.pxd ---------------------------------------------------------------------- diff --git a/python/pyarrow/schema.pxd b/python/pyarrow/schema.pxd index c0c2c70..94d65bf 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: http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/python/pyarrow/schema.pyx ---------------------------------------------------------------------- diff --git a/python/pyarrow/schema.pyx b/python/pyarrow/schema.pyx index 532a318..06df644 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 = <const CFixedWidthBinaryType*> type.get() + self.fixed_size_binary_type = <const CFixedSizeBinaryType*> 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() http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/python/pyarrow/tests/test_convert_builtin.py ---------------------------------------------------------------------- diff --git a/python/pyarrow/tests/test_convert_builtin.py b/python/pyarrow/tests/test_convert_builtin.py index 3309ba0..bb6d2d1 100644 --- a/python/pyarrow/tests/test_convert_builtin.py +++ b/python/pyarrow/tests/test_convert_builtin.py @@ -92,7 +92,7 @@ class TestConvertList(unittest.TestCase): 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 @@ class TestConvertList(unittest.TestCase): 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)) http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/python/pyarrow/tests/test_convert_pandas.py ---------------------------------------------------------------------- diff --git a/python/pyarrow/tests/test_convert_pandas.py b/python/pyarrow/tests/test_convert_pandas.py index 3f19b68..c472ee6 100644 --- a/python/pyarrow/tests/test_convert_pandas.py +++ b/python/pyarrow/tests/test_convert_pandas.py @@ -244,7 +244,7 @@ class TestPandasConversion(unittest.TestCase): 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 @@ class TestPandasConversion(unittest.TestCase): 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))]) http://git-wip-us.apache.org/repos/asf/arrow/blob/9f5e1744/python/pyarrow/tests/test_scalars.py ---------------------------------------------------------------------- diff --git a/python/pyarrow/tests/test_scalars.py b/python/pyarrow/tests/test_scalars.py index 265ce8d..a5db7e0 100644 --- a/python/pyarrow/tests/test_scalars.py +++ b/python/pyarrow/tests/test_scalars.py @@ -87,12 +87,12 @@ class TestScalars(unittest.TestCase): 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