You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by uw...@apache.org on 2017/02/27 07:14:15 UTC
[1/2] arrow git commit: ARROW-493: [C++] Permit large (length >
INT32_MAX) arrays in memory
Repository: arrow
Updated Branches:
refs/heads/master dc103feaf -> 01a67f3ff
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/ipc/adapter.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/adapter.cc b/cpp/src/arrow/ipc/adapter.cc
index 2be87a3..f11c88a 100644
--- a/cpp/src/arrow/ipc/adapter.cc
+++ b/cpp/src/arrow/ipc/adapter.cc
@@ -20,6 +20,7 @@
#include <algorithm>
#include <cstdint>
#include <cstring>
+#include <limits>
#include <sstream>
#include <vector>
@@ -65,8 +66,14 @@ class RecordBatchWriter : public ArrayVisitor {
if (max_recursion_depth_ <= 0) {
return Status::Invalid("Max recursion depth reached");
}
+
+ if (arr.length() > std::numeric_limits<int32_t>::max()) {
+ return Status::Invalid("Cannot write arrays larger than 2^31 - 1 in length");
+ }
+
// push back all common elements
- field_nodes_.push_back(flatbuf::FieldNode(arr.length(), arr.null_count()));
+ field_nodes_.push_back(flatbuf::FieldNode(
+ static_cast<int32_t>(arr.length()), static_cast<int32_t>(arr.null_count())));
if (arr.null_count() > 0) {
std::shared_ptr<Buffer> bitmap = arr.null_bitmap();
@@ -152,13 +159,14 @@ class RecordBatchWriter : public ArrayVisitor {
int64_t start_offset;
RETURN_NOT_OK(dst->Tell(&start_offset));
- int64_t padded_metadata_length = metadata_fb->size() + 4;
- const int remainder = (padded_metadata_length + start_offset) % 8;
+ int32_t padded_metadata_length = static_cast<int32_t>(metadata_fb->size()) + 4;
+ const int32_t remainder =
+ (padded_metadata_length + static_cast<int32_t>(start_offset)) % 8;
if (remainder != 0) { padded_metadata_length += 8 - remainder; }
// The returned metadata size includes the length prefix, the flatbuffer,
// plus padding
- *metadata_length = static_cast<int32_t>(padded_metadata_length);
+ *metadata_length = padded_metadata_length;
// Write the flatbuffer size prefix including padding
int32_t flatbuffer_size = padded_metadata_length - 4;
@@ -169,7 +177,8 @@ class RecordBatchWriter : public ArrayVisitor {
RETURN_NOT_OK(dst->Write(metadata_fb->data(), metadata_fb->size()));
// Write any padding
- int64_t padding = padded_metadata_length - metadata_fb->size() - 4;
+ int32_t padding =
+ padded_metadata_length - static_cast<int32_t>(metadata_fb->size()) - 4;
if (padding > 0) { RETURN_NOT_OK(dst->Write(kPaddingBytes, padding)); }
return Status::OK();
@@ -184,7 +193,8 @@ class RecordBatchWriter : public ArrayVisitor {
RETURN_NOT_OK(dst->Tell(&start_position));
#endif
- RETURN_NOT_OK(WriteMetadata(batch.num_rows(), *body_length, dst, metadata_length));
+ RETURN_NOT_OK(WriteMetadata(
+ static_cast<int32_t>(batch.num_rows()), *body_length, dst, metadata_length));
#ifndef NDEBUG
RETURN_NOT_OK(dst->Tell(¤t_position));
@@ -430,7 +440,7 @@ class RecordBatchWriter : public ArrayVisitor {
int32_t* shifted_offsets =
reinterpret_cast<int32_t*>(shifted_offsets_buffer->mutable_data());
- for (int32_t i = 0; i < array.length(); ++i) {
+ for (int64_t i = 0; i < array.length(); ++i) {
const uint8_t code = type_ids[i];
int32_t shift = child_offsets[code];
if (shift == -1) { child_offsets[code] = shift = unshifted_offsets[i]; }
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/ipc/ipc-json-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/ipc-json-test.cc b/cpp/src/arrow/ipc/ipc-json-test.cc
index 3e759cc..4c18a49 100644
--- a/cpp/src/arrow/ipc/ipc-json-test.cc
+++ b/cpp/src/arrow/ipc/ipc-json-test.cc
@@ -240,7 +240,7 @@ TEST(TestJsonFileReadWrite, BasicRoundTrip) {
const int nbatches = 3;
std::vector<std::shared_ptr<RecordBatch>> batches;
for (int i = 0; i < nbatches; ++i) {
- int32_t num_rows = 5 + i * 5;
+ int num_rows = 5 + i * 5;
std::vector<std::shared_ptr<Array>> arrays;
MakeBatchArrays(schema, num_rows, &arrays);
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/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 6253cd6..0458b85 100644
--- a/cpp/src/arrow/ipc/json-internal.cc
+++ b/cpp/src/arrow/ipc/json-internal.cc
@@ -355,7 +355,7 @@ class JsonArrayWriter : public ArrayVisitor {
writer_->String(name);
writer_->Key("count");
- writer_->Int(arr.length());
+ writer_->Int(static_cast<int32_t>(arr.length()));
RETURN_NOT_OK(arr.Accept(this));
@@ -394,7 +394,7 @@ class JsonArrayWriter : public ArrayVisitor {
template <typename T>
typename std::enable_if<std::is_base_of<BinaryArray, T>::value, void>::type
WriteDataValues(const T& arr) {
- for (int i = 0; i < arr.length(); ++i) {
+ for (int64_t i = 0; i < arr.length(); ++i) {
int32_t length;
const char* buf = reinterpret_cast<const char*>(arr.GetValue(i, &length));
@@ -430,7 +430,7 @@ class JsonArrayWriter : public ArrayVisitor {
}
template <typename T>
- void WriteIntegerField(const char* name, const T* values, int32_t length) {
+ void WriteIntegerField(const char* name, const T* values, int64_t length) {
writer_->Key(name);
writer_->StartArray();
for (int i = 0; i < length; ++i) {
@@ -573,7 +573,7 @@ class JsonSchemaReader {
const auto& values = obj.GetArray();
fields->resize(values.Size());
- for (size_t i = 0; i < fields->size(); ++i) {
+ for (rj::SizeType i = 0; i < fields->size(); ++i) {
RETURN_NOT_OK(GetField(values[i], &(*fields)[i]));
}
return Status::OK();
@@ -712,7 +712,7 @@ class JsonSchemaReader {
const auto& id_array = json_type_codes->value.GetArray();
for (const rj::Value& val : id_array) {
DCHECK(val.IsUint());
- type_codes.push_back(val.GetUint());
+ type_codes.push_back(static_cast<uint8_t>(val.GetUint()));
}
*type = union_(children, type_codes, mode);
@@ -770,10 +770,38 @@ static inline Status ParseHexValue(const char* data, uint8_t* out) {
// Error checking
if (*pos1 != c1 || *pos2 != c2) { return Status::Invalid("Encountered non-hex digit"); }
- *out = (pos1 - kAsciiTable) << 4 | (pos2 - kAsciiTable);
+ *out = static_cast<uint8_t>((pos1 - kAsciiTable) << 4 | (pos2 - kAsciiTable));
return Status::OK();
}
+template <typename T>
+inline typename std::enable_if<IsSignedInt<T>::value, typename T::c_type>::type
+UnboxValue(const rj::Value& val) {
+ DCHECK(val.IsInt());
+ return static_cast<typename T::c_type>(val.GetInt64());
+}
+
+template <typename T>
+inline typename std::enable_if<IsUnsignedInt<T>::value, typename T::c_type>::type
+UnboxValue(const rj::Value& val) {
+ DCHECK(val.IsUint());
+ return static_cast<typename T::c_type>(val.GetUint64());
+}
+
+template <typename T>
+inline typename std::enable_if<IsFloatingPoint<T>::value, typename T::c_type>::type
+UnboxValue(const rj::Value& val) {
+ DCHECK(val.IsFloat());
+ return static_cast<typename T::c_type>(val.GetDouble());
+}
+
+template <typename T>
+inline typename std::enable_if<std::is_base_of<BooleanType, T>::value, bool>::type
+UnboxValue(const rj::Value& val) {
+ DCHECK(val.IsBool());
+ return val.GetBool();
+}
+
class JsonArrayReader {
public:
explicit JsonArrayReader(MemoryPool* pool) : pool_(pool) {}
@@ -820,22 +848,7 @@ class JsonArrayReader {
}
const rj::Value& val = json_data_arr[i];
- if (IsSignedInt<T>::value) {
- DCHECK(val.IsInt());
- builder.Append(val.GetInt64());
- } else if (IsUnsignedInt<T>::value) {
- DCHECK(val.IsUint());
- builder.Append(val.GetUint64());
- } else if (IsFloatingPoint<T>::value) {
- DCHECK(val.IsFloat());
- builder.Append(val.GetDouble());
- } else if (std::is_base_of<BooleanType, T>::value) {
- DCHECK(val.IsBool());
- builder.Append(val.GetBool());
- } else {
- // We are in the wrong function
- return Status::Invalid(type->ToString());
- }
+ builder.Append(UnboxValue<T>(val));
}
return builder.Finish(array);
@@ -869,13 +882,13 @@ class JsonArrayReader {
std::string hex_string = val.GetString();
DCHECK(hex_string.size() % 2 == 0) << "Expected base16 hex string";
- int64_t length = static_cast<int>(hex_string.size()) / 2;
+ int32_t length = static_cast<int>(hex_string.size()) / 2;
if (byte_buffer->size() < length) { RETURN_NOT_OK(byte_buffer->Resize(length)); }
const char* hex_data = hex_string.c_str();
uint8_t* byte_buffer_data = byte_buffer->mutable_data();
- for (int64_t j = 0; j < length; ++j) {
+ for (int32_t j = 0; j < length; ++j) {
RETURN_NOT_OK(ParseHexValue(hex_data + j * 2, &byte_buffer_data[j]));
}
RETURN_NOT_OK(builder.Append(byte_buffer_data, length));
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/ipc/json.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/json.cc b/cpp/src/arrow/ipc/json.cc
index 773fb74..a01be19 100644
--- a/cpp/src/arrow/ipc/json.cc
+++ b/cpp/src/arrow/ipc/json.cc
@@ -69,7 +69,7 @@ class JsonWriter::JsonWriterImpl {
writer_->StartObject();
writer_->Key("count");
- writer_->Int(batch.num_rows());
+ writer_->Int(static_cast<int32_t>(batch.num_rows()));
writer_->Key("columns");
writer_->StartArray();
@@ -158,7 +158,7 @@ class JsonReader::JsonReaderImpl {
const auto& json_columns = it->value.GetArray();
std::vector<std::shared_ptr<Array>> columns(json_columns.Size());
- for (size_t i = 0; i < columns.size(); ++i) {
+ for (int i = 0; i < static_cast<int>(columns.size()); ++i) {
const std::shared_ptr<DataType>& type = schema_->field(i)->type;
RETURN_NOT_OK(ReadJsonArray(pool_, json_columns[i], type, &columns[i]));
}
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/ipc/metadata-internal.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/metadata-internal.cc b/cpp/src/arrow/ipc/metadata-internal.cc
index 7c8ddb9..1cc4a23 100644
--- a/cpp/src/arrow/ipc/metadata-internal.cc
+++ b/cpp/src/arrow/ipc/metadata-internal.cc
@@ -214,7 +214,8 @@ static Status TypeToFlatbuffer(FBB& fbb, const std::shared_ptr<DataType>& type,
vector_type = flatbuf::VectorType_DATA;
break;
}
- auto offset = flatbuf::CreateVectorLayout(fbb, descr.bit_width(), vector_type);
+ auto offset = flatbuf::CreateVectorLayout(
+ fbb, static_cast<int16_t>(descr.bit_width()), vector_type);
layout->push_back(offset);
}
@@ -328,7 +329,7 @@ Status FieldFromFlatbufferDictionary(
std::shared_ptr<DataType> type;
auto children = field->children();
std::vector<std::shared_ptr<Field>> child_fields(children->size());
- for (size_t i = 0; i < children->size(); ++i) {
+ for (int i = 0; i < static_cast<int>(children->size()); ++i) {
RETURN_NOT_OK(FieldFromFlatbuffer(children->Get(i), dummy_memo, &child_fields[i]));
}
@@ -350,7 +351,7 @@ Status FieldFromFlatbuffer(const flatbuf::Field* field,
// children to fully reconstruct the data type
auto children = field->children();
std::vector<std::shared_ptr<Field>> child_fields(children->size());
- for (size_t i = 0; i < children->size(); ++i) {
+ for (int i = 0; i < static_cast<int>(children->size()); ++i) {
RETURN_NOT_OK(
FieldFromFlatbuffer(children->Get(i), dictionary_memo, &child_fields[i]));
}
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/ipc/reader.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/reader.cc b/cpp/src/arrow/ipc/reader.cc
index 1a9af7d..9734166 100644
--- a/cpp/src/arrow/ipc/reader.cc
+++ b/cpp/src/arrow/ipc/reader.cc
@@ -203,7 +203,7 @@ class FileReader::FileReaderImpl {
}
std::shared_ptr<Buffer> buffer;
- int file_end_size = magic_size + sizeof(int32_t);
+ int file_end_size = static_cast<int>(magic_size + sizeof(int32_t));
RETURN_NOT_OK(file_->ReadAt(footer_offset_ - file_end_size, file_end_size, &buffer));
if (memcmp(buffer->data() + sizeof(int32_t), kArrowMagicBytes, magic_size)) {
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/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 07f786c..dc82366 100644
--- a/cpp/src/arrow/ipc/test-common.h
+++ b/cpp/src/arrow/ipc/test-common.h
@@ -51,7 +51,7 @@ const auto kListInt32 = list(int32());
const auto kListListInt32 = list(kListInt32);
Status MakeRandomInt32Array(
- int32_t length, bool include_nulls, MemoryPool* pool, std::shared_ptr<Array>* out) {
+ int64_t length, bool include_nulls, MemoryPool* pool, std::shared_ptr<Array>* out) {
std::shared_ptr<PoolBuffer> data;
test::MakeRandomInt32PoolBuffer(length, pool, &data);
Int32Builder builder(pool, int32());
@@ -79,7 +79,7 @@ Status MakeRandomListArray(const std::shared_ptr<Array>& child_array, int num_li
std::vector<int32_t> list_sizes(num_lists, 0);
std::vector<int32_t> offsets(
num_lists + 1, 0); // +1 so we can shift for nulls. See partial sum below.
- const int seed = child_array->length();
+ const uint32_t seed = static_cast<uint32_t>(child_array->length());
if (num_lists > 0) {
test::rand_uniform_int(num_lists, seed, 0, max_list_size, list_sizes.data());
// make sure sizes are consistent with null
@@ -89,7 +89,7 @@ Status MakeRandomListArray(const std::shared_ptr<Array>& child_array, int num_li
std::partial_sum(list_sizes.begin(), list_sizes.end(), ++offsets.begin());
// Force invariants
- const int child_length = child_array->length();
+ const int64_t child_length = child_array->length();
offsets[0] = 0;
std::replace_if(offsets.begin(), offsets.end(),
[child_length](int32_t offset) { return offset > child_length; }, child_length);
@@ -121,26 +121,26 @@ Status MakeIntRecordBatch(std::shared_ptr<RecordBatch>* out) {
template <class Builder, class RawType>
Status MakeRandomBinaryArray(
- int32_t length, MemoryPool* pool, std::shared_ptr<Array>* out) {
+ int64_t length, MemoryPool* pool, std::shared_ptr<Array>* out) {
const std::vector<std::string> values = {
"", "", "abc", "123", "efg", "456!@#!@#", "12312"};
Builder builder(pool);
- const auto values_len = values.size();
- for (int32_t i = 0; i < length; ++i) {
- int values_index = i % values_len;
+ const size_t values_len = values.size();
+ for (int64_t i = 0; i < length; ++i) {
+ int64_t values_index = i % values_len;
if (values_index == 0) {
RETURN_NOT_OK(builder.AppendNull());
} else {
const std::string& value = values[values_index];
- RETURN_NOT_OK(
- builder.Append(reinterpret_cast<const RawType*>(value.data()), value.size()));
+ RETURN_NOT_OK(builder.Append(reinterpret_cast<const RawType*>(value.data()),
+ static_cast<int32_t>(value.size())));
}
}
return builder.Finish(out);
}
Status MakeStringTypesRecordBatch(std::shared_ptr<RecordBatch>* out) {
- const int32_t length = 500;
+ const int64_t length = 500;
auto string_type = utf8();
auto binary_type = binary();
auto f0 = field("f0", string_type);
@@ -302,7 +302,7 @@ Status MakeUnion(std::shared_ptr<RecordBatch>* out) {
std::vector<std::shared_ptr<Array>> sparse_children(2);
std::vector<std::shared_ptr<Array>> dense_children(2);
- const int32_t length = 7;
+ const int64_t length = 7;
std::shared_ptr<Buffer> type_ids_buffer;
std::vector<uint8_t> type_ids = {5, 10, 5, 5, 10, 10, 5};
@@ -346,7 +346,7 @@ Status MakeUnion(std::shared_ptr<RecordBatch>* out) {
}
Status MakeDictionary(std::shared_ptr<RecordBatch>* out) {
- const int32_t length = 6;
+ const int64_t length = 6;
std::vector<bool> is_valid = {true, true, false, true, true, true};
std::shared_ptr<Array> dict1, dict2;
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/ipc/writer.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/writer.cc b/cpp/src/arrow/ipc/writer.cc
index 975b0d1..58402b5 100644
--- a/cpp/src/arrow/ipc/writer.cc
+++ b/cpp/src/arrow/ipc/writer.cc
@@ -61,7 +61,7 @@ class StreamWriter::StreamWriterImpl {
std::shared_ptr<Buffer> schema_fb;
RETURN_NOT_OK(WriteSchemaMessage(*schema_, dictionary_memo_.get(), &schema_fb));
- int32_t flatbuffer_size = schema_fb->size();
+ int32_t flatbuffer_size = static_cast<int32_t>(schema_fb->size());
RETURN_NOT_OK(
Write(reinterpret_cast<const uint8_t*>(&flatbuffer_size), sizeof(int32_t)));
@@ -252,7 +252,7 @@ class FileWriter::FileWriterImpl : public StreamWriter::StreamWriterImpl {
RETURN_NOT_OK(UpdatePosition());
// Write footer length
- int32_t footer_length = position_ - initial_position;
+ int32_t footer_length = static_cast<int32_t>(position_ - initial_position);
if (footer_length <= 0) { return Status::Invalid("Invalid file footer"); }
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/pretty_print.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/pretty_print.cc b/cpp/src/arrow/pretty_print.cc
index 23c0580..7e69e42 100644
--- a/cpp/src/arrow/pretty_print.cc
+++ b/cpp/src/arrow/pretty_print.cc
@@ -196,7 +196,7 @@ class ArrayPrinter : public ArrayVisitor {
}
Status PrintChildren(
- const std::vector<std::shared_ptr<Array>>& fields, int32_t offset, int32_t length) {
+ const std::vector<std::shared_ptr<Array>>& fields, int64_t offset, int64_t length) {
for (size_t i = 0; i < fields.size(); ++i) {
Newline();
std::stringstream ss;
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/schema.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/schema.cc b/cpp/src/arrow/schema.cc
index cd8256e..aa38fd3 100644
--- a/cpp/src/arrow/schema.cc
+++ b/cpp/src/arrow/schema.cc
@@ -45,7 +45,7 @@ bool Schema::Equals(const std::shared_ptr<Schema>& other) const {
std::shared_ptr<Field> Schema::GetFieldByName(const std::string& name) {
if (fields_.size() > 0 && name_to_index_.size() == 0) {
for (size_t i = 0; i < fields_.size(); ++i) {
- name_to_index_[fields_[i]->name] = i;
+ name_to_index_[fields_[i]->name] = static_cast<int>(i);
}
}
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/schema.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/schema.h b/cpp/src/arrow/schema.h
index 0e1ab5c..37cdbf7 100644
--- a/cpp/src/arrow/schema.h
+++ b/cpp/src/arrow/schema.h
@@ -47,7 +47,7 @@ class ARROW_EXPORT Schema {
// Render a string representation of the schema suitable for debugging
std::string ToString() const;
- int num_fields() const { return fields_.size(); }
+ int num_fields() const { return static_cast<int>(fields_.size()); }
private:
std::vector<std::shared_ptr<Field>> fields_;
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/status.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/status.cc b/cpp/src/arrow/status.cc
index e1a2427..3a39c84 100644
--- a/cpp/src/arrow/status.cc
+++ b/cpp/src/arrow/status.cc
@@ -18,7 +18,7 @@ namespace arrow {
Status::Status(StatusCode code, const std::string& msg, int16_t posix_code) {
assert(code != StatusCode::OK);
- const uint32_t size = msg.size();
+ const uint32_t size = static_cast<uint32_t>(msg.size());
char* result = new char[size + 7];
memcpy(result, &size, sizeof(size));
result[4] = static_cast<char>(code);
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/table-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/table-test.cc b/cpp/src/arrow/table-test.cc
index 25f12c4..3637473 100644
--- a/cpp/src/arrow/table-test.cc
+++ b/cpp/src/arrow/table-test.cc
@@ -150,7 +150,7 @@ TEST_F(TestTable, Equals) {
}
TEST_F(TestTable, FromRecordBatches) {
- const int32_t length = 10;
+ const int64_t length = 10;
MakeExample1(length);
auto batch1 = std::make_shared<RecordBatch>(schema_, length, arrays_);
@@ -184,7 +184,7 @@ TEST_F(TestTable, FromRecordBatches) {
}
TEST_F(TestTable, ConcatenateTables) {
- const int32_t length = 10;
+ const int64_t length = 10;
MakeExample1(length);
auto batch1 = std::make_shared<RecordBatch>(schema_, length, arrays_);
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/table.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/table.cc b/cpp/src/arrow/table.cc
index 8ac06b8..6b957c0 100644
--- a/cpp/src/arrow/table.cc
+++ b/cpp/src/arrow/table.cc
@@ -29,7 +29,7 @@
namespace arrow {
-RecordBatch::RecordBatch(const std::shared_ptr<Schema>& schema, int num_rows,
+RecordBatch::RecordBatch(const std::shared_ptr<Schema>& schema, int64_t num_rows,
const std::vector<std::shared_ptr<Array>>& columns)
: schema_(schema), num_rows_(num_rows), columns_(columns) {}
@@ -61,18 +61,18 @@ bool RecordBatch::ApproxEquals(const RecordBatch& other) const {
return true;
}
-std::shared_ptr<RecordBatch> RecordBatch::Slice(int32_t offset) {
+std::shared_ptr<RecordBatch> RecordBatch::Slice(int64_t offset) {
return Slice(offset, this->num_rows() - offset);
}
-std::shared_ptr<RecordBatch> RecordBatch::Slice(int32_t offset, int32_t length) {
+std::shared_ptr<RecordBatch> RecordBatch::Slice(int64_t offset, int64_t length) {
std::vector<std::shared_ptr<Array>> arrays;
arrays.reserve(num_columns());
for (const auto& field : columns_) {
arrays.emplace_back(field->Slice(offset, length));
}
- int32_t num_rows = std::min(num_rows_ - offset, length);
+ int64_t num_rows = std::min(num_rows_ - offset, length);
return std::make_shared<RecordBatch>(schema_, num_rows, arrays);
}
@@ -169,7 +169,7 @@ bool Table::Equals(const Table& other) const {
if (!schema_->Equals(other.schema())) { return false; }
if (static_cast<int64_t>(columns_.size()) != other.num_columns()) { return false; }
- for (size_t i = 0; i < columns_.size(); i++) {
+ for (int i = 0; i < static_cast<int>(columns_.size()); i++) {
if (!columns_[i]->Equals(other.column(i))) { return false; }
}
return true;
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/table.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/table.h b/cpp/src/arrow/table.h
index fa56824..68f664b 100644
--- a/cpp/src/arrow/table.h
+++ b/cpp/src/arrow/table.h
@@ -40,7 +40,7 @@ class ARROW_EXPORT RecordBatch {
// num_rows is a parameter to allow for record batches of a particular size not
// having any materialized columns. Each array should have the same length as
// num_rows
- RecordBatch(const std::shared_ptr<Schema>& schema, int32_t num_rows,
+ RecordBatch(const std::shared_ptr<Schema>& schema, int64_t num_rows,
const std::vector<std::shared_ptr<Array>>& columns);
bool Equals(const RecordBatch& other) const;
@@ -59,18 +59,18 @@ class ARROW_EXPORT RecordBatch {
const std::string& column_name(int i) const;
// @returns: the number of columns in the table
- int num_columns() const { return columns_.size(); }
+ int num_columns() const { return static_cast<int>(columns_.size()); }
// @returns: the number of rows (the corresponding length of each column)
- int32_t num_rows() const { return num_rows_; }
+ int64_t num_rows() const { return num_rows_; }
/// Slice each of the arrays in the record batch and construct a new RecordBatch object
- std::shared_ptr<RecordBatch> Slice(int32_t offset);
- std::shared_ptr<RecordBatch> Slice(int32_t offset, int32_t length);
+ std::shared_ptr<RecordBatch> Slice(int64_t offset);
+ std::shared_ptr<RecordBatch> Slice(int64_t offset, int64_t length);
private:
std::shared_ptr<Schema> schema_;
- int32_t num_rows_;
+ int64_t num_rows_;
std::vector<std::shared_ptr<Array>> columns_;
};
@@ -105,7 +105,7 @@ class ARROW_EXPORT Table {
std::shared_ptr<Column> column(int i) const { return columns_[i]; }
// @returns: the number of columns in the table
- int num_columns() const { return columns_.size(); }
+ int num_columns() const { return static_cast<int>(columns_.size()); }
// @returns: the number of rows (the corresponding length of each column)
int64_t num_rows() const { return num_rows_; }
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/test-util.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/test-util.h b/cpp/src/arrow/test-util.h
index ffc7806..5c7d04d 100644
--- a/cpp/src/arrow/test-util.h
+++ b/cpp/src/arrow/test-util.h
@@ -73,16 +73,17 @@ void randint(int64_t N, T lower, T upper, std::vector<T>* out) {
T val;
for (int64_t i = 0; i < N; ++i) {
draw = rng.Uniform64(span);
- val = lower + static_cast<T>(draw);
+ val = static_cast<T>(draw + lower);
out->push_back(val);
}
}
template <typename T>
-void random_real(int n, uint32_t seed, T min_value, T max_value, std::vector<T>* out) {
+void random_real(
+ int64_t n, uint32_t seed, T min_value, T max_value, std::vector<T>* out) {
std::mt19937 gen(seed);
std::uniform_real_distribution<T> d(min_value, max_value);
- for (int i = 0; i < n; ++i) {
+ for (int64_t i = 0; i < n; ++i) {
out->push_back(d(gen));
}
}
@@ -108,13 +109,13 @@ inline Status CopyBufferFromVector(
static inline Status GetBitmapFromBoolVector(
const std::vector<bool>& is_valid, std::shared_ptr<Buffer>* result) {
- int length = static_cast<int>(is_valid.size());
+ int64_t length = static_cast<int64_t>(is_valid.size());
std::shared_ptr<MutableBuffer> buffer;
RETURN_NOT_OK(GetEmptyBitmap(default_memory_pool(), length, &buffer));
uint8_t* bitmap = buffer->mutable_data();
- for (int i = 0; i < length; ++i) {
+ for (int64_t i = 0; i < length; ++i) {
if (is_valid[i]) { BitUtil::SetBit(bitmap, i); }
}
@@ -126,7 +127,7 @@ static inline Status GetBitmapFromBoolVector(
// and the rest to non-zero (true) values.
static inline void random_null_bytes(int64_t n, double pct_null, uint8_t* null_bytes) {
Random rng(random_seed());
- for (int i = 0; i < n; ++i) {
+ for (int64_t i = 0; i < n; ++i) {
null_bytes[i] = rng.NextDoubleFraction() > pct_null;
}
}
@@ -134,41 +135,41 @@ static inline void random_null_bytes(int64_t n, double pct_null, uint8_t* null_b
static inline void random_is_valid(
int64_t n, double pct_null, std::vector<bool>* is_valid) {
Random rng(random_seed());
- for (int i = 0; i < n; ++i) {
+ for (int64_t i = 0; i < n; ++i) {
is_valid->push_back(rng.NextDoubleFraction() > pct_null);
}
}
-static inline void random_bytes(int n, uint32_t seed, uint8_t* out) {
+static inline void random_bytes(int64_t n, uint32_t seed, uint8_t* out) {
std::mt19937 gen(seed);
std::uniform_int_distribution<int> d(0, 255);
- for (int i = 0; i < n; ++i) {
- out[i] = d(gen) & 0xFF;
+ for (int64_t i = 0; i < n; ++i) {
+ out[i] = static_cast<uint8_t>(d(gen) & 0xFF);
}
}
-static inline void random_ascii(int n, uint32_t seed, uint8_t* out) {
+static inline void random_ascii(int64_t n, uint32_t seed, uint8_t* out) {
std::mt19937 gen(seed);
std::uniform_int_distribution<int> d(65, 122);
- for (int i = 0; i < n; ++i) {
- out[i] = d(gen) & 0xFF;
+ for (int64_t i = 0; i < n; ++i) {
+ out[i] = static_cast<uint8_t>(d(gen) & 0xFF);
}
}
template <typename T>
-void rand_uniform_int(int n, uint32_t seed, T min_value, T max_value, T* out) {
+void rand_uniform_int(int64_t n, uint32_t seed, T min_value, T max_value, T* out) {
DCHECK(out || (n == 0));
std::mt19937 gen(seed);
std::uniform_int_distribution<T> d(min_value, max_value);
- for (int i = 0; i < n; ++i) {
- out[i] = d(gen);
+ for (int64_t i = 0; i < n; ++i) {
+ out[i] = static_cast<T>(d(gen));
}
}
-static inline int null_count(const std::vector<uint8_t>& valid_bytes) {
- int result = 0;
+static inline int64_t null_count(const std::vector<uint8_t>& valid_bytes) {
+ int64_t result = 0;
for (size_t i = 0; i < valid_bytes.size(); ++i) {
if (valid_bytes[i] == 0) { ++result; }
}
@@ -183,7 +184,7 @@ std::shared_ptr<Buffer> bytes_to_null_buffer(const std::vector<uint8_t>& bytes)
return out;
}
-Status MakeRandomInt32PoolBuffer(int32_t length, MemoryPool* pool,
+Status MakeRandomInt32PoolBuffer(int64_t length, MemoryPool* pool,
std::shared_ptr<PoolBuffer>* pool_buffer, uint32_t seed = 0) {
DCHECK(pool);
auto data = std::make_shared<PoolBuffer>(pool);
@@ -194,7 +195,7 @@ Status MakeRandomInt32PoolBuffer(int32_t length, MemoryPool* pool,
return Status::OK();
}
-Status MakeRandomBytePoolBuffer(int32_t length, MemoryPool* pool,
+Status MakeRandomBytePoolBuffer(int64_t length, MemoryPool* pool,
std::shared_ptr<PoolBuffer>* pool_buffer, uint32_t seed = 0) {
auto bytes = std::make_shared<PoolBuffer>(pool);
RETURN_NOT_OK(bytes->Resize(length));
@@ -213,7 +214,7 @@ class TestBase : public ::testing::Test {
}
template <typename ArrayType>
- std::shared_ptr<Array> MakePrimitive(int32_t length, int32_t null_count = 0) {
+ std::shared_ptr<Array> MakePrimitive(int64_t length, int64_t null_count = 0) {
auto data = std::make_shared<PoolBuffer>(pool_);
const int64_t data_nbytes = length * sizeof(typename ArrayType::value_type);
EXPECT_OK(data->Resize(data_nbytes));
@@ -275,9 +276,9 @@ class TestBuilder : public ::testing::Test {
template <class T, class Builder>
Status MakeArray(const std::vector<uint8_t>& valid_bytes, const std::vector<T>& values,
- int size, Builder* builder, std::shared_ptr<Array>* out) {
+ int64_t size, Builder* builder, std::shared_ptr<Array>* out) {
// Append the first 1000
- for (int i = 0; i < size; ++i) {
+ for (int64_t i = 0; i < size; ++i) {
if (valid_bytes[i] > 0) {
RETURN_NOT_OK(builder->Append(values[i]));
} else {
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/type.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/type.h b/cpp/src/arrow/type.h
index 9a97fc3..9b1ab32 100644
--- a/cpp/src/arrow/type.h
+++ b/cpp/src/arrow/type.h
@@ -162,7 +162,7 @@ struct ARROW_EXPORT DataType {
const std::vector<std::shared_ptr<Field>>& children() const { return children_; }
- int num_children() const { return children_.size(); }
+ int num_children() const { return static_cast<int>(children_.size()); }
virtual Status Accept(TypeVisitor* visitor) const = 0;
@@ -226,7 +226,7 @@ struct ARROW_EXPORT CTypeImpl : public PrimitiveCType {
CTypeImpl() : PrimitiveCType(TYPE_ID) {}
- int bit_width() const override { return sizeof(C_TYPE) * 8; }
+ int bit_width() const override { return static_cast<int>(sizeof(C_TYPE) * 8); }
Status Accept(TypeVisitor* visitor) const override {
return visitor->Visit(*static_cast<const DERIVED*>(this));
@@ -432,7 +432,7 @@ struct ARROW_EXPORT DateType : public FixedWidthType {
DateType() : FixedWidthType(Type::DATE) {}
- int bit_width() const override { return sizeof(c_type) * 8; }
+ int bit_width() const override { return static_cast<int>(sizeof(c_type) * 8); }
Status Accept(TypeVisitor* visitor) const override;
std::string ToString() const override;
@@ -448,7 +448,7 @@ struct ARROW_EXPORT TimeType : public FixedWidthType {
TimeUnit unit;
- int bit_width() const override { return sizeof(c_type) * 8; }
+ int bit_width() const override { return static_cast<int>(sizeof(c_type) * 8); }
explicit TimeType(TimeUnit unit = TimeUnit::MILLI)
: FixedWidthType(Type::TIME), unit(unit) {}
@@ -465,7 +465,7 @@ struct ARROW_EXPORT TimestampType : public FixedWidthType {
typedef int64_t c_type;
static constexpr Type::type type_id = Type::TIMESTAMP;
- int bit_width() const override { return sizeof(int64_t) * 8; }
+ int bit_width() const override { return static_cast<int>(sizeof(int64_t) * 8); }
TimeUnit unit;
@@ -485,7 +485,7 @@ struct ARROW_EXPORT IntervalType : public FixedWidthType {
using c_type = int64_t;
static constexpr Type::type type_id = Type::INTERVAL;
- int bit_width() const override { return sizeof(int64_t) * 8; }
+ int bit_width() const override { return static_cast<int>(sizeof(int64_t) * 8); }
Unit unit;
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/type_traits.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/type_traits.h b/cpp/src/arrow/type_traits.h
index c4898b1..d6687c1 100644
--- a/cpp/src/arrow/type_traits.h
+++ b/cpp/src/arrow/type_traits.h
@@ -32,7 +32,7 @@ template <>
struct TypeTraits<UInt8Type> {
using ArrayType = UInt8Array;
using BuilderType = UInt8Builder;
- static inline int bytes_required(int elements) { return elements; }
+ static inline int64_t bytes_required(int64_t elements) { return elements; }
constexpr static bool is_parameter_free = true;
static inline std::shared_ptr<DataType> type_singleton() { return uint8(); }
};
@@ -41,7 +41,7 @@ template <>
struct TypeTraits<Int8Type> {
using ArrayType = Int8Array;
using BuilderType = Int8Builder;
- static inline int bytes_required(int elements) { return elements; }
+ static inline int64_t bytes_required(int64_t elements) { return elements; }
constexpr static bool is_parameter_free = true;
static inline std::shared_ptr<DataType> type_singleton() { return int8(); }
};
@@ -51,7 +51,9 @@ struct TypeTraits<UInt16Type> {
using ArrayType = UInt16Array;
using BuilderType = UInt16Builder;
- static inline int bytes_required(int elements) { return elements * sizeof(uint16_t); }
+ static inline int64_t bytes_required(int64_t elements) {
+ return elements * sizeof(uint16_t);
+ }
constexpr static bool is_parameter_free = true;
static inline std::shared_ptr<DataType> type_singleton() { return uint16(); }
};
@@ -61,7 +63,9 @@ struct TypeTraits<Int16Type> {
using ArrayType = Int16Array;
using BuilderType = Int16Builder;
- static inline int bytes_required(int elements) { return elements * sizeof(int16_t); }
+ static inline int64_t bytes_required(int64_t elements) {
+ return elements * sizeof(int16_t);
+ }
constexpr static bool is_parameter_free = true;
static inline std::shared_ptr<DataType> type_singleton() { return int16(); }
};
@@ -71,7 +75,9 @@ struct TypeTraits<UInt32Type> {
using ArrayType = UInt32Array;
using BuilderType = UInt32Builder;
- static inline int bytes_required(int elements) { return elements * sizeof(uint32_t); }
+ static inline int64_t bytes_required(int64_t elements) {
+ return elements * sizeof(uint32_t);
+ }
constexpr static bool is_parameter_free = true;
static inline std::shared_ptr<DataType> type_singleton() { return uint32(); }
};
@@ -81,7 +87,9 @@ struct TypeTraits<Int32Type> {
using ArrayType = Int32Array;
using BuilderType = Int32Builder;
- static inline int bytes_required(int elements) { return elements * sizeof(int32_t); }
+ static inline int64_t bytes_required(int64_t elements) {
+ return elements * sizeof(int32_t);
+ }
constexpr static bool is_parameter_free = true;
static inline std::shared_ptr<DataType> type_singleton() { return int32(); }
};
@@ -91,7 +99,9 @@ struct TypeTraits<UInt64Type> {
using ArrayType = UInt64Array;
using BuilderType = UInt64Builder;
- static inline int bytes_required(int elements) { return elements * sizeof(uint64_t); }
+ static inline int64_t bytes_required(int64_t elements) {
+ return elements * sizeof(uint64_t);
+ }
constexpr static bool is_parameter_free = true;
static inline std::shared_ptr<DataType> type_singleton() { return uint64(); }
};
@@ -101,7 +111,9 @@ struct TypeTraits<Int64Type> {
using ArrayType = Int64Array;
using BuilderType = Int64Builder;
- static inline int bytes_required(int elements) { return elements * sizeof(int64_t); }
+ static inline int64_t bytes_required(int64_t elements) {
+ return elements * sizeof(int64_t);
+ }
constexpr static bool is_parameter_free = true;
static inline std::shared_ptr<DataType> type_singleton() { return int64(); }
};
@@ -111,7 +123,9 @@ struct TypeTraits<DateType> {
using ArrayType = DateArray;
// using BuilderType = DateBuilder;
- static inline int bytes_required(int elements) { return elements * sizeof(int64_t); }
+ static inline int64_t bytes_required(int64_t elements) {
+ return elements * sizeof(int64_t);
+ }
constexpr static bool is_parameter_free = true;
static inline std::shared_ptr<DataType> type_singleton() { return date(); }
};
@@ -121,7 +135,9 @@ struct TypeTraits<TimestampType> {
using ArrayType = TimestampArray;
// using BuilderType = TimestampBuilder;
- static inline int bytes_required(int elements) { return elements * sizeof(int64_t); }
+ static inline int64_t bytes_required(int64_t elements) {
+ return elements * sizeof(int64_t);
+ }
constexpr static bool is_parameter_free = false;
};
@@ -130,7 +146,9 @@ struct TypeTraits<TimeType> {
using ArrayType = TimeArray;
// using BuilderType = TimestampBuilder;
- static inline int bytes_required(int elements) { return elements * sizeof(int64_t); }
+ static inline int64_t bytes_required(int64_t elements) {
+ return elements * sizeof(int64_t);
+ }
constexpr static bool is_parameter_free = false;
};
@@ -139,7 +157,9 @@ struct TypeTraits<HalfFloatType> {
using ArrayType = HalfFloatArray;
using BuilderType = HalfFloatBuilder;
- static inline int bytes_required(int elements) { return elements * sizeof(uint16_t); }
+ static inline int64_t bytes_required(int64_t elements) {
+ return elements * sizeof(uint16_t);
+ }
constexpr static bool is_parameter_free = true;
static inline std::shared_ptr<DataType> type_singleton() { return float16(); }
};
@@ -149,7 +169,9 @@ struct TypeTraits<FloatType> {
using ArrayType = FloatArray;
using BuilderType = FloatBuilder;
- static inline int bytes_required(int elements) { return elements * sizeof(float); }
+ static inline int64_t bytes_required(int64_t elements) {
+ return static_cast<int64_t>(elements * sizeof(float));
+ }
constexpr static bool is_parameter_free = true;
static inline std::shared_ptr<DataType> type_singleton() { return float32(); }
};
@@ -159,7 +181,9 @@ struct TypeTraits<DoubleType> {
using ArrayType = DoubleArray;
using BuilderType = DoubleBuilder;
- static inline int bytes_required(int elements) { return elements * sizeof(double); }
+ static inline int64_t bytes_required(int64_t elements) {
+ return static_cast<int64_t>(elements * sizeof(double));
+ }
constexpr static bool is_parameter_free = true;
static inline std::shared_ptr<DataType> type_singleton() { return float64(); }
};
@@ -169,7 +193,7 @@ struct TypeTraits<BooleanType> {
using ArrayType = BooleanArray;
using BuilderType = BooleanBuilder;
- static inline int bytes_required(int elements) {
+ static inline int64_t bytes_required(int64_t elements) {
return BitUtil::BytesForBits(elements);
}
constexpr static bool is_parameter_free = true;
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/util/bit-util.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/bit-util.cc b/cpp/src/arrow/util/bit-util.cc
index f3fbb41..1bbd238 100644
--- a/cpp/src/arrow/util/bit-util.cc
+++ b/cpp/src/arrow/util/bit-util.cc
@@ -42,7 +42,7 @@ void BitUtil::BytesToBits(const std::vector<uint8_t>& bytes, uint8_t* bits) {
Status BitUtil::BytesToBits(
const std::vector<uint8_t>& bytes, std::shared_ptr<Buffer>* out) {
- int bit_length = BitUtil::BytesForBits(bytes.size());
+ int64_t bit_length = BitUtil::BytesForBits(bytes.size());
std::shared_ptr<MutableBuffer> buffer;
RETURN_NOT_OK(AllocateBuffer(default_memory_pool(), bit_length, &buffer));
@@ -98,7 +98,7 @@ Status GetEmptyBitmap(
return Status::OK();
}
-Status CopyBitmap(MemoryPool* pool, const uint8_t* data, int32_t offset, int32_t length,
+Status CopyBitmap(MemoryPool* pool, const uint8_t* data, int64_t offset, int64_t length,
std::shared_ptr<Buffer>* out) {
std::shared_ptr<MutableBuffer> buffer;
RETURN_NOT_OK(GetEmptyBitmap(pool, length, &buffer));
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/util/bit-util.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/bit-util.h b/cpp/src/arrow/util/bit-util.h
index a0fbdd2..6e3e8ae 100644
--- a/cpp/src/arrow/util/bit-util.h
+++ b/cpp/src/arrow/util/bit-util.h
@@ -34,6 +34,11 @@ class Status;
namespace BitUtil {
+static constexpr uint8_t kBitmask[] = {1, 2, 4, 8, 16, 32, 64, 128};
+
+// the ~i byte version of kBitmaks
+static constexpr uint8_t kFlippedBitmask[] = {254, 253, 251, 247, 239, 223, 191, 127};
+
static inline int64_t CeilByte(int64_t size) {
return (size + 7) & ~7;
}
@@ -46,28 +51,26 @@ static inline int64_t Ceil2Bytes(int64_t size) {
return (size + 15) & ~15;
}
-static constexpr uint8_t kBitmask[] = {1, 2, 4, 8, 16, 32, 64, 128};
-
-static inline bool GetBit(const uint8_t* bits, int i) {
+static inline bool GetBit(const uint8_t* bits, int64_t i) {
return static_cast<bool>(bits[i / 8] & kBitmask[i % 8]);
}
-static inline bool BitNotSet(const uint8_t* bits, int i) {
+static inline bool BitNotSet(const uint8_t* bits, int64_t i) {
return (bits[i / 8] & kBitmask[i % 8]) == 0;
}
-static inline void ClearBit(uint8_t* bits, int i) {
- bits[i / 8] &= ~kBitmask[i % 8];
+static inline void ClearBit(uint8_t* bits, int64_t i) {
+ bits[i / 8] &= kFlippedBitmask[i % 8];
}
-static inline void SetBit(uint8_t* bits, int i) {
+static inline void SetBit(uint8_t* bits, int64_t i) {
bits[i / 8] |= kBitmask[i % 8];
}
-static inline void SetBitTo(uint8_t* bits, int i, bool bit_is_set) {
+static inline void SetBitTo(uint8_t* bits, int64_t i, bool bit_is_set) {
// See https://graphics.stanford.edu/~seander/bithacks.html
// "Conditionally set or clear bits without branching"
- bits[i / 8] ^= (-bit_is_set ^ bits[i / 8]) & kBitmask[i % 8];
+ bits[i / 8] ^= static_cast<uint8_t>(-bit_is_set ^ bits[i / 8]) & kBitmask[i % 8];
}
static inline int64_t NextPower2(int64_t n) {
@@ -127,8 +130,8 @@ Status ARROW_EXPORT GetEmptyBitmap(
/// \param[out] out the resulting copy
///
/// \return Status message
-Status ARROW_EXPORT CopyBitmap(MemoryPool* pool, const uint8_t* bitmap, int32_t offset,
- int32_t length, std::shared_ptr<Buffer>* out);
+Status ARROW_EXPORT CopyBitmap(MemoryPool* pool, const uint8_t* bitmap, int64_t offset,
+ int64_t length, std::shared_ptr<Buffer>* out);
/// Compute the number of 1's in the given data array
///
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/python/pyarrow/array.pxd
----------------------------------------------------------------------
diff --git a/python/pyarrow/array.pxd b/python/pyarrow/array.pxd
index 9e4d469..56bb53d 100644
--- a/python/pyarrow/array.pxd
+++ b/python/pyarrow/array.pxd
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-from pyarrow.includes.common cimport shared_ptr
+from pyarrow.includes.common cimport shared_ptr, int64_t
from pyarrow.includes.libarrow cimport CArray
from pyarrow.scalar import NA
@@ -36,7 +36,7 @@ cdef class Array:
DataType type
cdef init(self, const shared_ptr[CArray]& sp_array)
- cdef getitem(self, int i)
+ cdef getitem(self, int64_t i)
cdef object box_array(const shared_ptr[CArray]& sp_array)
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/python/pyarrow/array.pyx
----------------------------------------------------------------------
diff --git a/python/pyarrow/array.pyx b/python/pyarrow/array.pyx
index 11abf03..7787e95 100644
--- a/python/pyarrow/array.pyx
+++ b/python/pyarrow/array.pyx
@@ -210,7 +210,7 @@ cdef class Array:
return self.getitem(key)
- cdef getitem(self, int i):
+ cdef getitem(self, int64_t i):
return scalar.box_scalar(self.type, self.sp_array, i)
def slice(self, offset=0, length=None):
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/python/pyarrow/includes/libarrow.pxd
----------------------------------------------------------------------
diff --git a/python/pyarrow/includes/libarrow.pxd b/python/pyarrow/includes/libarrow.pxd
index 702acfb..253cabb 100644
--- a/python/pyarrow/includes/libarrow.pxd
+++ b/python/pyarrow/includes/libarrow.pxd
@@ -64,15 +64,15 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
cdef cppclass CArray" arrow::Array":
shared_ptr[CDataType] type()
- int32_t length()
- int32_t null_count()
+ int64_t length()
+ int64_t null_count()
Type type_enum()
c_bool Equals(const shared_ptr[CArray]& arr)
c_bool IsNull(int i)
- shared_ptr[CArray] Slice(int32_t offset)
- shared_ptr[CArray] Slice(int32_t offset, int32_t length)
+ shared_ptr[CArray] Slice(int64_t offset)
+ shared_ptr[CArray] Slice(int64_t offset, int64_t length)
cdef cppclass CFixedWidthType" arrow::FixedWidthType"(CDataType):
int bit_width()
@@ -217,7 +217,7 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
shared_ptr[CChunkedArray] data()
cdef cppclass CRecordBatch" arrow::RecordBatch":
- CRecordBatch(const shared_ptr[CSchema]& schema, int32_t num_rows,
+ CRecordBatch(const shared_ptr[CSchema]& schema, int64_t num_rows,
const vector[shared_ptr[CArray]]& columns)
c_bool Equals(const CRecordBatch& other)
@@ -229,10 +229,10 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
const vector[shared_ptr[CArray]]& columns()
int num_columns()
- int32_t num_rows()
+ int64_t num_rows()
- shared_ptr[CRecordBatch] Slice(int32_t offset)
- shared_ptr[CRecordBatch] Slice(int32_t offset, int32_t length)
+ shared_ptr[CRecordBatch] Slice(int64_t offset)
+ shared_ptr[CRecordBatch] Slice(int64_t offset, int64_t length)
cdef cppclass CTable" arrow::Table":
CTable(const c_string& name, const shared_ptr[CSchema]& schema,
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/python/pyarrow/scalar.pxd
----------------------------------------------------------------------
diff --git a/python/pyarrow/scalar.pxd b/python/pyarrow/scalar.pxd
index 2d55757..551aeb9 100644
--- a/python/pyarrow/scalar.pxd
+++ b/python/pyarrow/scalar.pxd
@@ -32,10 +32,10 @@ cdef class NAType(Scalar):
cdef class ArrayValue(Scalar):
cdef:
shared_ptr[CArray] sp_array
- int index
+ int64_t index
cdef void init(self, DataType type,
- const shared_ptr[CArray]& sp_array, int index)
+ const shared_ptr[CArray]& sp_array, int64_t index)
cdef void _set_array(self, const shared_ptr[CArray]& sp_array)
@@ -55,7 +55,7 @@ cdef class ListValue(ArrayValue):
cdef:
CListArray* ap
- cdef getitem(self, int i)
+ cdef getitem(self, int64_t i)
cdef class StringValue(ArrayValue):
@@ -63,4 +63,4 @@ cdef class StringValue(ArrayValue):
cdef object box_scalar(DataType type,
const shared_ptr[CArray]& sp_array,
- int index)
+ int64_t index)
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/python/pyarrow/scalar.pyx
----------------------------------------------------------------------
diff --git a/python/pyarrow/scalar.pyx b/python/pyarrow/scalar.pyx
index 57a15ad..1337b2b 100644
--- a/python/pyarrow/scalar.pyx
+++ b/python/pyarrow/scalar.pyx
@@ -46,7 +46,7 @@ NA = NAType()
cdef class ArrayValue(Scalar):
cdef void init(self, DataType type, const shared_ptr[CArray]& sp_array,
- int index):
+ int64_t index):
self.type = type
self.index = index
self._set_array(sp_array)
@@ -201,13 +201,13 @@ cdef class ListValue(ArrayValue):
self.ap = <CListArray*> sp_array.get()
self.value_type = box_data_type(self.ap.value_type())
- cdef getitem(self, int i):
- cdef int j = self.ap.value_offset(self.index) + i
+ cdef getitem(self, int64_t i):
+ cdef int64_t j = self.ap.value_offset(self.index) + i
return box_scalar(self.value_type, self.ap.values(), j)
def as_py(self):
cdef:
- int j
+ int64_t j
list result = []
for j in range(len(self)):
@@ -236,7 +236,7 @@ cdef dict _scalar_classes = {
}
cdef object box_scalar(DataType type, const shared_ptr[CArray]& sp_array,
- int index):
+ int64_t index):
cdef ArrayValue val
if type.type.type == Type_NA:
return NA
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/python/pyarrow/table.pyx
----------------------------------------------------------------------
diff --git a/python/pyarrow/table.pyx b/python/pyarrow/table.pyx
index 7d73362..93bc6dd 100644
--- a/python/pyarrow/table.pyx
+++ b/python/pyarrow/table.pyx
@@ -497,7 +497,7 @@ cdef class RecordBatch:
shared_ptr[CSchema] schema
shared_ptr[CRecordBatch] batch
vector[shared_ptr[CArray]] c_arrays
- int32_t num_rows
+ int64_t num_rows
if len(arrays) == 0:
raise ValueError('Record batch cannot contain no arrays (for now)')
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/python/src/pyarrow/adapters/builtin.cc
----------------------------------------------------------------------
diff --git a/python/src/pyarrow/adapters/builtin.cc b/python/src/pyarrow/adapters/builtin.cc
index 5fd8eef..c125cc0 100644
--- a/python/src/pyarrow/adapters/builtin.cc
+++ b/python/src/pyarrow/adapters/builtin.cc
@@ -375,7 +375,7 @@ class BytesConverter : public TypedConverter<arrow::BinaryBuilder> {
PyObject* bytes_obj;
OwnedRef tmp;
const char* bytes;
- int32_t length;
+ int64_t length;
Py_ssize_t size = PySequence_Size(seq);
for (int64_t i = 0; i < size; ++i) {
item = PySequence_GetItem(seq, i);
@@ -409,7 +409,7 @@ class UTF8Converter : public TypedConverter<arrow::StringBuilder> {
PyObject* bytes_obj;
OwnedRef tmp;
const char* bytes;
- int32_t length;
+ int64_t length;
Py_ssize_t size = PySequence_Size(seq);
for (int64_t i = 0; i < size; ++i) {
item = PySequence_GetItem(seq, i);
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/python/src/pyarrow/adapters/pandas.cc
----------------------------------------------------------------------
diff --git a/python/src/pyarrow/adapters/pandas.cc b/python/src/pyarrow/adapters/pandas.cc
index bdc2cb7..cadb53e 100644
--- a/python/src/pyarrow/adapters/pandas.cc
+++ b/python/src/pyarrow/adapters/pandas.cc
@@ -224,13 +224,13 @@ Status AppendObjectStrings(arrow::StringBuilder& string_builder, PyObject** obje
PyErr_Clear();
return Status::TypeError("failed converting unicode to UTF8");
}
- const int32_t length = PyBytes_GET_SIZE(obj);
+ const int64_t length = PyBytes_GET_SIZE(obj);
Status s = string_builder.Append(PyBytes_AS_STRING(obj), length);
Py_DECREF(obj);
if (!s.ok()) { return s; }
} else if (PyBytes_Check(obj)) {
*have_bytes = true;
- const int32_t length = PyBytes_GET_SIZE(obj);
+ const int64_t length = PyBytes_GET_SIZE(obj);
RETURN_NOT_OK(string_builder.Append(PyBytes_AS_STRING(obj), length));
} else {
string_builder.AppendNull();
@@ -413,7 +413,7 @@ inline void ConvertIntegerNoNullsCast(const ChunkedArray& data, OutType* out_val
const std::shared_ptr<Array> arr = data.chunk(c);
auto prim_arr = static_cast<arrow::PrimitiveArray*>(arr.get());
auto in_values = reinterpret_cast<const InType*>(prim_arr->data()->data());
- for (int32_t i = 0; i < arr->length(); ++i) {
+ for (int64_t i = 0; i < arr->length(); ++i) {
*out_values = in_values[i];
}
}
@@ -507,7 +507,6 @@ inline Status ConvertListsLike(
auto arr = std::static_pointer_cast<arrow::ListArray>(data.chunk(c));
const uint8_t* data_ptr;
- int32_t length;
const bool has_nulls = data.null_count() > 0;
for (int64_t i = 0; i < arr->length(); ++i) {
if (has_nulls && arr->IsNull(i)) {
@@ -1520,7 +1519,7 @@ inline Status ArrowSerializer<TYPE>::Convert(std::shared_ptr<Array>* out) {
}
// For readability
- constexpr int32_t kOffset = 0;
+ constexpr int64_t kOffset = 0;
RETURN_NOT_OK(ConvertData());
std::shared_ptr<DataType> type;
@@ -1636,7 +1635,7 @@ inline Status ArrowSerializer<TYPE>::ConvertTypedLists(
// TODO(uwe): Support more complex numpy array structures
RETURN_NOT_OK(CheckFlatNumpyArray(numpy_array, ITEM_TYPE));
- int32_t size = PyArray_DIM(numpy_array, 0);
+ int64_t size = PyArray_DIM(numpy_array, 0);
auto data = reinterpret_cast<const T*>(PyArray_DATA(numpy_array));
if (traits::supports_nulls) {
null_bitmap_->Resize(size, false);
@@ -1678,7 +1677,7 @@ ArrowSerializer<NPY_OBJECT>::ConvertTypedLists<NPY_OBJECT, ::arrow::StringType>(
// TODO(uwe): Support more complex numpy array structures
RETURN_NOT_OK(CheckFlatNumpyArray(numpy_array, NPY_OBJECT));
- int32_t size = PyArray_DIM(numpy_array, 0);
+ int64_t size = PyArray_DIM(numpy_array, 0);
auto data = reinterpret_cast<PyObject**>(PyArray_DATA(numpy_array));
RETURN_NOT_OK(AppendObjectStrings(*value_builder.get(), data, size, &have_bytes));
} else if (PyList_Check(objects[i])) {
[2/2] arrow git commit: ARROW-493: [C++] Permit large (length >
INT32_MAX) arrays in memory
Posted by uw...@apache.org.
ARROW-493: [C++] Permit large (length > INT32_MAX) arrays in memory
This commit relaxes the INT32_MAX length requirement for in-memory data. It does not change the Arrow memory format, nor does it permit arrays over INT32_MAX elements to be included in a RecordBatch message sent in the streaming or file formats.
The purpose of this change is to enable Arrow containers to do zero-copy addressing of large datasets (generally of fixed-size elements) produced by other systems. Should those systems wish to send messages to Java, they will need to break those large arrays up into smaller pieces. We can create utilities to assist in copy-free segmentation of large in-memory datasets into compatible chunksizes.
If the large data is only being used in C++-land, then there are no problems.
This is a helpful change en route to adding an `arrow::Tensor` type per ARROW-550, and probably some other things.
This also includes ARROW-584, as I wanted to be sure that I caught all the places in the codebase where there were imprecise integer conversions.
cc @pcmoritz @robertnishihara
Author: Wes McKinney <we...@twosigma.com>
Closes #352 from wesm/ARROW-493 and squashes the following commits:
013d8cc [Wes McKinney] Fix some more compiler warnings
13c4067 [Wes McKinney] Do not pass CMAKE_CXX_FLAGS to googletest ep
dc50d80 [Wes McKinney] Fix last imprecise conversions
c8e90bc [Wes McKinney] Fix many imprecise integer conversions
6bacdf3 [Wes McKinney] Permit in-memory arrays with more than INT32_MAX elements in Array and Builder classes. Raise if large arrays used in IPC context
Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/01a67f3f
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/01a67f3f
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/01a67f3f
Branch: refs/heads/master
Commit: 01a67f3ff3f43f504dc92b66e04473a8b29053f1
Parents: dc103fe
Author: Wes McKinney <we...@twosigma.com>
Authored: Mon Feb 27 08:14:10 2017 +0100
Committer: Uwe L. Korn <uw...@xhochy.com>
Committed: Mon Feb 27 08:14:10 2017 +0100
----------------------------------------------------------------------
ci/travis_before_script_cpp.sh | 2 +-
cpp/CMakeLists.txt | 6 +-
cpp/src/arrow/array-dictionary-test.cc | 2 +-
cpp/src/arrow/array-primitive-test.cc | 69 ++++++++-------
cpp/src/arrow/array-string-test.cc | 24 ++---
cpp/src/arrow/array-test.cc | 17 +++-
cpp/src/arrow/array-union-test.cc | 2 +-
cpp/src/arrow/array.cc | 84 +++++++++---------
cpp/src/arrow/array.h | 132 ++++++++++++++--------------
cpp/src/arrow/buffer.h | 14 +--
cpp/src/arrow/builder.cc | 79 +++++++++--------
cpp/src/arrow/builder.h | 63 ++++++-------
cpp/src/arrow/column-benchmark.cc | 2 +-
cpp/src/arrow/column.cc | 6 +-
cpp/src/arrow/column.h | 2 +-
cpp/src/arrow/compare.cc | 48 +++++-----
cpp/src/arrow/compare.h | 2 +-
cpp/src/arrow/io/file.cc | 8 +-
cpp/src/arrow/io/hdfs.cc | 15 ++--
cpp/src/arrow/io/io-hdfs-test.cc | 2 +-
cpp/src/arrow/ipc/adapter.cc | 24 +++--
cpp/src/arrow/ipc/ipc-json-test.cc | 2 +-
cpp/src/arrow/ipc/json-internal.cc | 61 ++++++++-----
cpp/src/arrow/ipc/json.cc | 4 +-
cpp/src/arrow/ipc/metadata-internal.cc | 7 +-
cpp/src/arrow/ipc/reader.cc | 2 +-
cpp/src/arrow/ipc/test-common.h | 24 ++---
cpp/src/arrow/ipc/writer.cc | 4 +-
cpp/src/arrow/pretty_print.cc | 2 +-
cpp/src/arrow/schema.cc | 2 +-
cpp/src/arrow/schema.h | 2 +-
cpp/src/arrow/status.cc | 2 +-
cpp/src/arrow/table-test.cc | 4 +-
cpp/src/arrow/table.cc | 10 +--
cpp/src/arrow/table.h | 14 +--
cpp/src/arrow/test-util.h | 47 +++++-----
cpp/src/arrow/type.h | 12 +--
cpp/src/arrow/type_traits.h | 54 ++++++++----
cpp/src/arrow/util/bit-util.cc | 4 +-
cpp/src/arrow/util/bit-util.h | 25 +++---
python/pyarrow/array.pxd | 4 +-
python/pyarrow/array.pyx | 2 +-
python/pyarrow/includes/libarrow.pxd | 16 ++--
python/pyarrow/scalar.pxd | 8 +-
python/pyarrow/scalar.pyx | 10 +--
python/pyarrow/table.pyx | 2 +-
python/src/pyarrow/adapters/builtin.cc | 4 +-
python/src/pyarrow/adapters/pandas.cc | 13 ++-
48 files changed, 508 insertions(+), 436 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/ci/travis_before_script_cpp.sh
----------------------------------------------------------------------
diff --git a/ci/travis_before_script_cpp.sh b/ci/travis_before_script_cpp.sh
index feacf8f..f804a38 100755
--- a/ci/travis_before_script_cpp.sh
+++ b/ci/travis_before_script_cpp.sh
@@ -36,7 +36,7 @@ CMAKE_COMMON_FLAGS="\
if [ $TRAVIS_OS_NAME == "linux" ]; then
cmake -DARROW_TEST_MEMCHECK=on \
$CMAKE_COMMON_FLAGS \
- -DARROW_CXXFLAGS=-Werror \
+ -DARROW_CXXFLAGS="-Wconversion -Werror" \
$CPP_DIR
else
cmake $CMAKE_COMMON_FLAGS \
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index be3d4b9..f6dab78 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -123,7 +123,9 @@ endif()
include(SetupCxxFlags)
# Add common flags
-set(CMAKE_CXX_FLAGS "${ARROW_CXXFLAGS} ${CXX_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}")
+set(CMAKE_CXX_FLAGS "${CXX_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}")
+set(EP_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+set(CMAKE_CXX_FLAGS "${ARROW_CXXFLAGS} ${CMAKE_CXX_FLAGS}")
# Determine compiler version
include(CompilerInfo)
@@ -452,7 +454,7 @@ if(ARROW_BUILD_TESTS)
set(GTEST_CMAKE_CXX_FLAGS "-fPIC")
endif()
string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_BUILD_TYPE)
- set(GTEST_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPERCASE_BUILD_TYPE}} ${GTEST_CMAKE_CXX_FLAGS}")
+ set(GTEST_CMAKE_CXX_FLAGS "${EP_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPERCASE_BUILD_TYPE}} ${GTEST_CMAKE_CXX_FLAGS}")
set(GTEST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/googletest_ep-prefix/src/googletest_ep")
set(GTEST_INCLUDE_DIR "${GTEST_PREFIX}/include")
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/array-dictionary-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array-dictionary-test.cc b/cpp/src/arrow/array-dictionary-test.cc
index 61381b7..0c4e628 100644
--- a/cpp/src/arrow/array-dictionary-test.cc
+++ b/cpp/src/arrow/array-dictionary-test.cc
@@ -95,7 +95,7 @@ TEST(TestDictionary, Equals) {
ASSERT_FALSE(array->RangeEquals(1, 3, 1, array4));
// ARROW-33 Test slices
- const int size = array->length();
+ const int64_t size = array->length();
std::shared_ptr<Array> slice, slice2;
slice = array->Array::Slice(2);
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/array-primitive-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array-primitive-test.cc b/cpp/src/arrow/array-primitive-test.cc
index f8bbd77..7b36275 100644
--- a/cpp/src/arrow/array-primitive-test.cc
+++ b/cpp/src/arrow/array-primitive-test.cc
@@ -97,7 +97,7 @@ class TestPrimitiveBuilder : public TestBuilder {
builder_nn_ = std::dynamic_pointer_cast<BuilderType>(tmp);
}
- void RandomData(int N, double pct_null = 0.1) {
+ void RandomData(int64_t N, double pct_null = 0.1) {
Attrs::draw(N, &draws_);
valid_bytes_.resize(N);
@@ -105,13 +105,13 @@ class TestPrimitiveBuilder : public TestBuilder {
}
void Check(const std::shared_ptr<BuilderType>& builder, bool nullable) {
- int size = builder->length();
+ int64_t size = builder->length();
auto ex_data = std::make_shared<Buffer>(
reinterpret_cast<uint8_t*>(draws_.data()), size * sizeof(T));
std::shared_ptr<Buffer> ex_null_bitmap;
- int32_t ex_null_count = 0;
+ int64_t ex_null_count = 0;
if (nullable) {
ex_null_bitmap = test::bytes_to_null_buffer(valid_bytes_);
@@ -157,18 +157,18 @@ class TestPrimitiveBuilder : public TestBuilder {
return std::shared_ptr<DataType>(new Type()); \
}
-#define PINT_DECL(CapType, c_type, LOWER, UPPER) \
- struct P##CapType { \
- PTYPE_DECL(CapType, c_type); \
- static void draw(int N, vector<T>* draws) { \
- test::randint<T>(N, LOWER, UPPER, draws); \
- } \
+#define PINT_DECL(CapType, c_type, LOWER, UPPER) \
+ struct P##CapType { \
+ PTYPE_DECL(CapType, c_type); \
+ static void draw(int64_t N, vector<T>* draws) { \
+ test::randint<T>(N, LOWER, UPPER, draws); \
+ } \
}
#define PFLOAT_DECL(CapType, c_type, LOWER, UPPER) \
struct P##CapType { \
PTYPE_DECL(CapType, c_type); \
- static void draw(int N, vector<T>* draws) { \
+ static void draw(int64_t N, vector<T>* draws) { \
test::random_real<T>(N, 0, LOWER, UPPER, draws); \
} \
}
@@ -191,7 +191,7 @@ struct PBoolean {
};
template <>
-void TestPrimitiveBuilder<PBoolean>::RandomData(int N, double pct_null) {
+void TestPrimitiveBuilder<PBoolean>::RandomData(int64_t N, double pct_null) {
draws_.resize(N);
valid_bytes_.resize(N);
@@ -202,12 +202,12 @@ void TestPrimitiveBuilder<PBoolean>::RandomData(int N, double pct_null) {
template <>
void TestPrimitiveBuilder<PBoolean>::Check(
const std::shared_ptr<BooleanBuilder>& builder, bool nullable) {
- int size = builder->length();
+ int64_t size = builder->length();
auto ex_data = test::bytes_to_null_buffer(draws_);
std::shared_ptr<Buffer> ex_null_bitmap;
- int32_t ex_null_count = 0;
+ int64_t ex_null_count = 0;
if (nullable) {
ex_null_bitmap = test::bytes_to_null_buffer(valid_bytes_);
@@ -233,7 +233,7 @@ void TestPrimitiveBuilder<PBoolean>::Check(
ASSERT_EQ(expected->length(), result->length());
- for (int i = 0; i < result->length(); ++i) {
+ for (int64_t i = 0; i < result->length(); ++i) {
if (nullable) { ASSERT_EQ(valid_bytes_[i] == 0, result->IsNull(i)) << i; }
bool actual = BitUtil::GetBit(result->data()->data(), i);
ASSERT_EQ(static_cast<bool>(draws_[i]), actual) << i;
@@ -256,7 +256,7 @@ TYPED_TEST_CASE(TestPrimitiveBuilder, Primitives);
TYPED_TEST(TestPrimitiveBuilder, TestInit) {
DECL_TYPE();
- int n = 1000;
+ int64_t n = 1000;
ASSERT_OK(this->builder_->Reserve(n));
ASSERT_EQ(BitUtil::NextPower2(n), this->builder_->capacity());
ASSERT_EQ(BitUtil::NextPower2(TypeTraits<Type>::bytes_required(n)),
@@ -267,15 +267,15 @@ TYPED_TEST(TestPrimitiveBuilder, TestInit) {
}
TYPED_TEST(TestPrimitiveBuilder, TestAppendNull) {
- int size = 1000;
- for (int i = 0; i < size; ++i) {
+ int64_t size = 1000;
+ for (int64_t i = 0; i < size; ++i) {
ASSERT_OK(this->builder_->AppendNull());
}
std::shared_ptr<Array> result;
ASSERT_OK(this->builder_->Finish(&result));
- for (int i = 0; i < size; ++i) {
+ for (int64_t i = 0; i < size; ++i) {
ASSERT_TRUE(result->IsNull(i)) << i;
}
}
@@ -283,7 +283,7 @@ TYPED_TEST(TestPrimitiveBuilder, TestAppendNull) {
TYPED_TEST(TestPrimitiveBuilder, TestArrayDtorDealloc) {
DECL_T();
- int size = 1000;
+ int64_t size = 1000;
vector<T>& draws = this->draws_;
vector<uint8_t>& valid_bytes = this->valid_bytes_;
@@ -294,7 +294,7 @@ TYPED_TEST(TestPrimitiveBuilder, TestArrayDtorDealloc) {
this->builder_->Reserve(size);
- int i;
+ int64_t i;
for (i = 0; i < size; ++i) {
if (valid_bytes[i] > 0) {
this->builder_->Append(draws[i]);
@@ -314,7 +314,7 @@ TYPED_TEST(TestPrimitiveBuilder, TestArrayDtorDealloc) {
TYPED_TEST(TestPrimitiveBuilder, Equality) {
DECL_T();
- const int size = 1000;
+ const int64_t size = 1000;
this->RandomData(size);
vector<T>& draws = this->draws_;
vector<uint8_t>& valid_bytes = this->valid_bytes_;
@@ -326,10 +326,11 @@ TYPED_TEST(TestPrimitiveBuilder, Equality) {
// Make the not equal array by negating the first valid element with itself.
const auto first_valid = std::find_if(
valid_bytes.begin(), valid_bytes.end(), [](uint8_t valid) { return valid > 0; });
- const int first_valid_idx = std::distance(valid_bytes.begin(), first_valid);
+ const int64_t first_valid_idx = std::distance(valid_bytes.begin(), first_valid);
// This should be true with a very high probability, but might introduce flakiness
ASSERT_LT(first_valid_idx, size - 1);
- draws[first_valid_idx] = ~*reinterpret_cast<int64_t*>(&draws[first_valid_idx]);
+ draws[first_valid_idx] =
+ static_cast<T>(~*reinterpret_cast<int64_t*>(&draws[first_valid_idx]));
ASSERT_OK(MakeArray(valid_bytes, draws, size, builder, &unequal_array));
// test normal equality
@@ -350,7 +351,7 @@ TYPED_TEST(TestPrimitiveBuilder, Equality) {
TYPED_TEST(TestPrimitiveBuilder, SliceEquality) {
DECL_T();
- const int size = 1000;
+ const int64_t size = 1000;
this->RandomData(size);
vector<T>& draws = this->draws_;
vector<uint8_t>& valid_bytes = this->valid_bytes_;
@@ -383,7 +384,7 @@ TYPED_TEST(TestPrimitiveBuilder, SliceEquality) {
TYPED_TEST(TestPrimitiveBuilder, TestAppendScalar) {
DECL_T();
- const int size = 10000;
+ const int64_t size = 10000;
vector<T>& draws = this->draws_;
vector<uint8_t>& valid_bytes = this->valid_bytes_;
@@ -393,8 +394,8 @@ TYPED_TEST(TestPrimitiveBuilder, TestAppendScalar) {
this->builder_->Reserve(1000);
this->builder_nn_->Reserve(1000);
- int i;
- int null_count = 0;
+ int64_t i;
+ int64_t null_count = 0;
// Append the first 1000
for (i = 0; i < 1000; ++i) {
if (valid_bytes[i] > 0) {
@@ -440,14 +441,14 @@ TYPED_TEST(TestPrimitiveBuilder, TestAppendScalar) {
TYPED_TEST(TestPrimitiveBuilder, TestAppendVector) {
DECL_T();
- int size = 10000;
+ int64_t size = 10000;
this->RandomData(size);
vector<T>& draws = this->draws_;
vector<uint8_t>& valid_bytes = this->valid_bytes_;
// first slug
- int K = 1000;
+ int64_t K = 1000;
ASSERT_OK(this->builder_->Append(draws.data(), K, valid_bytes.data()));
ASSERT_OK(this->builder_nn_->Append(draws.data(), K));
@@ -470,7 +471,7 @@ TYPED_TEST(TestPrimitiveBuilder, TestAppendVector) {
}
TYPED_TEST(TestPrimitiveBuilder, TestAdvance) {
- int n = 1000;
+ int64_t n = 1000;
ASSERT_OK(this->builder_->Reserve(n));
ASSERT_OK(this->builder_->Advance(100));
@@ -478,14 +479,14 @@ TYPED_TEST(TestPrimitiveBuilder, TestAdvance) {
ASSERT_OK(this->builder_->Advance(900));
- int too_many = this->builder_->capacity() - 1000 + 1;
+ int64_t too_many = this->builder_->capacity() - 1000 + 1;
ASSERT_RAISES(Invalid, this->builder_->Advance(too_many));
}
TYPED_TEST(TestPrimitiveBuilder, TestResize) {
DECL_TYPE();
- int cap = kMinBuilderCapacity * 2;
+ int64_t cap = kMinBuilderCapacity * 2;
ASSERT_OK(this->builder_->Reserve(cap));
ASSERT_EQ(cap, this->builder_->capacity());
@@ -510,7 +511,7 @@ template <typename TYPE>
void CheckSliceApproxEquals() {
using T = typename TYPE::c_type;
- const int kSize = 50;
+ const int64_t kSize = 50;
std::vector<T> draws1;
std::vector<T> draws2;
@@ -520,7 +521,7 @@ void CheckSliceApproxEquals() {
// Make the draws equal in the sliced segment, but unequal elsewhere (to
// catch not using the slice offset)
- for (int i = 10; i < 30; ++i) {
+ for (int64_t i = 10; i < 30; ++i) {
draws2[i] = draws1[i];
}
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/array-string-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array-string-test.cc b/cpp/src/arrow/array-string-test.cc
index d8a3585..3fdeb3c 100644
--- a/cpp/src/arrow/array-string-test.cc
+++ b/cpp/src/arrow/array-string-test.cc
@@ -64,7 +64,7 @@ class TestStringArray : public ::testing::Test {
}
void MakeArray() {
- length_ = offsets_.size() - 1;
+ length_ = static_cast<int64_t>(offsets_.size()) - 1;
value_buf_ = test::GetBufferFromVector(chars_);
offsets_buf_ = test::GetBufferFromVector(offsets_);
null_bitmap_ = test::bytes_to_null_buffer(valid_bytes_);
@@ -85,8 +85,8 @@ class TestStringArray : public ::testing::Test {
std::shared_ptr<Buffer> offsets_buf_;
std::shared_ptr<Buffer> null_bitmap_;
- int null_count_;
- int length_;
+ int64_t null_count_;
+ int64_t length_;
std::shared_ptr<StringArray> strings_;
};
@@ -109,7 +109,7 @@ TEST_F(TestStringArray, TestListFunctions) {
for (size_t i = 0; i < expected_.size(); ++i) {
ASSERT_EQ(pos, strings_->value_offset(i));
ASSERT_EQ(static_cast<int>(expected_[i].size()), strings_->value_length(i));
- pos += expected_[i].size();
+ pos += static_cast<int>(expected_[i].size());
}
}
@@ -131,7 +131,7 @@ TEST_F(TestStringArray, TestGetString) {
TEST_F(TestStringArray, TestEmptyStringComparison) {
offsets_ = {0, 0, 0, 0, 0, 0};
offsets_buf_ = test::GetBufferFromVector(offsets_);
- length_ = offsets_.size() - 1;
+ length_ = static_cast<int64_t>(offsets_.size() - 1);
auto strings_a = std::make_shared<StringArray>(
length_, offsets_buf_, nullptr, null_bitmap_, null_count_);
@@ -208,7 +208,7 @@ TEST_F(TestStringBuilder, TestScalarAppend) {
std::vector<std::string> strings = {"", "bb", "a", "", "ccc"};
std::vector<uint8_t> is_null = {0, 0, 0, 1, 0};
- int N = strings.size();
+ int N = static_cast<int>(strings.size());
int reps = 1000;
for (int j = 0; j < reps; ++j) {
@@ -263,7 +263,7 @@ class TestBinaryArray : public ::testing::Test {
}
void MakeArray() {
- length_ = offsets_.size() - 1;
+ length_ = static_cast<int64_t>(offsets_.size() - 1);
value_buf_ = test::GetBufferFromVector(chars_);
offsets_buf_ = test::GetBufferFromVector(offsets_);
@@ -285,8 +285,8 @@ class TestBinaryArray : public ::testing::Test {
std::shared_ptr<Buffer> offsets_buf_;
std::shared_ptr<Buffer> null_bitmap_;
- int null_count_;
- int length_;
+ int64_t null_count_;
+ int64_t length_;
std::shared_ptr<BinaryArray> strings_;
};
@@ -305,7 +305,7 @@ TEST_F(TestBinaryArray, TestType) {
}
TEST_F(TestBinaryArray, TestListFunctions) {
- int pos = 0;
+ size_t pos = 0;
for (size_t i = 0; i < expected_.size(); ++i) {
ASSERT_EQ(pos, strings_->value_offset(i));
ASSERT_EQ(static_cast<int>(expected_[i].size()), strings_->value_length(i));
@@ -376,7 +376,7 @@ TEST_F(TestBinaryBuilder, TestScalarAppend) {
std::vector<std::string> strings = {"", "bb", "a", "", "ccc"};
std::vector<uint8_t> is_null = {0, 0, 0, 1, 0};
- int N = strings.size();
+ int N = static_cast<int>(strings.size());
int reps = 1000;
for (int j = 0; j < reps; ++j) {
@@ -425,7 +425,7 @@ void CheckSliceEquality() {
std::vector<std::string> strings = {"foo", "", "bar", "baz", "qux", ""};
std::vector<uint8_t> is_null = {0, 1, 0, 1, 0, 0};
- int N = strings.size();
+ int N = static_cast<int>(strings.size());
int reps = 10;
for (int j = 0; j < reps; ++j) {
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/array-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array-test.cc b/cpp/src/arrow/array-test.cc
index 45ab274..854ebb2 100644
--- a/cpp/src/arrow/array-test.cc
+++ b/cpp/src/arrow/array-test.cc
@@ -58,7 +58,7 @@ TEST_F(TestArray, TestLength) {
std::shared_ptr<Array> MakeArrayFromValidBytes(
const std::vector<uint8_t>& v, MemoryPool* pool) {
- int32_t null_count = v.size() - std::accumulate(v.begin(), v.end(), 0);
+ int64_t null_count = v.size() - std::accumulate(v.begin(), v.end(), 0);
std::shared_ptr<Buffer> null_buf = test::bytes_to_null_buffer(v);
BufferBuilder value_builder(pool);
@@ -121,7 +121,7 @@ TEST_F(TestArray, TestIsNull) {
1, 0, 1, 1, 0, 1, 0, 0,
1, 0, 0, 1};
// clang-format on
- int32_t null_count = 0;
+ int64_t null_count = 0;
for (uint8_t x : null_bitmap) {
if (x == 0) { ++null_count; }
}
@@ -140,6 +140,19 @@ TEST_F(TestArray, TestIsNull) {
}
}
+TEST_F(TestArray, BuildLargeInMemoryArray) {
+ const int64_t length = static_cast<int64_t>(std::numeric_limits<int32_t>::max()) + 1;
+
+ BooleanBuilder builder(default_memory_pool());
+ ASSERT_OK(builder.Reserve(length));
+ ASSERT_OK(builder.Advance(length));
+
+ std::shared_ptr<Array> result;
+ ASSERT_OK(builder.Finish(&result));
+
+ ASSERT_EQ(length, result->length());
+}
+
TEST_F(TestArray, TestCopy) {}
} // namespace arrow
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/array-union-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array-union-test.cc b/cpp/src/arrow/array-union-test.cc
index eb9bd7d..83c3196 100644
--- a/cpp/src/arrow/array-union-test.cc
+++ b/cpp/src/arrow/array-union-test.cc
@@ -37,7 +37,7 @@ TEST(TestUnionArrayAdHoc, TestSliceEquals) {
std::shared_ptr<RecordBatch> batch;
ASSERT_OK(ipc::MakeUnion(&batch));
- const int size = batch->num_rows();
+ const int64_t size = batch->num_rows();
auto CheckUnion = [&size](std::shared_ptr<Array> array) {
std::shared_ptr<Array> slice, slice2;
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/array.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array.cc b/cpp/src/arrow/array.cc
index eb4c210..284bb57 100644
--- a/cpp/src/arrow/array.cc
+++ b/cpp/src/arrow/array.cc
@@ -35,13 +35,13 @@ namespace arrow {
// doing some computation. To avoid doing this eagerly, we set the null count
// to -1 (any negative number will do). When Array::null_count is called the
// first time, the null count will be computed. See ARROW-33
-constexpr int32_t kUnknownNullCount = -1;
+constexpr int64_t kUnknownNullCount = -1;
// ----------------------------------------------------------------------
// Base array class
-Array::Array(const std::shared_ptr<DataType>& type, int32_t length,
- const std::shared_ptr<Buffer>& null_bitmap, int32_t null_count, int32_t offset)
+Array::Array(const std::shared_ptr<DataType>& type, int64_t length,
+ const std::shared_ptr<Buffer>& null_bitmap, int64_t null_count, int64_t offset)
: type_(type),
length_(length),
offset_(offset),
@@ -52,7 +52,7 @@ Array::Array(const std::shared_ptr<DataType>& type, int32_t length,
if (null_bitmap_) { null_bitmap_data_ = null_bitmap_->data(); }
}
-int32_t Array::null_count() const {
+int64_t Array::null_count() const {
if (null_count_ < 0) {
if (null_bitmap_) {
null_count_ = length_ - CountSetBits(null_bitmap_data_, offset_, length_);
@@ -87,14 +87,14 @@ bool Array::ApproxEquals(const std::shared_ptr<Array>& arr) const {
return ApproxEquals(*arr);
}
-bool Array::RangeEquals(int32_t start_idx, int32_t end_idx, int32_t other_start_idx,
+bool Array::RangeEquals(int64_t start_idx, int64_t end_idx, int64_t other_start_idx,
const std::shared_ptr<Array>& other) const {
if (!other) { return false; }
return RangeEquals(*other, start_idx, end_idx, other_start_idx);
}
-bool Array::RangeEquals(const Array& other, int32_t start_idx, int32_t end_idx,
- int32_t other_start_idx) const {
+bool Array::RangeEquals(const Array& other, int64_t start_idx, int64_t end_idx,
+ int64_t other_start_idx) const {
bool are_equal = false;
Status error =
ArrayRangeEquals(*this, other, start_idx, end_idx, other_start_idx, &are_equal);
@@ -104,15 +104,15 @@ bool Array::RangeEquals(const Array& other, int32_t start_idx, int32_t end_idx,
// Last two parameters are in-out parameters
static inline void ConformSliceParams(
- int32_t array_offset, int32_t array_length, int32_t* offset, int32_t* length) {
+ int64_t array_offset, int64_t array_length, int64_t* offset, int64_t* length) {
DCHECK_LE(*offset, array_length);
DCHECK_GE(offset, 0);
*length = std::min(array_length - *offset, *length);
*offset = array_offset + *offset;
}
-std::shared_ptr<Array> Array::Slice(int32_t offset) const {
- int32_t slice_length = length_ - offset;
+std::shared_ptr<Array> Array::Slice(int64_t offset) const {
+ int64_t slice_length = length_ - offset;
return Slice(offset, slice_length);
}
@@ -120,9 +120,9 @@ Status Array::Validate() const {
return Status::OK();
}
-NullArray::NullArray(int32_t length) : Array(null(), length, nullptr, length) {}
+NullArray::NullArray(int64_t length) : Array(null(), length, nullptr, length) {}
-std::shared_ptr<Array> NullArray::Slice(int32_t offset, int32_t length) const {
+std::shared_ptr<Array> NullArray::Slice(int64_t offset, int64_t length) const {
DCHECK_LE(offset, length_);
length = std::min(length_ - offset, length);
return std::make_shared<NullArray>(length);
@@ -135,9 +135,9 @@ Status NullArray::Accept(ArrayVisitor* visitor) const {
// ----------------------------------------------------------------------
// Primitive array base
-PrimitiveArray::PrimitiveArray(const std::shared_ptr<DataType>& type, int32_t length,
+PrimitiveArray::PrimitiveArray(const std::shared_ptr<DataType>& type, int64_t length,
const std::shared_ptr<Buffer>& data, const std::shared_ptr<Buffer>& null_bitmap,
- int32_t null_count, int32_t offset)
+ int64_t null_count, int64_t offset)
: Array(type, length, null_bitmap, null_count, offset) {
data_ = data;
raw_data_ = data == nullptr ? nullptr : data_->data();
@@ -149,7 +149,7 @@ Status NumericArray<T>::Accept(ArrayVisitor* visitor) const {
}
template <typename T>
-std::shared_ptr<Array> NumericArray<T>::Slice(int32_t offset, int32_t length) const {
+std::shared_ptr<Array> NumericArray<T>::Slice(int64_t offset, int64_t length) const {
ConformSliceParams(offset_, length_, &offset, &length);
return std::make_shared<NumericArray<T>>(
type_, length, data_, null_bitmap_, kUnknownNullCount, offset);
@@ -173,8 +173,8 @@ template class NumericArray<DoubleType>;
// ----------------------------------------------------------------------
// BooleanArray
-BooleanArray::BooleanArray(int32_t length, const std::shared_ptr<Buffer>& data,
- const std::shared_ptr<Buffer>& null_bitmap, int32_t null_count, int32_t offset)
+BooleanArray::BooleanArray(int64_t length, const std::shared_ptr<Buffer>& data,
+ const std::shared_ptr<Buffer>& null_bitmap, int64_t null_count, int64_t offset)
: PrimitiveArray(std::make_shared<BooleanType>(), length, data, null_bitmap,
null_count, offset) {}
@@ -182,7 +182,7 @@ Status BooleanArray::Accept(ArrayVisitor* visitor) const {
return visitor->Visit(*this);
}
-std::shared_ptr<Array> BooleanArray::Slice(int32_t offset, int32_t length) const {
+std::shared_ptr<Array> BooleanArray::Slice(int64_t offset, int64_t length) const {
ConformSliceParams(offset_, length_, &offset, &length);
return std::make_shared<BooleanArray>(
length, data_, null_bitmap_, kUnknownNullCount, offset);
@@ -222,7 +222,7 @@ Status ListArray::Validate() const {
int32_t prev_offset = this->value_offset(0);
if (prev_offset != 0) { return Status::Invalid("The first offset wasn't zero"); }
- for (int32_t i = 1; i <= length_; ++i) {
+ for (int64_t i = 1; i <= length_; ++i) {
int32_t current_offset = this->value_offset(i);
if (IsNull(i - 1) && current_offset != prev_offset) {
std::stringstream ss;
@@ -247,7 +247,7 @@ Status ListArray::Accept(ArrayVisitor* visitor) const {
return visitor->Visit(*this);
}
-std::shared_ptr<Array> ListArray::Slice(int32_t offset, int32_t length) const {
+std::shared_ptr<Array> ListArray::Slice(int64_t offset, int64_t length) const {
ConformSliceParams(offset_, length_, &offset, &length);
return std::make_shared<ListArray>(
type_, length, value_offsets_, values_, null_bitmap_, kUnknownNullCount, offset);
@@ -259,15 +259,15 @@ std::shared_ptr<Array> ListArray::Slice(int32_t offset, int32_t length) const {
static std::shared_ptr<DataType> kBinary = std::make_shared<BinaryType>();
static std::shared_ptr<DataType> kString = std::make_shared<StringType>();
-BinaryArray::BinaryArray(int32_t length, const std::shared_ptr<Buffer>& value_offsets,
+BinaryArray::BinaryArray(int64_t length, const std::shared_ptr<Buffer>& value_offsets,
const std::shared_ptr<Buffer>& data, const std::shared_ptr<Buffer>& null_bitmap,
- int32_t null_count, int32_t offset)
+ int64_t null_count, int64_t offset)
: BinaryArray(kBinary, length, value_offsets, data, null_bitmap, null_count, offset) {
}
-BinaryArray::BinaryArray(const std::shared_ptr<DataType>& type, int32_t length,
+BinaryArray::BinaryArray(const std::shared_ptr<DataType>& type, int64_t length,
const std::shared_ptr<Buffer>& value_offsets, const std::shared_ptr<Buffer>& data,
- const std::shared_ptr<Buffer>& null_bitmap, int32_t null_count, int32_t offset)
+ const std::shared_ptr<Buffer>& null_bitmap, int64_t null_count, int64_t offset)
: Array(type, length, null_bitmap, null_count, offset),
value_offsets_(value_offsets),
raw_value_offsets_(nullptr),
@@ -288,15 +288,15 @@ Status BinaryArray::Accept(ArrayVisitor* visitor) const {
return visitor->Visit(*this);
}
-std::shared_ptr<Array> BinaryArray::Slice(int32_t offset, int32_t length) const {
+std::shared_ptr<Array> BinaryArray::Slice(int64_t offset, int64_t length) const {
ConformSliceParams(offset_, length_, &offset, &length);
return std::make_shared<BinaryArray>(
length, value_offsets_, data_, null_bitmap_, kUnknownNullCount, offset);
}
-StringArray::StringArray(int32_t length, const std::shared_ptr<Buffer>& value_offsets,
+StringArray::StringArray(int64_t length, const std::shared_ptr<Buffer>& value_offsets,
const std::shared_ptr<Buffer>& data, const std::shared_ptr<Buffer>& null_bitmap,
- int32_t null_count, int32_t offset)
+ int64_t null_count, int64_t offset)
: BinaryArray(kString, length, value_offsets, data, null_bitmap, null_count, offset) {
}
@@ -309,7 +309,7 @@ Status StringArray::Accept(ArrayVisitor* visitor) const {
return visitor->Visit(*this);
}
-std::shared_ptr<Array> StringArray::Slice(int32_t offset, int32_t length) const {
+std::shared_ptr<Array> StringArray::Slice(int64_t offset, int64_t length) const {
ConformSliceParams(offset_, length_, &offset, &length);
return std::make_shared<StringArray>(
length, value_offsets_, data_, null_bitmap_, kUnknownNullCount, offset);
@@ -318,15 +318,15 @@ std::shared_ptr<Array> StringArray::Slice(int32_t offset, int32_t length) const
// ----------------------------------------------------------------------
// Struct
-StructArray::StructArray(const std::shared_ptr<DataType>& type, int32_t length,
+StructArray::StructArray(const std::shared_ptr<DataType>& type, int64_t length,
const std::vector<std::shared_ptr<Array>>& children,
- std::shared_ptr<Buffer> null_bitmap, int32_t null_count, int32_t offset)
+ std::shared_ptr<Buffer> null_bitmap, int64_t null_count, int64_t offset)
: Array(type, length, null_bitmap, null_count, offset) {
type_ = type;
children_ = children;
}
-std::shared_ptr<Array> StructArray::field(int32_t pos) const {
+std::shared_ptr<Array> StructArray::field(int pos) const {
DCHECK_GT(children_.size(), 0);
return children_[pos];
}
@@ -340,7 +340,7 @@ Status StructArray::Validate() const {
if (children_.size() > 0) {
// Validate fields
- int32_t array_length = children_[0]->length();
+ int64_t array_length = children_[0]->length();
size_t idx = 0;
for (auto it : children_) {
if (it->length() != array_length) {
@@ -371,7 +371,7 @@ Status StructArray::Accept(ArrayVisitor* visitor) const {
return visitor->Visit(*this);
}
-std::shared_ptr<Array> StructArray::Slice(int32_t offset, int32_t length) const {
+std::shared_ptr<Array> StructArray::Slice(int64_t offset, int64_t length) const {
ConformSliceParams(offset_, length_, &offset, &length);
return std::make_shared<StructArray>(
type_, length, children_, null_bitmap_, kUnknownNullCount, offset);
@@ -380,10 +380,10 @@ std::shared_ptr<Array> StructArray::Slice(int32_t offset, int32_t length) const
// ----------------------------------------------------------------------
// UnionArray
-UnionArray::UnionArray(const std::shared_ptr<DataType>& type, int32_t length,
+UnionArray::UnionArray(const std::shared_ptr<DataType>& type, int64_t length,
const std::vector<std::shared_ptr<Array>>& children,
const std::shared_ptr<Buffer>& type_ids, const std::shared_ptr<Buffer>& value_offsets,
- const std::shared_ptr<Buffer>& null_bitmap, int32_t null_count, int32_t offset)
+ const std::shared_ptr<Buffer>& null_bitmap, int64_t null_count, int64_t offset)
: Array(type, length, null_bitmap, null_count, offset),
children_(children),
type_ids_(type_ids),
@@ -396,7 +396,7 @@ UnionArray::UnionArray(const std::shared_ptr<DataType>& type, int32_t length,
}
}
-std::shared_ptr<Array> UnionArray::child(int32_t pos) const {
+std::shared_ptr<Array> UnionArray::child(int pos) const {
DCHECK_GT(children_.size(), 0);
return children_[pos];
}
@@ -416,7 +416,7 @@ Status UnionArray::Accept(ArrayVisitor* visitor) const {
return visitor->Visit(*this);
}
-std::shared_ptr<Array> UnionArray::Slice(int32_t offset, int32_t length) const {
+std::shared_ptr<Array> UnionArray::Slice(int64_t offset, int64_t length) const {
ConformSliceParams(offset_, length_, &offset, &length);
return std::make_shared<UnionArray>(type_, length, children_, type_ids_, value_offsets_,
null_bitmap_, kUnknownNullCount, offset);
@@ -425,9 +425,9 @@ std::shared_ptr<Array> UnionArray::Slice(int32_t offset, int32_t length) const {
// ----------------------------------------------------------------------
// DictionaryArray
-Status DictionaryArray::FromBuffer(const std::shared_ptr<DataType>& type, int32_t length,
+Status DictionaryArray::FromBuffer(const std::shared_ptr<DataType>& type, int64_t length,
const std::shared_ptr<Buffer>& indices, const std::shared_ptr<Buffer>& null_bitmap,
- int32_t null_count, int32_t offset, std::shared_ptr<DictionaryArray>* out) {
+ int64_t null_count, int64_t offset, std::shared_ptr<DictionaryArray>* out) {
DCHECK_EQ(type->type, Type::DICTIONARY);
const auto& dict_type = static_cast<const DictionaryType*>(type.get());
@@ -464,7 +464,7 @@ Status DictionaryArray::Accept(ArrayVisitor* visitor) const {
return visitor->Visit(*this);
}
-std::shared_ptr<Array> DictionaryArray::Slice(int32_t offset, int32_t length) const {
+std::shared_ptr<Array> DictionaryArray::Slice(int64_t offset, int64_t length) const {
std::shared_ptr<Array> sliced_indices = indices_->Slice(offset, length);
return std::make_shared<DictionaryArray>(type_, sliced_indices);
}
@@ -476,9 +476,9 @@ std::shared_ptr<Array> DictionaryArray::Slice(int32_t offset, int32_t length) co
out->reset(new ArrayType(type, length, data, null_bitmap, null_count, offset)); \
break;
-Status MakePrimitiveArray(const std::shared_ptr<DataType>& type, int32_t length,
+Status MakePrimitiveArray(const std::shared_ptr<DataType>& type, int64_t length,
const std::shared_ptr<Buffer>& data, const std::shared_ptr<Buffer>& null_bitmap,
- int32_t null_count, int32_t offset, std::shared_ptr<Array>* out) {
+ int64_t null_count, int64_t offset, std::shared_ptr<Array>* out) {
switch (type->type) {
MAKE_PRIMITIVE_ARRAY_CASE(BOOL, BooleanArray);
MAKE_PRIMITIVE_ARRAY_CASE(UINT8, UInt8Array);
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/array.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array.h b/cpp/src/arrow/array.h
index 8bb914e..f20f212 100644
--- a/cpp/src/arrow/array.h
+++ b/cpp/src/arrow/array.h
@@ -80,30 +80,30 @@ class ARROW_EXPORT ArrayVisitor {
/// be computed on the first call to null_count()
class ARROW_EXPORT Array {
public:
- Array(const std::shared_ptr<DataType>& type, int32_t length,
- const std::shared_ptr<Buffer>& null_bitmap = nullptr, int32_t null_count = 0,
- int32_t offset = 0);
+ Array(const std::shared_ptr<DataType>& type, int64_t length,
+ const std::shared_ptr<Buffer>& null_bitmap = nullptr, int64_t null_count = 0,
+ int64_t offset = 0);
virtual ~Array() = default;
/// Determine if a slot is null. For inner loops. Does *not* boundscheck
- bool IsNull(int i) const {
+ bool IsNull(int64_t i) const {
return null_bitmap_data_ != nullptr &&
BitUtil::BitNotSet(null_bitmap_data_, i + offset_);
}
/// Size in the number of elements this array contains.
- int32_t length() const { return length_; }
+ int64_t length() const { return length_; }
/// A relative position into another array's data, to enable zero-copy
/// slicing. This value defaults to zero
- int32_t offset() const { return offset_; }
+ int64_t offset() const { return offset_; }
/// The number of null entries in the array. If the null count was not known
/// at time of construction (and set to a negative value), then the null
/// count will be computed and cached on the first invocation of this
/// function
- int32_t null_count() const;
+ int64_t null_count() const;
std::shared_ptr<DataType> type() const { return type_; }
Type::type type_enum() const { return type_->type; }
@@ -128,11 +128,11 @@ class ARROW_EXPORT Array {
/// Compare if the range of slots specified are equal for the given array and
/// this array. end_idx exclusive. This methods does not bounds check.
- bool RangeEquals(int32_t start_idx, int32_t end_idx, int32_t other_start_idx,
+ bool RangeEquals(int64_t start_idx, int64_t end_idx, int64_t other_start_idx,
const std::shared_ptr<Array>& other) const;
- bool RangeEquals(const Array& other, int32_t start_idx, int32_t end_idx,
- int32_t other_start_idx) const;
+ bool RangeEquals(const Array& other, int64_t start_idx, int64_t end_idx,
+ int64_t other_start_idx) const;
/// Determines if the array is internally consistent.
///
@@ -150,20 +150,20 @@ class ARROW_EXPORT Array {
/// the length will be adjusted accordingly
///
/// \return a new object wrapped in std::shared_ptr<Array>
- virtual std::shared_ptr<Array> Slice(int32_t offset, int32_t length) const = 0;
+ virtual std::shared_ptr<Array> Slice(int64_t offset, int64_t length) const = 0;
/// Slice from offset until end of the array
- std::shared_ptr<Array> Slice(int32_t offset) const;
+ std::shared_ptr<Array> Slice(int64_t offset) const;
protected:
std::shared_ptr<DataType> type_;
- int32_t length_;
- int32_t offset_;
+ int64_t length_;
+ int64_t offset_;
// This member is marked mutable so that it can be modified when null_count()
// is called from a const context and the null count has to be computed (if
// it is not already known)
- mutable int32_t null_count_;
+ mutable int64_t null_count_;
std::shared_ptr<Buffer> null_bitmap_;
const uint8_t* null_bitmap_data_;
@@ -178,20 +178,20 @@ class ARROW_EXPORT NullArray : public Array {
public:
using TypeClass = NullType;
- explicit NullArray(int32_t length);
+ explicit NullArray(int64_t length);
Status Accept(ArrayVisitor* visitor) const override;
- std::shared_ptr<Array> Slice(int32_t offset, int32_t length) const override;
+ std::shared_ptr<Array> Slice(int64_t offset, int64_t length) const override;
};
/// Base class for fixed-size logical types
class ARROW_EXPORT PrimitiveArray : public Array {
public:
- PrimitiveArray(const std::shared_ptr<DataType>& type, int32_t length,
+ PrimitiveArray(const std::shared_ptr<DataType>& type, int64_t length,
const std::shared_ptr<Buffer>& data,
- const std::shared_ptr<Buffer>& null_bitmap = nullptr, int32_t null_count = 0,
- int32_t offset = 0);
+ const std::shared_ptr<Buffer>& null_bitmap = nullptr, int64_t null_count = 0,
+ int64_t offset = 0);
/// The memory containing this array's data
/// This buffer does not account for any slice offset
@@ -214,10 +214,10 @@ class ARROW_EXPORT NumericArray : public PrimitiveArray {
// metadata
template <typename T1 = TYPE>
NumericArray(
- typename std::enable_if<TypeTraits<T1>::is_parameter_free, int32_t>::type length,
+ typename std::enable_if<TypeTraits<T1>::is_parameter_free, int64_t>::type length,
const std::shared_ptr<Buffer>& data,
- const std::shared_ptr<Buffer>& null_bitmap = nullptr, int32_t null_count = 0,
- int32_t offset = 0)
+ const std::shared_ptr<Buffer>& null_bitmap = nullptr, int64_t null_count = 0,
+ int64_t offset = 0)
: PrimitiveArray(TypeTraits<T1>::type_singleton(), length, data, null_bitmap,
null_count, offset) {}
@@ -227,9 +227,9 @@ class ARROW_EXPORT NumericArray : public PrimitiveArray {
Status Accept(ArrayVisitor* visitor) const override;
- std::shared_ptr<Array> Slice(int32_t offset, int32_t length) const override;
+ std::shared_ptr<Array> Slice(int64_t offset, int64_t length) const override;
- value_type Value(int i) const { return raw_data()[i]; }
+ value_type Value(int64_t i) const { return raw_data()[i]; }
};
class ARROW_EXPORT BooleanArray : public PrimitiveArray {
@@ -238,15 +238,15 @@ class ARROW_EXPORT BooleanArray : public PrimitiveArray {
using PrimitiveArray::PrimitiveArray;
- BooleanArray(int32_t length, const std::shared_ptr<Buffer>& data,
- const std::shared_ptr<Buffer>& null_bitmap = nullptr, int32_t null_count = 0,
- int32_t offset = 0);
+ BooleanArray(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);
Status Accept(ArrayVisitor* visitor) const override;
- std::shared_ptr<Array> Slice(int32_t offset, int32_t length) const override;
+ std::shared_ptr<Array> Slice(int64_t offset, int64_t length) const override;
- bool Value(int i) const {
+ bool Value(int64_t i) const {
return BitUtil::GetBit(reinterpret_cast<const uint8_t*>(raw_data_), i + offset_);
}
};
@@ -258,10 +258,10 @@ class ARROW_EXPORT ListArray : public Array {
public:
using TypeClass = ListType;
- ListArray(const std::shared_ptr<DataType>& type, int32_t length,
+ ListArray(const std::shared_ptr<DataType>& type, int64_t length,
const std::shared_ptr<Buffer>& value_offsets, const std::shared_ptr<Array>& values,
- const std::shared_ptr<Buffer>& null_bitmap = nullptr, int32_t null_count = 0,
- int32_t offset = 0)
+ const std::shared_ptr<Buffer>& null_bitmap = nullptr, int64_t null_count = 0,
+ int64_t offset = 0)
: Array(type, length, null_bitmap, null_count, offset) {
value_offsets_ = value_offsets;
raw_value_offsets_ = value_offsets == nullptr
@@ -285,15 +285,15 @@ class ARROW_EXPORT ListArray : public Array {
const int32_t* raw_value_offsets() const { return raw_value_offsets_ + offset_; }
// Neither of these functions will perform boundschecking
- int32_t value_offset(int i) const { return raw_value_offsets_[i + offset_]; }
- int32_t value_length(int i) const {
+ int32_t value_offset(int64_t i) const { return raw_value_offsets_[i + offset_]; }
+ int32_t value_length(int64_t i) const {
i += offset_;
return raw_value_offsets_[i + 1] - raw_value_offsets_[i];
}
Status Accept(ArrayVisitor* visitor) const override;
- std::shared_ptr<Array> Slice(int32_t offset, int32_t length) const override;
+ std::shared_ptr<Array> Slice(int64_t offset, int64_t length) const override;
protected:
std::shared_ptr<Buffer> value_offsets_;
@@ -308,15 +308,15 @@ class ARROW_EXPORT BinaryArray : public Array {
public:
using TypeClass = BinaryType;
- BinaryArray(int32_t length, const std::shared_ptr<Buffer>& value_offsets,
+ BinaryArray(int64_t length, const std::shared_ptr<Buffer>& value_offsets,
const std::shared_ptr<Buffer>& data,
- const std::shared_ptr<Buffer>& null_bitmap = nullptr, int32_t null_count = 0,
- int32_t offset = 0);
+ const std::shared_ptr<Buffer>& null_bitmap = nullptr, int64_t null_count = 0,
+ int64_t offset = 0);
// Return the pointer to the given elements bytes
// TODO(emkornfield) introduce a StringPiece or something similar to capture zero-copy
// pointer + offset
- const uint8_t* GetValue(int i, int32_t* out_length) const {
+ const uint8_t* GetValue(int64_t i, int32_t* out_length) const {
// Account for base offset
i += offset_;
@@ -334,8 +334,8 @@ class ARROW_EXPORT BinaryArray : public Array {
const int32_t* raw_value_offsets() const { return raw_value_offsets_ + offset_; }
// Neither of these functions will perform boundschecking
- int32_t value_offset(int i) const { return raw_value_offsets_[i + offset_]; }
- int32_t value_length(int i) const {
+ int32_t value_offset(int64_t i) const { return raw_value_offsets_[i + offset_]; }
+ int32_t value_length(int64_t i) const {
i += offset_;
return raw_value_offsets_[i + 1] - raw_value_offsets_[i];
}
@@ -344,15 +344,15 @@ class ARROW_EXPORT BinaryArray : public Array {
Status Accept(ArrayVisitor* visitor) const override;
- std::shared_ptr<Array> Slice(int32_t offset, int32_t length) const override;
+ std::shared_ptr<Array> Slice(int64_t offset, int64_t length) const override;
protected:
// Constructor that allows sub-classes/builders to propagate there logical type up the
// class hierarchy.
- BinaryArray(const std::shared_ptr<DataType>& type, int32_t length,
+ BinaryArray(const std::shared_ptr<DataType>& type, int64_t length,
const std::shared_ptr<Buffer>& value_offsets, const std::shared_ptr<Buffer>& data,
- const std::shared_ptr<Buffer>& null_bitmap = nullptr, int32_t null_count = 0,
- int32_t offset = 0);
+ const std::shared_ptr<Buffer>& null_bitmap = nullptr, int64_t null_count = 0,
+ int64_t offset = 0);
std::shared_ptr<Buffer> value_offsets_;
const int32_t* raw_value_offsets_;
@@ -365,14 +365,14 @@ class ARROW_EXPORT StringArray : public BinaryArray {
public:
using TypeClass = StringType;
- StringArray(int32_t length, const std::shared_ptr<Buffer>& value_offsets,
+ StringArray(int64_t length, const std::shared_ptr<Buffer>& value_offsets,
const std::shared_ptr<Buffer>& data,
- const std::shared_ptr<Buffer>& null_bitmap = nullptr, int32_t null_count = 0,
- int32_t offset = 0);
+ const std::shared_ptr<Buffer>& null_bitmap = nullptr, int64_t null_count = 0,
+ int64_t offset = 0);
// Construct a std::string
// TODO: std::bad_alloc possibility
- std::string GetString(int i) const {
+ std::string GetString(int64_t i) const {
int32_t nchars;
const uint8_t* str = GetValue(i, &nchars);
return std::string(reinterpret_cast<const char*>(str), nchars);
@@ -382,7 +382,7 @@ class ARROW_EXPORT StringArray : public BinaryArray {
Status Accept(ArrayVisitor* visitor) const override;
- std::shared_ptr<Array> Slice(int32_t offset, int32_t length) const override;
+ std::shared_ptr<Array> Slice(int64_t offset, int64_t length) const override;
};
// ----------------------------------------------------------------------
@@ -392,22 +392,22 @@ class ARROW_EXPORT StructArray : public Array {
public:
using TypeClass = StructType;
- StructArray(const std::shared_ptr<DataType>& type, int32_t length,
+ StructArray(const std::shared_ptr<DataType>& type, int64_t length,
const std::vector<std::shared_ptr<Array>>& children,
- std::shared_ptr<Buffer> null_bitmap = nullptr, int32_t null_count = 0,
- int32_t offset = 0);
+ std::shared_ptr<Buffer> null_bitmap = nullptr, int64_t null_count = 0,
+ int64_t offset = 0);
Status Validate() const override;
// Return a shared pointer in case the requestor desires to share ownership
// with this array.
- std::shared_ptr<Array> field(int32_t pos) const;
+ std::shared_ptr<Array> field(int pos) const;
const std::vector<std::shared_ptr<Array>>& fields() const { return children_; }
Status Accept(ArrayVisitor* visitor) const override;
- std::shared_ptr<Array> Slice(int32_t offset, int32_t length) const override;
+ std::shared_ptr<Array> Slice(int64_t offset, int64_t length) const override;
protected:
// The child arrays corresponding to each field of the struct data type.
@@ -422,12 +422,12 @@ class ARROW_EXPORT UnionArray : public Array {
using TypeClass = UnionType;
using type_id_t = uint8_t;
- UnionArray(const std::shared_ptr<DataType>& type, int32_t length,
+ UnionArray(const std::shared_ptr<DataType>& type, int64_t length,
const std::vector<std::shared_ptr<Array>>& children,
const std::shared_ptr<Buffer>& type_ids,
const std::shared_ptr<Buffer>& value_offsets = nullptr,
- const std::shared_ptr<Buffer>& null_bitmap = nullptr, int32_t null_count = 0,
- int32_t offset = 0);
+ const std::shared_ptr<Buffer>& null_bitmap = nullptr, int64_t null_count = 0,
+ int64_t offset = 0);
Status Validate() const override;
@@ -442,13 +442,13 @@ class ARROW_EXPORT UnionArray : public Array {
UnionMode mode() const { return static_cast<const UnionType&>(*type_.get()).mode; }
- std::shared_ptr<Array> child(int32_t pos) const;
+ std::shared_ptr<Array> child(int pos) const;
const std::vector<std::shared_ptr<Array>>& children() const { return children_; }
Status Accept(ArrayVisitor* visitor) const override;
- std::shared_ptr<Array> Slice(int32_t offset, int32_t length) const override;
+ std::shared_ptr<Array> Slice(int64_t offset, int64_t length) const override;
protected:
std::vector<std::shared_ptr<Array>> children_;
@@ -487,9 +487,9 @@ class ARROW_EXPORT DictionaryArray : public Array {
// Alternate ctor; other attributes (like null count) are inherited from the
// passed indices array
- static Status FromBuffer(const std::shared_ptr<DataType>& type, int32_t length,
+ static Status FromBuffer(const std::shared_ptr<DataType>& type, int64_t length,
const std::shared_ptr<Buffer>& indices, const std::shared_ptr<Buffer>& null_bitmap,
- int32_t null_count, int32_t offset, std::shared_ptr<DictionaryArray>* out);
+ int64_t null_count, int64_t offset, std::shared_ptr<DictionaryArray>* out);
Status Validate() const override;
@@ -500,7 +500,7 @@ class ARROW_EXPORT DictionaryArray : public Array {
Status Accept(ArrayVisitor* visitor) const override;
- std::shared_ptr<Array> Slice(int32_t offset, int32_t length) const override;
+ std::shared_ptr<Array> Slice(int64_t offset, int64_t length) const override;
protected:
const DictionaryType* dict_type_;
@@ -542,8 +542,8 @@ extern template class ARROW_EXPORT NumericArray<TimeType>;
// Create new arrays for logical types that are backed by primitive arrays.
Status ARROW_EXPORT MakePrimitiveArray(const std::shared_ptr<DataType>& type,
- int32_t length, const std::shared_ptr<Buffer>& data,
- const std::shared_ptr<Buffer>& null_bitmap, int32_t null_count, int32_t offset,
+ int64_t length, const std::shared_ptr<Buffer>& data,
+ const std::shared_ptr<Buffer>& null_bitmap, int64_t null_count, int64_t offset,
std::shared_ptr<Array>* out);
} // namespace arrow
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/buffer.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/buffer.h b/cpp/src/arrow/buffer.h
index 9c400b1..be91af3 100644
--- a/cpp/src/arrow/buffer.h
+++ b/cpp/src/arrow/buffer.h
@@ -165,7 +165,7 @@ class ARROW_EXPORT BufferBuilder {
: pool_(pool), data_(nullptr), capacity_(0), size_(0) {}
/// Resizes the buffer to the nearest multiple of 64 bytes per Layout.md
- Status Resize(int32_t elements) {
+ Status Resize(int64_t elements) {
if (capacity_ == 0) { buffer_ = std::make_shared<PoolBuffer>(pool_); }
RETURN_NOT_OK(buffer_->Resize(elements));
capacity_ = buffer_->capacity();
@@ -173,7 +173,7 @@ class ARROW_EXPORT BufferBuilder {
return Status::OK();
}
- Status Append(const uint8_t* data, int length) {
+ Status Append(const uint8_t* data, int64_t length) {
if (capacity_ < length + size_) { RETURN_NOT_OK(Resize(length + size_)); }
UnsafeAppend(data, length);
return Status::OK();
@@ -187,7 +187,7 @@ class ARROW_EXPORT BufferBuilder {
}
template <typename T>
- Status Append(const T* arithmetic_values, int num_elements) {
+ Status Append(const T* arithmetic_values, int64_t num_elements) {
static_assert(std::is_arithmetic<T>::value,
"Convenience buffer append only supports arithmetic types");
return Append(
@@ -195,7 +195,7 @@ class ARROW_EXPORT BufferBuilder {
}
// Unsafe methods don't check existing size
- void UnsafeAppend(const uint8_t* data, int length) {
+ void UnsafeAppend(const uint8_t* data, int64_t length) {
memcpy(data_ + size_, data, length);
size_ += length;
}
@@ -208,7 +208,7 @@ class ARROW_EXPORT BufferBuilder {
}
template <typename T>
- void UnsafeAppend(const T* arithmetic_values, int num_elements) {
+ void UnsafeAppend(const T* arithmetic_values, int64_t num_elements) {
static_assert(std::is_arithmetic<T>::value,
"Convenience buffer append only supports arithmetic types");
UnsafeAppend(
@@ -221,8 +221,8 @@ class ARROW_EXPORT BufferBuilder {
capacity_ = size_ = 0;
return result;
}
- int capacity() { return capacity_; }
- int length() { return size_; }
+ int64_t capacity() { return capacity_; }
+ int64_t length() { return size_; }
private:
std::shared_ptr<PoolBuffer> buffer_;
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/builder.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/builder.cc b/cpp/src/arrow/builder.cc
index f5c13f9..63e083e 100644
--- a/cpp/src/arrow/builder.cc
+++ b/cpp/src/arrow/builder.cc
@@ -43,33 +43,33 @@ Status ArrayBuilder::AppendToBitmap(bool is_valid) {
return Status::OK();
}
-Status ArrayBuilder::AppendToBitmap(const uint8_t* valid_bytes, int32_t length) {
+Status ArrayBuilder::AppendToBitmap(const uint8_t* valid_bytes, int64_t length) {
RETURN_NOT_OK(Reserve(length));
UnsafeAppendToBitmap(valid_bytes, length);
return Status::OK();
}
-Status ArrayBuilder::Init(int32_t capacity) {
- int32_t to_alloc = BitUtil::CeilByte(capacity) / 8;
+Status ArrayBuilder::Init(int64_t capacity) {
+ int64_t to_alloc = BitUtil::CeilByte(capacity) / 8;
null_bitmap_ = std::make_shared<PoolBuffer>(pool_);
RETURN_NOT_OK(null_bitmap_->Resize(to_alloc));
// Buffers might allocate more then necessary to satisfy padding requirements
- const int byte_capacity = null_bitmap_->capacity();
+ const int64_t byte_capacity = null_bitmap_->capacity();
capacity_ = capacity;
null_bitmap_data_ = null_bitmap_->mutable_data();
memset(null_bitmap_data_, 0, byte_capacity);
return Status::OK();
}
-Status ArrayBuilder::Resize(int32_t new_bits) {
+Status ArrayBuilder::Resize(int64_t new_bits) {
if (!null_bitmap_) { return Init(new_bits); }
- int32_t new_bytes = BitUtil::CeilByte(new_bits) / 8;
- int32_t old_bytes = null_bitmap_->size();
+ int64_t new_bytes = BitUtil::CeilByte(new_bits) / 8;
+ int64_t old_bytes = null_bitmap_->size();
RETURN_NOT_OK(null_bitmap_->Resize(new_bytes));
null_bitmap_data_ = null_bitmap_->mutable_data();
// The buffer might be overpadded to deal with padding according to the spec
- const int32_t byte_capacity = null_bitmap_->capacity();
+ const int64_t byte_capacity = null_bitmap_->capacity();
capacity_ = new_bits;
if (old_bytes < new_bytes) {
memset(null_bitmap_data_ + old_bytes, 0, byte_capacity - old_bytes);
@@ -77,7 +77,7 @@ Status ArrayBuilder::Resize(int32_t new_bits) {
return Status::OK();
}
-Status ArrayBuilder::Advance(int32_t elements) {
+Status ArrayBuilder::Advance(int64_t elements) {
if (length_ + elements > capacity_) {
return Status::Invalid("Builder must be expanded");
}
@@ -85,16 +85,16 @@ Status ArrayBuilder::Advance(int32_t elements) {
return Status::OK();
}
-Status ArrayBuilder::Reserve(int32_t elements) {
+Status ArrayBuilder::Reserve(int64_t elements) {
if (length_ + elements > capacity_) {
// TODO(emkornfield) power of 2 growth is potentially suboptimal
- int32_t new_capacity = BitUtil::NextPower2(length_ + elements);
+ int64_t new_capacity = BitUtil::NextPower2(length_ + elements);
return Resize(new_capacity);
}
return Status::OK();
}
-Status ArrayBuilder::SetNotNull(int32_t length) {
+Status ArrayBuilder::SetNotNull(int64_t length) {
RETURN_NOT_OK(Reserve(length));
UnsafeSetNotNull(length);
return Status::OK();
@@ -109,21 +109,21 @@ void ArrayBuilder::UnsafeAppendToBitmap(bool is_valid) {
++length_;
}
-void ArrayBuilder::UnsafeAppendToBitmap(const uint8_t* valid_bytes, int32_t length) {
+void ArrayBuilder::UnsafeAppendToBitmap(const uint8_t* valid_bytes, int64_t length) {
if (valid_bytes == nullptr) {
UnsafeSetNotNull(length);
return;
}
- int byte_offset = length_ / 8;
- int bit_offset = length_ % 8;
+ int64_t byte_offset = length_ / 8;
+ int64_t bit_offset = length_ % 8;
uint8_t bitset = null_bitmap_data_[byte_offset];
- for (int32_t i = 0; i < length; ++i) {
+ for (int64_t i = 0; i < length; ++i) {
if (valid_bytes[i]) {
- bitset |= (1 << bit_offset);
+ bitset |= BitUtil::kBitmask[bit_offset];
} else {
- bitset &= ~(1 << bit_offset);
+ bitset &= BitUtil::kFlippedBitmask[bit_offset];
++null_count_;
}
@@ -140,22 +140,22 @@ void ArrayBuilder::UnsafeAppendToBitmap(const uint8_t* valid_bytes, int32_t leng
length_ += length;
}
-void ArrayBuilder::UnsafeSetNotNull(int32_t length) {
- const int32_t new_length = length + length_;
+void ArrayBuilder::UnsafeSetNotNull(int64_t length) {
+ const int64_t new_length = length + length_;
// Fill up the bytes until we have a byte alignment
- int32_t pad_to_byte = 8 - (length_ % 8);
+ int64_t pad_to_byte = 8 - (length_ % 8);
if (pad_to_byte == 8) { pad_to_byte = 0; }
- for (int32_t i = 0; i < pad_to_byte; ++i) {
+ for (int64_t i = 0; i < pad_to_byte; ++i) {
BitUtil::SetBit(null_bitmap_data_, i);
}
// Fast bitsetting
- int32_t fast_length = (length - pad_to_byte) / 8;
+ int64_t fast_length = (length - pad_to_byte) / 8;
memset(null_bitmap_data_ + ((length_ + pad_to_byte) / 8), 255, fast_length);
// Trailing bytes
- for (int32_t i = length_ + pad_to_byte + (fast_length * 8); i < new_length; ++i) {
+ for (int64_t i = length_ + pad_to_byte + (fast_length * 8); i < new_length; ++i) {
BitUtil::SetBit(null_bitmap_data_, i);
}
@@ -163,7 +163,7 @@ void ArrayBuilder::UnsafeSetNotNull(int32_t length) {
}
template <typename T>
-Status PrimitiveBuilder<T>::Init(int32_t capacity) {
+Status PrimitiveBuilder<T>::Init(int64_t capacity) {
RETURN_NOT_OK(ArrayBuilder::Init(capacity));
data_ = std::make_shared<PoolBuffer>(pool_);
@@ -177,7 +177,7 @@ Status PrimitiveBuilder<T>::Init(int32_t capacity) {
}
template <typename T>
-Status PrimitiveBuilder<T>::Resize(int32_t capacity) {
+Status PrimitiveBuilder<T>::Resize(int64_t capacity) {
// XXX: Set floor size for now
if (capacity < kMinBuilderCapacity) { capacity = kMinBuilderCapacity; }
@@ -197,11 +197,12 @@ Status PrimitiveBuilder<T>::Resize(int32_t capacity) {
template <typename T>
Status PrimitiveBuilder<T>::Append(
- const value_type* values, int32_t length, const uint8_t* valid_bytes) {
+ const value_type* values, int64_t length, const uint8_t* valid_bytes) {
RETURN_NOT_OK(Reserve(length));
if (length > 0) {
- memcpy(raw_data_ + length_, values, TypeTraits<T>::bytes_required(length));
+ std::memcpy(raw_data_ + length_, values,
+ static_cast<std::size_t>(TypeTraits<T>::bytes_required(length)));
}
// length_ is update by these
@@ -248,7 +249,7 @@ BooleanBuilder::BooleanBuilder(MemoryPool* pool, const std::shared_ptr<DataType>
DCHECK_EQ(Type::BOOL, type->type);
}
-Status BooleanBuilder::Init(int32_t capacity) {
+Status BooleanBuilder::Init(int64_t capacity) {
RETURN_NOT_OK(ArrayBuilder::Init(capacity));
data_ = std::make_shared<PoolBuffer>(pool_);
@@ -261,7 +262,7 @@ Status BooleanBuilder::Init(int32_t capacity) {
return Status::OK();
}
-Status BooleanBuilder::Resize(int32_t capacity) {
+Status BooleanBuilder::Resize(int64_t capacity) {
// XXX: Set floor size for now
if (capacity < kMinBuilderCapacity) { capacity = kMinBuilderCapacity; }
@@ -294,10 +295,10 @@ Status BooleanBuilder::Finish(std::shared_ptr<Array>* out) {
}
Status BooleanBuilder::Append(
- const uint8_t* values, int32_t length, const uint8_t* valid_bytes) {
+ const uint8_t* values, int64_t length, const uint8_t* valid_bytes) {
RETURN_NOT_OK(Reserve(length));
- for (int i = 0; i < length; ++i) {
+ for (int64_t i = 0; i < length; ++i) {
// Skip reading from unitialised memory
// TODO: This actually is only to keep valgrind happy but may or may not
// have a performance impact.
@@ -333,17 +334,17 @@ ListBuilder::ListBuilder(
offset_builder_(pool),
values_(values) {}
-Status ListBuilder::Init(int32_t elements) {
- DCHECK_LT(elements, std::numeric_limits<int32_t>::max());
+Status ListBuilder::Init(int64_t elements) {
+ DCHECK_LT(elements, std::numeric_limits<int64_t>::max());
RETURN_NOT_OK(ArrayBuilder::Init(elements));
// one more then requested for offsets
- return offset_builder_.Resize((elements + 1) * sizeof(int32_t));
+ return offset_builder_.Resize((elements + 1) * sizeof(int64_t));
}
-Status ListBuilder::Resize(int32_t capacity) {
- DCHECK_LT(capacity, std::numeric_limits<int32_t>::max());
+Status ListBuilder::Resize(int64_t capacity) {
+ DCHECK_LT(capacity, std::numeric_limits<int64_t>::max());
// one more then requested for offsets
- RETURN_NOT_OK(offset_builder_.Resize((capacity + 1) * sizeof(int32_t)));
+ RETURN_NOT_OK(offset_builder_.Resize((capacity + 1) * sizeof(int64_t)));
return ArrayBuilder::Resize(capacity);
}
@@ -351,7 +352,7 @@ Status ListBuilder::Finish(std::shared_ptr<Array>* out) {
std::shared_ptr<Array> items = values_;
if (!items) { RETURN_NOT_OK(value_builder_->Finish(&items)); }
- RETURN_NOT_OK(offset_builder_.Append<int32_t>(items->length()));
+ RETURN_NOT_OK(offset_builder_.Append<int64_t>(items->length()));
std::shared_ptr<Buffer> offsets = offset_builder_.Finish();
*out = std::make_shared<ListArray>(
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/builder.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/builder.h b/cpp/src/arrow/builder.h
index 0b83b9f..e642d3c 100644
--- a/cpp/src/arrow/builder.h
+++ b/cpp/src/arrow/builder.h
@@ -37,7 +37,7 @@ namespace arrow {
class Array;
-static constexpr int32_t kMinBuilderCapacity = 1 << 5;
+static constexpr int64_t kMinBuilderCapacity = 1 << 5;
/// Base class for all data array builders.
//
@@ -61,38 +61,38 @@ class ARROW_EXPORT ArrayBuilder {
/// skip shared pointers and just return a raw pointer
ArrayBuilder* child(int i) { return children_[i].get(); }
- int num_children() const { return children_.size(); }
+ int num_children() const { return static_cast<int>(children_.size()); }
- int32_t length() const { return length_; }
- int32_t null_count() const { return null_count_; }
- int32_t capacity() const { return capacity_; }
+ int64_t length() const { return length_; }
+ int64_t null_count() const { return null_count_; }
+ int64_t capacity() const { return capacity_; }
/// Append to null bitmap
Status AppendToBitmap(bool is_valid);
/// Vector append. Treat each zero byte as a null. If valid_bytes is null
/// assume all of length bits are valid.
- Status AppendToBitmap(const uint8_t* valid_bytes, int32_t length);
+ Status AppendToBitmap(const uint8_t* valid_bytes, int64_t length);
/// Set the next length bits to not null (i.e. valid).
- Status SetNotNull(int32_t length);
+ Status SetNotNull(int64_t length);
/// Allocates initial capacity requirements for the builder. In most
/// cases subclasses should override and call there parent classes
/// method as well.
- virtual Status Init(int32_t capacity);
+ virtual Status Init(int64_t capacity);
/// Resizes the null_bitmap array. In most
/// cases subclasses should override and call there parent classes
/// method as well.
- virtual Status Resize(int32_t new_bits);
+ virtual Status Resize(int64_t new_bits);
/// Ensures there is enough space for adding the number of elements by checking
/// capacity and calling Resize if necessary.
- Status Reserve(int32_t elements);
+ Status Reserve(int64_t elements);
/// For cases where raw data was memcpy'd into the internal buffers, allows us
/// to advance the length of the builder. It is your responsibility to use
/// this function responsibly.
- Status Advance(int32_t elements);
+ Status Advance(int64_t elements);
std::shared_ptr<PoolBuffer> null_bitmap() const { return null_bitmap_; }
@@ -109,12 +109,12 @@ class ARROW_EXPORT ArrayBuilder {
// When null_bitmap are first appended to the builder, the null bitmap is allocated
std::shared_ptr<PoolBuffer> null_bitmap_;
- int32_t null_count_;
+ int64_t null_count_;
uint8_t* null_bitmap_data_;
// Array length, so far. Also, the index of the next element to be added
- int32_t length_;
- int32_t capacity_;
+ int64_t length_;
+ int64_t capacity_;
// Child value array builders. These are owned by this class
std::vector<std::unique_ptr<ArrayBuilder>> children_;
@@ -127,9 +127,9 @@ class ARROW_EXPORT ArrayBuilder {
void UnsafeAppendToBitmap(bool is_valid);
// Vector append. Treat each zero byte as a nullzero. If valid_bytes is null
// assume all of length bits are valid.
- void UnsafeAppendToBitmap(const uint8_t* valid_bytes, int32_t length);
+ void UnsafeAppendToBitmap(const uint8_t* valid_bytes, int64_t length);
// Set the next length bits to not null (i.e. valid).
- void UnsafeSetNotNull(int32_t length);
+ void UnsafeSetNotNull(int64_t length);
private:
DISALLOW_COPY_AND_ASSIGN(ArrayBuilder);
@@ -146,7 +146,7 @@ class ARROW_EXPORT PrimitiveBuilder : public ArrayBuilder {
using ArrayBuilder::Advance;
/// Write nulls as uint8_t* (0 value indicates null) into pre-allocated memory
- Status AppendNulls(const uint8_t* valid_bytes, int32_t length) {
+ Status AppendNulls(const uint8_t* valid_bytes, int64_t length) {
RETURN_NOT_OK(Reserve(length));
UnsafeAppendToBitmap(valid_bytes, length);
return Status::OK();
@@ -165,14 +165,14 @@ class ARROW_EXPORT PrimitiveBuilder : public ArrayBuilder {
/// If passed, valid_bytes is of equal length to values, and any zero byte
/// will be considered as a null for that slot
Status Append(
- const value_type* values, int32_t length, const uint8_t* valid_bytes = nullptr);
+ const value_type* values, int64_t length, const uint8_t* valid_bytes = nullptr);
Status Finish(std::shared_ptr<Array>* out) override;
- Status Init(int32_t capacity) override;
+ Status Init(int64_t capacity) override;
/// Increase the capacity of the builder to accommodate at least the indicated
/// number of elements
- Status Resize(int32_t capacity) override;
+ Status Resize(int64_t capacity) override;
protected:
std::shared_ptr<PoolBuffer> data_;
@@ -246,7 +246,7 @@ class ARROW_EXPORT BooleanBuilder : public ArrayBuilder {
using ArrayBuilder::Advance;
/// Write nulls as uint8_t* (0 value indicates null) into pre-allocated memory
- Status AppendNulls(const uint8_t* valid_bytes, int32_t length) {
+ Status AppendNulls(const uint8_t* valid_bytes, int64_t length) {
RETURN_NOT_OK(Reserve(length));
UnsafeAppendToBitmap(valid_bytes, length);
return Status::OK();
@@ -278,14 +278,14 @@ class ARROW_EXPORT BooleanBuilder : public ArrayBuilder {
/// If passed, valid_bytes is of equal length to values, and any zero byte
/// will be considered as a null for that slot
Status Append(
- const uint8_t* values, int32_t length, const uint8_t* valid_bytes = nullptr);
+ const uint8_t* values, int64_t length, const uint8_t* valid_bytes = nullptr);
Status Finish(std::shared_ptr<Array>* out) override;
- Status Init(int32_t capacity) override;
+ Status Init(int64_t capacity) override;
/// Increase the capacity of the builder to accommodate at least the indicated
/// number of elements
- Status Resize(int32_t capacity) override;
+ Status Resize(int64_t capacity) override;
protected:
std::shared_ptr<PoolBuffer> data_;
@@ -318,8 +318,8 @@ class ARROW_EXPORT ListBuilder : public ArrayBuilder {
ListBuilder(
MemoryPool* pool, std::shared_ptr<Array> values, const TypePtr& type = nullptr);
- Status Init(int32_t elements) override;
- Status Resize(int32_t capacity) override;
+ Status Init(int64_t elements) override;
+ Status Resize(int64_t capacity) override;
Status Finish(std::shared_ptr<Array>* out) override;
/// Vector append
@@ -327,7 +327,7 @@ class ARROW_EXPORT ListBuilder : public ArrayBuilder {
/// If passed, valid_bytes is of equal length to values, and any zero byte
/// will be considered as a null for that slot
Status Append(
- const int32_t* offsets, int32_t length, const uint8_t* valid_bytes = nullptr) {
+ const int32_t* offsets, int64_t length, const uint8_t* valid_bytes = nullptr) {
RETURN_NOT_OK(Reserve(length));
UnsafeAppendToBitmap(valid_bytes, length);
offset_builder_.UnsafeAppend<int32_t>(offsets, length);
@@ -341,7 +341,8 @@ class ARROW_EXPORT ListBuilder : public ArrayBuilder {
Status Append(bool is_valid = true) {
RETURN_NOT_OK(Reserve(1));
UnsafeAppendToBitmap(is_valid);
- RETURN_NOT_OK(offset_builder_.Append<int32_t>(value_builder_->length()));
+ RETURN_NOT_OK(
+ offset_builder_.Append<int32_t>(static_cast<int32_t>(value_builder_->length())));
return Status::OK();
}
@@ -375,7 +376,9 @@ class ARROW_EXPORT BinaryBuilder : public ListBuilder {
return Append(reinterpret_cast<const uint8_t*>(value), length);
}
- Status Append(const std::string& value) { return Append(value.c_str(), value.size()); }
+ Status Append(const std::string& value) {
+ return Append(value.c_str(), static_cast<int32_t>(value.size()));
+ }
Status Finish(std::shared_ptr<Array>* out) override;
@@ -417,7 +420,7 @@ class ARROW_EXPORT StructBuilder : public ArrayBuilder {
/// will be considered as a null for that field, but users must using app-
/// end methods or advance methods of the child builders' independently to
/// insert data.
- Status Append(int32_t length, const uint8_t* valid_bytes) {
+ Status Append(int64_t length, const uint8_t* valid_bytes) {
RETURN_NOT_OK(Reserve(length));
UnsafeAppendToBitmap(valid_bytes, length);
return Status::OK();
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/column-benchmark.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/column-benchmark.cc b/cpp/src/arrow/column-benchmark.cc
index 1bab5a8..13076a4 100644
--- a/cpp/src/arrow/column-benchmark.cc
+++ b/cpp/src/arrow/column-benchmark.cc
@@ -24,7 +24,7 @@
namespace arrow {
namespace {
template <typename ArrayType>
-std::shared_ptr<Array> MakePrimitive(int32_t length, int32_t null_count = 0) {
+std::shared_ptr<Array> MakePrimitive(int64_t length, int64_t null_count = 0) {
auto pool = default_memory_pool();
auto data = std::make_shared<PoolBuffer>(pool);
auto null_bitmap = std::make_shared<PoolBuffer>(pool);
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/column.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/column.cc b/cpp/src/arrow/column.cc
index 1376f65..1822870 100644
--- a/cpp/src/arrow/column.cc
+++ b/cpp/src/arrow/column.cc
@@ -42,15 +42,15 @@ bool ChunkedArray::Equals(const ChunkedArray& other) const {
// Check contents of the underlying arrays. This checks for equality of
// the underlying data independently of the chunk size.
int this_chunk_idx = 0;
- int32_t this_start_idx = 0;
+ int64_t this_start_idx = 0;
int other_chunk_idx = 0;
- int32_t other_start_idx = 0;
+ int64_t other_start_idx = 0;
int64_t elements_compared = 0;
while (elements_compared < length_) {
const std::shared_ptr<Array> this_array = chunks_[this_chunk_idx];
const std::shared_ptr<Array> other_array = other.chunk(other_chunk_idx);
- int32_t common_length = std::min(
+ int64_t common_length = std::min(
this_array->length() - this_start_idx, other_array->length() - other_start_idx);
if (!this_array->RangeEquals(this_start_idx, this_start_idx + common_length,
other_start_idx, other_array)) {
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/column.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/column.h b/cpp/src/arrow/column.h
index a28b266..93a34c7 100644
--- a/cpp/src/arrow/column.h
+++ b/cpp/src/arrow/column.h
@@ -44,7 +44,7 @@ class ARROW_EXPORT ChunkedArray {
int64_t null_count() const { return null_count_; }
- int num_chunks() const { return chunks_.size(); }
+ int num_chunks() const { return static_cast<int>(chunks_.size()); }
std::shared_ptr<Array> chunk(int i) const { return chunks_[i]; }
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/compare.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/compare.cc b/cpp/src/arrow/compare.cc
index ff3c59f..e94fa74 100644
--- a/cpp/src/arrow/compare.cc
+++ b/cpp/src/arrow/compare.cc
@@ -37,8 +37,8 @@ namespace arrow {
class RangeEqualsVisitor : public ArrayVisitor {
public:
- RangeEqualsVisitor(const Array& right, int32_t left_start_idx, int32_t left_end_idx,
- int32_t right_start_idx)
+ RangeEqualsVisitor(const Array& right, int64_t left_start_idx, int64_t left_end_idx,
+ int64_t right_start_idx)
: right_(right),
left_start_idx_(left_start_idx),
left_end_idx_(left_end_idx),
@@ -55,7 +55,7 @@ class RangeEqualsVisitor : public ArrayVisitor {
inline Status CompareValues(const ArrayType& left) {
const auto& right = static_cast<const ArrayType&>(right_);
- for (int32_t i = left_start_idx_, o_i = right_start_idx_; i < left_end_idx_;
+ for (int64_t i = left_start_idx_, o_i = right_start_idx_; i < left_end_idx_;
++i, ++o_i) {
const bool is_null = left.IsNull(i);
if (is_null != right.IsNull(o_i) ||
@@ -71,7 +71,7 @@ class RangeEqualsVisitor : public ArrayVisitor {
bool CompareBinaryRange(const BinaryArray& left) const {
const auto& right = static_cast<const BinaryArray&>(right_);
- for (int32_t i = left_start_idx_, o_i = right_start_idx_; i < left_end_idx_;
+ for (int64_t i = left_start_idx_, o_i = right_start_idx_; i < left_end_idx_;
++i, ++o_i) {
const bool is_null = left.IsNull(i);
if (is_null != right.IsNull(o_i)) { return false; }
@@ -164,7 +164,7 @@ class RangeEqualsVisitor : public ArrayVisitor {
const std::shared_ptr<Array>& left_values = left.values();
const std::shared_ptr<Array>& right_values = right.values();
- for (int32_t i = left_start_idx_, o_i = right_start_idx_; i < left_end_idx_;
+ for (int64_t i = left_start_idx_, o_i = right_start_idx_; i < left_end_idx_;
++i, ++o_i) {
const bool is_null = left.IsNull(i);
if (is_null != right.IsNull(o_i)) { return false; }
@@ -193,15 +193,15 @@ class RangeEqualsVisitor : public ArrayVisitor {
bool CompareStructs(const StructArray& left) {
const auto& right = static_cast<const StructArray&>(right_);
bool equal_fields = true;
- for (int32_t i = left_start_idx_, o_i = right_start_idx_; i < left_end_idx_;
+ for (int64_t i = left_start_idx_, o_i = right_start_idx_; i < left_end_idx_;
++i, ++o_i) {
if (left.IsNull(i) != right.IsNull(o_i)) { return false; }
if (left.IsNull(i)) continue;
- for (size_t j = 0; j < left.fields().size(); ++j) {
+ for (int j = 0; j < static_cast<int>(left.fields().size()); ++j) {
// TODO: really we should be comparing stretches of non-null data rather
// than looking at one value at a time.
- const int left_abs_index = i + left.offset();
- const int right_abs_index = o_i + right.offset();
+ const int64_t left_abs_index = i + left.offset();
+ const int64_t right_abs_index = o_i + right.offset();
equal_fields = left.field(j)->RangeEquals(
left_abs_index, left_abs_index + 1, right_abs_index, right.field(j));
@@ -243,7 +243,7 @@ class RangeEqualsVisitor : public ArrayVisitor {
const uint8_t* right_ids = right.raw_type_ids();
uint8_t id, child_num;
- for (int32_t i = left_start_idx_, o_i = right_start_idx_; i < left_end_idx_;
+ for (int64_t i = left_start_idx_, o_i = right_start_idx_; i < left_end_idx_;
++i, ++o_i) {
if (left.IsNull(i) != right.IsNull(o_i)) { return false; }
if (left.IsNull(i)) continue;
@@ -252,8 +252,8 @@ class RangeEqualsVisitor : public ArrayVisitor {
id = left_ids[i];
child_num = type_id_to_child_num[id];
- const int left_abs_index = i + left.offset();
- const int right_abs_index = o_i + right.offset();
+ const int64_t left_abs_index = i + left.offset();
+ const int64_t right_abs_index = o_i + right.offset();
// TODO(wesm): really we should be comparing stretches of non-null data
// rather than looking at one value at a time.
@@ -294,9 +294,9 @@ class RangeEqualsVisitor : public ArrayVisitor {
protected:
const Array& right_;
- int32_t left_start_idx_;
- int32_t left_end_idx_;
- int32_t right_start_idx_;
+ int64_t left_start_idx_;
+ int64_t left_end_idx_;
+ int64_t right_start_idx_;
bool result_;
};
@@ -314,7 +314,7 @@ class ArrayEqualsVisitor : public RangeEqualsVisitor {
const uint8_t* left_data = left.data()->data();
const uint8_t* right_data = right.data()->data();
- for (int i = 0; i < left.length(); ++i) {
+ for (int64_t i = 0; i < left.length(); ++i) {
if (!left.IsNull(i) &&
BitUtil::GetBit(left_data, i) != BitUtil::GetBit(right_data, i)) {
result_ = false;
@@ -339,7 +339,7 @@ class ArrayEqualsVisitor : public RangeEqualsVisitor {
const uint8_t* right_data = right.data()->data() + right.offset() * value_byte_size;
if (left.null_count() > 0) {
- for (int i = 0; i < left.length(); ++i) {
+ for (int64_t i = 0; i < left.length(); ++i) {
if (!left.IsNull(i) && memcmp(left_data, right_data, value_byte_size)) {
return false;
}
@@ -401,7 +401,7 @@ class ArrayEqualsVisitor : public RangeEqualsVisitor {
reinterpret_cast<const int32_t*>(right.value_offsets()->data()) +
right.offset();
- for (int32_t i = 0; i < left.length() + 1; ++i) {
+ for (int64_t i = 0; i < left.length() + 1; ++i) {
if (left_offsets[i] - left_offsets[0] != right_offsets[i] - right_offsets[0]) {
return false;
}
@@ -437,7 +437,7 @@ class ArrayEqualsVisitor : public RangeEqualsVisitor {
// ARROW-537: Only compare data in non-null slots
const int32_t* left_offsets = left.raw_value_offsets();
const int32_t* right_offsets = right.raw_value_offsets();
- for (int32_t i = 0; i < left.length(); ++i) {
+ for (int64_t i = 0; i < left.length(); ++i) {
if (left.IsNull(i)) { continue; }
if (std::memcmp(left_data + left_offsets[i], right_data + right_offsets[i],
left.value_length(i))) {
@@ -496,15 +496,15 @@ inline bool FloatingApproxEquals(
const T* left_data = left.raw_data();
const T* right_data = right.raw_data();
- static constexpr T EPSILON = 1E-5;
+ static constexpr T EPSILON = static_cast<T>(1E-5);
if (left.null_count() > 0) {
- for (int32_t i = 0; i < left.length(); ++i) {
+ for (int64_t i = 0; i < left.length(); ++i) {
if (left.IsNull(i)) continue;
if (fabs(left_data[i] - right_data[i]) > EPSILON) { return false; }
}
} else {
- for (int32_t i = 0; i < left.length(); ++i) {
+ for (int64_t i = 0; i < left.length(); ++i) {
if (fabs(left_data[i] - right_data[i]) > EPSILON) { return false; }
}
}
@@ -556,8 +556,8 @@ Status ArrayEquals(const Array& left, const Array& right, bool* are_equal) {
return Status::OK();
}
-Status ArrayRangeEquals(const Array& left, const Array& right, int32_t left_start_idx,
- int32_t left_end_idx, int32_t right_start_idx, bool* are_equal) {
+Status ArrayRangeEquals(const Array& left, const Array& right, int64_t left_start_idx,
+ int64_t left_end_idx, int64_t right_start_idx, bool* are_equal) {
if (&left == &right) {
*are_equal = true;
} else if (left.type_enum() != right.type_enum()) {
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/compare.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/compare.h b/cpp/src/arrow/compare.h
index 6a71f9f..1ddf049 100644
--- a/cpp/src/arrow/compare.h
+++ b/cpp/src/arrow/compare.h
@@ -40,7 +40,7 @@ Status ARROW_EXPORT ArrayApproxEquals(
/// Returns true if indicated equal-length segment of arrays is exactly equal
Status ARROW_EXPORT ArrayRangeEquals(const Array& left, const Array& right,
- int32_t start_idx, int32_t end_idx, int32_t other_start_idx, bool* are_equal);
+ int64_t start_idx, int64_t end_idx, int64_t other_start_idx, bool* are_equal);
/// Returns true if the type metadata are exactly equal
Status ARROW_EXPORT TypeEquals(
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/io/file.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/file.cc b/cpp/src/arrow/io/file.cc
index c1f0ea4..230c7fe 100644
--- a/cpp/src/arrow/io/file.cc
+++ b/cpp/src/arrow/io/file.cc
@@ -263,9 +263,9 @@ static inline Status FileWrite(int fd, const uint8_t* buffer, int64_t nbytes) {
if (nbytes > INT32_MAX) {
return Status::IOError("Unable to write > 2GB blocks to file yet");
}
- ret = _write(fd, buffer, static_cast<unsigned int>(nbytes));
+ ret = static_cast<int>(_write(fd, buffer, static_cast<unsigned int>(nbytes)));
#else
- ret = write(fd, buffer, nbytes);
+ ret = static_cast<int>(write(fd, buffer, nbytes));
#endif
if (ret == -1) {
@@ -303,9 +303,9 @@ static inline Status FileClose(int fd) {
int ret;
#if defined(_MSC_VER)
- ret = _close(fd);
+ ret = static_cast<int>(_close(fd));
#else
- ret = close(fd);
+ ret = static_cast<int>(close(fd));
#endif
if (ret == -1) { return Status::IOError("error closing file"); }
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/io/hdfs.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/hdfs.cc b/cpp/src/arrow/io/hdfs.cc
index 5682f44..408b85f 100644
--- a/cpp/src/arrow/io/hdfs.cc
+++ b/cpp/src/arrow/io/hdfs.cc
@@ -114,7 +114,7 @@ class HdfsReadableFile::HdfsReadableFileImpl : public HdfsAnyFileImpl {
tSize ret;
if (driver_->HasPread()) {
ret = driver_->Pread(fs_, file_, static_cast<tOffset>(position),
- reinterpret_cast<void*>(buffer), nbytes);
+ reinterpret_cast<void*>(buffer), static_cast<tSize>(nbytes));
} else {
RETURN_NOT_OK(Seek(position));
return Read(nbytes, bytes_read, buffer);
@@ -141,7 +141,7 @@ class HdfsReadableFile::HdfsReadableFileImpl : public HdfsAnyFileImpl {
int64_t total_bytes = 0;
while (total_bytes < nbytes) {
tSize ret = driver_->Read(fs_, file_, reinterpret_cast<void*>(buffer + total_bytes),
- std::min<int64_t>(buffer_size_, nbytes - total_bytes));
+ static_cast<tSize>(std::min<int64_t>(buffer_size_, nbytes - total_bytes)));
RETURN_NOT_OK(CheckReadResult(ret));
total_bytes += ret;
if (ret == 0) { break; }
@@ -253,7 +253,8 @@ class HdfsOutputStream::HdfsOutputStreamImpl : public HdfsAnyFileImpl {
}
Status Write(const uint8_t* buffer, int64_t nbytes, int64_t* bytes_written) {
- tSize ret = driver_->Write(fs_, file_, reinterpret_cast<const void*>(buffer), nbytes);
+ tSize ret = driver_->Write(
+ fs_, file_, reinterpret_cast<const void*>(buffer), static_cast<tSize>(nbytes));
CHECK_FAILURE(ret, "Write");
*bytes_written = ret;
return Status::OK();
@@ -328,7 +329,7 @@ class HdfsClient::HdfsClientImpl {
if (!config->host.empty()) {
driver_->BuilderSetNameNode(builder, config->host.c_str());
}
- driver_->BuilderSetNameNodePort(builder, config->port);
+ driver_->BuilderSetNameNodePort(builder, static_cast<tPort>(config->port));
if (!config->user.empty()) {
driver_->BuilderSetUserName(builder, config->user.c_str());
}
@@ -411,7 +412,7 @@ class HdfsClient::HdfsClientImpl {
// Allocate additional space for elements
- int vec_offset = listing->size();
+ int vec_offset = static_cast<int>(listing->size());
listing->resize(vec_offset + num_entries);
for (int i = 0; i < num_entries; ++i) {
@@ -449,8 +450,8 @@ class HdfsClient::HdfsClientImpl {
int flags = O_WRONLY;
if (append) flags |= O_APPEND;
- hdfsFile handle = driver_->OpenFile(
- fs_, path.c_str(), flags, buffer_size, replication, default_block_size);
+ hdfsFile handle = driver_->OpenFile(fs_, path.c_str(), flags, buffer_size,
+ replication, static_cast<tSize>(default_block_size));
if (handle == nullptr) {
// TODO(wesm): determine cause of failure
http://git-wip-us.apache.org/repos/asf/arrow/blob/01a67f3f/cpp/src/arrow/io/io-hdfs-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/io-hdfs-test.cc b/cpp/src/arrow/io/io-hdfs-test.cc
index f0e5a28..648d4ba 100644
--- a/cpp/src/arrow/io/io-hdfs-test.cc
+++ b/cpp/src/arrow/io/io-hdfs-test.cc
@@ -49,7 +49,7 @@ class TestHdfsClient : public ::testing::Test {
}
Status WriteDummyFile(const std::string& path, const uint8_t* buffer, int64_t size,
- bool append = false, int buffer_size = 0, int replication = 0,
+ bool append = false, int buffer_size = 0, int16_t replication = 0,
int default_block_size = 0) {
std::shared_ptr<HdfsOutputStream> file;
RETURN_NOT_OK(client_->OpenWriteable(