From 5d2b8f066b3f4a1add8386894232517cdb1a928c Mon Sep 17 00:00:00 2001 From: Weston Pace Date: Mon, 8 Aug 2022 17:02:09 -0700 Subject: [PATCH] ARROW-16740: [C++] Remove IR Consumer (#13301) Authored-by: Weston Pace Signed-off-by: Weston Pace --- cpp/src/arrow/CMakeLists.txt | 1 - cpp/src/arrow/compute/exec/CMakeLists.txt | 8 - cpp/src/arrow/compute/exec/ir_consumer.cc | 660 ------- cpp/src/arrow/compute/exec/ir_consumer.h | 70 - cpp/src/arrow/compute/exec/ir_test.cc | 829 --------- cpp/src/arrow/compute/exec/test_util.cc | 29 - cpp/src/generated/Expression_generated.h | 1870 ------------------- cpp/src/generated/Literal_generated.h | 2037 --------------------- cpp/src/generated/Plan_generated.h | 115 -- cpp/src/generated/Relation_generated.h | 1428 --------------- experimental/computeir/Expression.fbs | 222 --- experimental/computeir/Literal.fbs | 184 -- experimental/computeir/Plan.fbs | 28 - experimental/computeir/Relation.fbs | 218 --- 14 files changed, 7699 deletions(-) delete mode 100644 cpp/src/arrow/compute/exec/ir_consumer.cc delete mode 100644 cpp/src/arrow/compute/exec/ir_consumer.h delete mode 100644 cpp/src/arrow/compute/exec/ir_test.cc delete mode 100644 cpp/src/generated/Expression_generated.h delete mode 100644 cpp/src/generated/Literal_generated.h delete mode 100644 cpp/src/generated/Plan_generated.h delete mode 100644 cpp/src/generated/Relation_generated.h delete mode 100644 experimental/computeir/Expression.fbs delete mode 100644 experimental/computeir/Literal.fbs delete mode 100644 experimental/computeir/Plan.fbs delete mode 100644 experimental/computeir/Relation.fbs diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index 93dd1297bd744..5070d22fc5524 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -395,7 +395,6 @@ if(ARROW_COMPUTE) compute/exec/hash_join.cc compute/exec/hash_join_dict.cc compute/exec/hash_join_node.cc - compute/exec/ir_consumer.cc compute/exec/key_hash.cc compute/exec/key_map.cc compute/exec/order_by_impl.cc diff --git a/cpp/src/arrow/compute/exec/CMakeLists.txt b/cpp/src/arrow/compute/exec/CMakeLists.txt index d59cb30986b56..4ce73359d0f1f 100644 --- a/cpp/src/arrow/compute/exec/CMakeLists.txt +++ b/cpp/src/arrow/compute/exec/CMakeLists.txt @@ -78,11 +78,3 @@ if(ARROW_BUILD_OPENMP_BENCHMARKS) PRIVATE "-openmp:experimental -openmp:llvm") endif() endif() - -add_arrow_compute_test(ir_test - PREFIX - "arrow-compute" - EXTRA_LINK_LIBS - ${GFLAGS_LIBRARIES} - TEST_ARGUMENTS - "--computeir_dir=${CMAKE_SOURCE_DIR}/../experimental/computeir") diff --git a/cpp/src/arrow/compute/exec/ir_consumer.cc b/cpp/src/arrow/compute/exec/ir_consumer.cc deleted file mode 100644 index f17dbf1ed7962..0000000000000 --- a/cpp/src/arrow/compute/exec/ir_consumer.cc +++ /dev/null @@ -1,660 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#include "arrow/compute/exec/ir_consumer.h" - -#include "arrow/array/array_nested.h" -#include "arrow/array/builder_base.h" -#include "arrow/compute/cast.h" -#include "arrow/compute/exec/exec_plan.h" -#include "arrow/compute/exec/expression.h" -#include "arrow/compute/exec/options.h" -#include "arrow/compute/function_internal.h" -#include "arrow/ipc/dictionary.h" -#include "arrow/ipc/metadata_internal.h" -#include "arrow/util/unreachable.h" -#include "arrow/visit_type_inline.h" - -#include "generated/Plan_generated.h" - -namespace arrow { - -using internal::checked_cast; - -namespace compute { - -static inline Status UnexpectedNullField(const char* name) { - return Status::IOError("Unexpected null field ", name, " in flatbuffer-encoded IR"); -} - -Result> Convert(const flatbuf::Field& f) { - std::string name = ipc::internal::StringFromFlatbuffers(f.name()); - - FieldVector fields; - if (auto children = f.children()) { - fields.resize(children->size()); - int i = 0; - for (const flatbuf::Field* child : *children) { - if (child) return UnexpectedNullField("Field.children[i]"); - ARROW_ASSIGN_OR_RAISE(fields[i++], Convert(*child)); - } - } - - if (!f.type()) return UnexpectedNullField("Field.type"); - - std::shared_ptr type; - RETURN_NOT_OK(ipc::internal::ConcreteTypeFromFlatbuffer(f.type_type(), f.type(), - std::move(fields), &type)); - - std::shared_ptr metadata; - RETURN_NOT_OK(ipc::internal::GetKeyValueMetadata(f.custom_metadata(), &metadata)); - - return field(std::move(name), std::move(type), f.nullable(), std::move(metadata)); -} - -std::string LabelFromRelId(const ir::RelId* id) { - return id ? std::to_string(id->id()) : ""; -} - -Result> BufferFromFlatbufferByteVector( - const flatbuffers::Vector* vec) { - if (!vec) return nullptr; - - ARROW_ASSIGN_OR_RAISE(auto buf, AllocateBuffer(vec->size())); - - if (!vec->data()) return UnexpectedNullField("Vector.data"); - std::memcpy(buf->mutable_data(), vec->data(), vec->size()); - - return std::move(buf); -} - -Result Convert(const ir::Literal& lit); - -struct ConvertLiteralImpl { - Result Convert(const BooleanType& t) { return ValueOf(t); } - - Result Convert(const Int8Type& t) { return ValueOf(t); } - Result Convert(const Int16Type& t) { return ValueOf(t); } - Result Convert(const Int32Type& t) { return ValueOf(t); } - Result Convert(const Int64Type& t) { return ValueOf(t); } - - Result Convert(const UInt8Type& t) { return ValueOf(t); } - Result Convert(const UInt16Type& t) { return ValueOf(t); } - Result Convert(const UInt32Type& t) { return ValueOf(t); } - Result Convert(const UInt64Type& t) { return ValueOf(t); } - - Result Convert(const HalfFloatType& t) { return ValueOf(t); } - Result Convert(const FloatType& t) { return ValueOf(t); } - Result Convert(const DoubleType& t) { return ValueOf(t); } - - Result Convert(const Date32Type& t) { return ValueOf(t); } - Result Convert(const Date64Type& t) { return ValueOf(t); } - Result Convert(const Time32Type& t) { return ValueOf(t); } - Result Convert(const Time64Type& t) { return ValueOf(t); } - Result Convert(const DurationType& t) { return ValueOf(t); } - Result Convert(const TimestampType& t) { - return ValueOf(t); - } - - Result Convert(const IntervalType& t) { - ARROW_ASSIGN_OR_RAISE(auto lit, GetLiteral()); - - if (!lit->value()) return UnexpectedNullField("IntervalLiteral.value"); - switch (t.interval_type()) { - case IntervalType::MONTHS: - if (auto value = lit->value_as()) { - return Datum(std::make_shared(value->months())); - } - break; - - case IntervalType::DAY_TIME: - if (auto value = lit->value_as()) { - DayTimeIntervalType::DayMilliseconds day_ms{value->days(), - value->milliseconds()}; - return Datum(std::make_shared(day_ms)); - } - break; - - case IntervalType::MONTH_DAY_NANO: - return Status::NotImplemented( - "IntervalLiteral with interval_type=MONTH_DAY_NANO"); - } - - return Status::IOError("IntervalLiteral.type was ", t.ToString(), - " but IntervalLiteral.value had value_type ", - ir::EnumNameIntervalLiteralImpl(lit->value_type())); - } - - Result Convert(const DecimalType& t) { - ARROW_ASSIGN_OR_RAISE(auto lit, GetLiteral()); - - if (!lit->value()) return UnexpectedNullField("DecimalLiteral.value"); - if (static_cast(lit->value()->size()) != t.byte_width()) { - return Status::IOError("DecimalLiteral.type was ", t.ToString(), - " (expected byte width ", t.byte_width(), ")", - " but DecimalLiteral.value had size ", lit->value()->size()); - } - - switch (t.id()) { - case Type::DECIMAL128: { - std::array little_endian; - std::memcpy(little_endian.data(), lit->value(), lit->value()->size()); - Decimal128 value{BasicDecimal128::LittleEndianArray, little_endian}; - return Datum(std::make_shared(value, type_)); - } - - case Type::DECIMAL256: { - std::array little_endian; - std::memcpy(little_endian.data(), lit->value(), lit->value()->size()); - Decimal256 value{BasicDecimal256::LittleEndianArray, little_endian}; - return Datum(std::make_shared(value, type_)); - } - - default: - break; - } - - Unreachable(); - } - - Result Convert(const ListType&) { - ARROW_ASSIGN_OR_RAISE(auto lit, GetLiteral()); - - if (!lit->values()) return UnexpectedNullField("ListLiteral.values"); - ScalarVector values{lit->values()->size()}; - - int i = 0; - for (const ir::Literal* v : *lit->values()) { - if (!v) return UnexpectedNullField("ListLiteral.values[i]"); - ARROW_ASSIGN_OR_RAISE(Datum value, arrow::compute::Convert(*v)); - values[i++] = value.scalar(); - } - - std::unique_ptr builder; - RETURN_NOT_OK(MakeBuilder(default_memory_pool(), type_, &builder)); - RETURN_NOT_OK(builder->AppendScalars(std::move(values))); - ARROW_ASSIGN_OR_RAISE(auto arr, builder->Finish()); - return Datum(std::make_shared(std::move(arr), type_)); - } - - Result Convert(const MapType& t) { - ARROW_ASSIGN_OR_RAISE(auto lit, GetLiteral()); - - if (!lit->values()) return UnexpectedNullField("MapLiteral.values"); - ScalarVector keys{lit->values()->size()}, values{lit->values()->size()}; - - int i = 0; - for (const ir::KeyValue* kv : *lit->values()) { - if (!kv) return UnexpectedNullField("MapLiteral.values[i]"); - ARROW_ASSIGN_OR_RAISE(Datum key, arrow::compute::Convert(*kv->value())); - ARROW_ASSIGN_OR_RAISE(Datum value, arrow::compute::Convert(*kv->value())); - keys[i] = key.scalar(); - values[i] = value.scalar(); - ++i; - } - - ArrayVector kv_arrays(2); - std::unique_ptr builder; - RETURN_NOT_OK(MakeBuilder(default_memory_pool(), t.key_type(), &builder)); - RETURN_NOT_OK(builder->AppendScalars(std::move(keys))); - ARROW_ASSIGN_OR_RAISE(kv_arrays[0], builder->Finish()); - - RETURN_NOT_OK(MakeBuilder(default_memory_pool(), t.value_type(), &builder)); - RETURN_NOT_OK(builder->AppendScalars(std::move(values))); - ARROW_ASSIGN_OR_RAISE(kv_arrays[1], builder->Finish()); - - ARROW_ASSIGN_OR_RAISE(auto item_arr, - StructArray::Make(kv_arrays, t.value_type()->fields())); - return Datum(std::make_shared(std::move(item_arr), type_)); - } - - Result Convert(const StructType& t) { - ARROW_ASSIGN_OR_RAISE(auto lit, GetLiteral()); - if (!lit->values()) return UnexpectedNullField("StructLiteral.values"); - if (static_cast(lit->values()->size()) != t.num_fields()) { - return Status::IOError( - "StructLiteral.type was ", t.ToString(), "(expected ", t.num_fields(), - " fields)", " but StructLiteral.values has size ", lit->values()->size()); - } - - ScalarVector values{lit->values()->size()}; - int i = 0; - for (const ir::Literal* v : *lit->values()) { - if (!v) return UnexpectedNullField("StructLiteral.values[i]"); - ARROW_ASSIGN_OR_RAISE(Datum value, arrow::compute::Convert(*v)); - if (!value.type()->Equals(*t.field(i)->type())) { - return Status::IOError("StructLiteral.type was ", t.ToString(), " but value ", i, - " had type ", value.type()->ToString(), "(expected ", - t.field(i)->type()->ToString(), ")"); - } - values[i++] = value.scalar(); - } - - return Datum(std::make_shared(std::move(values), type_)); - } - - Result Convert(const StringType&) { - ARROW_ASSIGN_OR_RAISE(auto lit, GetLiteral()); - if (!lit->value()) return UnexpectedNullField("StringLiteral.value"); - - return Datum(ipc::internal::StringFromFlatbuffers(lit->value())); - } - - Result Convert(const BinaryType&) { - ARROW_ASSIGN_OR_RAISE(auto lit, GetLiteral()); - if (!lit->value()) return UnexpectedNullField("BinaryLiteral.value"); - - ARROW_ASSIGN_OR_RAISE(auto buf, BufferFromFlatbufferByteVector(lit->value())); - return Datum(std::make_shared(std::move(buf))); - } - - Result Convert(const FixedSizeBinaryType& t) { - ARROW_ASSIGN_OR_RAISE(auto lit, GetLiteral()); - if (!lit->value()) return UnexpectedNullField("FixedSizeBinaryLiteral.value"); - - if (static_cast(lit->value()->size()) != t.byte_width()) { - return Status::IOError("FixedSizeBinaryLiteral.type was ", t.ToString(), - " but FixedSizeBinaryLiteral.value had size ", - lit->value()->size()); - } - - ARROW_ASSIGN_OR_RAISE(auto buf, BufferFromFlatbufferByteVector(lit->value())); - return Datum(std::make_shared(std::move(buf), type_)); - } - - Status Visit(const NullType&) { Unreachable(); } - - Status NotImplemented() { - return Status::NotImplemented("Literals of type ", type_->ToString()); - } - Status Visit(const ExtensionType& t) { return NotImplemented(); } - Status Visit(const SparseUnionType& t) { return NotImplemented(); } - Status Visit(const DenseUnionType& t) { return NotImplemented(); } - Status Visit(const FixedSizeListType& t) { return NotImplemented(); } - Status Visit(const DictionaryType& t) { return NotImplemented(); } - Status Visit(const LargeStringType& t) { return NotImplemented(); } - Status Visit(const LargeBinaryType& t) { return NotImplemented(); } - Status Visit(const LargeListType& t) { return NotImplemented(); } - - template - Status Visit(const T& t) { - ARROW_ASSIGN_OR_RAISE(out_, Convert(t)); - return Status::OK(); - } - - template - Result GetLiteral() { - if (const Lit* l = lit_.impl_as()) return l; - - return Status::IOError( - "Literal.type was ", type_->ToString(), " but got ", - ir::EnumNameLiteralImpl(ir::LiteralImplTraits::enum_value), " Literal.impl"); - } - - template ::ScalarType, - typename ValueType = typename ScalarType::ValueType> - Result ValueOf(const T&) { - ARROW_ASSIGN_OR_RAISE(auto lit, GetLiteral()); - auto scalar = - std::make_shared(static_cast(lit->value()), type_); - return Datum(std::move(scalar)); - } - - Datum out_; - const std::shared_ptr& type_; - const ir::Literal& lit_; -}; - -Result Convert(const ir::Literal& lit) { - if (!lit.type()) return UnexpectedNullField("Literal.type"); - if (lit.type()->name()) { - return Status::IOError("Literal.type should have null Field.name"); - } - - ARROW_ASSIGN_OR_RAISE(auto field, Convert(*lit.type())); - if (!lit.impl()) return MakeNullScalar(field->type()); - - if (field->type()->id() == Type::NA) { - return Status::IOError("Literal of type null had non-null Literal.impl"); - } - - ConvertLiteralImpl visitor{{}, field->type(), lit}; - RETURN_NOT_OK(VisitTypeInline(*field->type(), &visitor)); - return std::move(visitor.out_); -} - -Result Convert(const ir::FieldRef& ref) { - switch (ref.ref_type()) { - case ir::Deref::StructField: - return FieldRef(ref.ref_as()->position()); - - case ir::Deref::FieldIndex: - return FieldRef(ref.ref_as()->position()); - - case ir::Deref::MapKey: - case ir::Deref::ArraySubscript: - case ir::Deref::ArraySlice: - default: - break; - } - return Status::NotImplemented("Deref::", EnumNameDeref(ref.ref_type())); -} - -Result Convert(const ir::Expression& expr); - -Result, std::vector>> Convert( - const flatbuffers::Vector>& cases) { - std::vector conditions(cases.size()), arguments(cases.size()); - - int i = 0; - for (const ir::CaseFragment* c : cases) { - if (!c) return UnexpectedNullField("Vector[i]"); - ARROW_ASSIGN_OR_RAISE(conditions[i], Convert(*c->match())); - ARROW_ASSIGN_OR_RAISE(arguments[i], Convert(*c->result())); - ++i; - } - - return std::make_pair(std::move(conditions), std::move(arguments)); -} - -Expression CaseWhen(std::vector conditions, std::vector arguments, - Expression default_value) { - arguments.insert(arguments.begin(), call("make_struct", std::move(conditions))); - arguments.push_back(std::move(default_value)); - return call("case_when", std::move(arguments)); -} - -Result Convert(const ir::Expression& expr) { - switch (expr.impl_type()) { - case ir::ExpressionImpl::Literal: { - ARROW_ASSIGN_OR_RAISE(Datum value, Convert(*expr.impl_as())); - return literal(std::move(value)); - } - - case ir::ExpressionImpl::FieldRef: { - ARROW_ASSIGN_OR_RAISE(FieldRef ref, Convert(*expr.impl_as())); - return field_ref(std::move(ref)); - } - - case ir::ExpressionImpl::Call: { - auto call = expr.impl_as(); - - if (!call->name()) return UnexpectedNullField("Call.name"); - auto name = ipc::internal::StringFromFlatbuffers(call->name()); - - if (!call->arguments()) return UnexpectedNullField("Call.arguments"); - std::vector arguments(call->arguments()->size()); - - int i = 0; - for (const ir::Expression* a : *call->arguments()) { - if (!a) return UnexpectedNullField("Call.arguments[i]"); - ARROW_ASSIGN_OR_RAISE(arguments[i++], Convert(*a)); - } - - // What about options...? - return arrow::compute::call(std::move(name), std::move(arguments)); - } - - case ir::ExpressionImpl::Cast: { - auto cast = expr.impl_as(); - - if (!cast->operand()) return UnexpectedNullField("Cast.operand"); - ARROW_ASSIGN_OR_RAISE(Expression arg, Convert(*cast->operand())); - - if (!cast->to()) return UnexpectedNullField("Cast.to"); - ARROW_ASSIGN_OR_RAISE(auto to, Convert(*cast->to())); - - return call("cast", {std::move(arg)}, CastOptions::Safe(to->type())); - } - - case ir::ExpressionImpl::ConditionalCase: { - auto conditional_case = expr.impl_as(); - - if (!conditional_case->conditions()) { - return UnexpectedNullField("ConditionalCase.conditions"); - } - ARROW_ASSIGN_OR_RAISE(auto cases, Convert(*conditional_case->conditions())); - - if (!conditional_case->else_()) return UnexpectedNullField("ConditionalCase.else"); - ARROW_ASSIGN_OR_RAISE(auto default_value, Convert(*conditional_case->else_())); - - return CaseWhen(std::move(cases.first), std::move(cases.second), - std::move(default_value)); - } - - case ir::ExpressionImpl::SimpleCase: { - auto simple_case = expr.impl_as(); - auto expression = simple_case->expression(); - auto matches = simple_case->matches(); - auto else_ = simple_case->else_(); - - if (!expression) return UnexpectedNullField("SimpleCase.expression"); - ARROW_ASSIGN_OR_RAISE(auto rhs, Convert(*expression)); - - if (!matches) return UnexpectedNullField("SimpleCase.matches"); - ARROW_ASSIGN_OR_RAISE(auto cases, Convert(*simple_case->matches())); - - // replace each condition with an equality expression with the rhs - for (auto& condition : cases.first) { - condition = equal(std::move(condition), rhs); - } - - if (!else_) return UnexpectedNullField("SimpleCase.else"); - ARROW_ASSIGN_OR_RAISE(auto default_value, Convert(*simple_case->else_())); - - return CaseWhen(std::move(cases.first), std::move(cases.second), - std::move(default_value)); - } - - case ir::ExpressionImpl::WindowCall: - default: - break; - } - - return Status::NotImplemented("ExpressionImpl::", - EnumNameExpressionImpl(expr.impl_type())); -} - -Result Convert(const ir::Relation& rel) { - switch (rel.impl_type()) { - case ir::RelationImpl::Source: { - auto source = rel.impl_as(); - - if (!source->name()) return UnexpectedNullField("Source.name"); - auto name = ipc::internal::StringFromFlatbuffers(source->name()); - - std::shared_ptr schema; - if (source->schema()) { - ipc::DictionaryMemo ignore; - RETURN_NOT_OK(ipc::internal::GetSchema(source->schema(), &ignore, &schema)); - } - - return Declaration{"catalog_source", - {}, - CatalogSourceNodeOptions{std::move(name), std::move(schema)}, - LabelFromRelId(source->id())}; - } - - case ir::RelationImpl::Filter: { - auto filter = rel.impl_as(); - - if (!filter->predicate()) return UnexpectedNullField("Filter.predicate"); - ARROW_ASSIGN_OR_RAISE(auto predicate, Convert(*filter->predicate())); - - if (!filter->rel()) return UnexpectedNullField("Filter.rel"); - ARROW_ASSIGN_OR_RAISE(auto arg, Convert(*filter->rel()).As()); - - return Declaration{"filter", - {std::move(arg)}, - FilterNodeOptions{std::move(predicate)}, - LabelFromRelId(filter->id())}; - } - - case ir::RelationImpl::Project: { - auto project = rel.impl_as(); - - if (!project->rel()) return UnexpectedNullField("Project.rel"); - ARROW_ASSIGN_OR_RAISE(auto arg, Convert(*project->rel()).As()); - - ProjectNodeOptions opts{{}}; - - if (!project->expressions()) return UnexpectedNullField("Project.expressions"); - for (const ir::Expression* expression : *project->expressions()) { - if (!expression) return UnexpectedNullField("Project.expressions[i]"); - ARROW_ASSIGN_OR_RAISE(auto expr, Convert(*expression)); - opts.expressions.push_back(std::move(expr)); - } - - return Declaration{ - "project", {std::move(arg)}, std::move(opts), LabelFromRelId(project->id())}; - } - - case ir::RelationImpl::Aggregate: { - auto aggregate = rel.impl_as(); - - if (!aggregate->rel()) return UnexpectedNullField("Aggregate.rel"); - ARROW_ASSIGN_OR_RAISE(auto arg, - Convert(*aggregate->rel()).As()); - - AggregateNodeOptions opts{{}, {}}; - - if (!aggregate->measures()) return UnexpectedNullField("Aggregate.measures"); - for (const ir::Expression* m : *aggregate->measures()) { - if (!m) return UnexpectedNullField("Aggregate.measures[i]"); - ARROW_ASSIGN_OR_RAISE(auto measure, Convert(*m)); - - auto call = measure.call(); - if (!call || call->arguments.size() != 1) { - return Status::IOError("One of Aggregate.measures was ", measure.ToString(), - " (expected Expression::Call with one argument)"); - } - - auto target = call->arguments.front().field_ref(); - if (!target) { - return Status::NotImplemented( - "Support for non-FieldRef arguments to Aggregate.measures"); - } - - opts.aggregates.push_back({call->function_name, nullptr, *target, - call->function_name + " " + target->ToString()}); - } - - if (!aggregate->groupings()) return UnexpectedNullField("Aggregate.groupings"); - if (aggregate->groupings()->size() > 1) { - return Status::NotImplemented("Support for multiple grouping sets"); - } - - if (aggregate->groupings()->size() == 1) { - if (!aggregate->groupings()->Get(0)) { - return UnexpectedNullField("Aggregate.groupings[0]"); - } - - if (!aggregate->groupings()->Get(0)->keys()) { - return UnexpectedNullField("Grouping.keys"); - } - - for (const ir::Expression* key : *aggregate->groupings()->Get(0)->keys()) { - if (!key) return UnexpectedNullField("Grouping.keys[i]"); - ARROW_ASSIGN_OR_RAISE(auto key_expr, Convert(*key)); - - auto key_ref = key_expr.field_ref(); - if (!key_ref) { - return Status::NotImplemented("Support for non-FieldRef grouping keys"); - } - opts.keys.push_back(*key_ref); - } - } - - return Declaration{"aggregate", - {std::move(arg)}, - std::move(opts), - LabelFromRelId(aggregate->id())}; - } - - case ir::RelationImpl::OrderBy: { - auto order_by = rel.impl_as(); - - if (!order_by->rel()) return UnexpectedNullField("OrderBy.rel"); - ARROW_ASSIGN_OR_RAISE(auto arg, Convert(*order_by->rel()).As()); - - if (!order_by->keys()) return UnexpectedNullField("OrderBy.keys"); - if (order_by->keys()->size() == 0) { - return Status::NotImplemented("Empty sort key list"); - } - - util::optional null_placement; - std::vector sort_keys; - - for (const ir::SortKey* key : *order_by->keys()) { - if (!key) return UnexpectedNullField("OrderBy.keys[i]"); - ARROW_ASSIGN_OR_RAISE(auto expr, Convert(*key->expression())); - - auto target = expr.field_ref(); - if (!target) { - return Status::NotImplemented( - "Support for non-FieldRef expressions in SortKey"); - } - if (target->IsNested()) { - return Status::NotImplemented( - "Support for nested FieldRef expressions in SortKey"); - } - switch (key->ordering()) { - case ir::Ordering::ASCENDING_THEN_NULLS: - case ir::Ordering::NULLS_THEN_ASCENDING: - sort_keys.emplace_back(*target, SortOrder::Ascending); - break; - case ir::Ordering::DESCENDING_THEN_NULLS: - case ir::Ordering::NULLS_THEN_DESCENDING: - sort_keys.emplace_back(*target, SortOrder::Descending); - break; - } - - NullPlacement key_null_placement{}; - switch (key->ordering()) { - case ir::Ordering::ASCENDING_THEN_NULLS: - case ir::Ordering::DESCENDING_THEN_NULLS: - key_null_placement = NullPlacement::AtEnd; - break; - case ir::Ordering::NULLS_THEN_ASCENDING: - case ir::Ordering::NULLS_THEN_DESCENDING: - key_null_placement = NullPlacement::AtStart; - break; - } - - if (null_placement && *null_placement != key_null_placement) { - return Status::NotImplemented("Per-key null_placement"); - } - null_placement = key_null_placement; - } - - return Declaration{"order_by_sink", - {std::move(arg)}, - OrderBySinkNodeOptions{ - SortOptions{std::move(sort_keys), *null_placement}, nullptr}, - LabelFromRelId(order_by->id())}; - } - - default: - break; - } - - return Status::NotImplemented("RelationImpl::", EnumNameRelationImpl(rel.impl_type())); -} - -} // namespace compute -} // namespace arrow diff --git a/cpp/src/arrow/compute/exec/ir_consumer.h b/cpp/src/arrow/compute/exec/ir_consumer.h deleted file mode 100644 index 5af27f98f58fe..0000000000000 --- a/cpp/src/arrow/compute/exec/ir_consumer.h +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include - -#include "arrow/compute/exec/exec_plan.h" -#include "arrow/compute/exec/expression.h" -#include "arrow/compute/exec/options.h" -#include "arrow/datum.h" -#include "arrow/result.h" -#include "arrow/util/visibility.h" - -#include "generated/Plan_generated.h" - -namespace arrow { - -namespace flatbuf = org::apache::arrow::flatbuf; - -namespace compute { - -namespace ir = org::apache::arrow::computeir::flatbuf; - -class ARROW_EXPORT CatalogSourceNodeOptions : public ExecNodeOptions { - public: - CatalogSourceNodeOptions(std::string name, std::shared_ptr schema, - Expression filter = literal(true), - std::vector projection = {}) - : name(std::move(name)), - schema(std::move(schema)), - filter(std::move(filter)), - projection(std::move(projection)) {} - - std::string name; - std::shared_ptr schema; - Expression filter; - std::vector projection; -}; - -ARROW_EXPORT -Result Convert(const ir::Literal& lit); - -ARROW_EXPORT -Result Convert(const ir::Expression& lit); - -ARROW_EXPORT -Result Convert(const ir::Relation& rel); - -template -auto ConvertRoot(const Buffer& buf) -> decltype(Convert(std::declval())) { - return Convert(*flatbuffers::GetRoot(buf.data())); -} - -} // namespace compute -} // namespace arrow diff --git a/cpp/src/arrow/compute/exec/ir_test.cc b/cpp/src/arrow/compute/exec/ir_test.cc deleted file mode 100644 index d7eb37c185e13..0000000000000 --- a/cpp/src/arrow/compute/exec/ir_test.cc +++ /dev/null @@ -1,829 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#include "arrow/compute/exec/ir_consumer.h" - -#include - -#include - -#include "arrow/compute/exec/options.h" -#include "arrow/compute/exec/test_util.h" -#include "arrow/io/file.h" -#include "arrow/testing/matchers.h" -#include "arrow/util/io_util.h" -#include "arrow/util/string_view.h" - -#include "generated/Plan_generated.h" - -using testing::ElementsAre; -using testing::ElementsAreArray; -using testing::Eq; -using testing::HasSubstr; -using testing::Optional; -using testing::UnorderedElementsAreArray; - -namespace ir = org::apache::arrow::computeir::flatbuf; -namespace flatbuf = org::apache::arrow::flatbuf; - -DEFINE_string(computeir_dir, "", - "Directory containing Flatbuffer schemas for Arrow compute IR.\n" - "This is currently $ARROW_REPO/experimental/computeir/"); - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - gflags::ParseCommandLineFlags(&argc, &argv, true); - - if (std::system("flatc --version") != 0) { - std::cout << "flatc not available, skipping tests" << std::endl; - return 0; - } - - int ret = RUN_ALL_TESTS(); - gflags::ShutDownCommandLineFlags(); - return ret; -} - -namespace arrow { -namespace compute { - -std::shared_ptr FlatbufferFromJSON(std::string root_type, - util::string_view json) { - static std::unique_ptr dir; - - if (!dir) { - if (FLAGS_computeir_dir == "") { - std::cout << "Required argument -computeir_dir was not provided!" << std::endl; - std::abort(); - } - - dir = *arrow::internal::TemporaryDir::Make("ir_json_"); - } - - auto json_path = dir->path().ToString() + "ir.json"; - std::ofstream{json_path} << json; - - std::string cmd = "flatc --binary " + FLAGS_computeir_dir + "/Plan.fbs" + - " --root-type org.apache.arrow.computeir.flatbuf." + root_type + " " + - json_path; - - if (int err = std::system(cmd.c_str())) { - std::cerr << cmd << " failed with error code: " << err; - std::abort(); - } - - auto bin = *io::MemoryMappedFile::Open("ir.bin", io::FileMode::READ); - return *bin->Read(*bin->GetSize()); -} - -template -auto ConvertJSON(util::string_view json) -> decltype(Convert(std::declval())) { - std::string root_type; - if (std::is_same::value) { - root_type = "Literal"; - } else if (std::is_same::value) { - root_type = "Expression"; - } else if (std::is_same::value) { - root_type = "Relation"; - } else if (std::is_same::value) { - root_type = "Plan"; - } else { - std::cout << "Unknown Ir class in."; - std::abort(); - } - - auto buf = FlatbufferFromJSON(root_type, json); - return ConvertRoot(*buf); -} - -TEST(Literal, Int64) { - ASSERT_THAT(ConvertJSON(R"({ - type: { - type_type: "Int", - type: { bitWidth: 64, is_signed: true } - } - })"), - ResultWith(DataEq(std::make_shared()))); - - ASSERT_THAT(ConvertJSON(R"({ - type: { - type_type: "Int", - type: { bitWidth: 64, is_signed: true } - }, - impl_type: "Int64Literal", - impl: { value: 42 } - })"), - ResultWith(DataEq(42))); -} - -TEST(Expression, Comparison) { - ASSERT_THAT(ConvertJSON(R"({ - impl_type: "Call", - impl: { - name: "equal", - arguments: [ - { - impl_type: "FieldRef", - impl: { - ref_type: "FieldIndex", - ref: { - position: 2 - } - } - }, - { - impl_type: "Literal", - impl: { - type: { - type_type: "Int", - type: { bitWidth: 64, is_signed: true } - }, - impl_type: "Int64Literal", - impl: { value: 42 } - } - } - ] - } - })"), - ResultWith(Eq(equal(field_ref(2), literal(42))))); -} - -TEST(Relation, Filter) { - ASSERT_THAT( - ConvertJSON(R"({ - impl_type: "Filter", - impl: { - id: { id: 1 }, - rel: { - impl_type: "Source", - impl: { - id: { id: 0 }, - name: "test source", - schema: { - endianness: "Little", - fields: [ - { - name: "i32", - type_type: "Int", - type: { - bitWidth: 32, - is_signed: true - }, - nullable: true - }, - { - name: "f64", - type_type: "FloatingPoint", - type: { - precision: "DOUBLE" - }, - nullable: true - }, - { - name: "i64", - type_type: "Int", - type: { - bitWidth: 64, - is_signed: true - }, - nullable: true - } - ] - } - } - }, - predicate: { - impl_type: "Call", - impl: { - name: "equal", - arguments: [ - { - impl_type: "FieldRef", - impl: { - ref_type: "FieldIndex", - ref: { - position: 2 - } - } - }, - { - impl_type: "Literal", - impl: { - type: { - type_type: "Int", - type: { bitWidth: 64, is_signed: true } - }, - impl_type: "Int64Literal", - impl: { value: 42 } - } - } - ] - } - } - } - })"), - ResultWith(Eq(Declaration::Sequence({ - {"catalog_source", - CatalogSourceNodeOptions{"test source", schema({ - field("i32", int32()), - field("f64", float64()), - field("i64", int64()), - })}, - "0"}, - {"filter", FilterNodeOptions{equal(field_ref(2), literal(42))}, "1"}, - })))); -} - -TEST(Relation, AggregateSimple) { - ASSERT_THAT( - ConvertJSON(R"({ - "impl": { - id: {id: 1}, - "groupings": [ - { - "keys": [ - { - "impl": { - "ref": { - "position": 0 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - } - ] - } - ], - "measures": [ - { - "impl": { - "arguments": [ - { - "impl": { - "ref": { - "position": 1 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - } - ], - "name": "sum" - }, - "impl_type": "Call" - }, - { - "impl": { - "arguments": [ - { - "impl": { - "ref": { - "position": 2 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - } - ], - "name": "mean" - }, - "impl_type": "Call" - } - ], - "rel": { - "impl": { - id: {id: 0}, - "name": "tbl", - "schema": { - "endianness": "Little", - "fields": [ - { - "name": "foo", - "nullable": true, - "type": { - "bitWidth": 32, - "is_signed": true - }, - "type_type": "Int" - }, - { - "name": "bar", - "nullable": true, - "type": { - "bitWidth": 64, - "is_signed": true - }, - "type_type": "Int" - }, - { - "name": "baz", - "nullable": true, - "type": { - "precision": "DOUBLE" - }, - "type_type": "FloatingPoint" - } - ] - } - }, - "impl_type": "Source" - } - }, - "impl_type": "Aggregate" -})"), - ResultWith(Eq(Declaration::Sequence({ - {"catalog_source", - CatalogSourceNodeOptions{"tbl", schema({ - field("foo", int32()), - field("bar", int64()), - field("baz", float64()), - })}, - "0"}, - {"aggregate", - AggregateNodeOptions{/*aggregates=*/{ - {"sum", nullptr, 1, "sum FieldRef.FieldPath(1)"}, - {"mean", nullptr, 2, "mean FieldRef.FieldPath(2)"}, - }, - /*keys=*/{0}}, - "1"}, - })))); -} - -TEST(Relation, AggregateWithHaving) { - ASSERT_THAT( - ConvertJSON(R"({ - "impl": { - id: {id: 3}, - "predicate": { - "impl": { - "arguments": [ - { - "impl": { - "ref": { - "position": 0 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - }, - { - "impl": { - "impl": { - "value": 10 - }, - "impl_type": "Int8Literal", - "type": { - "nullable": true, - "type": { - "bitWidth": 8, - "is_signed": true - }, - "type_type": "Int" - } - }, - "impl_type": "Literal" - } - ], - "name": "greater" - }, - "impl_type": "Call" - }, - "rel": { - "impl": { - id: {id: 2}, - "groupings": [ - { - "keys": [ - { - "impl": { - "ref": { - "position": 0 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - } - ] - } - ], - "measures": [ - { - "impl": { - "arguments": [ - { - "impl": { - "ref": { - "position": 1 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - } - ], - "name": "sum" - }, - "impl_type": "Call" - }, - { - "impl": { - "arguments": [ - { - "impl": { - "ref": { - "position": 2 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - } - ], - "name": "mean" - }, - "impl_type": "Call" - } - ], - "rel": { - "impl": { - id: {id: 1}, - "predicate": { - "impl": { - "arguments": [ - { - "impl": { - "ref": { - "position": 0 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - }, - { - "impl": { - "impl": { - "value": 3 - }, - "impl_type": "Int8Literal", - "type": { - "nullable": true, - "type": { - "bitWidth": 8, - "is_signed": true - }, - "type_type": "Int" - } - }, - "impl_type": "Literal" - } - ], - "name": "less" - }, - "impl_type": "Call" - }, - "rel": { - "impl": { - id: {id: 0}, - "name": "tbl", - "schema": { - "endianness": "Little", - "fields": [ - { - "name": "foo", - "nullable": true, - "type": { - "bitWidth": 32, - "is_signed": true - }, - "type_type": "Int" - }, - { - "name": "bar", - "nullable": true, - "type": { - "bitWidth": 64, - "is_signed": true - }, - "type_type": "Int" - }, - { - "name": "baz", - "nullable": true, - "type": { - "precision": "DOUBLE" - }, - "type_type": "FloatingPoint" - } - ] - } - }, - "impl_type": "Source" - } - }, - "impl_type": "Filter" - } - }, - "impl_type": "Aggregate" - } - }, - "impl_type": "Filter" -})"), - ResultWith(Eq(Declaration::Sequence({ - {"catalog_source", - CatalogSourceNodeOptions{"tbl", schema({ - field("foo", int32()), - field("bar", int64()), - field("baz", float64()), - })}, - "0"}, - {"filter", FilterNodeOptions{less(field_ref(0), literal(3))}, "1"}, - {"aggregate", - AggregateNodeOptions{/*aggregates=*/{ - {"sum", nullptr, 1, "sum FieldRef.FieldPath(1)"}, - {"mean", nullptr, 2, "mean FieldRef.FieldPath(2)"}, - }, - /*keys=*/{0}}, - "2"}, - {"filter", FilterNodeOptions{greater(field_ref(0), literal(10))}, "3"}, - })))); -} - -TEST(Relation, ProjectionWithFilter) { - ASSERT_THAT( - ConvertJSON(R"({ - "impl": { - id: {id:2}, - "predicate": { - "impl": { - "arguments": [ - { - "impl": { - "ref": { - "position": 0 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - }, - { - "impl": { - "impl": { - "value": 3 - }, - "impl_type": "Int8Literal", - "type": { - "nullable": true, - "type": { - "bitWidth": 8, - "is_signed": true - }, - "type_type": "Int" - } - }, - "impl_type": "Literal" - } - ], - "name": "less" - }, - "impl_type": "Call" - }, - "rel": { - "impl": { - id: {id:1}, - "expressions": [ - { - "impl": { - "ref": { - "position": 1 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - }, - { - "impl": { - "ref": { - "position": 2 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - } - ], - "rel": { - "impl": { - id: {id:0}, - "name": "tbl", - "schema": { - "endianness": "Little", - "fields": [ - { - "name": "foo", - "nullable": true, - "type": { - "bitWidth": 32, - "is_signed": true - }, - "type_type": "Int" - }, - { - "name": "bar", - "nullable": true, - "type": { - "bitWidth": 64, - "is_signed": true - }, - "type_type": "Int" - }, - { - "name": "baz", - "nullable": true, - "type": { - "precision": "DOUBLE" - }, - "type_type": "FloatingPoint" - } - ] - } - }, - "impl_type": "Source" - } - }, - "impl_type": "Project" - } - }, - "impl_type": "Filter" -})"), - ResultWith(Eq(Declaration::Sequence({ - {"catalog_source", - CatalogSourceNodeOptions{"tbl", schema({ - field("foo", int32()), - field("bar", int64()), - field("baz", float64()), - })}, - "0"}, - {"project", ProjectNodeOptions{/*expressions=*/{field_ref(1), field_ref(2)}}, - "1"}, - {"filter", FilterNodeOptions{less(field_ref(0), literal(3))}, "2"}, - })))); -} - -TEST(Relation, ProjectionWithSort) { - ASSERT_THAT( - ConvertJSON(R"({ - "impl": { - id: {id:2}, - "keys": [ - { - "expression": { - "impl": { - "ref": { - "position": 0 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - }, - "ordering": "NULLS_THEN_ASCENDING" - }, - { - "expression": { - "impl": { - "ref": { - "position": 1 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - }, - "ordering": "NULLS_THEN_DESCENDING" - } - ], - "rel": { - "impl": { - id: {id:1}, - "expressions": [ - { - "impl": { - "ref": { - "position": 0 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - }, - { - "impl": { - "ref": { - "position": 1 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - }, - { - "impl": { - "ref": { - "position": 2 - }, - "ref_type": "FieldIndex", - "relation_index": 0 - }, - "impl_type": "FieldRef" - } - ], - "rel": { - "impl": { - id: {id: 0}, - "name": "tbl", - "schema": { - "endianness": "Little", - "fields": [ - { - "name": "foo", - "nullable": true, - "type": { - "bitWidth": 32, - "is_signed": true - }, - "type_type": "Int" - }, - { - "name": "bar", - "nullable": true, - "type": { - "bitWidth": 64, - "is_signed": true - }, - "type_type": "Int" - }, - { - "name": "baz", - "nullable": true, - "type": { - "precision": "DOUBLE" - }, - "type_type": "FloatingPoint" - } - ] - } - }, - "impl_type": "Source" - } - }, - "impl_type": "Project" - } - }, - "impl_type": "OrderBy" -})"), - ResultWith(Eq(Declaration::Sequence({ - {"catalog_source", - CatalogSourceNodeOptions{"tbl", schema({ - field("foo", int32()), - field("bar", int64()), - field("baz", float64()), - })}, - "0"}, - {"project", - ProjectNodeOptions{/*expressions=*/{field_ref(0), field_ref(1), field_ref(2)}}, - "1"}, - {"order_by_sink", - OrderBySinkNodeOptions{SortOptions{{ - SortKey{0, SortOrder::Ascending}, - SortKey{1, SortOrder::Descending}, - }, - NullPlacement::AtStart}, - nullptr}, - "2"}, - })))); -} - -} // namespace compute -} // namespace arrow diff --git a/cpp/src/arrow/compute/exec/test_util.cc b/cpp/src/arrow/compute/exec/test_util.cc index 7ea515c1c5135..cc26143179a36 100644 --- a/cpp/src/arrow/compute/exec/test_util.cc +++ b/cpp/src/arrow/compute/exec/test_util.cc @@ -33,7 +33,6 @@ #include "arrow/compute/api_vector.h" #include "arrow/compute/exec.h" #include "arrow/compute/exec/exec_plan.h" -#include "arrow/compute/exec/ir_consumer.h" #include "arrow/compute/exec/options.h" #include "arrow/compute/exec/util.h" #include "arrow/compute/function_internal.h" @@ -308,18 +307,6 @@ bool operator==(const Declaration& l, const Declaration& r) { if (l.inputs != r.inputs) return false; if (l.label != r.label) return false; - if (l.factory_name == "catalog_source") { - auto l_opts = &OptionsAs(l); - auto r_opts = &OptionsAs(r); - - bool schemas_equal = l_opts->schema == nullptr - ? r_opts->schema == nullptr - : l_opts->schema->Equals(r_opts->schema); - - return l_opts->name == r_opts->name && schemas_equal && - l_opts->filter == r_opts->filter && l_opts->projection == r_opts->projection; - } - if (l.factory_name == "filter") { return OptionsAs(l).filter_expression == OptionsAs(r).filter_expression; @@ -367,22 +354,6 @@ bool operator==(const Declaration& l, const Declaration& r) { static inline void PrintToImpl(const std::string& factory_name, const ExecNodeOptions& opts, std::ostream* os) { - if (factory_name == "catalog_source") { - auto o = &OptionsAs(opts); - *os << o->name << ", schema=" << o->schema->ToString(); - if (o->filter != literal(true)) { - *os << ", filter=" << o->filter.ToString(); - } - if (!o->projection.empty()) { - *os << ", projection=["; - for (const auto& ref : o->projection) { - *os << ref.ToString() << ","; - } - *os << "]"; - } - return; - } - if (factory_name == "filter") { return PrintTo(OptionsAs(opts).filter_expression, os); } diff --git a/cpp/src/generated/Expression_generated.h b/cpp/src/generated/Expression_generated.h deleted file mode 100644 index 730b001497db8..0000000000000 --- a/cpp/src/generated/Expression_generated.h +++ /dev/null @@ -1,1870 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_EXPRESSION_ORG_APACHE_ARROW_COMPUTEIR_FLATBUF_H_ -#define FLATBUFFERS_GENERATED_EXPRESSION_ORG_APACHE_ARROW_COMPUTEIR_FLATBUF_H_ - -#include "flatbuffers/flatbuffers.h" - -#include "Schema_generated.h" -#include "Literal_generated.h" - -namespace org { -namespace apache { -namespace arrow { -namespace computeir { -namespace flatbuf { - -struct MapKey; -struct MapKeyBuilder; - -struct StructField; -struct StructFieldBuilder; - -struct ArraySubscript; -struct ArraySubscriptBuilder; - -struct ArraySlice; -struct ArraySliceBuilder; - -struct FieldIndex; -struct FieldIndexBuilder; - -struct FieldRef; -struct FieldRefBuilder; - -struct Call; -struct CallBuilder; - -struct CaseFragment; -struct CaseFragmentBuilder; - -struct ConditionalCase; -struct ConditionalCaseBuilder; - -struct SimpleCase; -struct SimpleCaseBuilder; - -struct SortKey; -struct SortKeyBuilder; - -struct Unbounded; -struct UnboundedBuilder; - -struct Preceding; -struct PrecedingBuilder; - -struct Following; -struct FollowingBuilder; - -struct CurrentRow; -struct CurrentRowBuilder; - -struct WindowCall; -struct WindowCallBuilder; - -struct Cast; -struct CastBuilder; - -struct Expression; -struct ExpressionBuilder; - -/// A union of possible dereference operations -enum class Deref : uint8_t { - NONE = 0, - /// Access a value for a given map key - MapKey = 1, - /// Access the value at a struct field - StructField = 2, - /// Access the element at a given index in an array - ArraySubscript = 3, - /// Access a range of elements in an array - ArraySlice = 4, - /// Access a field of a relation - FieldIndex = 5, - MIN = NONE, - MAX = FieldIndex -}; - -inline const Deref (&EnumValuesDeref())[6] { - static const Deref values[] = { - Deref::NONE, - Deref::MapKey, - Deref::StructField, - Deref::ArraySubscript, - Deref::ArraySlice, - Deref::FieldIndex - }; - return values; -} - -inline const char * const *EnumNamesDeref() { - static const char * const names[7] = { - "NONE", - "MapKey", - "StructField", - "ArraySubscript", - "ArraySlice", - "FieldIndex", - nullptr - }; - return names; -} - -inline const char *EnumNameDeref(Deref e) { - if (flatbuffers::IsOutRange(e, Deref::NONE, Deref::FieldIndex)) return ""; - const size_t index = static_cast(e); - return EnumNamesDeref()[index]; -} - -template struct DerefTraits { - static const Deref enum_value = Deref::NONE; -}; - -template<> struct DerefTraits { - static const Deref enum_value = Deref::MapKey; -}; - -template<> struct DerefTraits { - static const Deref enum_value = Deref::StructField; -}; - -template<> struct DerefTraits { - static const Deref enum_value = Deref::ArraySubscript; -}; - -template<> struct DerefTraits { - static const Deref enum_value = Deref::ArraySlice; -}; - -template<> struct DerefTraits { - static const Deref enum_value = Deref::FieldIndex; -}; - -bool VerifyDeref(flatbuffers::Verifier &verifier, const void *obj, Deref type); -bool VerifyDerefVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types); - -/// Whether lesser values should precede greater or vice versa, -/// also whether nulls should preced or follow values -enum class Ordering : uint8_t { - ASCENDING_THEN_NULLS = 0, - DESCENDING_THEN_NULLS = 1, - NULLS_THEN_ASCENDING = 2, - NULLS_THEN_DESCENDING = 3, - MIN = ASCENDING_THEN_NULLS, - MAX = NULLS_THEN_DESCENDING -}; - -inline const Ordering (&EnumValuesOrdering())[4] { - static const Ordering values[] = { - Ordering::ASCENDING_THEN_NULLS, - Ordering::DESCENDING_THEN_NULLS, - Ordering::NULLS_THEN_ASCENDING, - Ordering::NULLS_THEN_DESCENDING - }; - return values; -} - -inline const char * const *EnumNamesOrdering() { - static const char * const names[5] = { - "ASCENDING_THEN_NULLS", - "DESCENDING_THEN_NULLS", - "NULLS_THEN_ASCENDING", - "NULLS_THEN_DESCENDING", - nullptr - }; - return names; -} - -inline const char *EnumNameOrdering(Ordering e) { - if (flatbuffers::IsOutRange(e, Ordering::ASCENDING_THEN_NULLS, Ordering::NULLS_THEN_DESCENDING)) return ""; - const size_t index = static_cast(e); - return EnumNamesOrdering()[index]; -} - -/// A concrete bound, which can be an expression or unbounded -enum class ConcreteBoundImpl : uint8_t { - NONE = 0, - Expression = 1, - Unbounded = 2, - MIN = NONE, - MAX = Unbounded -}; - -inline const ConcreteBoundImpl (&EnumValuesConcreteBoundImpl())[3] { - static const ConcreteBoundImpl values[] = { - ConcreteBoundImpl::NONE, - ConcreteBoundImpl::Expression, - ConcreteBoundImpl::Unbounded - }; - return values; -} - -inline const char * const *EnumNamesConcreteBoundImpl() { - static const char * const names[4] = { - "NONE", - "Expression", - "Unbounded", - nullptr - }; - return names; -} - -inline const char *EnumNameConcreteBoundImpl(ConcreteBoundImpl e) { - if (flatbuffers::IsOutRange(e, ConcreteBoundImpl::NONE, ConcreteBoundImpl::Unbounded)) return ""; - const size_t index = static_cast(e); - return EnumNamesConcreteBoundImpl()[index]; -} - -template struct ConcreteBoundImplTraits { - static const ConcreteBoundImpl enum_value = ConcreteBoundImpl::NONE; -}; - -template<> struct ConcreteBoundImplTraits { - static const ConcreteBoundImpl enum_value = ConcreteBoundImpl::Expression; -}; - -template<> struct ConcreteBoundImplTraits { - static const ConcreteBoundImpl enum_value = ConcreteBoundImpl::Unbounded; -}; - -bool VerifyConcreteBoundImpl(flatbuffers::Verifier &verifier, const void *obj, ConcreteBoundImpl type); -bool VerifyConcreteBoundImplVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types); - -enum class Bound : uint8_t { - NONE = 0, - Preceding = 1, - Following = 2, - CurrentRow = 3, - MIN = NONE, - MAX = CurrentRow -}; - -inline const Bound (&EnumValuesBound())[4] { - static const Bound values[] = { - Bound::NONE, - Bound::Preceding, - Bound::Following, - Bound::CurrentRow - }; - return values; -} - -inline const char * const *EnumNamesBound() { - static const char * const names[5] = { - "NONE", - "Preceding", - "Following", - "CurrentRow", - nullptr - }; - return names; -} - -inline const char *EnumNameBound(Bound e) { - if (flatbuffers::IsOutRange(e, Bound::NONE, Bound::CurrentRow)) return ""; - const size_t index = static_cast(e); - return EnumNamesBound()[index]; -} - -template struct BoundTraits { - static const Bound enum_value = Bound::NONE; -}; - -template<> struct BoundTraits { - static const Bound enum_value = Bound::Preceding; -}; - -template<> struct BoundTraits { - static const Bound enum_value = Bound::Following; -}; - -template<> struct BoundTraits { - static const Bound enum_value = Bound::CurrentRow; -}; - -bool VerifyBound(flatbuffers::Verifier &verifier, const void *obj, Bound type); -bool VerifyBoundVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types); - -/// The kind of window function to be executed -enum class Frame : uint8_t { - Rows = 0, - Range = 1, - MIN = Rows, - MAX = Range -}; - -inline const Frame (&EnumValuesFrame())[2] { - static const Frame values[] = { - Frame::Rows, - Frame::Range - }; - return values; -} - -inline const char * const *EnumNamesFrame() { - static const char * const names[3] = { - "Rows", - "Range", - nullptr - }; - return names; -} - -inline const char *EnumNameFrame(Frame e) { - if (flatbuffers::IsOutRange(e, Frame::Rows, Frame::Range)) return ""; - const size_t index = static_cast(e); - return EnumNamesFrame()[index]; -} - -/// Various expression types -/// -/// WindowCall is a separate variant -/// due to special options for each that don't apply to generic -/// function calls. Again this is done to make it easier -/// for consumers to deal with the structure of the operation -enum class ExpressionImpl : uint8_t { - NONE = 0, - Literal = 1, - FieldRef = 2, - Call = 3, - ConditionalCase = 4, - SimpleCase = 5, - WindowCall = 6, - Cast = 7, - MIN = NONE, - MAX = Cast -}; - -inline const ExpressionImpl (&EnumValuesExpressionImpl())[8] { - static const ExpressionImpl values[] = { - ExpressionImpl::NONE, - ExpressionImpl::Literal, - ExpressionImpl::FieldRef, - ExpressionImpl::Call, - ExpressionImpl::ConditionalCase, - ExpressionImpl::SimpleCase, - ExpressionImpl::WindowCall, - ExpressionImpl::Cast - }; - return values; -} - -inline const char * const *EnumNamesExpressionImpl() { - static const char * const names[9] = { - "NONE", - "Literal", - "FieldRef", - "Call", - "ConditionalCase", - "SimpleCase", - "WindowCall", - "Cast", - nullptr - }; - return names; -} - -inline const char *EnumNameExpressionImpl(ExpressionImpl e) { - if (flatbuffers::IsOutRange(e, ExpressionImpl::NONE, ExpressionImpl::Cast)) return ""; - const size_t index = static_cast(e); - return EnumNamesExpressionImpl()[index]; -} - -template struct ExpressionImplTraits { - static const ExpressionImpl enum_value = ExpressionImpl::NONE; -}; - -template<> struct ExpressionImplTraits { - static const ExpressionImpl enum_value = ExpressionImpl::Literal; -}; - -template<> struct ExpressionImplTraits { - static const ExpressionImpl enum_value = ExpressionImpl::FieldRef; -}; - -template<> struct ExpressionImplTraits { - static const ExpressionImpl enum_value = ExpressionImpl::Call; -}; - -template<> struct ExpressionImplTraits { - static const ExpressionImpl enum_value = ExpressionImpl::ConditionalCase; -}; - -template<> struct ExpressionImplTraits { - static const ExpressionImpl enum_value = ExpressionImpl::SimpleCase; -}; - -template<> struct ExpressionImplTraits { - static const ExpressionImpl enum_value = ExpressionImpl::WindowCall; -}; - -template<> struct ExpressionImplTraits { - static const ExpressionImpl enum_value = ExpressionImpl::Cast; -}; - -bool VerifyExpressionImpl(flatbuffers::Verifier &verifier, const void *obj, ExpressionImpl type); -bool VerifyExpressionImplVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types); - -/// Access a value for a given map key -struct MapKey FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef MapKeyBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_KEY = 4 - }; - /// Any expression can be a map key. - const org::apache::arrow::computeir::flatbuf::Expression *key() const { - return GetPointer(VT_KEY); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_KEY) && - verifier.VerifyTable(key()) && - verifier.EndTable(); - } -}; - -struct MapKeyBuilder { - typedef MapKey Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_key(flatbuffers::Offset key) { - fbb_.AddOffset(MapKey::VT_KEY, key); - } - explicit MapKeyBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - MapKeyBuilder &operator=(const MapKeyBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, MapKey::VT_KEY); - return o; - } -}; - -inline flatbuffers::Offset CreateMapKey( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset key = 0) { - MapKeyBuilder builder_(_fbb); - builder_.add_key(key); - return builder_.Finish(); -} - -/// Struct field access -struct StructField FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef StructFieldBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_POSITION = 4 - }; - /// The position of the field in the struct schema - uint32_t position() const { - return GetField(VT_POSITION, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_POSITION) && - verifier.EndTable(); - } -}; - -struct StructFieldBuilder { - typedef StructField Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_position(uint32_t position) { - fbb_.AddElement(StructField::VT_POSITION, position, 0); - } - explicit StructFieldBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - StructFieldBuilder &operator=(const StructFieldBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateStructField( - flatbuffers::FlatBufferBuilder &_fbb, - uint32_t position = 0) { - StructFieldBuilder builder_(_fbb); - builder_.add_position(position); - return builder_.Finish(); -} - -/// Zero-based array index -struct ArraySubscript FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef ArraySubscriptBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_POSITION = 4 - }; - uint32_t position() const { - return GetField(VT_POSITION, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_POSITION) && - verifier.EndTable(); - } -}; - -struct ArraySubscriptBuilder { - typedef ArraySubscript Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_position(uint32_t position) { - fbb_.AddElement(ArraySubscript::VT_POSITION, position, 0); - } - explicit ArraySubscriptBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - ArraySubscriptBuilder &operator=(const ArraySubscriptBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateArraySubscript( - flatbuffers::FlatBufferBuilder &_fbb, - uint32_t position = 0) { - ArraySubscriptBuilder builder_(_fbb); - builder_.add_position(position); - return builder_.Finish(); -} - -/// Zero-based range of elements in an array -struct ArraySlice FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef ArraySliceBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_START_INCLUSIVE = 4, - VT_END_EXCLUSIVE = 6 - }; - /// The start of an array slice, inclusive - uint32_t start_inclusive() const { - return GetField(VT_START_INCLUSIVE, 0); - } - /// The end of an array slice, exclusive - uint32_t end_exclusive() const { - return GetField(VT_END_EXCLUSIVE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_START_INCLUSIVE) && - VerifyField(verifier, VT_END_EXCLUSIVE) && - verifier.EndTable(); - } -}; - -struct ArraySliceBuilder { - typedef ArraySlice Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_start_inclusive(uint32_t start_inclusive) { - fbb_.AddElement(ArraySlice::VT_START_INCLUSIVE, start_inclusive, 0); - } - void add_end_exclusive(uint32_t end_exclusive) { - fbb_.AddElement(ArraySlice::VT_END_EXCLUSIVE, end_exclusive, 0); - } - explicit ArraySliceBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - ArraySliceBuilder &operator=(const ArraySliceBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateArraySlice( - flatbuffers::FlatBufferBuilder &_fbb, - uint32_t start_inclusive = 0, - uint32_t end_exclusive = 0) { - ArraySliceBuilder builder_(_fbb); - builder_.add_end_exclusive(end_exclusive); - builder_.add_start_inclusive(start_inclusive); - return builder_.Finish(); -} - -/// Field name in a relation, in ordinal position of the relation's schema. -struct FieldIndex FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef FieldIndexBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_POSITION = 4 - }; - uint32_t position() const { - return GetField(VT_POSITION, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_POSITION) && - verifier.EndTable(); - } -}; - -struct FieldIndexBuilder { - typedef FieldIndex Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_position(uint32_t position) { - fbb_.AddElement(FieldIndex::VT_POSITION, position, 0); - } - explicit FieldIndexBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - FieldIndexBuilder &operator=(const FieldIndexBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateFieldIndex( - flatbuffers::FlatBufferBuilder &_fbb, - uint32_t position = 0) { - FieldIndexBuilder builder_(_fbb); - builder_.add_position(position); - return builder_.Finish(); -} - -/// Access the data of a field -struct FieldRef FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef FieldRefBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_REF_TYPE = 4, - VT_REF = 6, - VT_RELATION_INDEX = 8 - }; - org::apache::arrow::computeir::flatbuf::Deref ref_type() const { - return static_cast(GetField(VT_REF_TYPE, 0)); - } - const void *ref() const { - return GetPointer(VT_REF); - } - template const T *ref_as() const; - const org::apache::arrow::computeir::flatbuf::MapKey *ref_as_MapKey() const { - return ref_type() == org::apache::arrow::computeir::flatbuf::Deref::MapKey ? static_cast(ref()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::StructField *ref_as_StructField() const { - return ref_type() == org::apache::arrow::computeir::flatbuf::Deref::StructField ? static_cast(ref()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::ArraySubscript *ref_as_ArraySubscript() const { - return ref_type() == org::apache::arrow::computeir::flatbuf::Deref::ArraySubscript ? static_cast(ref()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::ArraySlice *ref_as_ArraySlice() const { - return ref_type() == org::apache::arrow::computeir::flatbuf::Deref::ArraySlice ? static_cast(ref()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::FieldIndex *ref_as_FieldIndex() const { - return ref_type() == org::apache::arrow::computeir::flatbuf::Deref::FieldIndex ? static_cast(ref()) : nullptr; - } - /// For Expressions which might reference fields in multiple Relations, - /// this index may be provided to indicate which Relation's fields - /// `ref` points into. For example in the case of a join, - /// 0 refers to the left relation and 1 to the right relation. - int32_t relation_index() const { - return GetField(VT_RELATION_INDEX, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_REF_TYPE) && - VerifyOffsetRequired(verifier, VT_REF) && - VerifyDeref(verifier, ref(), ref_type()) && - VerifyField(verifier, VT_RELATION_INDEX) && - verifier.EndTable(); - } -}; - -template<> inline const org::apache::arrow::computeir::flatbuf::MapKey *FieldRef::ref_as() const { - return ref_as_MapKey(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::StructField *FieldRef::ref_as() const { - return ref_as_StructField(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::ArraySubscript *FieldRef::ref_as() const { - return ref_as_ArraySubscript(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::ArraySlice *FieldRef::ref_as() const { - return ref_as_ArraySlice(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::FieldIndex *FieldRef::ref_as() const { - return ref_as_FieldIndex(); -} - -struct FieldRefBuilder { - typedef FieldRef Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_ref_type(org::apache::arrow::computeir::flatbuf::Deref ref_type) { - fbb_.AddElement(FieldRef::VT_REF_TYPE, static_cast(ref_type), 0); - } - void add_ref(flatbuffers::Offset ref) { - fbb_.AddOffset(FieldRef::VT_REF, ref); - } - void add_relation_index(int32_t relation_index) { - fbb_.AddElement(FieldRef::VT_RELATION_INDEX, relation_index, 0); - } - explicit FieldRefBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - FieldRefBuilder &operator=(const FieldRefBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, FieldRef::VT_REF); - return o; - } -}; - -inline flatbuffers::Offset CreateFieldRef( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::computeir::flatbuf::Deref ref_type = org::apache::arrow::computeir::flatbuf::Deref::NONE, - flatbuffers::Offset ref = 0, - int32_t relation_index = 0) { - FieldRefBuilder builder_(_fbb); - builder_.add_relation_index(relation_index); - builder_.add_ref(ref); - builder_.add_ref_type(ref_type); - return builder_.Finish(); -} - -/// A function call expression -struct Call FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef CallBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_NAME = 4, - VT_ARGUMENTS = 6, - VT_ORDERINGS = 8 - }; - /// The function to call - const flatbuffers::String *name() const { - return GetPointer(VT_NAME); - } - /// The arguments passed to `name`. - const flatbuffers::Vector> *arguments() const { - return GetPointer> *>(VT_ARGUMENTS); - } - /// Possible ordering of input. These are useful - /// in aggregates where ordering in meaningful such as - /// string concatenation - const flatbuffers::Vector> *orderings() const { - return GetPointer> *>(VT_ORDERINGS); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_NAME) && - verifier.VerifyString(name()) && - VerifyOffsetRequired(verifier, VT_ARGUMENTS) && - verifier.VerifyVector(arguments()) && - verifier.VerifyVectorOfTables(arguments()) && - VerifyOffset(verifier, VT_ORDERINGS) && - verifier.VerifyVector(orderings()) && - verifier.VerifyVectorOfTables(orderings()) && - verifier.EndTable(); - } -}; - -struct CallBuilder { - typedef Call Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset name) { - fbb_.AddOffset(Call::VT_NAME, name); - } - void add_arguments(flatbuffers::Offset>> arguments) { - fbb_.AddOffset(Call::VT_ARGUMENTS, arguments); - } - void add_orderings(flatbuffers::Offset>> orderings) { - fbb_.AddOffset(Call::VT_ORDERINGS, orderings); - } - explicit CallBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - CallBuilder &operator=(const CallBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Call::VT_NAME); - fbb_.Required(o, Call::VT_ARGUMENTS); - return o; - } -}; - -inline flatbuffers::Offset CreateCall( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset name = 0, - flatbuffers::Offset>> arguments = 0, - flatbuffers::Offset>> orderings = 0) { - CallBuilder builder_(_fbb); - builder_.add_orderings(orderings); - builder_.add_arguments(arguments); - builder_.add_name(name); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateCallDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *name = nullptr, - const std::vector> *arguments = nullptr, - const std::vector> *orderings = nullptr) { - auto name__ = name ? _fbb.CreateString(name) : 0; - auto arguments__ = arguments ? _fbb.CreateVector>(*arguments) : 0; - auto orderings__ = orderings ? _fbb.CreateVector>(*orderings) : 0; - return org::apache::arrow::computeir::flatbuf::CreateCall( - _fbb, - name__, - arguments__, - orderings__); -} - -/// A single WHEN x THEN y fragment. -struct CaseFragment FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef CaseFragmentBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_MATCH = 4, - VT_RESULT = 6 - }; - const org::apache::arrow::computeir::flatbuf::Expression *match() const { - return GetPointer(VT_MATCH); - } - const org::apache::arrow::computeir::flatbuf::Expression *result() const { - return GetPointer(VT_RESULT); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_MATCH) && - verifier.VerifyTable(match()) && - VerifyOffsetRequired(verifier, VT_RESULT) && - verifier.VerifyTable(result()) && - verifier.EndTable(); - } -}; - -struct CaseFragmentBuilder { - typedef CaseFragment Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_match(flatbuffers::Offset match) { - fbb_.AddOffset(CaseFragment::VT_MATCH, match); - } - void add_result(flatbuffers::Offset result) { - fbb_.AddOffset(CaseFragment::VT_RESULT, result); - } - explicit CaseFragmentBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - CaseFragmentBuilder &operator=(const CaseFragmentBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, CaseFragment::VT_MATCH); - fbb_.Required(o, CaseFragment::VT_RESULT); - return o; - } -}; - -inline flatbuffers::Offset CreateCaseFragment( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset match = 0, - flatbuffers::Offset result = 0) { - CaseFragmentBuilder builder_(_fbb); - builder_.add_result(result); - builder_.add_match(match); - return builder_.Finish(); -} - -/// Conditional case statement expression -struct ConditionalCase FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef ConditionalCaseBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_CONDITIONS = 4, - VT_ELSE_ = 6 - }; - /// List of conditions to evaluate - const flatbuffers::Vector> *conditions() const { - return GetPointer> *>(VT_CONDITIONS); - } - /// The default value if no cases match. This is typically NULL in SQL - /// implementations. - /// - /// Defaulting to NULL is a frontend choice, so producers must specify NULL - /// if that's their desired behavior. - const org::apache::arrow::computeir::flatbuf::Expression *else_() const { - return GetPointer(VT_ELSE_); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_CONDITIONS) && - verifier.VerifyVector(conditions()) && - verifier.VerifyVectorOfTables(conditions()) && - VerifyOffsetRequired(verifier, VT_ELSE_) && - verifier.VerifyTable(else_()) && - verifier.EndTable(); - } -}; - -struct ConditionalCaseBuilder { - typedef ConditionalCase Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_conditions(flatbuffers::Offset>> conditions) { - fbb_.AddOffset(ConditionalCase::VT_CONDITIONS, conditions); - } - void add_else_(flatbuffers::Offset else_) { - fbb_.AddOffset(ConditionalCase::VT_ELSE_, else_); - } - explicit ConditionalCaseBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - ConditionalCaseBuilder &operator=(const ConditionalCaseBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, ConditionalCase::VT_CONDITIONS); - fbb_.Required(o, ConditionalCase::VT_ELSE_); - return o; - } -}; - -inline flatbuffers::Offset CreateConditionalCase( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset>> conditions = 0, - flatbuffers::Offset else_ = 0) { - ConditionalCaseBuilder builder_(_fbb); - builder_.add_else_(else_); - builder_.add_conditions(conditions); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateConditionalCaseDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector> *conditions = nullptr, - flatbuffers::Offset else_ = 0) { - auto conditions__ = conditions ? _fbb.CreateVector>(*conditions) : 0; - return org::apache::arrow::computeir::flatbuf::CreateConditionalCase( - _fbb, - conditions__, - else_); -} - -/// Switch-style case expression -struct SimpleCase FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef SimpleCaseBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_EXPRESSION = 4, - VT_MATCHES = 6, - VT_ELSE_ = 8 - }; - /// The expression whose value will be matched - const org::apache::arrow::computeir::flatbuf::Expression *expression() const { - return GetPointer(VT_EXPRESSION); - } - /// Matches for `expression` - const flatbuffers::Vector> *matches() const { - return GetPointer> *>(VT_MATCHES); - } - /// The default value if no cases match - const org::apache::arrow::computeir::flatbuf::Expression *else_() const { - return GetPointer(VT_ELSE_); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_EXPRESSION) && - verifier.VerifyTable(expression()) && - VerifyOffsetRequired(verifier, VT_MATCHES) && - verifier.VerifyVector(matches()) && - verifier.VerifyVectorOfTables(matches()) && - VerifyOffsetRequired(verifier, VT_ELSE_) && - verifier.VerifyTable(else_()) && - verifier.EndTable(); - } -}; - -struct SimpleCaseBuilder { - typedef SimpleCase Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_expression(flatbuffers::Offset expression) { - fbb_.AddOffset(SimpleCase::VT_EXPRESSION, expression); - } - void add_matches(flatbuffers::Offset>> matches) { - fbb_.AddOffset(SimpleCase::VT_MATCHES, matches); - } - void add_else_(flatbuffers::Offset else_) { - fbb_.AddOffset(SimpleCase::VT_ELSE_, else_); - } - explicit SimpleCaseBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - SimpleCaseBuilder &operator=(const SimpleCaseBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, SimpleCase::VT_EXPRESSION); - fbb_.Required(o, SimpleCase::VT_MATCHES); - fbb_.Required(o, SimpleCase::VT_ELSE_); - return o; - } -}; - -inline flatbuffers::Offset CreateSimpleCase( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset expression = 0, - flatbuffers::Offset>> matches = 0, - flatbuffers::Offset else_ = 0) { - SimpleCaseBuilder builder_(_fbb); - builder_.add_else_(else_); - builder_.add_matches(matches); - builder_.add_expression(expression); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateSimpleCaseDirect( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset expression = 0, - const std::vector> *matches = nullptr, - flatbuffers::Offset else_ = 0) { - auto matches__ = matches ? _fbb.CreateVector>(*matches) : 0; - return org::apache::arrow::computeir::flatbuf::CreateSimpleCase( - _fbb, - expression, - matches__, - else_); -} - -/// An expression with an order -struct SortKey FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef SortKeyBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_EXPRESSION = 4, - VT_ORDERING = 6 - }; - const org::apache::arrow::computeir::flatbuf::Expression *expression() const { - return GetPointer(VT_EXPRESSION); - } - org::apache::arrow::computeir::flatbuf::Ordering ordering() const { - return static_cast(GetField(VT_ORDERING, 0)); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_EXPRESSION) && - verifier.VerifyTable(expression()) && - VerifyField(verifier, VT_ORDERING) && - verifier.EndTable(); - } -}; - -struct SortKeyBuilder { - typedef SortKey Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_expression(flatbuffers::Offset expression) { - fbb_.AddOffset(SortKey::VT_EXPRESSION, expression); - } - void add_ordering(org::apache::arrow::computeir::flatbuf::Ordering ordering) { - fbb_.AddElement(SortKey::VT_ORDERING, static_cast(ordering), 0); - } - explicit SortKeyBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - SortKeyBuilder &operator=(const SortKeyBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, SortKey::VT_EXPRESSION); - return o; - } -}; - -inline flatbuffers::Offset CreateSortKey( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset expression = 0, - org::apache::arrow::computeir::flatbuf::Ordering ordering = org::apache::arrow::computeir::flatbuf::Ordering::ASCENDING_THEN_NULLS) { - SortKeyBuilder builder_(_fbb); - builder_.add_expression(expression); - builder_.add_ordering(ordering); - return builder_.Finish(); -} - -/// An unbounded window bound -struct Unbounded FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef UnboundedBuilder Builder; - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - verifier.EndTable(); - } -}; - -struct UnboundedBuilder { - typedef Unbounded Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - explicit UnboundedBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - UnboundedBuilder &operator=(const UnboundedBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateUnbounded( - flatbuffers::FlatBufferBuilder &_fbb) { - UnboundedBuilder builder_(_fbb); - return builder_.Finish(); -} - -/// Boundary is preceding rows, determined by the contained expression -struct Preceding FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef PrecedingBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_IMPL_TYPE = 4, - VT_IMPL = 6 - }; - org::apache::arrow::computeir::flatbuf::ConcreteBoundImpl impl_type() const { - return static_cast(GetField(VT_IMPL_TYPE, 0)); - } - const void *impl() const { - return GetPointer(VT_IMPL); - } - template const T *impl_as() const; - const org::apache::arrow::computeir::flatbuf::Expression *impl_as_Expression() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::ConcreteBoundImpl::Expression ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Unbounded *impl_as_Unbounded() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::ConcreteBoundImpl::Unbounded ? static_cast(impl()) : nullptr; - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_IMPL_TYPE) && - VerifyOffsetRequired(verifier, VT_IMPL) && - VerifyConcreteBoundImpl(verifier, impl(), impl_type()) && - verifier.EndTable(); - } -}; - -template<> inline const org::apache::arrow::computeir::flatbuf::Expression *Preceding::impl_as() const { - return impl_as_Expression(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Unbounded *Preceding::impl_as() const { - return impl_as_Unbounded(); -} - -struct PrecedingBuilder { - typedef Preceding Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_impl_type(org::apache::arrow::computeir::flatbuf::ConcreteBoundImpl impl_type) { - fbb_.AddElement(Preceding::VT_IMPL_TYPE, static_cast(impl_type), 0); - } - void add_impl(flatbuffers::Offset impl) { - fbb_.AddOffset(Preceding::VT_IMPL, impl); - } - explicit PrecedingBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - PrecedingBuilder &operator=(const PrecedingBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Preceding::VT_IMPL); - return o; - } -}; - -inline flatbuffers::Offset CreatePreceding( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::computeir::flatbuf::ConcreteBoundImpl impl_type = org::apache::arrow::computeir::flatbuf::ConcreteBoundImpl::NONE, - flatbuffers::Offset impl = 0) { - PrecedingBuilder builder_(_fbb); - builder_.add_impl(impl); - builder_.add_impl_type(impl_type); - return builder_.Finish(); -} - -/// Boundary is following rows, determined by the contained expression -struct Following FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef FollowingBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_IMPL_TYPE = 4, - VT_IMPL = 6 - }; - org::apache::arrow::computeir::flatbuf::ConcreteBoundImpl impl_type() const { - return static_cast(GetField(VT_IMPL_TYPE, 0)); - } - const void *impl() const { - return GetPointer(VT_IMPL); - } - template const T *impl_as() const; - const org::apache::arrow::computeir::flatbuf::Expression *impl_as_Expression() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::ConcreteBoundImpl::Expression ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Unbounded *impl_as_Unbounded() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::ConcreteBoundImpl::Unbounded ? static_cast(impl()) : nullptr; - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_IMPL_TYPE) && - VerifyOffsetRequired(verifier, VT_IMPL) && - VerifyConcreteBoundImpl(verifier, impl(), impl_type()) && - verifier.EndTable(); - } -}; - -template<> inline const org::apache::arrow::computeir::flatbuf::Expression *Following::impl_as() const { - return impl_as_Expression(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Unbounded *Following::impl_as() const { - return impl_as_Unbounded(); -} - -struct FollowingBuilder { - typedef Following Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_impl_type(org::apache::arrow::computeir::flatbuf::ConcreteBoundImpl impl_type) { - fbb_.AddElement(Following::VT_IMPL_TYPE, static_cast(impl_type), 0); - } - void add_impl(flatbuffers::Offset impl) { - fbb_.AddOffset(Following::VT_IMPL, impl); - } - explicit FollowingBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - FollowingBuilder &operator=(const FollowingBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Following::VT_IMPL); - return o; - } -}; - -inline flatbuffers::Offset CreateFollowing( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::computeir::flatbuf::ConcreteBoundImpl impl_type = org::apache::arrow::computeir::flatbuf::ConcreteBoundImpl::NONE, - flatbuffers::Offset impl = 0) { - FollowingBuilder builder_(_fbb); - builder_.add_impl(impl); - builder_.add_impl_type(impl_type); - return builder_.Finish(); -} - -/// Boundary is the current row -struct CurrentRow FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef CurrentRowBuilder Builder; - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - verifier.EndTable(); - } -}; - -struct CurrentRowBuilder { - typedef CurrentRow Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - explicit CurrentRowBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - CurrentRowBuilder &operator=(const CurrentRowBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateCurrentRow( - flatbuffers::FlatBufferBuilder &_fbb) { - CurrentRowBuilder builder_(_fbb); - return builder_.Finish(); -} - -/// An expression representing a window function call. -struct WindowCall FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef WindowCallBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_EXPRESSION = 4, - VT_KIND = 6, - VT_PARTITIONS = 8, - VT_ORDERINGS = 10, - VT_LOWER_BOUND_TYPE = 12, - VT_LOWER_BOUND = 14, - VT_UPPER_BOUND_TYPE = 16, - VT_UPPER_BOUND = 18 - }; - /// The expression to operate over - const org::apache::arrow::computeir::flatbuf::Expression *expression() const { - return GetPointer(VT_EXPRESSION); - } - /// The kind of window frame - org::apache::arrow::computeir::flatbuf::Frame kind() const { - return static_cast(GetField(VT_KIND, 0)); - } - /// Partition keys - const flatbuffers::Vector> *partitions() const { - return GetPointer> *>(VT_PARTITIONS); - } - /// Sort keys - const flatbuffers::Vector> *orderings() const { - return GetPointer> *>(VT_ORDERINGS); - } - org::apache::arrow::computeir::flatbuf::Bound lower_bound_type() const { - return static_cast(GetField(VT_LOWER_BOUND_TYPE, 0)); - } - /// Lower window bound - const void *lower_bound() const { - return GetPointer(VT_LOWER_BOUND); - } - template const T *lower_bound_as() const; - const org::apache::arrow::computeir::flatbuf::Preceding *lower_bound_as_Preceding() const { - return lower_bound_type() == org::apache::arrow::computeir::flatbuf::Bound::Preceding ? static_cast(lower_bound()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Following *lower_bound_as_Following() const { - return lower_bound_type() == org::apache::arrow::computeir::flatbuf::Bound::Following ? static_cast(lower_bound()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::CurrentRow *lower_bound_as_CurrentRow() const { - return lower_bound_type() == org::apache::arrow::computeir::flatbuf::Bound::CurrentRow ? static_cast(lower_bound()) : nullptr; - } - org::apache::arrow::computeir::flatbuf::Bound upper_bound_type() const { - return static_cast(GetField(VT_UPPER_BOUND_TYPE, 0)); - } - /// Upper window bound - const void *upper_bound() const { - return GetPointer(VT_UPPER_BOUND); - } - template const T *upper_bound_as() const; - const org::apache::arrow::computeir::flatbuf::Preceding *upper_bound_as_Preceding() const { - return upper_bound_type() == org::apache::arrow::computeir::flatbuf::Bound::Preceding ? static_cast(upper_bound()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Following *upper_bound_as_Following() const { - return upper_bound_type() == org::apache::arrow::computeir::flatbuf::Bound::Following ? static_cast(upper_bound()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::CurrentRow *upper_bound_as_CurrentRow() const { - return upper_bound_type() == org::apache::arrow::computeir::flatbuf::Bound::CurrentRow ? static_cast(upper_bound()) : nullptr; - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_EXPRESSION) && - verifier.VerifyTable(expression()) && - VerifyField(verifier, VT_KIND) && - VerifyOffsetRequired(verifier, VT_PARTITIONS) && - verifier.VerifyVector(partitions()) && - verifier.VerifyVectorOfTables(partitions()) && - VerifyOffsetRequired(verifier, VT_ORDERINGS) && - verifier.VerifyVector(orderings()) && - verifier.VerifyVectorOfTables(orderings()) && - VerifyField(verifier, VT_LOWER_BOUND_TYPE) && - VerifyOffsetRequired(verifier, VT_LOWER_BOUND) && - VerifyBound(verifier, lower_bound(), lower_bound_type()) && - VerifyField(verifier, VT_UPPER_BOUND_TYPE) && - VerifyOffsetRequired(verifier, VT_UPPER_BOUND) && - VerifyBound(verifier, upper_bound(), upper_bound_type()) && - verifier.EndTable(); - } -}; - -template<> inline const org::apache::arrow::computeir::flatbuf::Preceding *WindowCall::lower_bound_as() const { - return lower_bound_as_Preceding(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Following *WindowCall::lower_bound_as() const { - return lower_bound_as_Following(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::CurrentRow *WindowCall::lower_bound_as() const { - return lower_bound_as_CurrentRow(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Preceding *WindowCall::upper_bound_as() const { - return upper_bound_as_Preceding(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Following *WindowCall::upper_bound_as() const { - return upper_bound_as_Following(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::CurrentRow *WindowCall::upper_bound_as() const { - return upper_bound_as_CurrentRow(); -} - -struct WindowCallBuilder { - typedef WindowCall Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_expression(flatbuffers::Offset expression) { - fbb_.AddOffset(WindowCall::VT_EXPRESSION, expression); - } - void add_kind(org::apache::arrow::computeir::flatbuf::Frame kind) { - fbb_.AddElement(WindowCall::VT_KIND, static_cast(kind), 0); - } - void add_partitions(flatbuffers::Offset>> partitions) { - fbb_.AddOffset(WindowCall::VT_PARTITIONS, partitions); - } - void add_orderings(flatbuffers::Offset>> orderings) { - fbb_.AddOffset(WindowCall::VT_ORDERINGS, orderings); - } - void add_lower_bound_type(org::apache::arrow::computeir::flatbuf::Bound lower_bound_type) { - fbb_.AddElement(WindowCall::VT_LOWER_BOUND_TYPE, static_cast(lower_bound_type), 0); - } - void add_lower_bound(flatbuffers::Offset lower_bound) { - fbb_.AddOffset(WindowCall::VT_LOWER_BOUND, lower_bound); - } - void add_upper_bound_type(org::apache::arrow::computeir::flatbuf::Bound upper_bound_type) { - fbb_.AddElement(WindowCall::VT_UPPER_BOUND_TYPE, static_cast(upper_bound_type), 0); - } - void add_upper_bound(flatbuffers::Offset upper_bound) { - fbb_.AddOffset(WindowCall::VT_UPPER_BOUND, upper_bound); - } - explicit WindowCallBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - WindowCallBuilder &operator=(const WindowCallBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, WindowCall::VT_EXPRESSION); - fbb_.Required(o, WindowCall::VT_PARTITIONS); - fbb_.Required(o, WindowCall::VT_ORDERINGS); - fbb_.Required(o, WindowCall::VT_LOWER_BOUND); - fbb_.Required(o, WindowCall::VT_UPPER_BOUND); - return o; - } -}; - -inline flatbuffers::Offset CreateWindowCall( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset expression = 0, - org::apache::arrow::computeir::flatbuf::Frame kind = org::apache::arrow::computeir::flatbuf::Frame::Rows, - flatbuffers::Offset>> partitions = 0, - flatbuffers::Offset>> orderings = 0, - org::apache::arrow::computeir::flatbuf::Bound lower_bound_type = org::apache::arrow::computeir::flatbuf::Bound::NONE, - flatbuffers::Offset lower_bound = 0, - org::apache::arrow::computeir::flatbuf::Bound upper_bound_type = org::apache::arrow::computeir::flatbuf::Bound::NONE, - flatbuffers::Offset upper_bound = 0) { - WindowCallBuilder builder_(_fbb); - builder_.add_upper_bound(upper_bound); - builder_.add_lower_bound(lower_bound); - builder_.add_orderings(orderings); - builder_.add_partitions(partitions); - builder_.add_expression(expression); - builder_.add_upper_bound_type(upper_bound_type); - builder_.add_lower_bound_type(lower_bound_type); - builder_.add_kind(kind); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateWindowCallDirect( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset expression = 0, - org::apache::arrow::computeir::flatbuf::Frame kind = org::apache::arrow::computeir::flatbuf::Frame::Rows, - const std::vector> *partitions = nullptr, - const std::vector> *orderings = nullptr, - org::apache::arrow::computeir::flatbuf::Bound lower_bound_type = org::apache::arrow::computeir::flatbuf::Bound::NONE, - flatbuffers::Offset lower_bound = 0, - org::apache::arrow::computeir::flatbuf::Bound upper_bound_type = org::apache::arrow::computeir::flatbuf::Bound::NONE, - flatbuffers::Offset upper_bound = 0) { - auto partitions__ = partitions ? _fbb.CreateVector>(*partitions) : 0; - auto orderings__ = orderings ? _fbb.CreateVector>(*orderings) : 0; - return org::apache::arrow::computeir::flatbuf::CreateWindowCall( - _fbb, - expression, - kind, - partitions__, - orderings__, - lower_bound_type, - lower_bound, - upper_bound_type, - upper_bound); -} - -/// A cast expression -struct Cast FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef CastBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_OPERAND = 4, - VT_TO = 6 - }; - /// The expression to cast - const org::apache::arrow::computeir::flatbuf::Expression *operand() const { - return GetPointer(VT_OPERAND); - } - /// The type to cast to. This value is a `Field` to allow complete representation - /// of arrow types. - /// - /// `Type` is unable to completely represent complex types like lists and - /// maps. - const org::apache::arrow::flatbuf::Field *to() const { - return GetPointer(VT_TO); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_OPERAND) && - verifier.VerifyTable(operand()) && - VerifyOffsetRequired(verifier, VT_TO) && - verifier.VerifyTable(to()) && - verifier.EndTable(); - } -}; - -struct CastBuilder { - typedef Cast Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_operand(flatbuffers::Offset operand) { - fbb_.AddOffset(Cast::VT_OPERAND, operand); - } - void add_to(flatbuffers::Offset to) { - fbb_.AddOffset(Cast::VT_TO, to); - } - explicit CastBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - CastBuilder &operator=(const CastBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Cast::VT_OPERAND); - fbb_.Required(o, Cast::VT_TO); - return o; - } -}; - -inline flatbuffers::Offset CreateCast( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset operand = 0, - flatbuffers::Offset to = 0) { - CastBuilder builder_(_fbb); - builder_.add_to(to); - builder_.add_operand(operand); - return builder_.Finish(); -} - -/// Expression types -/// -/// Expressions have a concrete `impl` value, which is a specific operation. -/// -/// This is a workaround for flatbuffers' lack of support for direct use of -/// union types. -struct Expression FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef ExpressionBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_IMPL_TYPE = 4, - VT_IMPL = 6 - }; - org::apache::arrow::computeir::flatbuf::ExpressionImpl impl_type() const { - return static_cast(GetField(VT_IMPL_TYPE, 0)); - } - const void *impl() const { - return GetPointer(VT_IMPL); - } - template const T *impl_as() const; - const org::apache::arrow::computeir::flatbuf::Literal *impl_as_Literal() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::ExpressionImpl::Literal ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::FieldRef *impl_as_FieldRef() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::ExpressionImpl::FieldRef ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Call *impl_as_Call() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::ExpressionImpl::Call ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::ConditionalCase *impl_as_ConditionalCase() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::ExpressionImpl::ConditionalCase ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::SimpleCase *impl_as_SimpleCase() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::ExpressionImpl::SimpleCase ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::WindowCall *impl_as_WindowCall() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::ExpressionImpl::WindowCall ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Cast *impl_as_Cast() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::ExpressionImpl::Cast ? static_cast(impl()) : nullptr; - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_IMPL_TYPE) && - VerifyOffsetRequired(verifier, VT_IMPL) && - VerifyExpressionImpl(verifier, impl(), impl_type()) && - verifier.EndTable(); - } -}; - -template<> inline const org::apache::arrow::computeir::flatbuf::Literal *Expression::impl_as() const { - return impl_as_Literal(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::FieldRef *Expression::impl_as() const { - return impl_as_FieldRef(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Call *Expression::impl_as() const { - return impl_as_Call(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::ConditionalCase *Expression::impl_as() const { - return impl_as_ConditionalCase(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::SimpleCase *Expression::impl_as() const { - return impl_as_SimpleCase(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::WindowCall *Expression::impl_as() const { - return impl_as_WindowCall(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Cast *Expression::impl_as() const { - return impl_as_Cast(); -} - -struct ExpressionBuilder { - typedef Expression Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_impl_type(org::apache::arrow::computeir::flatbuf::ExpressionImpl impl_type) { - fbb_.AddElement(Expression::VT_IMPL_TYPE, static_cast(impl_type), 0); - } - void add_impl(flatbuffers::Offset impl) { - fbb_.AddOffset(Expression::VT_IMPL, impl); - } - explicit ExpressionBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - ExpressionBuilder &operator=(const ExpressionBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Expression::VT_IMPL); - return o; - } -}; - -inline flatbuffers::Offset CreateExpression( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::computeir::flatbuf::ExpressionImpl impl_type = org::apache::arrow::computeir::flatbuf::ExpressionImpl::NONE, - flatbuffers::Offset impl = 0) { - ExpressionBuilder builder_(_fbb); - builder_.add_impl(impl); - builder_.add_impl_type(impl_type); - return builder_.Finish(); -} - -inline bool VerifyDeref(flatbuffers::Verifier &verifier, const void *obj, Deref type) { - switch (type) { - case Deref::NONE: { - return true; - } - case Deref::MapKey: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case Deref::StructField: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case Deref::ArraySubscript: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case Deref::ArraySlice: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case Deref::FieldIndex: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - default: return true; - } -} - -inline bool VerifyDerefVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types) { - if (!values || !types) return !values && !types; - if (values->size() != types->size()) return false; - for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { - if (!VerifyDeref( - verifier, values->Get(i), types->GetEnum(i))) { - return false; - } - } - return true; -} - -inline bool VerifyConcreteBoundImpl(flatbuffers::Verifier &verifier, const void *obj, ConcreteBoundImpl type) { - switch (type) { - case ConcreteBoundImpl::NONE: { - return true; - } - case ConcreteBoundImpl::Expression: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case ConcreteBoundImpl::Unbounded: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - default: return true; - } -} - -inline bool VerifyConcreteBoundImplVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types) { - if (!values || !types) return !values && !types; - if (values->size() != types->size()) return false; - for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { - if (!VerifyConcreteBoundImpl( - verifier, values->Get(i), types->GetEnum(i))) { - return false; - } - } - return true; -} - -inline bool VerifyBound(flatbuffers::Verifier &verifier, const void *obj, Bound type) { - switch (type) { - case Bound::NONE: { - return true; - } - case Bound::Preceding: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case Bound::Following: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case Bound::CurrentRow: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - default: return true; - } -} - -inline bool VerifyBoundVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types) { - if (!values || !types) return !values && !types; - if (values->size() != types->size()) return false; - for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { - if (!VerifyBound( - verifier, values->Get(i), types->GetEnum(i))) { - return false; - } - } - return true; -} - -inline bool VerifyExpressionImpl(flatbuffers::Verifier &verifier, const void *obj, ExpressionImpl type) { - switch (type) { - case ExpressionImpl::NONE: { - return true; - } - case ExpressionImpl::Literal: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case ExpressionImpl::FieldRef: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case ExpressionImpl::Call: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case ExpressionImpl::ConditionalCase: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case ExpressionImpl::SimpleCase: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case ExpressionImpl::WindowCall: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case ExpressionImpl::Cast: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - default: return true; - } -} - -inline bool VerifyExpressionImplVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types) { - if (!values || !types) return !values && !types; - if (values->size() != types->size()) return false; - for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { - if (!VerifyExpressionImpl( - verifier, values->Get(i), types->GetEnum(i))) { - return false; - } - } - return true; -} - -inline const org::apache::arrow::computeir::flatbuf::Expression *GetExpression(const void *buf) { - return flatbuffers::GetRoot(buf); -} - -inline const org::apache::arrow::computeir::flatbuf::Expression *GetSizePrefixedExpression(const void *buf) { - return flatbuffers::GetSizePrefixedRoot(buf); -} - -inline bool VerifyExpressionBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer(nullptr); -} - -inline bool VerifySizePrefixedExpressionBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifySizePrefixedBuffer(nullptr); -} - -inline void FinishExpressionBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset root) { - fbb.Finish(root); -} - -inline void FinishSizePrefixedExpressionBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset root) { - fbb.FinishSizePrefixed(root); -} - -} // namespace flatbuf -} // namespace computeir -} // namespace arrow -} // namespace apache -} // namespace org - -#endif // FLATBUFFERS_GENERATED_EXPRESSION_ORG_APACHE_ARROW_COMPUTEIR_FLATBUF_H_ diff --git a/cpp/src/generated/Literal_generated.h b/cpp/src/generated/Literal_generated.h deleted file mode 100644 index ea095a8244783..0000000000000 --- a/cpp/src/generated/Literal_generated.h +++ /dev/null @@ -1,2037 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_LITERAL_ORG_APACHE_ARROW_COMPUTEIR_FLATBUF_H_ -#define FLATBUFFERS_GENERATED_LITERAL_ORG_APACHE_ARROW_COMPUTEIR_FLATBUF_H_ - -#include "flatbuffers/flatbuffers.h" - -#include "Schema_generated.h" - -namespace org { -namespace apache { -namespace arrow { -namespace computeir { -namespace flatbuf { - -struct ListLiteral; -struct ListLiteralBuilder; - -struct StructLiteral; -struct StructLiteralBuilder; - -struct KeyValue; -struct KeyValueBuilder; - -struct MapLiteral; -struct MapLiteralBuilder; - -struct Int8Literal; -struct Int8LiteralBuilder; - -struct Int16Literal; -struct Int16LiteralBuilder; - -struct Int32Literal; -struct Int32LiteralBuilder; - -struct Int64Literal; -struct Int64LiteralBuilder; - -struct UInt8Literal; -struct UInt8LiteralBuilder; - -struct UInt16Literal; -struct UInt16LiteralBuilder; - -struct UInt32Literal; -struct UInt32LiteralBuilder; - -struct UInt64Literal; -struct UInt64LiteralBuilder; - -struct Float16Literal; -struct Float16LiteralBuilder; - -struct Float32Literal; -struct Float32LiteralBuilder; - -struct Float64Literal; -struct Float64LiteralBuilder; - -struct DecimalLiteral; -struct DecimalLiteralBuilder; - -struct BooleanLiteral; -struct BooleanLiteralBuilder; - -struct DateLiteral; -struct DateLiteralBuilder; - -struct TimeLiteral; -struct TimeLiteralBuilder; - -struct TimestampLiteral; -struct TimestampLiteralBuilder; - -struct IntervalLiteralMonths; -struct IntervalLiteralMonthsBuilder; - -struct IntervalLiteralDaysMilliseconds; -struct IntervalLiteralDaysMillisecondsBuilder; - -struct IntervalLiteral; -struct IntervalLiteralBuilder; - -struct DurationLiteral; -struct DurationLiteralBuilder; - -struct BinaryLiteral; -struct BinaryLiteralBuilder; - -struct FixedSizeBinaryLiteral; -struct FixedSizeBinaryLiteralBuilder; - -struct StringLiteral; -struct StringLiteralBuilder; - -struct Literal; -struct LiteralBuilder; - -enum class IntervalLiteralImpl : uint8_t { - NONE = 0, - IntervalLiteralMonths = 1, - IntervalLiteralDaysMilliseconds = 2, - MIN = NONE, - MAX = IntervalLiteralDaysMilliseconds -}; - -inline const IntervalLiteralImpl (&EnumValuesIntervalLiteralImpl())[3] { - static const IntervalLiteralImpl values[] = { - IntervalLiteralImpl::NONE, - IntervalLiteralImpl::IntervalLiteralMonths, - IntervalLiteralImpl::IntervalLiteralDaysMilliseconds - }; - return values; -} - -inline const char * const *EnumNamesIntervalLiteralImpl() { - static const char * const names[4] = { - "NONE", - "IntervalLiteralMonths", - "IntervalLiteralDaysMilliseconds", - nullptr - }; - return names; -} - -inline const char *EnumNameIntervalLiteralImpl(IntervalLiteralImpl e) { - if (flatbuffers::IsOutRange(e, IntervalLiteralImpl::NONE, IntervalLiteralImpl::IntervalLiteralDaysMilliseconds)) return ""; - const size_t index = static_cast(e); - return EnumNamesIntervalLiteralImpl()[index]; -} - -template struct IntervalLiteralImplTraits { - static const IntervalLiteralImpl enum_value = IntervalLiteralImpl::NONE; -}; - -template<> struct IntervalLiteralImplTraits { - static const IntervalLiteralImpl enum_value = IntervalLiteralImpl::IntervalLiteralMonths; -}; - -template<> struct IntervalLiteralImplTraits { - static const IntervalLiteralImpl enum_value = IntervalLiteralImpl::IntervalLiteralDaysMilliseconds; -}; - -bool VerifyIntervalLiteralImpl(flatbuffers::Verifier &verifier, const void *obj, IntervalLiteralImpl type); -bool VerifyIntervalLiteralImplVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types); - -enum class LiteralImpl : uint8_t { - NONE = 0, - BooleanLiteral = 1, - Int8Literal = 2, - Int16Literal = 3, - Int32Literal = 4, - Int64Literal = 5, - UInt8Literal = 6, - UInt16Literal = 7, - UInt32Literal = 8, - UInt64Literal = 9, - DateLiteral = 10, - TimeLiteral = 11, - TimestampLiteral = 12, - IntervalLiteral = 13, - DurationLiteral = 14, - DecimalLiteral = 15, - Float16Literal = 16, - Float32Literal = 17, - Float64Literal = 18, - ListLiteral = 19, - StructLiteral = 20, - MapLiteral = 21, - StringLiteral = 22, - BinaryLiteral = 23, - FixedSizeBinaryLiteral = 24, - MIN = NONE, - MAX = FixedSizeBinaryLiteral -}; - -inline const LiteralImpl (&EnumValuesLiteralImpl())[25] { - static const LiteralImpl values[] = { - LiteralImpl::NONE, - LiteralImpl::BooleanLiteral, - LiteralImpl::Int8Literal, - LiteralImpl::Int16Literal, - LiteralImpl::Int32Literal, - LiteralImpl::Int64Literal, - LiteralImpl::UInt8Literal, - LiteralImpl::UInt16Literal, - LiteralImpl::UInt32Literal, - LiteralImpl::UInt64Literal, - LiteralImpl::DateLiteral, - LiteralImpl::TimeLiteral, - LiteralImpl::TimestampLiteral, - LiteralImpl::IntervalLiteral, - LiteralImpl::DurationLiteral, - LiteralImpl::DecimalLiteral, - LiteralImpl::Float16Literal, - LiteralImpl::Float32Literal, - LiteralImpl::Float64Literal, - LiteralImpl::ListLiteral, - LiteralImpl::StructLiteral, - LiteralImpl::MapLiteral, - LiteralImpl::StringLiteral, - LiteralImpl::BinaryLiteral, - LiteralImpl::FixedSizeBinaryLiteral - }; - return values; -} - -inline const char * const *EnumNamesLiteralImpl() { - static const char * const names[26] = { - "NONE", - "BooleanLiteral", - "Int8Literal", - "Int16Literal", - "Int32Literal", - "Int64Literal", - "UInt8Literal", - "UInt16Literal", - "UInt32Literal", - "UInt64Literal", - "DateLiteral", - "TimeLiteral", - "TimestampLiteral", - "IntervalLiteral", - "DurationLiteral", - "DecimalLiteral", - "Float16Literal", - "Float32Literal", - "Float64Literal", - "ListLiteral", - "StructLiteral", - "MapLiteral", - "StringLiteral", - "BinaryLiteral", - "FixedSizeBinaryLiteral", - nullptr - }; - return names; -} - -inline const char *EnumNameLiteralImpl(LiteralImpl e) { - if (flatbuffers::IsOutRange(e, LiteralImpl::NONE, LiteralImpl::FixedSizeBinaryLiteral)) return ""; - const size_t index = static_cast(e); - return EnumNamesLiteralImpl()[index]; -} - -template struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::NONE; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::BooleanLiteral; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::Int8Literal; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::Int16Literal; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::Int32Literal; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::Int64Literal; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::UInt8Literal; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::UInt16Literal; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::UInt32Literal; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::UInt64Literal; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::DateLiteral; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::TimeLiteral; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::TimestampLiteral; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::IntervalLiteral; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::DurationLiteral; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::DecimalLiteral; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::Float16Literal; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::Float32Literal; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::Float64Literal; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::ListLiteral; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::StructLiteral; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::MapLiteral; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::StringLiteral; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::BinaryLiteral; -}; - -template<> struct LiteralImplTraits { - static const LiteralImpl enum_value = LiteralImpl::FixedSizeBinaryLiteral; -}; - -bool VerifyLiteralImpl(flatbuffers::Verifier &verifier, const void *obj, LiteralImpl type); -bool VerifyLiteralImplVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types); - -struct ListLiteral FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef ListLiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUES = 4 - }; - const flatbuffers::Vector> *values() const { - return GetPointer> *>(VT_VALUES); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_VALUES) && - verifier.VerifyVector(values()) && - verifier.VerifyVectorOfTables(values()) && - verifier.EndTable(); - } -}; - -struct ListLiteralBuilder { - typedef ListLiteral Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_values(flatbuffers::Offset>> values) { - fbb_.AddOffset(ListLiteral::VT_VALUES, values); - } - explicit ListLiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - ListLiteralBuilder &operator=(const ListLiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, ListLiteral::VT_VALUES); - return o; - } -}; - -inline flatbuffers::Offset CreateListLiteral( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset>> values = 0) { - ListLiteralBuilder builder_(_fbb); - builder_.add_values(values); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateListLiteralDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector> *values = nullptr) { - auto values__ = values ? _fbb.CreateVector>(*values) : 0; - return org::apache::arrow::computeir::flatbuf::CreateListLiteral( - _fbb, - values__); -} - -struct StructLiteral FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef StructLiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUES = 4 - }; - /// Values for each struct field; the order must match the order of fields - /// in the `type` field of `Literal`. - const flatbuffers::Vector> *values() const { - return GetPointer> *>(VT_VALUES); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_VALUES) && - verifier.VerifyVector(values()) && - verifier.VerifyVectorOfTables(values()) && - verifier.EndTable(); - } -}; - -struct StructLiteralBuilder { - typedef StructLiteral Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_values(flatbuffers::Offset>> values) { - fbb_.AddOffset(StructLiteral::VT_VALUES, values); - } - explicit StructLiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - StructLiteralBuilder &operator=(const StructLiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, StructLiteral::VT_VALUES); - return o; - } -}; - -inline flatbuffers::Offset CreateStructLiteral( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset>> values = 0) { - StructLiteralBuilder builder_(_fbb); - builder_.add_values(values); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateStructLiteralDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector> *values = nullptr) { - auto values__ = values ? _fbb.CreateVector>(*values) : 0; - return org::apache::arrow::computeir::flatbuf::CreateStructLiteral( - _fbb, - values__); -} - -struct KeyValue FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef KeyValueBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_KEY = 4, - VT_VALUE = 6 - }; - const org::apache::arrow::computeir::flatbuf::Literal *key() const { - return GetPointer(VT_KEY); - } - const org::apache::arrow::computeir::flatbuf::Literal *value() const { - return GetPointer(VT_VALUE); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_KEY) && - verifier.VerifyTable(key()) && - VerifyOffsetRequired(verifier, VT_VALUE) && - verifier.VerifyTable(value()) && - verifier.EndTable(); - } -}; - -struct KeyValueBuilder { - typedef KeyValue Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_key(flatbuffers::Offset key) { - fbb_.AddOffset(KeyValue::VT_KEY, key); - } - void add_value(flatbuffers::Offset value) { - fbb_.AddOffset(KeyValue::VT_VALUE, value); - } - explicit KeyValueBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - KeyValueBuilder &operator=(const KeyValueBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, KeyValue::VT_KEY); - fbb_.Required(o, KeyValue::VT_VALUE); - return o; - } -}; - -inline flatbuffers::Offset CreateKeyValue( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset key = 0, - flatbuffers::Offset value = 0) { - KeyValueBuilder builder_(_fbb); - builder_.add_value(value); - builder_.add_key(key); - return builder_.Finish(); -} - -struct MapLiteral FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef MapLiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUES = 4 - }; - const flatbuffers::Vector> *values() const { - return GetPointer> *>(VT_VALUES); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_VALUES) && - verifier.VerifyVector(values()) && - verifier.VerifyVectorOfTables(values()) && - verifier.EndTable(); - } -}; - -struct MapLiteralBuilder { - typedef MapLiteral Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_values(flatbuffers::Offset>> values) { - fbb_.AddOffset(MapLiteral::VT_VALUES, values); - } - explicit MapLiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - MapLiteralBuilder &operator=(const MapLiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, MapLiteral::VT_VALUES); - return o; - } -}; - -inline flatbuffers::Offset CreateMapLiteral( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset>> values = 0) { - MapLiteralBuilder builder_(_fbb); - builder_.add_values(values); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateMapLiteralDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector> *values = nullptr) { - auto values__ = values ? _fbb.CreateVector>(*values) : 0; - return org::apache::arrow::computeir::flatbuf::CreateMapLiteral( - _fbb, - values__); -} - -struct Int8Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Int8LiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - int8_t value() const { - return GetField(VT_VALUE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct Int8LiteralBuilder { - typedef Int8Literal Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(int8_t value) { - fbb_.AddElement(Int8Literal::VT_VALUE, value, 0); - } - explicit Int8LiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - Int8LiteralBuilder &operator=(const Int8LiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateInt8Literal( - flatbuffers::FlatBufferBuilder &_fbb, - int8_t value = 0) { - Int8LiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct Int16Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Int16LiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - int16_t value() const { - return GetField(VT_VALUE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct Int16LiteralBuilder { - typedef Int16Literal Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(int16_t value) { - fbb_.AddElement(Int16Literal::VT_VALUE, value, 0); - } - explicit Int16LiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - Int16LiteralBuilder &operator=(const Int16LiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateInt16Literal( - flatbuffers::FlatBufferBuilder &_fbb, - int16_t value = 0) { - Int16LiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct Int32Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Int32LiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - int32_t value() const { - return GetField(VT_VALUE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct Int32LiteralBuilder { - typedef Int32Literal Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(int32_t value) { - fbb_.AddElement(Int32Literal::VT_VALUE, value, 0); - } - explicit Int32LiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - Int32LiteralBuilder &operator=(const Int32LiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateInt32Literal( - flatbuffers::FlatBufferBuilder &_fbb, - int32_t value = 0) { - Int32LiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct Int64Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Int64LiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - int64_t value() const { - return GetField(VT_VALUE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct Int64LiteralBuilder { - typedef Int64Literal Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(int64_t value) { - fbb_.AddElement(Int64Literal::VT_VALUE, value, 0); - } - explicit Int64LiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - Int64LiteralBuilder &operator=(const Int64LiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateInt64Literal( - flatbuffers::FlatBufferBuilder &_fbb, - int64_t value = 0) { - Int64LiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct UInt8Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef UInt8LiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - uint8_t value() const { - return GetField(VT_VALUE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct UInt8LiteralBuilder { - typedef UInt8Literal Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(uint8_t value) { - fbb_.AddElement(UInt8Literal::VT_VALUE, value, 0); - } - explicit UInt8LiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - UInt8LiteralBuilder &operator=(const UInt8LiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateUInt8Literal( - flatbuffers::FlatBufferBuilder &_fbb, - uint8_t value = 0) { - UInt8LiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct UInt16Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef UInt16LiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - uint16_t value() const { - return GetField(VT_VALUE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct UInt16LiteralBuilder { - typedef UInt16Literal Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(uint16_t value) { - fbb_.AddElement(UInt16Literal::VT_VALUE, value, 0); - } - explicit UInt16LiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - UInt16LiteralBuilder &operator=(const UInt16LiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateUInt16Literal( - flatbuffers::FlatBufferBuilder &_fbb, - uint16_t value = 0) { - UInt16LiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct UInt32Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef UInt32LiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - uint32_t value() const { - return GetField(VT_VALUE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct UInt32LiteralBuilder { - typedef UInt32Literal Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(uint32_t value) { - fbb_.AddElement(UInt32Literal::VT_VALUE, value, 0); - } - explicit UInt32LiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - UInt32LiteralBuilder &operator=(const UInt32LiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateUInt32Literal( - flatbuffers::FlatBufferBuilder &_fbb, - uint32_t value = 0) { - UInt32LiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct UInt64Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef UInt64LiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - uint64_t value() const { - return GetField(VT_VALUE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct UInt64LiteralBuilder { - typedef UInt64Literal Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(uint64_t value) { - fbb_.AddElement(UInt64Literal::VT_VALUE, value, 0); - } - explicit UInt64LiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - UInt64LiteralBuilder &operator=(const UInt64LiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateUInt64Literal( - flatbuffers::FlatBufferBuilder &_fbb, - uint64_t value = 0) { - UInt64LiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct Float16Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Float16LiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - uint16_t value() const { - return GetField(VT_VALUE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct Float16LiteralBuilder { - typedef Float16Literal Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(uint16_t value) { - fbb_.AddElement(Float16Literal::VT_VALUE, value, 0); - } - explicit Float16LiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - Float16LiteralBuilder &operator=(const Float16LiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateFloat16Literal( - flatbuffers::FlatBufferBuilder &_fbb, - uint16_t value = 0) { - Float16LiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct Float32Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Float32LiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - float value() const { - return GetField(VT_VALUE, 0.0f); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct Float32LiteralBuilder { - typedef Float32Literal Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(float value) { - fbb_.AddElement(Float32Literal::VT_VALUE, value, 0.0f); - } - explicit Float32LiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - Float32LiteralBuilder &operator=(const Float32LiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateFloat32Literal( - flatbuffers::FlatBufferBuilder &_fbb, - float value = 0.0f) { - Float32LiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct Float64Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Float64LiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - double value() const { - return GetField(VT_VALUE, 0.0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct Float64LiteralBuilder { - typedef Float64Literal Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(double value) { - fbb_.AddElement(Float64Literal::VT_VALUE, value, 0.0); - } - explicit Float64LiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - Float64LiteralBuilder &operator=(const Float64LiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateFloat64Literal( - flatbuffers::FlatBufferBuilder &_fbb, - double value = 0.0) { - Float64LiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct DecimalLiteral FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef DecimalLiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - /// Bytes of a Decimal value; bytes must be in little-endian order. - const flatbuffers::Vector *value() const { - return GetPointer *>(VT_VALUE); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_VALUE) && - verifier.VerifyVector(value()) && - verifier.EndTable(); - } -}; - -struct DecimalLiteralBuilder { - typedef DecimalLiteral Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(flatbuffers::Offset> value) { - fbb_.AddOffset(DecimalLiteral::VT_VALUE, value); - } - explicit DecimalLiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - DecimalLiteralBuilder &operator=(const DecimalLiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, DecimalLiteral::VT_VALUE); - return o; - } -}; - -inline flatbuffers::Offset CreateDecimalLiteral( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset> value = 0) { - DecimalLiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateDecimalLiteralDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector *value = nullptr) { - auto value__ = value ? _fbb.CreateVector(*value) : 0; - return org::apache::arrow::computeir::flatbuf::CreateDecimalLiteral( - _fbb, - value__); -} - -struct BooleanLiteral FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef BooleanLiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - bool value() const { - return GetField(VT_VALUE, 0) != 0; - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct BooleanLiteralBuilder { - typedef BooleanLiteral Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(bool value) { - fbb_.AddElement(BooleanLiteral::VT_VALUE, static_cast(value), 0); - } - explicit BooleanLiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - BooleanLiteralBuilder &operator=(const BooleanLiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateBooleanLiteral( - flatbuffers::FlatBufferBuilder &_fbb, - bool value = false) { - BooleanLiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct DateLiteral FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef DateLiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - int64_t value() const { - return GetField(VT_VALUE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct DateLiteralBuilder { - typedef DateLiteral Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(int64_t value) { - fbb_.AddElement(DateLiteral::VT_VALUE, value, 0); - } - explicit DateLiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - DateLiteralBuilder &operator=(const DateLiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateDateLiteral( - flatbuffers::FlatBufferBuilder &_fbb, - int64_t value = 0) { - DateLiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct TimeLiteral FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef TimeLiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - int64_t value() const { - return GetField(VT_VALUE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct TimeLiteralBuilder { - typedef TimeLiteral Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(int64_t value) { - fbb_.AddElement(TimeLiteral::VT_VALUE, value, 0); - } - explicit TimeLiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - TimeLiteralBuilder &operator=(const TimeLiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateTimeLiteral( - flatbuffers::FlatBufferBuilder &_fbb, - int64_t value = 0) { - TimeLiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct TimestampLiteral FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef TimestampLiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - int64_t value() const { - return GetField(VT_VALUE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct TimestampLiteralBuilder { - typedef TimestampLiteral Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(int64_t value) { - fbb_.AddElement(TimestampLiteral::VT_VALUE, value, 0); - } - explicit TimestampLiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - TimestampLiteralBuilder &operator=(const TimestampLiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateTimestampLiteral( - flatbuffers::FlatBufferBuilder &_fbb, - int64_t value = 0) { - TimestampLiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct IntervalLiteralMonths FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef IntervalLiteralMonthsBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_MONTHS = 4 - }; - int32_t months() const { - return GetField(VT_MONTHS, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_MONTHS) && - verifier.EndTable(); - } -}; - -struct IntervalLiteralMonthsBuilder { - typedef IntervalLiteralMonths Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_months(int32_t months) { - fbb_.AddElement(IntervalLiteralMonths::VT_MONTHS, months, 0); - } - explicit IntervalLiteralMonthsBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - IntervalLiteralMonthsBuilder &operator=(const IntervalLiteralMonthsBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateIntervalLiteralMonths( - flatbuffers::FlatBufferBuilder &_fbb, - int32_t months = 0) { - IntervalLiteralMonthsBuilder builder_(_fbb); - builder_.add_months(months); - return builder_.Finish(); -} - -struct IntervalLiteralDaysMilliseconds FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef IntervalLiteralDaysMillisecondsBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_DAYS = 4, - VT_MILLISECONDS = 6 - }; - int32_t days() const { - return GetField(VT_DAYS, 0); - } - int32_t milliseconds() const { - return GetField(VT_MILLISECONDS, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_DAYS) && - VerifyField(verifier, VT_MILLISECONDS) && - verifier.EndTable(); - } -}; - -struct IntervalLiteralDaysMillisecondsBuilder { - typedef IntervalLiteralDaysMilliseconds Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_days(int32_t days) { - fbb_.AddElement(IntervalLiteralDaysMilliseconds::VT_DAYS, days, 0); - } - void add_milliseconds(int32_t milliseconds) { - fbb_.AddElement(IntervalLiteralDaysMilliseconds::VT_MILLISECONDS, milliseconds, 0); - } - explicit IntervalLiteralDaysMillisecondsBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - IntervalLiteralDaysMillisecondsBuilder &operator=(const IntervalLiteralDaysMillisecondsBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateIntervalLiteralDaysMilliseconds( - flatbuffers::FlatBufferBuilder &_fbb, - int32_t days = 0, - int32_t milliseconds = 0) { - IntervalLiteralDaysMillisecondsBuilder builder_(_fbb); - builder_.add_milliseconds(milliseconds); - builder_.add_days(days); - return builder_.Finish(); -} - -struct IntervalLiteral FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef IntervalLiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE_TYPE = 4, - VT_VALUE = 6 - }; - org::apache::arrow::computeir::flatbuf::IntervalLiteralImpl value_type() const { - return static_cast(GetField(VT_VALUE_TYPE, 0)); - } - const void *value() const { - return GetPointer(VT_VALUE); - } - template const T *value_as() const; - const org::apache::arrow::computeir::flatbuf::IntervalLiteralMonths *value_as_IntervalLiteralMonths() const { - return value_type() == org::apache::arrow::computeir::flatbuf::IntervalLiteralImpl::IntervalLiteralMonths ? static_cast(value()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::IntervalLiteralDaysMilliseconds *value_as_IntervalLiteralDaysMilliseconds() const { - return value_type() == org::apache::arrow::computeir::flatbuf::IntervalLiteralImpl::IntervalLiteralDaysMilliseconds ? static_cast(value()) : nullptr; - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE_TYPE) && - VerifyOffsetRequired(verifier, VT_VALUE) && - VerifyIntervalLiteralImpl(verifier, value(), value_type()) && - verifier.EndTable(); - } -}; - -template<> inline const org::apache::arrow::computeir::flatbuf::IntervalLiteralMonths *IntervalLiteral::value_as() const { - return value_as_IntervalLiteralMonths(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::IntervalLiteralDaysMilliseconds *IntervalLiteral::value_as() const { - return value_as_IntervalLiteralDaysMilliseconds(); -} - -struct IntervalLiteralBuilder { - typedef IntervalLiteral Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value_type(org::apache::arrow::computeir::flatbuf::IntervalLiteralImpl value_type) { - fbb_.AddElement(IntervalLiteral::VT_VALUE_TYPE, static_cast(value_type), 0); - } - void add_value(flatbuffers::Offset value) { - fbb_.AddOffset(IntervalLiteral::VT_VALUE, value); - } - explicit IntervalLiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - IntervalLiteralBuilder &operator=(const IntervalLiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, IntervalLiteral::VT_VALUE); - return o; - } -}; - -inline flatbuffers::Offset CreateIntervalLiteral( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::computeir::flatbuf::IntervalLiteralImpl value_type = org::apache::arrow::computeir::flatbuf::IntervalLiteralImpl::NONE, - flatbuffers::Offset value = 0) { - IntervalLiteralBuilder builder_(_fbb); - builder_.add_value(value); - builder_.add_value_type(value_type); - return builder_.Finish(); -} - -struct DurationLiteral FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef DurationLiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - int64_t value() const { - return GetField(VT_VALUE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUE) && - verifier.EndTable(); - } -}; - -struct DurationLiteralBuilder { - typedef DurationLiteral Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(int64_t value) { - fbb_.AddElement(DurationLiteral::VT_VALUE, value, 0); - } - explicit DurationLiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - DurationLiteralBuilder &operator=(const DurationLiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateDurationLiteral( - flatbuffers::FlatBufferBuilder &_fbb, - int64_t value = 0) { - DurationLiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -struct BinaryLiteral FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef BinaryLiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - const flatbuffers::Vector *value() const { - return GetPointer *>(VT_VALUE); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_VALUE) && - verifier.VerifyVector(value()) && - verifier.EndTable(); - } -}; - -struct BinaryLiteralBuilder { - typedef BinaryLiteral Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(flatbuffers::Offset> value) { - fbb_.AddOffset(BinaryLiteral::VT_VALUE, value); - } - explicit BinaryLiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - BinaryLiteralBuilder &operator=(const BinaryLiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, BinaryLiteral::VT_VALUE); - return o; - } -}; - -inline flatbuffers::Offset CreateBinaryLiteral( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset> value = 0) { - BinaryLiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateBinaryLiteralDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector *value = nullptr) { - auto value__ = value ? _fbb.CreateVector(*value) : 0; - return org::apache::arrow::computeir::flatbuf::CreateBinaryLiteral( - _fbb, - value__); -} - -struct FixedSizeBinaryLiteral FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef FixedSizeBinaryLiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - const flatbuffers::Vector *value() const { - return GetPointer *>(VT_VALUE); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_VALUE) && - verifier.VerifyVector(value()) && - verifier.EndTable(); - } -}; - -struct FixedSizeBinaryLiteralBuilder { - typedef FixedSizeBinaryLiteral Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(flatbuffers::Offset> value) { - fbb_.AddOffset(FixedSizeBinaryLiteral::VT_VALUE, value); - } - explicit FixedSizeBinaryLiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - FixedSizeBinaryLiteralBuilder &operator=(const FixedSizeBinaryLiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, FixedSizeBinaryLiteral::VT_VALUE); - return o; - } -}; - -inline flatbuffers::Offset CreateFixedSizeBinaryLiteral( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset> value = 0) { - FixedSizeBinaryLiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateFixedSizeBinaryLiteralDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector *value = nullptr) { - auto value__ = value ? _fbb.CreateVector(*value) : 0; - return org::apache::arrow::computeir::flatbuf::CreateFixedSizeBinaryLiteral( - _fbb, - value__); -} - -struct StringLiteral FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef StringLiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VALUE = 4 - }; - const flatbuffers::String *value() const { - return GetPointer(VT_VALUE); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_VALUE) && - verifier.VerifyString(value()) && - verifier.EndTable(); - } -}; - -struct StringLiteralBuilder { - typedef StringLiteral Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_value(flatbuffers::Offset value) { - fbb_.AddOffset(StringLiteral::VT_VALUE, value); - } - explicit StringLiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - StringLiteralBuilder &operator=(const StringLiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, StringLiteral::VT_VALUE); - return o; - } -}; - -inline flatbuffers::Offset CreateStringLiteral( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset value = 0) { - StringLiteralBuilder builder_(_fbb); - builder_.add_value(value); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateStringLiteralDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *value = nullptr) { - auto value__ = value ? _fbb.CreateString(value) : 0; - return org::apache::arrow::computeir::flatbuf::CreateStringLiteral( - _fbb, - value__); -} - -struct Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef LiteralBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_IMPL_TYPE = 4, - VT_IMPL = 6, - VT_TYPE = 8 - }; - org::apache::arrow::computeir::flatbuf::LiteralImpl impl_type() const { - return static_cast(GetField(VT_IMPL_TYPE, 0)); - } - /// Literal value data; for null literals do not include this field. - const void *impl() const { - return GetPointer(VT_IMPL); - } - template const T *impl_as() const; - const org::apache::arrow::computeir::flatbuf::BooleanLiteral *impl_as_BooleanLiteral() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::BooleanLiteral ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Int8Literal *impl_as_Int8Literal() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::Int8Literal ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Int16Literal *impl_as_Int16Literal() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::Int16Literal ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Int32Literal *impl_as_Int32Literal() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::Int32Literal ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Int64Literal *impl_as_Int64Literal() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::Int64Literal ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::UInt8Literal *impl_as_UInt8Literal() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::UInt8Literal ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::UInt16Literal *impl_as_UInt16Literal() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::UInt16Literal ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::UInt32Literal *impl_as_UInt32Literal() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::UInt32Literal ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::UInt64Literal *impl_as_UInt64Literal() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::UInt64Literal ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::DateLiteral *impl_as_DateLiteral() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::DateLiteral ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::TimeLiteral *impl_as_TimeLiteral() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::TimeLiteral ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::TimestampLiteral *impl_as_TimestampLiteral() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::TimestampLiteral ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::IntervalLiteral *impl_as_IntervalLiteral() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::IntervalLiteral ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::DurationLiteral *impl_as_DurationLiteral() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::DurationLiteral ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::DecimalLiteral *impl_as_DecimalLiteral() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::DecimalLiteral ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Float16Literal *impl_as_Float16Literal() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::Float16Literal ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Float32Literal *impl_as_Float32Literal() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::Float32Literal ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Float64Literal *impl_as_Float64Literal() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::Float64Literal ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::ListLiteral *impl_as_ListLiteral() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::ListLiteral ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::StructLiteral *impl_as_StructLiteral() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::StructLiteral ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::MapLiteral *impl_as_MapLiteral() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::MapLiteral ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::StringLiteral *impl_as_StringLiteral() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::StringLiteral ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::BinaryLiteral *impl_as_BinaryLiteral() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::BinaryLiteral ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::FixedSizeBinaryLiteral *impl_as_FixedSizeBinaryLiteral() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::LiteralImpl::FixedSizeBinaryLiteral ? static_cast(impl()) : nullptr; - } - /// Type of the literal value. This must match `impl`. - const org::apache::arrow::flatbuf::Field *type() const { - return GetPointer(VT_TYPE); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_IMPL_TYPE) && - VerifyOffset(verifier, VT_IMPL) && - VerifyLiteralImpl(verifier, impl(), impl_type()) && - VerifyOffsetRequired(verifier, VT_TYPE) && - verifier.VerifyTable(type()) && - verifier.EndTable(); - } -}; - -template<> inline const org::apache::arrow::computeir::flatbuf::BooleanLiteral *Literal::impl_as() const { - return impl_as_BooleanLiteral(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Int8Literal *Literal::impl_as() const { - return impl_as_Int8Literal(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Int16Literal *Literal::impl_as() const { - return impl_as_Int16Literal(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Int32Literal *Literal::impl_as() const { - return impl_as_Int32Literal(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Int64Literal *Literal::impl_as() const { - return impl_as_Int64Literal(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::UInt8Literal *Literal::impl_as() const { - return impl_as_UInt8Literal(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::UInt16Literal *Literal::impl_as() const { - return impl_as_UInt16Literal(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::UInt32Literal *Literal::impl_as() const { - return impl_as_UInt32Literal(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::UInt64Literal *Literal::impl_as() const { - return impl_as_UInt64Literal(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::DateLiteral *Literal::impl_as() const { - return impl_as_DateLiteral(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::TimeLiteral *Literal::impl_as() const { - return impl_as_TimeLiteral(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::TimestampLiteral *Literal::impl_as() const { - return impl_as_TimestampLiteral(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::IntervalLiteral *Literal::impl_as() const { - return impl_as_IntervalLiteral(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::DurationLiteral *Literal::impl_as() const { - return impl_as_DurationLiteral(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::DecimalLiteral *Literal::impl_as() const { - return impl_as_DecimalLiteral(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Float16Literal *Literal::impl_as() const { - return impl_as_Float16Literal(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Float32Literal *Literal::impl_as() const { - return impl_as_Float32Literal(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Float64Literal *Literal::impl_as() const { - return impl_as_Float64Literal(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::ListLiteral *Literal::impl_as() const { - return impl_as_ListLiteral(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::StructLiteral *Literal::impl_as() const { - return impl_as_StructLiteral(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::MapLiteral *Literal::impl_as() const { - return impl_as_MapLiteral(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::StringLiteral *Literal::impl_as() const { - return impl_as_StringLiteral(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::BinaryLiteral *Literal::impl_as() const { - return impl_as_BinaryLiteral(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::FixedSizeBinaryLiteral *Literal::impl_as() const { - return impl_as_FixedSizeBinaryLiteral(); -} - -struct LiteralBuilder { - typedef Literal Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_impl_type(org::apache::arrow::computeir::flatbuf::LiteralImpl impl_type) { - fbb_.AddElement(Literal::VT_IMPL_TYPE, static_cast(impl_type), 0); - } - void add_impl(flatbuffers::Offset impl) { - fbb_.AddOffset(Literal::VT_IMPL, impl); - } - void add_type(flatbuffers::Offset type) { - fbb_.AddOffset(Literal::VT_TYPE, type); - } - explicit LiteralBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - LiteralBuilder &operator=(const LiteralBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Literal::VT_TYPE); - return o; - } -}; - -inline flatbuffers::Offset CreateLiteral( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::computeir::flatbuf::LiteralImpl impl_type = org::apache::arrow::computeir::flatbuf::LiteralImpl::NONE, - flatbuffers::Offset impl = 0, - flatbuffers::Offset type = 0) { - LiteralBuilder builder_(_fbb); - builder_.add_type(type); - builder_.add_impl(impl); - builder_.add_impl_type(impl_type); - return builder_.Finish(); -} - -inline bool VerifyIntervalLiteralImpl(flatbuffers::Verifier &verifier, const void *obj, IntervalLiteralImpl type) { - switch (type) { - case IntervalLiteralImpl::NONE: { - return true; - } - case IntervalLiteralImpl::IntervalLiteralMonths: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case IntervalLiteralImpl::IntervalLiteralDaysMilliseconds: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - default: return true; - } -} - -inline bool VerifyIntervalLiteralImplVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types) { - if (!values || !types) return !values && !types; - if (values->size() != types->size()) return false; - for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { - if (!VerifyIntervalLiteralImpl( - verifier, values->Get(i), types->GetEnum(i))) { - return false; - } - } - return true; -} - -inline bool VerifyLiteralImpl(flatbuffers::Verifier &verifier, const void *obj, LiteralImpl type) { - switch (type) { - case LiteralImpl::NONE: { - return true; - } - case LiteralImpl::BooleanLiteral: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::Int8Literal: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::Int16Literal: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::Int32Literal: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::Int64Literal: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::UInt8Literal: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::UInt16Literal: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::UInt32Literal: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::UInt64Literal: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::DateLiteral: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::TimeLiteral: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::TimestampLiteral: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::IntervalLiteral: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::DurationLiteral: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::DecimalLiteral: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::Float16Literal: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::Float32Literal: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::Float64Literal: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::ListLiteral: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::StructLiteral: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::MapLiteral: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::StringLiteral: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::BinaryLiteral: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case LiteralImpl::FixedSizeBinaryLiteral: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - default: return true; - } -} - -inline bool VerifyLiteralImplVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types) { - if (!values || !types) return !values && !types; - if (values->size() != types->size()) return false; - for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { - if (!VerifyLiteralImpl( - verifier, values->Get(i), types->GetEnum(i))) { - return false; - } - } - return true; -} - -inline const org::apache::arrow::computeir::flatbuf::Literal *GetLiteral(const void *buf) { - return flatbuffers::GetRoot(buf); -} - -inline const org::apache::arrow::computeir::flatbuf::Literal *GetSizePrefixedLiteral(const void *buf) { - return flatbuffers::GetSizePrefixedRoot(buf); -} - -inline bool VerifyLiteralBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer(nullptr); -} - -inline bool VerifySizePrefixedLiteralBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifySizePrefixedBuffer(nullptr); -} - -inline void FinishLiteralBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset root) { - fbb.Finish(root); -} - -inline void FinishSizePrefixedLiteralBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset root) { - fbb.FinishSizePrefixed(root); -} - -} // namespace flatbuf -} // namespace computeir -} // namespace arrow -} // namespace apache -} // namespace org - -#endif // FLATBUFFERS_GENERATED_LITERAL_ORG_APACHE_ARROW_COMPUTEIR_FLATBUF_H_ diff --git a/cpp/src/generated/Plan_generated.h b/cpp/src/generated/Plan_generated.h deleted file mode 100644 index 33f02af58a07f..0000000000000 --- a/cpp/src/generated/Plan_generated.h +++ /dev/null @@ -1,115 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_PLAN_ORG_APACHE_ARROW_COMPUTEIR_FLATBUF_H_ -#define FLATBUFFERS_GENERATED_PLAN_ORG_APACHE_ARROW_COMPUTEIR_FLATBUF_H_ - -#include "flatbuffers/flatbuffers.h" - -#include "Schema_generated.h" -#include "Expression_generated.h" -#include "Literal_generated.h" -#include "Relation_generated.h" - -namespace org { -namespace apache { -namespace arrow { -namespace computeir { -namespace flatbuf { - -struct Plan; -struct PlanBuilder; - -/// A specification of a query. -struct Plan FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef PlanBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_SINKS = 4 - }; - /// One or more output relations. - const flatbuffers::Vector> *sinks() const { - return GetPointer> *>(VT_SINKS); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_SINKS) && - verifier.VerifyVector(sinks()) && - verifier.VerifyVectorOfTables(sinks()) && - verifier.EndTable(); - } -}; - -struct PlanBuilder { - typedef Plan Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_sinks(flatbuffers::Offset>> sinks) { - fbb_.AddOffset(Plan::VT_SINKS, sinks); - } - explicit PlanBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - PlanBuilder &operator=(const PlanBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Plan::VT_SINKS); - return o; - } -}; - -inline flatbuffers::Offset CreatePlan( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset>> sinks = 0) { - PlanBuilder builder_(_fbb); - builder_.add_sinks(sinks); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreatePlanDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector> *sinks = nullptr) { - auto sinks__ = sinks ? _fbb.CreateVector>(*sinks) : 0; - return org::apache::arrow::computeir::flatbuf::CreatePlan( - _fbb, - sinks__); -} - -inline const org::apache::arrow::computeir::flatbuf::Plan *GetPlan(const void *buf) { - return flatbuffers::GetRoot(buf); -} - -inline const org::apache::arrow::computeir::flatbuf::Plan *GetSizePrefixedPlan(const void *buf) { - return flatbuffers::GetSizePrefixedRoot(buf); -} - -inline bool VerifyPlanBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer(nullptr); -} - -inline bool VerifySizePrefixedPlanBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifySizePrefixedBuffer(nullptr); -} - -inline void FinishPlanBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset root) { - fbb.Finish(root); -} - -inline void FinishSizePrefixedPlanBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset root) { - fbb.FinishSizePrefixed(root); -} - -} // namespace flatbuf -} // namespace computeir -} // namespace arrow -} // namespace apache -} // namespace org - -#endif // FLATBUFFERS_GENERATED_PLAN_ORG_APACHE_ARROW_COMPUTEIR_FLATBUF_H_ diff --git a/cpp/src/generated/Relation_generated.h b/cpp/src/generated/Relation_generated.h deleted file mode 100644 index 110e632aa3f68..0000000000000 --- a/cpp/src/generated/Relation_generated.h +++ /dev/null @@ -1,1428 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_RELATION_ORG_APACHE_ARROW_COMPUTEIR_FLATBUF_H_ -#define FLATBUFFERS_GENERATED_RELATION_ORG_APACHE_ARROW_COMPUTEIR_FLATBUF_H_ - -#include "flatbuffers/flatbuffers.h" - -#include "Schema_generated.h" -#include "Expression_generated.h" -#include "Literal_generated.h" - -namespace org { -namespace apache { -namespace arrow { -namespace computeir { -namespace flatbuf { - -struct RelId; -struct RelIdBuilder; - -struct Filter; -struct FilterBuilder; - -struct Project; -struct ProjectBuilder; - -struct Grouping; -struct GroupingBuilder; - -struct Aggregate; -struct AggregateBuilder; - -struct Join; -struct JoinBuilder; - -struct OrderBy; -struct OrderByBuilder; - -struct Limit; -struct LimitBuilder; - -struct SetOperation; -struct SetOperationBuilder; - -struct LiteralColumn; -struct LiteralColumnBuilder; - -struct LiteralRelation; -struct LiteralRelationBuilder; - -struct Source; -struct SourceBuilder; - -struct Relation; -struct RelationBuilder; - -enum class JoinKind : uint8_t { - Anti = 0, - Cross = 1, - FullOuter = 2, - Inner = 3, - LeftOuter = 4, - LeftSemi = 5, - RightOuter = 6, - MIN = Anti, - MAX = RightOuter -}; - -inline const JoinKind (&EnumValuesJoinKind())[7] { - static const JoinKind values[] = { - JoinKind::Anti, - JoinKind::Cross, - JoinKind::FullOuter, - JoinKind::Inner, - JoinKind::LeftOuter, - JoinKind::LeftSemi, - JoinKind::RightOuter - }; - return values; -} - -inline const char * const *EnumNamesJoinKind() { - static const char * const names[8] = { - "Anti", - "Cross", - "FullOuter", - "Inner", - "LeftOuter", - "LeftSemi", - "RightOuter", - nullptr - }; - return names; -} - -inline const char *EnumNameJoinKind(JoinKind e) { - if (flatbuffers::IsOutRange(e, JoinKind::Anti, JoinKind::RightOuter)) return ""; - const size_t index = static_cast(e); - return EnumNamesJoinKind()[index]; -} - -/// The kind of set operation being performed. -enum class SetOpKind : uint8_t { - Union = 0, - Intersection = 1, - Difference = 2, - MIN = Union, - MAX = Difference -}; - -inline const SetOpKind (&EnumValuesSetOpKind())[3] { - static const SetOpKind values[] = { - SetOpKind::Union, - SetOpKind::Intersection, - SetOpKind::Difference - }; - return values; -} - -inline const char * const *EnumNamesSetOpKind() { - static const char * const names[4] = { - "Union", - "Intersection", - "Difference", - nullptr - }; - return names; -} - -inline const char *EnumNameSetOpKind(SetOpKind e) { - if (flatbuffers::IsOutRange(e, SetOpKind::Union, SetOpKind::Difference)) return ""; - const size_t index = static_cast(e); - return EnumNamesSetOpKind()[index]; -} - -/// The varieties of relations -enum class RelationImpl : uint8_t { - NONE = 0, - Aggregate = 1, - Filter = 2, - Join = 3, - Limit = 4, - LiteralRelation = 5, - OrderBy = 6, - Project = 7, - SetOperation = 8, - Source = 9, - MIN = NONE, - MAX = Source -}; - -inline const RelationImpl (&EnumValuesRelationImpl())[10] { - static const RelationImpl values[] = { - RelationImpl::NONE, - RelationImpl::Aggregate, - RelationImpl::Filter, - RelationImpl::Join, - RelationImpl::Limit, - RelationImpl::LiteralRelation, - RelationImpl::OrderBy, - RelationImpl::Project, - RelationImpl::SetOperation, - RelationImpl::Source - }; - return values; -} - -inline const char * const *EnumNamesRelationImpl() { - static const char * const names[11] = { - "NONE", - "Aggregate", - "Filter", - "Join", - "Limit", - "LiteralRelation", - "OrderBy", - "Project", - "SetOperation", - "Source", - nullptr - }; - return names; -} - -inline const char *EnumNameRelationImpl(RelationImpl e) { - if (flatbuffers::IsOutRange(e, RelationImpl::NONE, RelationImpl::Source)) return ""; - const size_t index = static_cast(e); - return EnumNamesRelationImpl()[index]; -} - -template struct RelationImplTraits { - static const RelationImpl enum_value = RelationImpl::NONE; -}; - -template<> struct RelationImplTraits { - static const RelationImpl enum_value = RelationImpl::Aggregate; -}; - -template<> struct RelationImplTraits { - static const RelationImpl enum_value = RelationImpl::Filter; -}; - -template<> struct RelationImplTraits { - static const RelationImpl enum_value = RelationImpl::Join; -}; - -template<> struct RelationImplTraits { - static const RelationImpl enum_value = RelationImpl::Limit; -}; - -template<> struct RelationImplTraits { - static const RelationImpl enum_value = RelationImpl::LiteralRelation; -}; - -template<> struct RelationImplTraits { - static const RelationImpl enum_value = RelationImpl::OrderBy; -}; - -template<> struct RelationImplTraits { - static const RelationImpl enum_value = RelationImpl::Project; -}; - -template<> struct RelationImplTraits { - static const RelationImpl enum_value = RelationImpl::SetOperation; -}; - -template<> struct RelationImplTraits { - static const RelationImpl enum_value = RelationImpl::Source; -}; - -bool VerifyRelationImpl(flatbuffers::Verifier &verifier, const void *obj, RelationImpl type); -bool VerifyRelationImplVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types); - -/// An identifier for relations in a query. -/// -/// A table is used here to allow plan implementations optionality. -struct RelId FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef RelIdBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ID = 4 - }; - uint64_t id() const { - return GetField(VT_ID, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_ID) && - verifier.EndTable(); - } -}; - -struct RelIdBuilder { - typedef RelId Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_id(uint64_t id) { - fbb_.AddElement(RelId::VT_ID, id, 0); - } - explicit RelIdBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - RelIdBuilder &operator=(const RelIdBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateRelId( - flatbuffers::FlatBufferBuilder &_fbb, - uint64_t id = 0) { - RelIdBuilder builder_(_fbb); - builder_.add_id(id); - return builder_.Finish(); -} - -/// Filter operation -struct Filter FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef FilterBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ID = 4, - VT_REL = 6, - VT_PREDICATE = 8 - }; - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - const org::apache::arrow::computeir::flatbuf::RelId *id() const { - return GetPointer(VT_ID); - } - /// Child relation - const org::apache::arrow::computeir::flatbuf::Relation *rel() const { - return GetPointer(VT_REL); - } - /// The expression which will be evaluated against input rows - /// to determine whether they should be excluded from the - /// filter relation's output. - const org::apache::arrow::computeir::flatbuf::Expression *predicate() const { - return GetPointer(VT_PREDICATE); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_ID) && - verifier.VerifyTable(id()) && - VerifyOffsetRequired(verifier, VT_REL) && - verifier.VerifyTable(rel()) && - VerifyOffsetRequired(verifier, VT_PREDICATE) && - verifier.VerifyTable(predicate()) && - verifier.EndTable(); - } -}; - -struct FilterBuilder { - typedef Filter Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_id(flatbuffers::Offset id) { - fbb_.AddOffset(Filter::VT_ID, id); - } - void add_rel(flatbuffers::Offset rel) { - fbb_.AddOffset(Filter::VT_REL, rel); - } - void add_predicate(flatbuffers::Offset predicate) { - fbb_.AddOffset(Filter::VT_PREDICATE, predicate); - } - explicit FilterBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - FilterBuilder &operator=(const FilterBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Filter::VT_REL); - fbb_.Required(o, Filter::VT_PREDICATE); - return o; - } -}; - -inline flatbuffers::Offset CreateFilter( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - flatbuffers::Offset rel = 0, - flatbuffers::Offset predicate = 0) { - FilterBuilder builder_(_fbb); - builder_.add_predicate(predicate); - builder_.add_rel(rel); - builder_.add_id(id); - return builder_.Finish(); -} - -/// Projection -struct Project FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef ProjectBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ID = 4, - VT_REL = 6, - VT_EXPRESSIONS = 8 - }; - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - const org::apache::arrow::computeir::flatbuf::RelId *id() const { - return GetPointer(VT_ID); - } - /// Child relation - const org::apache::arrow::computeir::flatbuf::Relation *rel() const { - return GetPointer(VT_REL); - } - /// Expressions which will be evaluated to produce to - /// the rows of the project relation's output. - const flatbuffers::Vector> *expressions() const { - return GetPointer> *>(VT_EXPRESSIONS); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_ID) && - verifier.VerifyTable(id()) && - VerifyOffsetRequired(verifier, VT_REL) && - verifier.VerifyTable(rel()) && - VerifyOffsetRequired(verifier, VT_EXPRESSIONS) && - verifier.VerifyVector(expressions()) && - verifier.VerifyVectorOfTables(expressions()) && - verifier.EndTable(); - } -}; - -struct ProjectBuilder { - typedef Project Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_id(flatbuffers::Offset id) { - fbb_.AddOffset(Project::VT_ID, id); - } - void add_rel(flatbuffers::Offset rel) { - fbb_.AddOffset(Project::VT_REL, rel); - } - void add_expressions(flatbuffers::Offset>> expressions) { - fbb_.AddOffset(Project::VT_EXPRESSIONS, expressions); - } - explicit ProjectBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - ProjectBuilder &operator=(const ProjectBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Project::VT_REL); - fbb_.Required(o, Project::VT_EXPRESSIONS); - return o; - } -}; - -inline flatbuffers::Offset CreateProject( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - flatbuffers::Offset rel = 0, - flatbuffers::Offset>> expressions = 0) { - ProjectBuilder builder_(_fbb); - builder_.add_expressions(expressions); - builder_.add_rel(rel); - builder_.add_id(id); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateProjectDirect( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - flatbuffers::Offset rel = 0, - const std::vector> *expressions = nullptr) { - auto expressions__ = expressions ? _fbb.CreateVector>(*expressions) : 0; - return org::apache::arrow::computeir::flatbuf::CreateProject( - _fbb, - id, - rel, - expressions__); -} - -/// A set of grouping keys -struct Grouping FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef GroupingBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_KEYS = 4 - }; - /// Expressions to group by - const flatbuffers::Vector> *keys() const { - return GetPointer> *>(VT_KEYS); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_KEYS) && - verifier.VerifyVector(keys()) && - verifier.VerifyVectorOfTables(keys()) && - verifier.EndTable(); - } -}; - -struct GroupingBuilder { - typedef Grouping Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_keys(flatbuffers::Offset>> keys) { - fbb_.AddOffset(Grouping::VT_KEYS, keys); - } - explicit GroupingBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - GroupingBuilder &operator=(const GroupingBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Grouping::VT_KEYS); - return o; - } -}; - -inline flatbuffers::Offset CreateGrouping( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset>> keys = 0) { - GroupingBuilder builder_(_fbb); - builder_.add_keys(keys); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateGroupingDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector> *keys = nullptr) { - auto keys__ = keys ? _fbb.CreateVector>(*keys) : 0; - return org::apache::arrow::computeir::flatbuf::CreateGrouping( - _fbb, - keys__); -} - -/// Aggregate operation -struct Aggregate FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef AggregateBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ID = 4, - VT_REL = 6, - VT_MEASURES = 8, - VT_GROUPINGS = 10 - }; - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - const org::apache::arrow::computeir::flatbuf::RelId *id() const { - return GetPointer(VT_ID); - } - /// Child relation - const org::apache::arrow::computeir::flatbuf::Relation *rel() const { - return GetPointer(VT_REL); - } - /// Expressions which will be evaluated to produce to - /// the rows of the aggregate relation's output. - const flatbuffers::Vector> *measures() const { - return GetPointer> *>(VT_MEASURES); - } - /// Keys by which `aggregations` will be grouped. - /// - /// The nested list here is to support grouping sets - /// eg - /// - /// SELECT a, b, c, sum(d) - /// FROM t - /// GROUP BY - /// GROUPING SETS ( - /// (a, b, c), - /// (a, b), - /// (a), - /// () - /// ); - const flatbuffers::Vector> *groupings() const { - return GetPointer> *>(VT_GROUPINGS); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_ID) && - verifier.VerifyTable(id()) && - VerifyOffsetRequired(verifier, VT_REL) && - verifier.VerifyTable(rel()) && - VerifyOffsetRequired(verifier, VT_MEASURES) && - verifier.VerifyVector(measures()) && - verifier.VerifyVectorOfTables(measures()) && - VerifyOffsetRequired(verifier, VT_GROUPINGS) && - verifier.VerifyVector(groupings()) && - verifier.VerifyVectorOfTables(groupings()) && - verifier.EndTable(); - } -}; - -struct AggregateBuilder { - typedef Aggregate Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_id(flatbuffers::Offset id) { - fbb_.AddOffset(Aggregate::VT_ID, id); - } - void add_rel(flatbuffers::Offset rel) { - fbb_.AddOffset(Aggregate::VT_REL, rel); - } - void add_measures(flatbuffers::Offset>> measures) { - fbb_.AddOffset(Aggregate::VT_MEASURES, measures); - } - void add_groupings(flatbuffers::Offset>> groupings) { - fbb_.AddOffset(Aggregate::VT_GROUPINGS, groupings); - } - explicit AggregateBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - AggregateBuilder &operator=(const AggregateBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Aggregate::VT_REL); - fbb_.Required(o, Aggregate::VT_MEASURES); - fbb_.Required(o, Aggregate::VT_GROUPINGS); - return o; - } -}; - -inline flatbuffers::Offset CreateAggregate( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - flatbuffers::Offset rel = 0, - flatbuffers::Offset>> measures = 0, - flatbuffers::Offset>> groupings = 0) { - AggregateBuilder builder_(_fbb); - builder_.add_groupings(groupings); - builder_.add_measures(measures); - builder_.add_rel(rel); - builder_.add_id(id); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateAggregateDirect( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - flatbuffers::Offset rel = 0, - const std::vector> *measures = nullptr, - const std::vector> *groupings = nullptr) { - auto measures__ = measures ? _fbb.CreateVector>(*measures) : 0; - auto groupings__ = groupings ? _fbb.CreateVector>(*groupings) : 0; - return org::apache::arrow::computeir::flatbuf::CreateAggregate( - _fbb, - id, - rel, - measures__, - groupings__); -} - -/// Join between two tables -struct Join FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef JoinBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ID = 4, - VT_LEFT = 6, - VT_RIGHT = 8, - VT_ON_EXPRESSION = 10, - VT_JOIN_KIND = 12 - }; - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - const org::apache::arrow::computeir::flatbuf::RelId *id() const { - return GetPointer(VT_ID); - } - /// Left relation - const org::apache::arrow::computeir::flatbuf::Relation *left() const { - return GetPointer(VT_LEFT); - } - /// Right relation - const org::apache::arrow::computeir::flatbuf::Relation *right() const { - return GetPointer(VT_RIGHT); - } - /// The expression which will be evaluated against rows from each - /// input to determine whether they should be included in the - /// join relation's output. - const org::apache::arrow::computeir::flatbuf::Expression *on_expression() const { - return GetPointer(VT_ON_EXPRESSION); - } - /// The kind of join to use. - org::apache::arrow::computeir::flatbuf::JoinKind join_kind() const { - return static_cast(GetField(VT_JOIN_KIND, 0)); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_ID) && - verifier.VerifyTable(id()) && - VerifyOffsetRequired(verifier, VT_LEFT) && - verifier.VerifyTable(left()) && - VerifyOffsetRequired(verifier, VT_RIGHT) && - verifier.VerifyTable(right()) && - VerifyOffsetRequired(verifier, VT_ON_EXPRESSION) && - verifier.VerifyTable(on_expression()) && - VerifyField(verifier, VT_JOIN_KIND) && - verifier.EndTable(); - } -}; - -struct JoinBuilder { - typedef Join Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_id(flatbuffers::Offset id) { - fbb_.AddOffset(Join::VT_ID, id); - } - void add_left(flatbuffers::Offset left) { - fbb_.AddOffset(Join::VT_LEFT, left); - } - void add_right(flatbuffers::Offset right) { - fbb_.AddOffset(Join::VT_RIGHT, right); - } - void add_on_expression(flatbuffers::Offset on_expression) { - fbb_.AddOffset(Join::VT_ON_EXPRESSION, on_expression); - } - void add_join_kind(org::apache::arrow::computeir::flatbuf::JoinKind join_kind) { - fbb_.AddElement(Join::VT_JOIN_KIND, static_cast(join_kind), 0); - } - explicit JoinBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - JoinBuilder &operator=(const JoinBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Join::VT_LEFT); - fbb_.Required(o, Join::VT_RIGHT); - fbb_.Required(o, Join::VT_ON_EXPRESSION); - return o; - } -}; - -inline flatbuffers::Offset CreateJoin( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - flatbuffers::Offset left = 0, - flatbuffers::Offset right = 0, - flatbuffers::Offset on_expression = 0, - org::apache::arrow::computeir::flatbuf::JoinKind join_kind = org::apache::arrow::computeir::flatbuf::JoinKind::Anti) { - JoinBuilder builder_(_fbb); - builder_.add_on_expression(on_expression); - builder_.add_right(right); - builder_.add_left(left); - builder_.add_id(id); - builder_.add_join_kind(join_kind); - return builder_.Finish(); -} - -/// Order by relation -struct OrderBy FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef OrderByBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ID = 4, - VT_REL = 6, - VT_KEYS = 8 - }; - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - const org::apache::arrow::computeir::flatbuf::RelId *id() const { - return GetPointer(VT_ID); - } - /// Child relation - const org::apache::arrow::computeir::flatbuf::Relation *rel() const { - return GetPointer(VT_REL); - } - /// Define sort order for rows of output. - /// Keys with higher precedence are ordered ahead of other keys. - const flatbuffers::Vector> *keys() const { - return GetPointer> *>(VT_KEYS); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_ID) && - verifier.VerifyTable(id()) && - VerifyOffsetRequired(verifier, VT_REL) && - verifier.VerifyTable(rel()) && - VerifyOffsetRequired(verifier, VT_KEYS) && - verifier.VerifyVector(keys()) && - verifier.VerifyVectorOfTables(keys()) && - verifier.EndTable(); - } -}; - -struct OrderByBuilder { - typedef OrderBy Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_id(flatbuffers::Offset id) { - fbb_.AddOffset(OrderBy::VT_ID, id); - } - void add_rel(flatbuffers::Offset rel) { - fbb_.AddOffset(OrderBy::VT_REL, rel); - } - void add_keys(flatbuffers::Offset>> keys) { - fbb_.AddOffset(OrderBy::VT_KEYS, keys); - } - explicit OrderByBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - OrderByBuilder &operator=(const OrderByBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, OrderBy::VT_REL); - fbb_.Required(o, OrderBy::VT_KEYS); - return o; - } -}; - -inline flatbuffers::Offset CreateOrderBy( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - flatbuffers::Offset rel = 0, - flatbuffers::Offset>> keys = 0) { - OrderByBuilder builder_(_fbb); - builder_.add_keys(keys); - builder_.add_rel(rel); - builder_.add_id(id); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateOrderByDirect( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - flatbuffers::Offset rel = 0, - const std::vector> *keys = nullptr) { - auto keys__ = keys ? _fbb.CreateVector>(*keys) : 0; - return org::apache::arrow::computeir::flatbuf::CreateOrderBy( - _fbb, - id, - rel, - keys__); -} - -/// Limit operation -struct Limit FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef LimitBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ID = 4, - VT_REL = 6, - VT_OFFSET = 8, - VT_COUNT = 10 - }; - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - const org::apache::arrow::computeir::flatbuf::RelId *id() const { - return GetPointer(VT_ID); - } - /// Child relation - const org::apache::arrow::computeir::flatbuf::Relation *rel() const { - return GetPointer(VT_REL); - } - /// Starting index of rows - uint32_t offset() const { - return GetField(VT_OFFSET, 0); - } - /// The maximum number of rows of output. - uint32_t count() const { - return GetField(VT_COUNT, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_ID) && - verifier.VerifyTable(id()) && - VerifyOffsetRequired(verifier, VT_REL) && - verifier.VerifyTable(rel()) && - VerifyField(verifier, VT_OFFSET) && - VerifyField(verifier, VT_COUNT) && - verifier.EndTable(); - } -}; - -struct LimitBuilder { - typedef Limit Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_id(flatbuffers::Offset id) { - fbb_.AddOffset(Limit::VT_ID, id); - } - void add_rel(flatbuffers::Offset rel) { - fbb_.AddOffset(Limit::VT_REL, rel); - } - void add_offset(uint32_t offset) { - fbb_.AddElement(Limit::VT_OFFSET, offset, 0); - } - void add_count(uint32_t count) { - fbb_.AddElement(Limit::VT_COUNT, count, 0); - } - explicit LimitBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - LimitBuilder &operator=(const LimitBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Limit::VT_REL); - return o; - } -}; - -inline flatbuffers::Offset CreateLimit( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - flatbuffers::Offset rel = 0, - uint32_t offset = 0, - uint32_t count = 0) { - LimitBuilder builder_(_fbb); - builder_.add_count(count); - builder_.add_offset(offset); - builder_.add_rel(rel); - builder_.add_id(id); - return builder_.Finish(); -} - -/// A set operation on two or more relations -struct SetOperation FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef SetOperationBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ID = 4, - VT_RELS = 6, - VT_SET_OP = 8 - }; - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - const org::apache::arrow::computeir::flatbuf::RelId *id() const { - return GetPointer(VT_ID); - } - /// Child relations - const flatbuffers::Vector> *rels() const { - return GetPointer> *>(VT_RELS); - } - /// The kind of set operation - org::apache::arrow::computeir::flatbuf::SetOpKind set_op() const { - return static_cast(GetField(VT_SET_OP, 0)); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_ID) && - verifier.VerifyTable(id()) && - VerifyOffsetRequired(verifier, VT_RELS) && - verifier.VerifyVector(rels()) && - verifier.VerifyVectorOfTables(rels()) && - VerifyField(verifier, VT_SET_OP) && - verifier.EndTable(); - } -}; - -struct SetOperationBuilder { - typedef SetOperation Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_id(flatbuffers::Offset id) { - fbb_.AddOffset(SetOperation::VT_ID, id); - } - void add_rels(flatbuffers::Offset>> rels) { - fbb_.AddOffset(SetOperation::VT_RELS, rels); - } - void add_set_op(org::apache::arrow::computeir::flatbuf::SetOpKind set_op) { - fbb_.AddElement(SetOperation::VT_SET_OP, static_cast(set_op), 0); - } - explicit SetOperationBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - SetOperationBuilder &operator=(const SetOperationBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, SetOperation::VT_RELS); - return o; - } -}; - -inline flatbuffers::Offset CreateSetOperation( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - flatbuffers::Offset>> rels = 0, - org::apache::arrow::computeir::flatbuf::SetOpKind set_op = org::apache::arrow::computeir::flatbuf::SetOpKind::Union) { - SetOperationBuilder builder_(_fbb); - builder_.add_rels(rels); - builder_.add_id(id); - builder_.add_set_op(set_op); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateSetOperationDirect( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - const std::vector> *rels = nullptr, - org::apache::arrow::computeir::flatbuf::SetOpKind set_op = org::apache::arrow::computeir::flatbuf::SetOpKind::Union) { - auto rels__ = rels ? _fbb.CreateVector>(*rels) : 0; - return org::apache::arrow::computeir::flatbuf::CreateSetOperation( - _fbb, - id, - rels__, - set_op); -} - -/// A single column of literal values. -struct LiteralColumn FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef LiteralColumnBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ELEMENTS = 4 - }; - /// The literal values of the column - const flatbuffers::Vector> *elements() const { - return GetPointer> *>(VT_ELEMENTS); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_ELEMENTS) && - verifier.VerifyVector(elements()) && - verifier.VerifyVectorOfTables(elements()) && - verifier.EndTable(); - } -}; - -struct LiteralColumnBuilder { - typedef LiteralColumn Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_elements(flatbuffers::Offset>> elements) { - fbb_.AddOffset(LiteralColumn::VT_ELEMENTS, elements); - } - explicit LiteralColumnBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - LiteralColumnBuilder &operator=(const LiteralColumnBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, LiteralColumn::VT_ELEMENTS); - return o; - } -}; - -inline flatbuffers::Offset CreateLiteralColumn( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset>> elements = 0) { - LiteralColumnBuilder builder_(_fbb); - builder_.add_elements(elements); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateLiteralColumnDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector> *elements = nullptr) { - auto elements__ = elements ? _fbb.CreateVector>(*elements) : 0; - return org::apache::arrow::computeir::flatbuf::CreateLiteralColumn( - _fbb, - elements__); -} - -/// Literal relation -struct LiteralRelation FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef LiteralRelationBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ID = 4, - VT_COLUMNS = 6 - }; - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - const org::apache::arrow::computeir::flatbuf::RelId *id() const { - return GetPointer(VT_ID); - } - /// The columns of this literal relation. - const flatbuffers::Vector> *columns() const { - return GetPointer> *>(VT_COLUMNS); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_ID) && - verifier.VerifyTable(id()) && - VerifyOffsetRequired(verifier, VT_COLUMNS) && - verifier.VerifyVector(columns()) && - verifier.VerifyVectorOfTables(columns()) && - verifier.EndTable(); - } -}; - -struct LiteralRelationBuilder { - typedef LiteralRelation Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_id(flatbuffers::Offset id) { - fbb_.AddOffset(LiteralRelation::VT_ID, id); - } - void add_columns(flatbuffers::Offset>> columns) { - fbb_.AddOffset(LiteralRelation::VT_COLUMNS, columns); - } - explicit LiteralRelationBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - LiteralRelationBuilder &operator=(const LiteralRelationBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, LiteralRelation::VT_COLUMNS); - return o; - } -}; - -inline flatbuffers::Offset CreateLiteralRelation( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - flatbuffers::Offset>> columns = 0) { - LiteralRelationBuilder builder_(_fbb); - builder_.add_columns(columns); - builder_.add_id(id); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateLiteralRelationDirect( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - const std::vector> *columns = nullptr) { - auto columns__ = columns ? _fbb.CreateVector>(*columns) : 0; - return org::apache::arrow::computeir::flatbuf::CreateLiteralRelation( - _fbb, - id, - columns__); -} - -/// An external source of tabular data -struct Source FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef SourceBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ID = 4, - VT_NAME = 6, - VT_FILTER = 8, - VT_SCHEMA = 10, - VT_PROJECTION = 12 - }; - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - const org::apache::arrow::computeir::flatbuf::RelId *id() const { - return GetPointer(VT_ID); - } - const flatbuffers::String *name() const { - return GetPointer(VT_NAME); - } - /// An optional expression used to filter out rows directly from the source. - /// - /// Useful for consumers that implement predicate pushdown. - /// - /// A missing filter value indicates no filter, i.e., all rows are - /// returned from the source. - const org::apache::arrow::computeir::flatbuf::Expression *filter() const { - return GetPointer(VT_FILTER); - } - /// Schemas are explicitly optional - const org::apache::arrow::flatbuf::Schema *schema() const { - return GetPointer(VT_SCHEMA); - } - /// An optional list of field indices indicating which columns should be read - /// from the source. Columns excluded from this listing will instead be replaced - /// with all-null placeholders to guarantee that the schema of the source is - /// unaffected by this projection. - /// - /// A missing value indicates all columns should be read. - /// - /// The behavior of an empty list is undefined. - const flatbuffers::Vector> *projection() const { - return GetPointer> *>(VT_PROJECTION); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_ID) && - verifier.VerifyTable(id()) && - VerifyOffsetRequired(verifier, VT_NAME) && - verifier.VerifyString(name()) && - VerifyOffset(verifier, VT_FILTER) && - verifier.VerifyTable(filter()) && - VerifyOffset(verifier, VT_SCHEMA) && - verifier.VerifyTable(schema()) && - VerifyOffset(verifier, VT_PROJECTION) && - verifier.VerifyVector(projection()) && - verifier.VerifyVectorOfTables(projection()) && - verifier.EndTable(); - } -}; - -struct SourceBuilder { - typedef Source Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_id(flatbuffers::Offset id) { - fbb_.AddOffset(Source::VT_ID, id); - } - void add_name(flatbuffers::Offset name) { - fbb_.AddOffset(Source::VT_NAME, name); - } - void add_filter(flatbuffers::Offset filter) { - fbb_.AddOffset(Source::VT_FILTER, filter); - } - void add_schema(flatbuffers::Offset schema) { - fbb_.AddOffset(Source::VT_SCHEMA, schema); - } - void add_projection(flatbuffers::Offset>> projection) { - fbb_.AddOffset(Source::VT_PROJECTION, projection); - } - explicit SourceBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - SourceBuilder &operator=(const SourceBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Source::VT_NAME); - return o; - } -}; - -inline flatbuffers::Offset CreateSource( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - flatbuffers::Offset name = 0, - flatbuffers::Offset filter = 0, - flatbuffers::Offset schema = 0, - flatbuffers::Offset>> projection = 0) { - SourceBuilder builder_(_fbb); - builder_.add_projection(projection); - builder_.add_schema(schema); - builder_.add_filter(filter); - builder_.add_name(name); - builder_.add_id(id); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateSourceDirect( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset id = 0, - const char *name = nullptr, - flatbuffers::Offset filter = 0, - flatbuffers::Offset schema = 0, - const std::vector> *projection = nullptr) { - auto name__ = name ? _fbb.CreateString(name) : 0; - auto projection__ = projection ? _fbb.CreateVector>(*projection) : 0; - return org::apache::arrow::computeir::flatbuf::CreateSource( - _fbb, - id, - name__, - filter, - schema, - projection__); -} - -/// A table holding an instance of the possible relation types. -struct Relation FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef RelationBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_IMPL_TYPE = 4, - VT_IMPL = 6 - }; - org::apache::arrow::computeir::flatbuf::RelationImpl impl_type() const { - return static_cast(GetField(VT_IMPL_TYPE, 0)); - } - const void *impl() const { - return GetPointer(VT_IMPL); - } - template const T *impl_as() const; - const org::apache::arrow::computeir::flatbuf::Aggregate *impl_as_Aggregate() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::RelationImpl::Aggregate ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Filter *impl_as_Filter() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::RelationImpl::Filter ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Join *impl_as_Join() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::RelationImpl::Join ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Limit *impl_as_Limit() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::RelationImpl::Limit ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::LiteralRelation *impl_as_LiteralRelation() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::RelationImpl::LiteralRelation ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::OrderBy *impl_as_OrderBy() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::RelationImpl::OrderBy ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Project *impl_as_Project() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::RelationImpl::Project ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::SetOperation *impl_as_SetOperation() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::RelationImpl::SetOperation ? static_cast(impl()) : nullptr; - } - const org::apache::arrow::computeir::flatbuf::Source *impl_as_Source() const { - return impl_type() == org::apache::arrow::computeir::flatbuf::RelationImpl::Source ? static_cast(impl()) : nullptr; - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, VT_IMPL_TYPE) && - VerifyOffsetRequired(verifier, VT_IMPL) && - VerifyRelationImpl(verifier, impl(), impl_type()) && - verifier.EndTable(); - } -}; - -template<> inline const org::apache::arrow::computeir::flatbuf::Aggregate *Relation::impl_as() const { - return impl_as_Aggregate(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Filter *Relation::impl_as() const { - return impl_as_Filter(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Join *Relation::impl_as() const { - return impl_as_Join(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Limit *Relation::impl_as() const { - return impl_as_Limit(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::LiteralRelation *Relation::impl_as() const { - return impl_as_LiteralRelation(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::OrderBy *Relation::impl_as() const { - return impl_as_OrderBy(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Project *Relation::impl_as() const { - return impl_as_Project(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::SetOperation *Relation::impl_as() const { - return impl_as_SetOperation(); -} - -template<> inline const org::apache::arrow::computeir::flatbuf::Source *Relation::impl_as() const { - return impl_as_Source(); -} - -struct RelationBuilder { - typedef Relation Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_impl_type(org::apache::arrow::computeir::flatbuf::RelationImpl impl_type) { - fbb_.AddElement(Relation::VT_IMPL_TYPE, static_cast(impl_type), 0); - } - void add_impl(flatbuffers::Offset impl) { - fbb_.AddOffset(Relation::VT_IMPL, impl); - } - explicit RelationBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - RelationBuilder &operator=(const RelationBuilder &); - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - fbb_.Required(o, Relation::VT_IMPL); - return o; - } -}; - -inline flatbuffers::Offset CreateRelation( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::computeir::flatbuf::RelationImpl impl_type = org::apache::arrow::computeir::flatbuf::RelationImpl::NONE, - flatbuffers::Offset impl = 0) { - RelationBuilder builder_(_fbb); - builder_.add_impl(impl); - builder_.add_impl_type(impl_type); - return builder_.Finish(); -} - -inline bool VerifyRelationImpl(flatbuffers::Verifier &verifier, const void *obj, RelationImpl type) { - switch (type) { - case RelationImpl::NONE: { - return true; - } - case RelationImpl::Aggregate: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case RelationImpl::Filter: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case RelationImpl::Join: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case RelationImpl::Limit: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case RelationImpl::LiteralRelation: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case RelationImpl::OrderBy: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case RelationImpl::Project: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case RelationImpl::SetOperation: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case RelationImpl::Source: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - default: return true; - } -} - -inline bool VerifyRelationImplVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types) { - if (!values || !types) return !values && !types; - if (values->size() != types->size()) return false; - for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { - if (!VerifyRelationImpl( - verifier, values->Get(i), types->GetEnum(i))) { - return false; - } - } - return true; -} - -inline const org::apache::arrow::computeir::flatbuf::Relation *GetRelation(const void *buf) { - return flatbuffers::GetRoot(buf); -} - -inline const org::apache::arrow::computeir::flatbuf::Relation *GetSizePrefixedRelation(const void *buf) { - return flatbuffers::GetSizePrefixedRoot(buf); -} - -inline bool VerifyRelationBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer(nullptr); -} - -inline bool VerifySizePrefixedRelationBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifySizePrefixedBuffer(nullptr); -} - -inline void FinishRelationBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset root) { - fbb.Finish(root); -} - -inline void FinishSizePrefixedRelationBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset root) { - fbb.FinishSizePrefixed(root); -} - -} // namespace flatbuf -} // namespace computeir -} // namespace arrow -} // namespace apache -} // namespace org - -#endif // FLATBUFFERS_GENERATED_RELATION_ORG_APACHE_ARROW_COMPUTEIR_FLATBUF_H_ diff --git a/experimental/computeir/Expression.fbs b/experimental/computeir/Expression.fbs deleted file mode 100644 index e3a7fb4eb0378..0000000000000 --- a/experimental/computeir/Expression.fbs +++ /dev/null @@ -1,222 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -include "../../format/Schema.fbs"; -include "Literal.fbs"; - -namespace org.apache.arrow.computeir.flatbuf; - -/// Access a value for a given map key -table MapKey { - /// Any expression can be a map key. - key: Expression (required); -} - -/// Struct field access -table StructField { - /// The position of the field in the struct schema - position: uint32; -} - -/// Zero-based array index -table ArraySubscript { - position: uint32; -} - -/// Zero-based range of elements in an array -table ArraySlice { - /// The start of an array slice, inclusive - start_inclusive: uint32; - /// The end of an array slice, exclusive - end_exclusive: uint32; -} - -/// Field name in a relation, in ordinal position of the relation's schema. -table FieldIndex { - position: uint32; -} - -/// A union of possible dereference operations -union Deref { - /// Access a value for a given map key - MapKey, - /// Access the value at a struct field - StructField, - /// Access the element at a given index in an array - ArraySubscript, - /// Access a range of elements in an array - ArraySlice, - /// Access a field of a relation - FieldIndex, -} - -/// Access the data of a field -table FieldRef { - ref: Deref (required); - /// For Expressions which might reference fields in multiple Relations, - /// this index may be provided to indicate which Relation's fields - /// `ref` points into. For example in the case of a join, - /// 0 refers to the left relation and 1 to the right relation. - relation_index: int = 0; -} - -/// A function call expression -table Call { - /// The function to call - name: string (required); - - /// The arguments passed to `name`. - arguments: [Expression] (required); - - /// Possible ordering of input. These are useful - /// in aggregates where ordering in meaningful such as - /// string concatenation - orderings: [SortKey]; -} - -/// A single WHEN x THEN y fragment. -table CaseFragment { - match: Expression (required); - result: Expression (required); -} - -/// Conditional case statement expression -table ConditionalCase { - /// List of conditions to evaluate - conditions: [CaseFragment] (required); - /// The default value if no cases match. This is typically NULL in SQL - /// implementations. - /// - /// Defaulting to NULL is a frontend choice, so producers must specify NULL - /// if that's their desired behavior. - else: Expression (required); -} - -/// Switch-style case expression -table SimpleCase { - /// The expression whose value will be matched - expression: Expression (required); - /// Matches for `expression` - matches: [CaseFragment] (required); - /// The default value if no cases match - else: Expression (required); -} - -/// Whether lesser values should precede greater or vice versa, -/// also whether nulls should preced or follow values -enum Ordering : uint8 { - ASCENDING_THEN_NULLS, - DESCENDING_THEN_NULLS, - NULLS_THEN_ASCENDING, - NULLS_THEN_DESCENDING, -} - -/// An expression with an order -table SortKey { - expression: Expression (required); - ordering: Ordering = ASCENDING_THEN_NULLS; -} - -/// An unbounded window bound -table Unbounded {} - -/// A concrete bound, which can be an expression or unbounded -union ConcreteBoundImpl { - Expression, - Unbounded, -} - -/// Boundary is preceding rows, determined by the contained expression -table Preceding { - impl: ConcreteBoundImpl (required); -} - -/// Boundary is following rows, determined by the contained expression -table Following { - impl: ConcreteBoundImpl (required); -} - -/// Boundary is the current row -table CurrentRow {} - -union Bound { - Preceding, - Following, - CurrentRow, -} - -/// The kind of window function to be executed -enum Frame : uint8 { - Rows, - Range, -} - -/// An expression representing a window function call. -table WindowCall { - /// The expression to operate over - expression: Expression (required); - /// The kind of window frame - kind: Frame; - /// Partition keys - partitions: [Expression] (required); - /// Sort keys - orderings: [SortKey] (required); - /// Lower window bound - lower_bound: Bound (required); - /// Upper window bound - upper_bound: Bound (required); -} - -/// A cast expression -table Cast { - /// The expression to cast - operand: Expression (required); - /// The type to cast to. This value is a `Field` to allow complete representation - /// of arrow types. - /// - /// `Type` is unable to completely represent complex types like lists and - /// maps. - to: org.apache.arrow.flatbuf.Field (required); -} - -/// Various expression types -/// -/// WindowCall is a separate variant -/// due to special options for each that don't apply to generic -/// function calls. Again this is done to make it easier -/// for consumers to deal with the structure of the operation -union ExpressionImpl { - Literal, - FieldRef, - Call, - ConditionalCase, - SimpleCase, - WindowCall, - Cast, -} - -/// Expression types -/// -/// Expressions have a concrete `impl` value, which is a specific operation. -/// -/// This is a workaround for flatbuffers' lack of support for direct use of -/// union types. -table Expression { - impl: ExpressionImpl (required); -} - -root_type Expression; diff --git a/experimental/computeir/Literal.fbs b/experimental/computeir/Literal.fbs deleted file mode 100644 index a966b6ece3fc0..0000000000000 --- a/experimental/computeir/Literal.fbs +++ /dev/null @@ -1,184 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -include "../../format/Schema.fbs"; - -namespace org.apache.arrow.computeir.flatbuf; - -table ListLiteral { - values: [Literal] (required); -} - -table StructLiteral { - /// Values for each struct field; the order must match the order of fields - /// in the `type` field of `Literal`. - values: [Literal] (required); -} - -table KeyValue { - key: Literal (required); - value: Literal (required); -} - -table MapLiteral { - values: [KeyValue] (required); -} - -table Int8Literal { - value: int8; -} - -table Int16Literal { - value: int16; -} - -table Int32Literal { - value: int32; -} - -table Int64Literal { - value: int64; -} - -table UInt8Literal { - value: uint8; -} - -table UInt16Literal { - value: uint16; -} - -table UInt32Literal { - value: uint32; -} - -table UInt64Literal { - value: uint64; -} - -table Float16Literal { - value: uint16; -} - -table Float32Literal { - value: float32; -} - -table Float64Literal { - value: float64; -} - -table DecimalLiteral { - /// Bytes of a Decimal value; bytes must be in little-endian order. - value: [byte] (required); -} - -table BooleanLiteral { - value: bool; -} - -table DateLiteral { - value: int64; -} - -table TimeLiteral { - value: int64; -} - -table TimestampLiteral { - value: int64; -} - -table IntervalLiteralMonths { - months: int32; -} - -table IntervalLiteralDaysMilliseconds { - days: int32; - milliseconds: int32; -} - -union IntervalLiteralImpl { - IntervalLiteralMonths, - IntervalLiteralDaysMilliseconds, -} - -table IntervalLiteral { - value: IntervalLiteralImpl (required); -} - -table DurationLiteral { - value: int64; -} - -table BinaryLiteral { - value: [byte] (required); -} - -table FixedSizeBinaryLiteral { - value: [byte] (required); -} - -table StringLiteral { - value: string (required); -} - -// no union literal is defined as only one branch of a union can be resolved. -// no literals for large string/binary types as flatbuffer is limited to 2gb. - -union LiteralImpl { - BooleanLiteral, - - Int8Literal, - Int16Literal, - Int32Literal, - Int64Literal, - - UInt8Literal, - UInt16Literal, - UInt32Literal, - UInt64Literal, - - DateLiteral, - TimeLiteral, - TimestampLiteral, - IntervalLiteral, - DurationLiteral, - - DecimalLiteral, - - Float16Literal, - Float32Literal, - Float64Literal, - - ListLiteral, - StructLiteral, - MapLiteral, - - StringLiteral, - BinaryLiteral, - FixedSizeBinaryLiteral, -} - -table Literal { - /// Literal value data; for null literals do not include this field. - impl: LiteralImpl; - /// Type of the literal value. This must match `impl`. - type: org.apache.arrow.flatbuf.Field (required); -} - -root_type Literal; diff --git a/experimental/computeir/Plan.fbs b/experimental/computeir/Plan.fbs deleted file mode 100644 index 779974ac92586..0000000000000 --- a/experimental/computeir/Plan.fbs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -include "Relation.fbs"; - -namespace org.apache.arrow.computeir.flatbuf; - -/// A specification of a query. -table Plan { - /// One or more output relations. - sinks: [Relation] (required); -} - -root_type Plan; diff --git a/experimental/computeir/Relation.fbs b/experimental/computeir/Relation.fbs deleted file mode 100644 index 308dcdb9ae17a..0000000000000 --- a/experimental/computeir/Relation.fbs +++ /dev/null @@ -1,218 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -include "../../format/Schema.fbs"; -include "Literal.fbs"; -include "Expression.fbs"; - -namespace org.apache.arrow.computeir.flatbuf; - -/// An identifier for relations in a query. -/// -/// A table is used here to allow plan implementations optionality. -table RelId { - id: uint64; -} - -/// Filter operation -table Filter { - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - id: RelId; - /// Child relation - rel: Relation (required); - /// The expression which will be evaluated against input rows - /// to determine whether they should be excluded from the - /// filter relation's output. - predicate: Expression (required); -} - -/// Projection -table Project { - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - id: RelId; - /// Child relation - rel: Relation (required); - /// Expressions which will be evaluated to produce to - /// the rows of the project relation's output. - expressions: [Expression] (required); -} - -/// A set of grouping keys -table Grouping { - /// Expressions to group by - keys: [Expression] (required); -} - -/// Aggregate operation -table Aggregate { - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - id: RelId; - /// Child relation - rel: Relation (required); - /// Expressions which will be evaluated to produce to - /// the rows of the aggregate relation's output. - measures: [Expression] (required); - /// Keys by which `aggregations` will be grouped. - /// - /// The nested list here is to support grouping sets - /// eg - /// - /// SELECT a, b, c, sum(d) - /// FROM t - /// GROUP BY - /// GROUPING SETS ( - /// (a, b, c), - /// (a, b), - /// (a), - /// () - /// ); - groupings: [Grouping] (required); -} - -enum JoinKind : uint8 { - Anti, - Cross, - FullOuter, - Inner, - LeftOuter, - LeftSemi, - RightOuter, -} - -/// Join between two tables -table Join { - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - id: RelId; - /// Left relation - left: Relation (required); - /// Right relation - right: Relation (required); - /// The expression which will be evaluated against rows from each - /// input to determine whether they should be included in the - /// join relation's output. - on_expression: Expression (required); - /// The kind of join to use. - join_kind: JoinKind; -} - -/// Order by relation -table OrderBy { - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - id: RelId; - /// Child relation - rel: Relation (required); - /// Define sort order for rows of output. - /// Keys with higher precedence are ordered ahead of other keys. - keys: [SortKey] (required); -} - -/// Limit operation -table Limit { - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - id: RelId; - /// Child relation - rel: Relation (required); - /// Starting index of rows - offset: uint32; - /// The maximum number of rows of output. - count: uint32; -} - -/// The kind of set operation being performed. -enum SetOpKind : uint8 { - Union, - Intersection, - Difference, -} - -/// A set operation on two or more relations -table SetOperation { - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - id: RelId; - /// Child relations - rels: [Relation] (required); - /// The kind of set operation - set_op: SetOpKind; -} - -/// A single column of literal values. -table LiteralColumn { - /// The literal values of the column - elements: [Literal] (required); -} - -/// Literal relation -table LiteralRelation { - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - id: RelId; - /// The columns of this literal relation. - columns: [LiteralColumn] (required); -} - -/// An external source of tabular data -table Source { - /// An identifiier for the relation. The identifier should be unique over the - /// entire plan. Optional. - id: RelId; - name: string (required); - /// An optional expression used to filter out rows directly from the source. - /// - /// Useful for consumers that implement predicate pushdown. - /// - /// A missing filter value indicates no filter, i.e., all rows are - /// returned from the source. - filter: Expression; - /// Schemas are explicitly optional - schema: org.apache.arrow.flatbuf.Schema; - /// An optional list of field indices indicating which columns should be read - /// from the source. Columns excluded from this listing will instead be replaced - /// with all-null placeholders to guarantee that the schema of the source is - /// unaffected by this projection. - /// - /// A missing value indicates all columns should be read. - /// - /// The behavior of an empty list is undefined. - projection: [FieldIndex]; -} - -/// The varieties of relations -union RelationImpl { - Aggregate, - Filter, - Join, - Limit, - LiteralRelation, - OrderBy, - Project, - SetOperation, - Source, -} - -/// A table holding an instance of the possible relation types. -table Relation { - impl: RelationImpl (required); -} - -root_type Relation;