mirror of
https://github.com/wassname/ray.git
synced 2026-07-24 13:20:22 +08:00
Rebase numbuf to latest arrow (#23)
* rebase to latest arrow * fix arrow linking * finish rebase * point arrow to pcmoritz's arrow * fix * fix macOS * fix
This commit is contained in:
committed by
Robert Nishihara
parent
c3db225cbe
commit
c3ab68e88c
+23
-15
@@ -5,13 +5,16 @@ using namespace arrow;
|
||||
namespace numbuf {
|
||||
|
||||
SequenceBuilder::SequenceBuilder(MemoryPool* pool)
|
||||
: pool_(pool), types_(pool), offsets_(pool),
|
||||
: pool_(pool),
|
||||
types_(pool, std::make_shared<Int8Type>()),
|
||||
offsets_(pool, std::make_shared<Int32Type>()),
|
||||
nones_(pool, std::make_shared<NullType>()),
|
||||
bools_(pool, std::make_shared<BooleanType>()),
|
||||
ints_(pool),
|
||||
ints_(pool, std::make_shared<Int64Type>()),
|
||||
bytes_(pool, std::make_shared<BinaryType>()),
|
||||
strings_(pool, std::make_shared<StringType>()),
|
||||
floats_(pool), doubles_(pool),
|
||||
floats_(pool, std::make_shared<FloatType>()),
|
||||
doubles_(pool, std::make_shared<DoubleType>()),
|
||||
uint8_tensors_(std::make_shared<UInt8Type>(), pool),
|
||||
int8_tensors_(std::make_shared<Int8Type>(), pool),
|
||||
uint16_tensors_(std::make_shared<UInt16Type>(), pool),
|
||||
@@ -76,6 +79,9 @@ Status SequenceBuilder::AppendDouble(double data) {
|
||||
|
||||
#define DEF_TENSOR_APPEND(NAME, TYPE, TAG) \
|
||||
Status SequenceBuilder::AppendTensor(const std::vector<int64_t>& dims, TYPE* data) { \
|
||||
if (TAG == -1) { \
|
||||
NAME.Start(); \
|
||||
} \
|
||||
UPDATE(NAME.length(), TAG); \
|
||||
return NAME.Append(dims, data); \
|
||||
}
|
||||
@@ -109,11 +115,11 @@ Status SequenceBuilder::AppendDict(int32_t size) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
#define ADD_ELEMENT(VARNAME, TAG) \
|
||||
if (TAG != -1) { \
|
||||
types[TAG] = VARNAME.type(); \
|
||||
children[TAG] = VARNAME.Finish(); \
|
||||
ARROW_CHECK_OK(nones_.AppendToBitmap(true)); \
|
||||
#define ADD_ELEMENT(VARNAME, TAG) \
|
||||
if (TAG != -1) { \
|
||||
types[TAG] = std::make_shared<Field>("", VARNAME.type()); \
|
||||
RETURN_NOT_OK(VARNAME.Finish(&children[TAG])); \
|
||||
RETURN_NOT_OK(nones_.AppendToBitmap(true)); \
|
||||
}
|
||||
|
||||
#define ADD_SUBSEQUENCE(DATA, OFFSETS, BUILDER, TAG, NAME) \
|
||||
@@ -132,12 +138,13 @@ Status SequenceBuilder::AppendDict(int32_t size) {
|
||||
DCHECK(OFFSETS.size() == 1); \
|
||||
}
|
||||
|
||||
std::shared_ptr<DenseUnionArray> SequenceBuilder::Finish(
|
||||
Status SequenceBuilder::Finish(
|
||||
std::shared_ptr<Array> list_data,
|
||||
std::shared_ptr<Array> tuple_data,
|
||||
std::shared_ptr<Array> dict_data) {
|
||||
std::shared_ptr<Array> dict_data,
|
||||
std::shared_ptr<Array>* out) {
|
||||
|
||||
std::vector<TypePtr> types(num_tags);
|
||||
std::vector<std::shared_ptr<Field>> types(num_tags);
|
||||
std::vector<ArrayPtr> children(num_tags);
|
||||
|
||||
ADD_ELEMENT(bools_, bool_tag);
|
||||
@@ -165,11 +172,12 @@ std::shared_ptr<DenseUnionArray> SequenceBuilder::Finish(
|
||||
ADD_SUBSEQUENCE(tuple_data, tuple_offsets_, tuple_builder, tuple_tag, "tuple");
|
||||
ADD_SUBSEQUENCE(dict_data, dict_offsets_, dict_builder, dict_tag, "dict");
|
||||
|
||||
TypePtr type = TypePtr(new DenseUnionType(types));
|
||||
|
||||
return std::make_shared<DenseUnionArray>(type, types_.length(),
|
||||
std::vector<uint8_t> type_ids = {};
|
||||
TypePtr type = TypePtr(new UnionType(types, type_ids, UnionMode::DENSE));
|
||||
out->reset(new UnionArray(type, types_.length(),
|
||||
children, types_.data(), offsets_.data(),
|
||||
nones_.null_count(), nones_.null_bitmap());
|
||||
nones_.null_count(), nones_.null_bitmap()));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user