Skip to content

Commit

Permalink
Add ListView to visitor_generate.h
Browse files Browse the repository at this point in the history
And all the placeholders necessary to make all the code compile
  • Loading branch information
felipecrv committed Apr 26, 2023
1 parent dd9d9b8 commit db662bc
Show file tree
Hide file tree
Showing 19 changed files with 98 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cpp/src/arrow/array/array_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ struct ScalarFromArraySlotImpl {
return Status::OK();
}

Status Visit(const ListViewArray& a) {
return Status::NotImplemented("Creating scalar from list-view array");
}

Status Visit(const ExtensionArray& a) {
ARROW_ASSIGN_OR_RAISE(auto storage, a.storage()->GetScalar(index_));
out_ = std::make_shared<ExtensionScalar>(std::move(storage), a.type());
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/array/concatenate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@ class ConcatenateImpl {
return Status::OK();
}

Status Visit(const ListViewType& type) {
return Status::NotImplemented("concatenation of ", type);
}

Status Visit(const ExtensionType& e) {
ArrayDataVector storage_data(in_.size());
for (size_t i = 0; i < in_.size(); ++i) {
Expand Down
9 changes: 8 additions & 1 deletion cpp/src/arrow/array/diff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ struct ValueComparatorVisitor {
return Status::NotImplemented("run-end encoded type");
}

Status Visit(const ListViewType&) { return Status::NotImplemented("list-view type"); }

ValueComparator Create(const DataType& type) {
DCHECK_OK(VisitTypeInline(type, this));
return out;
Expand Down Expand Up @@ -386,7 +388,8 @@ Result<std::shared_ptr<StructArray>> Diff(const Array& base, const Array& target
return Diff(*base_storage, *target_storage, pool);
} else if (base.type()->id() == Type::DICTIONARY) {
return Status::NotImplemented("diffing arrays of type ", *base.type());
} else if (base.type()->id() == Type::RUN_END_ENCODED) {
} else if (base.type()->id() == Type::RUN_END_ENCODED ||
base.type()->id() == Type::LIST_VIEW) {
return Status::NotImplemented("diffing arrays of type ", *base.type());
} else {
return QuadraticSpaceMyersDiff(base, target, pool).Diff();
Expand Down Expand Up @@ -643,6 +646,10 @@ class MakeFormatterImpl {
return Status::NotImplemented("formatting diffs between arrays of type ", t);
}

Status Visit(const ListViewType& t) {
return Status::NotImplemented("formatting diffs between arrays of type ", t);
}

template <typename T, bool AddEpoch>
Formatter MakeTimeFormatter(const std::string& fmt_str) {
return [fmt_str](const Array& array, int64_t index, std::ostream* os) {
Expand Down
11 changes: 11 additions & 0 deletions cpp/src/arrow/array/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ class ArrayDataEndianSwapper {
Status Visit(const RunEndEncodedType& type) {
return Status::NotImplemented("swapping endianness of run-end encoded array");
}
Status Visit(const ListViewType& type) {
return Status::NotImplemented("swapping endianness of list-view array");
}
Status Visit(const UnionType& type) {
out_->buffers[1] = data_->buffers[1];
if (type.mode() == UnionMode::DENSE) {
Expand Down Expand Up @@ -559,6 +562,10 @@ class NullArrayFactory {
return Status::OK();
}

Status Visit(const ListViewType& type) {
return Status::NotImplemented("construction of all-null ", type);
}

Status Visit(const ExtensionType& type) {
out_->child_data.resize(type.storage_type()->num_fields());
RETURN_NOT_OK(VisitTypeInline(*type.storage_type(), this));
Expand Down Expand Up @@ -789,6 +796,10 @@ class RepeatedArrayFactory {
return Status::OK();
}

Status Visit(const ListViewType& type) {
return Status::NotImplemented("construction from scalar of type ", *scalar_.type);
}

Status Visit(const ExtensionType& type) {
return Status::NotImplemented("construction from scalar of type ", *scalar_.type);
}
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/array/validate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ struct ValidateArrayImpl {
}
}

Status Visit(const ListViewType& type) {
return Status::NotImplemented("ListViewType validation not implemented");
}

Status Visit(const ExtensionType& type) {
// Visit storage
return ValidateWithType(*type.storage_type());
Expand Down
12 changes: 12 additions & 0 deletions cpp/src/arrow/compare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ class RangeDataEqualsImpl {
}
}

Status Visit(const ListViewType& type) {
return Status::NotImplemented("comparing ListViewType");
}

Status Visit(const ExtensionType& type) {
// Compare storages
result_ &= CompareWithType(*type.storage_type());
Expand Down Expand Up @@ -746,6 +750,10 @@ class TypeEqualsVisitor {
return Status::OK();
}

Status Visit(const ListViewType& left) {
return Status::NotImplemented("list-view type comparison");
}

Status Visit(const ExtensionType& left) {
result_ = left.ExtensionEquals(static_cast<const ExtensionType&>(right_));
return Status::OK();
Expand Down Expand Up @@ -890,6 +898,10 @@ class ScalarEqualsVisitor {
return Status::OK();
}

Status Visit(const ListViewScalar& left) {
return Status::NotImplemented("list-view comparison");
}

Status Visit(const ExtensionScalar& left) {
const auto& right = checked_cast<const ExtensionScalar&>(right_);
result_ = ScalarEquals(*left.value, *right.value, options_, floating_approximate_);
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/engine/substrait/expression_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,10 @@ struct ScalarToProtoImpl {

Status Visit(const RunEndEncodedScalar& s) { return (*this)(*s.value); }

Status Visit(const ListViewScalar& s) {
return Status::NotImplemented("list-view to proto");
}

Status Visit(const ExtensionScalar& s) {
if (UnwrapUuid(*s.type)) {
return FromBuffer([](Lit* lit, std::string&& s) { lit->set_uuid(std::move(s)); },
Expand Down
1 change: 1 addition & 0 deletions cpp/src/arrow/engine/substrait/type_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ struct DataTypeToProtoImpl {
Status Visit(const DenseUnionType& t) { return NotImplemented(t); }
Status Visit(const DictionaryType& t) { return NotImplemented(t); }
Status Visit(const RunEndEncodedType& t) { return NotImplemented(t); }
Status Visit(const ListViewType& t) { return NotImplemented(t); }

Status Visit(const MapType& t) {
// FIXME assert default field names; custom ones won't roundtrip
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/ipc/metadata_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,10 @@ class FieldToFlatbufferVisitor {
return Status::OK();
}

Status Visit(const ListViewType& type) {
return Status::NotImplemented("list-view type in IPC");
}

Status Visit(const ExtensionType& type) {
RETURN_NOT_OK(VisitType(*type.storage_type()));
extra_type_metadata_[kExtensionTypeKeyName] = type.extension_name();
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/ipc/reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ class ArrayLoader {
return LoadChildren(type.fields());
}

Status Visit(const ListViewType& type) {
return Status::NotImplemented("list-view array in IPC");
}

Status Visit(const ExtensionType& type) { return LoadType(*type.storage_type()); }

BatchDataReadRequest& read_request() { return read_request_; }
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/ipc/writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,10 @@ class RecordBatchSerializer {
return Status::OK();
}

Status Visit(const ListViewArray& array) {
return Status::NotImplemented("list-view array in IPC");
}

Status Visit(const ExtensionArray& array) { return VisitType(*array.storage()); }

Status VisitType(const Array& values) { return VisitArrayInline(values, this); }
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/arrow/json/test_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ struct GenerateImpl {

Status Visit(const RunEndEncodedType& t) { return NotImplemented(t); }

Status Visit(const ListViewType& t) { return NotImplemented(t); }

Status NotImplemented(const DataType& t) {
return Status::NotImplemented("random generation of arrays of type ", t);
}
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/pretty_print.cc
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ class ArrayPrinter : public PrettyPrinter {
return PrettyPrint(*array.values(), ChildOptions(true), sink_);
}

Status Visit(const ListViewArray& array) {
return Status::NotImplemented("printing list-view array");
}

Status Print(const Array& array) {
RETURN_NOT_OK(VisitArrayInline(array, this));
Flush();
Expand Down
12 changes: 12 additions & 0 deletions cpp/src/arrow/scalar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ struct ScalarHashImpl {
return Status::OK();
}

Status Visit(const ListViewScalar& s) {
return Status::NotImplemented("list-view scalar hashing");
}

Status Visit(const ExtensionScalar& s) {
AccumulateHashFrom(*s.value);
return Status::OK();
Expand Down Expand Up @@ -461,6 +465,10 @@ struct ScalarValidateImpl {
return ValidateValue(s, *s.value);
}

Status Visit(const ListViewScalar& s) {
return Status::NotImplemented("list-view scalar validation");
}

Status Visit(const ExtensionScalar& s) {
if (!s.value) {
return Status::Invalid(s.type->ToString(), " scalar doesn't have storage value");
Expand Down Expand Up @@ -823,6 +831,10 @@ struct MakeNullImpl {
return Status::OK();
}

Status Visit(const ListViewType& type) {
return Status::NotImplemented("making null array of list-view");
}

Status Visit(const ExtensionType& type) {
out_ = std::make_shared<ExtensionScalar>(MakeNullScalar(type.storage_type()), type_,
/*is_valid=*/false);
Expand Down
10 changes: 10 additions & 0 deletions cpp/src/arrow/testing/json_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ class SchemaWriter {
return Status::OK();
}

Status Visit(const ListViewType& type) { return Status::NotImplemented(type.name()); }

Status Visit(const ExtensionType& type) { return Status::NotImplemented(type.name()); }

private:
Expand Down Expand Up @@ -758,6 +760,10 @@ class ArrayWriter {
return WriteChildren(ree_type.fields(), children);
}

Status Visit(const ListViewArray& array) {
return Status::NotImplemented("list-view array in JSON");
}

Status Visit(const ExtensionArray& array) { return VisitArrayValues(*array.storage()); }

private:
Expand Down Expand Up @@ -1596,6 +1602,10 @@ class ArrayReader {
return Status::OK();
}

Status Visit(const ListViewType& type) {
return Status::NotImplemented("list-view in JSON");
}

Status Visit(const ExtensionType& type) {
ArrayReader parser(obj_, pool_, field_->WithType(type.storage_type()));
ARROW_ASSIGN_OR_RAISE(data_, parser.Parse());
Expand Down
4 changes: 3 additions & 1 deletion cpp/src/arrow/type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ std::vector<Type::type> AllTypeIds() {
Type::DICTIONARY,
Type::EXTENSION,
Type::INTERVAL_MONTH_DAY_NANO,
Type::RUN_END_ENCODED};
Type::RUN_END_ENCODED,
Type::LIST_VIEW};
}

namespace internal {
Expand Down Expand Up @@ -203,6 +204,7 @@ std::string ToString(Type::type id) {
TO_STRING_CASE(SPARSE_UNION)
TO_STRING_CASE(DICTIONARY)
TO_STRING_CASE(RUN_END_ENCODED)
TO_STRING_CASE(LIST_VIEW)
TO_STRING_CASE(EXTENSION)

#undef TO_STRING_CASE
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/arrow/visitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ ARRAY_VISITOR_DEFAULT(DictionaryArray)
ARRAY_VISITOR_DEFAULT(Decimal128Array)
ARRAY_VISITOR_DEFAULT(Decimal256Array)
ARRAY_VISITOR_DEFAULT(RunEndEncodedArray)
ARRAY_VISITOR_DEFAULT(ListViewArray)
ARRAY_VISITOR_DEFAULT(ExtensionArray)

#undef ARRAY_VISITOR_DEFAULT
Expand Down Expand Up @@ -120,6 +121,7 @@ TYPE_VISITOR_DEFAULT(SparseUnionType)
TYPE_VISITOR_DEFAULT(DenseUnionType)
TYPE_VISITOR_DEFAULT(DictionaryType)
TYPE_VISITOR_DEFAULT(RunEndEncodedType)
TYPE_VISITOR_DEFAULT(ListViewType)
TYPE_VISITOR_DEFAULT(ExtensionType)

#undef TYPE_VISITOR_DEFAULT
Expand Down Expand Up @@ -171,6 +173,7 @@ SCALAR_VISITOR_DEFAULT(DictionaryScalar)
SCALAR_VISITOR_DEFAULT(SparseUnionScalar)
SCALAR_VISITOR_DEFAULT(DenseUnionScalar)
SCALAR_VISITOR_DEFAULT(RunEndEncodedScalar)
SCALAR_VISITOR_DEFAULT(ListViewScalar)
SCALAR_VISITOR_DEFAULT(ExtensionScalar)

#undef SCALAR_VISITOR_DEFAULT
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/arrow/visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class ARROW_EXPORT ArrayVisitor {
virtual Status Visit(const DenseUnionArray& array);
virtual Status Visit(const DictionaryArray& array);
virtual Status Visit(const RunEndEncodedArray& array);
virtual Status Visit(const ListViewArray& array);
virtual Status Visit(const ExtensionArray& array);
};

Expand Down Expand Up @@ -118,6 +119,7 @@ class ARROW_EXPORT TypeVisitor {
virtual Status Visit(const DenseUnionType& type);
virtual Status Visit(const DictionaryType& type);
virtual Status Visit(const RunEndEncodedType& type);
virtual Status Visit(const ListViewType& scalar);
virtual Status Visit(const ExtensionType& type);
};

Expand Down Expand Up @@ -167,6 +169,7 @@ class ARROW_EXPORT ScalarVisitor {
virtual Status Visit(const SparseUnionScalar& scalar);
virtual Status Visit(const DenseUnionScalar& scalar);
virtual Status Visit(const RunEndEncodedScalar& scalar);
virtual Status Visit(const ListViewScalar& scalar);
virtual Status Visit(const ExtensionScalar& scalar);
};

Expand Down
1 change: 1 addition & 0 deletions cpp/src/arrow/visitor_generate.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace arrow {
ACTION(DenseUnion); \
ACTION(Dictionary); \
ACTION(RunEndEncoded); \
ACTION(ListView); \
ACTION(Extension)

} // namespace arrow

0 comments on commit db662bc

Please sign in to comment.