diff options
author | reshilkin <reshilkin@yandex-team.com> | 2023-08-02 13:42:42 +0300 |
---|---|---|
committer | reshilkin <reshilkin@yandex-team.com> | 2023-08-02 13:42:42 +0300 |
commit | 9355caf367a5fa8b2658dc09120a181e17e88646 (patch) | |
tree | edb8bd5125d918304808f1161f8f9a58acd623e8 /contrib/libs/apache/arrow | |
parent | 65d926376d67e796c234da615753ab7c16021560 (diff) | |
download | ydb-9355caf367a5fa8b2658dc09120a181e17e88646.tar.gz |
Auto code-generation for .fbs.h in arrow
Diffstat (limited to 'contrib/libs/apache/arrow')
22 files changed, 1454 insertions, 5304 deletions
diff --git a/contrib/libs/apache/arrow/CMakeLists.darwin-x86_64.txt b/contrib/libs/apache/arrow/CMakeLists.darwin-x86_64.txt index 94c9dda6b7..25ad7cb3bf 100644 --- a/contrib/libs/apache/arrow/CMakeLists.darwin-x86_64.txt +++ b/contrib/libs/apache/arrow/CMakeLists.darwin-x86_64.txt @@ -7,6 +7,42 @@ find_package(ZLIB REQUIRED) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) add_library(libs-apache-arrow) target_compile_options(libs-apache-arrow PUBLIC @@ -31,6 +67,7 @@ target_compile_options(libs-apache-arrow PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything> ) target_include_directories(libs-apache-arrow PUBLIC + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/src ) @@ -60,6 +97,7 @@ target_link_libraries(libs-apache-arrow PUBLIC contrib-restricted-fast_float contrib-restricted-thrift contrib-restricted-uriparser + contrib-libs-flatbuffers ) target_sources(libs-apache-arrow PRIVATE ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/arrow/adapters/orc/adapter.cc @@ -262,4 +300,58 @@ target_sources(libs-apache-arrow PRIVATE ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/parquet/stream_reader.cc ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/parquet/stream_writer.cc ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/parquet/types.cc + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/File.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Message.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Schema.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/SparseTensor.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Tensor.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/feather.fbs.cpp +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/File.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Message.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Schema.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/SparseTensor.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Tensor.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/feather.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} ) diff --git a/contrib/libs/apache/arrow/CMakeLists.linux-aarch64.txt b/contrib/libs/apache/arrow/CMakeLists.linux-aarch64.txt index c7853de814..82596c804a 100644 --- a/contrib/libs/apache/arrow/CMakeLists.linux-aarch64.txt +++ b/contrib/libs/apache/arrow/CMakeLists.linux-aarch64.txt @@ -7,6 +7,42 @@ find_package(ZLIB REQUIRED) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) add_library(libs-apache-arrow) target_compile_options(libs-apache-arrow PUBLIC @@ -31,6 +67,7 @@ target_compile_options(libs-apache-arrow PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything> ) target_include_directories(libs-apache-arrow PUBLIC + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/src ) @@ -61,6 +98,7 @@ target_link_libraries(libs-apache-arrow PUBLIC contrib-restricted-fast_float contrib-restricted-thrift contrib-restricted-uriparser + contrib-libs-flatbuffers ) target_sources(libs-apache-arrow PRIVATE ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/arrow/adapters/orc/adapter.cc @@ -263,4 +301,58 @@ target_sources(libs-apache-arrow PRIVATE ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/parquet/stream_reader.cc ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/parquet/stream_writer.cc ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/parquet/types.cc + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/File.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Message.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Schema.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/SparseTensor.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Tensor.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/feather.fbs.cpp +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/File.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Message.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Schema.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/SparseTensor.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Tensor.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/feather.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} ) diff --git a/contrib/libs/apache/arrow/CMakeLists.linux-x86_64.txt b/contrib/libs/apache/arrow/CMakeLists.linux-x86_64.txt index c7853de814..82596c804a 100644 --- a/contrib/libs/apache/arrow/CMakeLists.linux-x86_64.txt +++ b/contrib/libs/apache/arrow/CMakeLists.linux-x86_64.txt @@ -7,6 +7,42 @@ find_package(ZLIB REQUIRED) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) add_library(libs-apache-arrow) target_compile_options(libs-apache-arrow PUBLIC @@ -31,6 +67,7 @@ target_compile_options(libs-apache-arrow PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything> ) target_include_directories(libs-apache-arrow PUBLIC + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/src ) @@ -61,6 +98,7 @@ target_link_libraries(libs-apache-arrow PUBLIC contrib-restricted-fast_float contrib-restricted-thrift contrib-restricted-uriparser + contrib-libs-flatbuffers ) target_sources(libs-apache-arrow PRIVATE ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/arrow/adapters/orc/adapter.cc @@ -263,4 +301,58 @@ target_sources(libs-apache-arrow PRIVATE ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/parquet/stream_reader.cc ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/parquet/stream_writer.cc ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/parquet/types.cc + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/File.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Message.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Schema.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/SparseTensor.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Tensor.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/feather.fbs.cpp +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/File.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Message.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Schema.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/SparseTensor.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Tensor.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/feather.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} ) diff --git a/contrib/libs/apache/arrow/CMakeLists.windows-x86_64.txt b/contrib/libs/apache/arrow/CMakeLists.windows-x86_64.txt index 78fddcc593..e0d4023872 100644 --- a/contrib/libs/apache/arrow/CMakeLists.windows-x86_64.txt +++ b/contrib/libs/apache/arrow/CMakeLists.windows-x86_64.txt @@ -7,6 +7,42 @@ find_package(ZLIB REQUIRED) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) +get_built_tool_path( + TOOL_flatc_bin + TOOL_flatc_dependency + contrib/tools/flatc/bin + flatc +) add_library(libs-apache-arrow) target_compile_options(libs-apache-arrow PUBLIC @@ -30,6 +66,7 @@ target_compile_options(libs-apache-arrow PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything> ) target_include_directories(libs-apache-arrow PUBLIC + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/src ) @@ -59,6 +96,7 @@ target_link_libraries(libs-apache-arrow PUBLIC contrib-restricted-fast_float contrib-restricted-thrift contrib-restricted-uriparser + contrib-libs-flatbuffers ) target_sources(libs-apache-arrow PRIVATE ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/arrow/adapters/orc/adapter.cc @@ -261,4 +299,58 @@ target_sources(libs-apache-arrow PRIVATE ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/parquet/stream_reader.cc ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/parquet/stream_writer.cc ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/parquet/types.cc + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/File.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Message.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Schema.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/SparseTensor.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Tensor.fbs.cpp + ${CMAKE_BINARY_DIR}/contrib/libs/apache/arrow/cpp/src/generated/feather.fbs.cpp +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/File.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Message.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Schema.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/SparseTensor.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/Tensor.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} +) +target_fbs_source(libs-apache-arrow + PRIVATE + ${CMAKE_SOURCE_DIR}/contrib/libs/apache/arrow/cpp/src/generated/feather.fbs + -I + ${CMAKE_BINARY_DIR} + -I + ${CMAKE_SOURCE_DIR} ) diff --git a/contrib/libs/apache/arrow/cpp/src/arrow/ipc/feather.cc b/contrib/libs/apache/arrow/cpp/src/arrow/ipc/feather.cc index b1c30eec0b..ff7726ae4b 100644 --- a/contrib/libs/apache/arrow/cpp/src/arrow/ipc/feather.cc +++ b/contrib/libs/apache/arrow/cpp/src/arrow/ipc/feather.cc @@ -49,7 +49,7 @@ #include "arrow/util/make_unique.h" #include "arrow/visitor_inline.h" -#include "generated/feather_generated.h" +#include "generated/feather.fbs.h" namespace arrow { @@ -207,8 +207,8 @@ class ReaderV1 : public Reader { TimeUnit::type unit = FromFlatbufferEnum(meta->unit()); std::string tz; // flatbuffer non-null - if (meta->timezone() != 0) { - tz = meta->timezone()->str(); + if (meta->time_zone() != 0) { + tz = meta->time_zone()->str(); } else { tz = ""; } diff --git a/contrib/libs/apache/arrow/cpp/src/arrow/ipc/message.cc b/contrib/libs/apache/arrow/cpp/src/arrow/ipc/message.cc index 197556efce..dd269a0dc0 100644 --- a/contrib/libs/apache/arrow/cpp/src/arrow/ipc/message.cc +++ b/contrib/libs/apache/arrow/cpp/src/arrow/ipc/message.cc @@ -37,7 +37,7 @@ #include "arrow/util/logging.h" #include "arrow/util/ubsan.h" -#include "generated/Message_generated.h" +#include "generated/Message.fbs.h" namespace arrow { diff --git a/contrib/libs/apache/arrow/cpp/src/arrow/ipc/metadata_internal.cc b/contrib/libs/apache/arrow/cpp/src/arrow/ipc/metadata_internal.cc index 4b332bd9e1..ad46cdc58f 100644 --- a/contrib/libs/apache/arrow/cpp/src/arrow/ipc/metadata_internal.cc +++ b/contrib/libs/apache/arrow/cpp/src/arrow/ipc/metadata_internal.cc @@ -41,11 +41,11 @@ #include "arrow/util/ubsan.h" #include "arrow/visitor_inline.h" -#include "generated/File_generated.h" -#include "generated/Message_generated.h" -#include "generated/Schema_generated.h" -#include "generated/SparseTensor_generated.h" -#include "generated/Tensor_generated.h" +#include "generated/File.fbs.h" +#include "generated/Message.fbs.h" +#include "generated/Schema.fbs.h" +#include "generated/SparseTensor.fbs.h" +#include "generated/Tensor.fbs.h" namespace arrow { @@ -312,7 +312,7 @@ Status ConcreteTypeFromFlatbuffer(flatbuf::Type type, const void* type_data, case flatbuf::Type::Timestamp: { auto ts_type = static_cast<const flatbuf::Timestamp*>(type_data); TimeUnit::type unit = FromFlatbufferUnit(ts_type->unit()); - *out = timestamp(unit, StringFromFlatbuffers(ts_type->timezone())); + *out = timestamp(unit, StringFromFlatbuffers(ts_type->time_zone())); return Status::OK(); } case flatbuf::Type::Duration: { diff --git a/contrib/libs/apache/arrow/cpp/src/arrow/ipc/metadata_internal.h b/contrib/libs/apache/arrow/cpp/src/arrow/ipc/metadata_internal.h index 9cf489dd66..9cc24a5d5b 100644 --- a/contrib/libs/apache/arrow/cpp/src/arrow/ipc/metadata_internal.h +++ b/contrib/libs/apache/arrow/cpp/src/arrow/ipc/metadata_internal.h @@ -38,9 +38,9 @@ #include "arrow/util/macros.h" #include "arrow/util/visibility.h" -#include "generated/Message_generated.h" -#include "generated/Schema_generated.h" -#include "generated/SparseTensor_generated.h" // IWYU pragma: keep +#include "generated/Message.fbs.h" +#include "generated/Schema.fbs.h" +#include "generated/SparseTensor.fbs.h" // IWYU pragma: keep namespace arrow { diff --git a/contrib/libs/apache/arrow/cpp/src/arrow/ipc/reader.cc b/contrib/libs/apache/arrow/cpp/src/arrow/ipc/reader.cc index a3c345cc44..eb62a83f04 100644 --- a/contrib/libs/apache/arrow/cpp/src/arrow/ipc/reader.cc +++ b/contrib/libs/apache/arrow/cpp/src/arrow/ipc/reader.cc @@ -57,10 +57,10 @@ #include "arrow/util/vector.h" #include "arrow/visitor_inline.h" -#include "generated/File_generated.h" // IWYU pragma: export -#include "generated/Message_generated.h" -#include "generated/Schema_generated.h" -#include "generated/SparseTensor_generated.h" +#include "generated/File.fbs.h" // IWYU pragma: export +#include "generated/Message.fbs.h" +#include "generated/Schema.fbs.h" +#include "generated/SparseTensor.fbs.h" namespace arrow { diff --git a/contrib/libs/apache/arrow/cpp/src/generated/File.fbs b/contrib/libs/apache/arrow/cpp/src/generated/File.fbs new file mode 100644 index 0000000000..906d494f27 --- /dev/null +++ b/contrib/libs/apache/arrow/cpp/src/generated/File.fbs @@ -0,0 +1,52 @@ +// 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 "Schema.fbs"; + +namespace org.apache.arrow.flatbuf; + +/// ---------------------------------------------------------------------- +/// Arrow File metadata +/// + +table Footer { + version: org.apache.arrow.flatbuf.MetadataVersion; + + schema: org.apache.arrow.flatbuf.Schema; + + dictionaries: [ Block ]; + + recordBatches: [ Block ]; + + /// User-defined metadata + custom_metadata: [ KeyValue ]; +} + +struct Block { + + /// Index to the start of the RecordBlock (note this is past the Message header) + offset: long; + + /// Length of the metadata + metaDataLength: int; + + /// Length of the data (this is aligned so there can be a gap between this and + /// the metadata). + bodyLength: long; +} + +root_type Footer; diff --git a/contrib/libs/apache/arrow/cpp/src/generated/File_generated.h b/contrib/libs/apache/arrow/cpp/src/generated/File_generated.h deleted file mode 100644 index 06953c4a04..0000000000 --- a/contrib/libs/apache/arrow/cpp/src/generated/File_generated.h +++ /dev/null @@ -1,200 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_FILE_ORG_APACHE_ARROW_FLATBUF_H_ -#define FLATBUFFERS_GENERATED_FILE_ORG_APACHE_ARROW_FLATBUF_H_ - -#include "flatbuffers/flatbuffers.h" - -#include "Schema_generated.h" - -namespace org { -namespace apache { -namespace arrow { -namespace flatbuf { - -struct Footer; -struct FooterBuilder; - -struct Block; - -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Block FLATBUFFERS_FINAL_CLASS { - private: - int64_t offset_; - int32_t metaDataLength_; - int32_t padding0__; - int64_t bodyLength_; - - public: - Block() { - memset(static_cast<void *>(this), 0, sizeof(Block)); - } - Block(int64_t _offset, int32_t _metaDataLength, int64_t _bodyLength) - : offset_(flatbuffers::EndianScalar(_offset)), - metaDataLength_(flatbuffers::EndianScalar(_metaDataLength)), - padding0__(0), - bodyLength_(flatbuffers::EndianScalar(_bodyLength)) { - (void)padding0__; - } - /// Index to the start of the RecordBlock (note this is past the Message header) - int64_t offset() const { - return flatbuffers::EndianScalar(offset_); - } - /// Length of the metadata - int32_t metaDataLength() const { - return flatbuffers::EndianScalar(metaDataLength_); - } - /// Length of the data (this is aligned so there can be a gap between this and - /// the metadata). - int64_t bodyLength() const { - return flatbuffers::EndianScalar(bodyLength_); - } -}; -FLATBUFFERS_STRUCT_END(Block, 24); - -/// ---------------------------------------------------------------------- -/// Arrow File metadata -/// -struct Footer FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef FooterBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VERSION = 4, - VT_SCHEMA = 6, - VT_DICTIONARIES = 8, - VT_RECORDBATCHES = 10, - VT_CUSTOM_METADATA = 12 - }; - org::apache::arrow::flatbuf::MetadataVersion version() const { - return static_cast<org::apache::arrow::flatbuf::MetadataVersion>(GetField<int16_t>(VT_VERSION, 0)); - } - const org::apache::arrow::flatbuf::Schema *schema() const { - return GetPointer<const org::apache::arrow::flatbuf::Schema *>(VT_SCHEMA); - } - const flatbuffers::Vector<const org::apache::arrow::flatbuf::Block *> *dictionaries() const { - return GetPointer<const flatbuffers::Vector<const org::apache::arrow::flatbuf::Block *> *>(VT_DICTIONARIES); - } - const flatbuffers::Vector<const org::apache::arrow::flatbuf::Block *> *recordBatches() const { - return GetPointer<const flatbuffers::Vector<const org::apache::arrow::flatbuf::Block *> *>(VT_RECORDBATCHES); - } - /// User-defined metadata - const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>> *custom_metadata() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>> *>(VT_CUSTOM_METADATA); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int16_t>(verifier, VT_VERSION) && - VerifyOffset(verifier, VT_SCHEMA) && - verifier.VerifyTable(schema()) && - VerifyOffset(verifier, VT_DICTIONARIES) && - verifier.VerifyVector(dictionaries()) && - VerifyOffset(verifier, VT_RECORDBATCHES) && - verifier.VerifyVector(recordBatches()) && - VerifyOffset(verifier, VT_CUSTOM_METADATA) && - verifier.VerifyVector(custom_metadata()) && - verifier.VerifyVectorOfTables(custom_metadata()) && - verifier.EndTable(); - } -}; - -struct FooterBuilder { - typedef Footer Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_version(org::apache::arrow::flatbuf::MetadataVersion version) { - fbb_.AddElement<int16_t>(Footer::VT_VERSION, static_cast<int16_t>(version), 0); - } - void add_schema(flatbuffers::Offset<org::apache::arrow::flatbuf::Schema> schema) { - fbb_.AddOffset(Footer::VT_SCHEMA, schema); - } - void add_dictionaries(flatbuffers::Offset<flatbuffers::Vector<const org::apache::arrow::flatbuf::Block *>> dictionaries) { - fbb_.AddOffset(Footer::VT_DICTIONARIES, dictionaries); - } - void add_recordBatches(flatbuffers::Offset<flatbuffers::Vector<const org::apache::arrow::flatbuf::Block *>> recordBatches) { - fbb_.AddOffset(Footer::VT_RECORDBATCHES, recordBatches); - } - void add_custom_metadata(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>>> custom_metadata) { - fbb_.AddOffset(Footer::VT_CUSTOM_METADATA, custom_metadata); - } - explicit FooterBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - FooterBuilder &operator=(const FooterBuilder &); - flatbuffers::Offset<Footer> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Footer>(end); - return o; - } -}; - -inline flatbuffers::Offset<Footer> CreateFooter( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::MetadataVersion version = org::apache::arrow::flatbuf::MetadataVersion::V1, - flatbuffers::Offset<org::apache::arrow::flatbuf::Schema> schema = 0, - flatbuffers::Offset<flatbuffers::Vector<const org::apache::arrow::flatbuf::Block *>> dictionaries = 0, - flatbuffers::Offset<flatbuffers::Vector<const org::apache::arrow::flatbuf::Block *>> recordBatches = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>>> custom_metadata = 0) { - FooterBuilder builder_(_fbb); - builder_.add_custom_metadata(custom_metadata); - builder_.add_recordBatches(recordBatches); - builder_.add_dictionaries(dictionaries); - builder_.add_schema(schema); - builder_.add_version(version); - return builder_.Finish(); -} - -inline flatbuffers::Offset<Footer> CreateFooterDirect( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::MetadataVersion version = org::apache::arrow::flatbuf::MetadataVersion::V1, - flatbuffers::Offset<org::apache::arrow::flatbuf::Schema> schema = 0, - const std::vector<org::apache::arrow::flatbuf::Block> *dictionaries = nullptr, - const std::vector<org::apache::arrow::flatbuf::Block> *recordBatches = nullptr, - const std::vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>> *custom_metadata = nullptr) { - auto dictionaries__ = dictionaries ? _fbb.CreateVectorOfStructs<org::apache::arrow::flatbuf::Block>(*dictionaries) : 0; - auto recordBatches__ = recordBatches ? _fbb.CreateVectorOfStructs<org::apache::arrow::flatbuf::Block>(*recordBatches) : 0; - auto custom_metadata__ = custom_metadata ? _fbb.CreateVector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>>(*custom_metadata) : 0; - return org::apache::arrow::flatbuf::CreateFooter( - _fbb, - version, - schema, - dictionaries__, - recordBatches__, - custom_metadata__); -} - -inline const org::apache::arrow::flatbuf::Footer *GetFooter(const void *buf) { - return flatbuffers::GetRoot<org::apache::arrow::flatbuf::Footer>(buf); -} - -inline const org::apache::arrow::flatbuf::Footer *GetSizePrefixedFooter(const void *buf) { - return flatbuffers::GetSizePrefixedRoot<org::apache::arrow::flatbuf::Footer>(buf); -} - -inline bool VerifyFooterBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer<org::apache::arrow::flatbuf::Footer>(nullptr); -} - -inline bool VerifySizePrefixedFooterBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifySizePrefixedBuffer<org::apache::arrow::flatbuf::Footer>(nullptr); -} - -inline void FinishFooterBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<org::apache::arrow::flatbuf::Footer> root) { - fbb.Finish(root); -} - -inline void FinishSizePrefixedFooterBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<org::apache::arrow::flatbuf::Footer> root) { - fbb.FinishSizePrefixed(root); -} - -} // namespace flatbuf -} // namespace arrow -} // namespace apache -} // namespace org - -#endif // FLATBUFFERS_GENERATED_FILE_ORG_APACHE_ARROW_FLATBUF_H_ diff --git a/contrib/libs/apache/arrow/cpp/src/generated/Message.fbs b/contrib/libs/apache/arrow/cpp/src/generated/Message.fbs new file mode 100644 index 0000000000..f1c18d765d --- /dev/null +++ b/contrib/libs/apache/arrow/cpp/src/generated/Message.fbs @@ -0,0 +1,140 @@ +// 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 "Schema.fbs"; +include "SparseTensor.fbs"; +include "Tensor.fbs"; + +namespace org.apache.arrow.flatbuf; + +/// ---------------------------------------------------------------------- +/// Data structures for describing a table row batch (a collection of +/// equal-length Arrow arrays) + +/// Metadata about a field at some level of a nested type tree (but not +/// its children). +/// +/// For example, a List<Int16> with values `[[1, 2, 3], null, [4], [5, 6], null]` +/// would have {length: 5, null_count: 2} for its List node, and {length: 6, +/// null_count: 0} for its Int16 node, as separate FieldNode structs +struct FieldNode { + /// The number of value slots in the Arrow array at this level of a nested + /// tree + length: long; + + /// The number of observed nulls. Fields with null_count == 0 may choose not + /// to write their physical validity bitmap out as a materialized buffer, + /// instead setting the length of the bitmap buffer to 0. + null_count: long; +} + +enum CompressionType:byte { + // LZ4 frame format, for portability, as provided by lz4frame.h or wrappers + // thereof. Not to be confused with "raw" (also called "block") format + // provided by lz4.h + LZ4_FRAME, + + // Zstandard + ZSTD +} + +/// Provided for forward compatibility in case we need to support different +/// strategies for compressing the IPC message body (like whole-body +/// compression rather than buffer-level) in the future +enum BodyCompressionMethod:byte { + /// Each constituent buffer is first compressed with the indicated + /// compressor, and then written with the uncompressed length in the first 8 + /// bytes as a 64-bit little-endian signed integer followed by the compressed + /// buffer bytes (and then padding as required by the protocol). The + /// uncompressed length may be set to -1 to indicate that the data that + /// follows is not compressed, which can be useful for cases where + /// compression does not yield appreciable savings. + BUFFER +} + +/// Optional compression for the memory buffers constituting IPC message +/// bodies. Intended for use with RecordBatch but could be used for other +/// message types +table BodyCompression { + /// Compressor library + codec: CompressionType = LZ4_FRAME; + + /// Indicates the way the record batch body was compressed + method: BodyCompressionMethod = BUFFER; +} + +/// A data header describing the shared memory layout of a "record" or "row" +/// batch. Some systems call this a "row batch" internally and others a "record +/// batch". +table RecordBatch { + /// number of records / rows. The arrays in the batch should all have this + /// length + length: long; + + /// Nodes correspond to the pre-ordered flattened logical schema + nodes: [FieldNode]; + + /// Buffers correspond to the pre-ordered flattened buffer tree + /// + /// The number of buffers appended to this list depends on the schema. For + /// example, most primitive arrays will have 2 buffers, 1 for the validity + /// bitmap and 1 for the values. For struct arrays, there will only be a + /// single buffer for the validity (nulls) bitmap + buffers: [Buffer]; + + /// Optional compression of the message body + compression: BodyCompression; +} + +/// For sending dictionary encoding information. Any Field can be +/// dictionary-encoded, but in this case none of its children may be +/// dictionary-encoded. +/// There is one vector / column per dictionary, but that vector / column +/// may be spread across multiple dictionary batches by using the isDelta +/// flag + +table DictionaryBatch { + id: long; + data: RecordBatch; + + /// If isDelta is true the values in the dictionary are to be appended to a + /// dictionary with the indicated id. If isDelta is false this dictionary + /// should replace the existing dictionary. + isDelta: bool = false; +} + +/// ---------------------------------------------------------------------- +/// The root Message type + +/// This union enables us to easily send different message types without +/// redundant storage, and in the future we can easily add new message types. +/// +/// Arrow implementations do not need to implement all of the message types, +/// which may include experimental metadata types. For maximum compatibility, +/// it is best to send data using RecordBatch +union MessageHeader { + Schema, DictionaryBatch, RecordBatch, Tensor, SparseTensor +} + +table Message { + version: org.apache.arrow.flatbuf.MetadataVersion; + header: MessageHeader; + bodyLength: long; + custom_metadata: [ KeyValue ]; +} + +root_type Message; diff --git a/contrib/libs/apache/arrow/cpp/src/generated/Message_generated.h b/contrib/libs/apache/arrow/cpp/src/generated/Message_generated.h deleted file mode 100644 index 822bec9952..0000000000 --- a/contrib/libs/apache/arrow/cpp/src/generated/Message_generated.h +++ /dev/null @@ -1,659 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_MESSAGE_ORG_APACHE_ARROW_FLATBUF_H_ -#define FLATBUFFERS_GENERATED_MESSAGE_ORG_APACHE_ARROW_FLATBUF_H_ - -#include "flatbuffers/flatbuffers.h" - -#include "Schema_generated.h" -#include "SparseTensor_generated.h" -#include "Tensor_generated.h" - -namespace org { -namespace apache { -namespace arrow { -namespace flatbuf { - -struct FieldNode; - -struct BodyCompression; -struct BodyCompressionBuilder; - -struct RecordBatch; -struct RecordBatchBuilder; - -struct DictionaryBatch; -struct DictionaryBatchBuilder; - -struct Message; -struct MessageBuilder; - -enum class CompressionType : int8_t { - LZ4_FRAME = 0, - ZSTD = 1, - MIN = LZ4_FRAME, - MAX = ZSTD -}; - -inline const CompressionType (&EnumValuesCompressionType())[2] { - static const CompressionType values[] = { - CompressionType::LZ4_FRAME, - CompressionType::ZSTD - }; - return values; -} - -inline const char * const *EnumNamesCompressionType() { - static const char * const names[3] = { - "LZ4_FRAME", - "ZSTD", - nullptr - }; - return names; -} - -inline const char *EnumNameCompressionType(CompressionType e) { - if (flatbuffers::IsOutRange(e, CompressionType::LZ4_FRAME, CompressionType::ZSTD)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesCompressionType()[index]; -} - -/// Provided for forward compatibility in case we need to support different -/// strategies for compressing the IPC message body (like whole-body -/// compression rather than buffer-level) in the future -enum class BodyCompressionMethod : int8_t { - /// Each constituent buffer is first compressed with the indicated - /// compressor, and then written with the uncompressed length in the first 8 - /// bytes as a 64-bit little-endian signed integer followed by the compressed - /// buffer bytes (and then padding as required by the protocol). The - /// uncompressed length may be set to -1 to indicate that the data that - /// follows is not compressed, which can be useful for cases where - /// compression does not yield appreciable savings. - BUFFER = 0, - MIN = BUFFER, - MAX = BUFFER -}; - -inline const BodyCompressionMethod (&EnumValuesBodyCompressionMethod())[1] { - static const BodyCompressionMethod values[] = { - BodyCompressionMethod::BUFFER - }; - return values; -} - -inline const char * const *EnumNamesBodyCompressionMethod() { - static const char * const names[2] = { - "BUFFER", - nullptr - }; - return names; -} - -inline const char *EnumNameBodyCompressionMethod(BodyCompressionMethod e) { - if (flatbuffers::IsOutRange(e, BodyCompressionMethod::BUFFER, BodyCompressionMethod::BUFFER)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesBodyCompressionMethod()[index]; -} - -/// ---------------------------------------------------------------------- -/// The root Message type -/// This union enables us to easily send different message types without -/// redundant storage, and in the future we can easily add new message types. -/// -/// Arrow implementations do not need to implement all of the message types, -/// which may include experimental metadata types. For maximum compatibility, -/// it is best to send data using RecordBatch -enum class MessageHeader : uint8_t { - NONE = 0, - Schema = 1, - DictionaryBatch = 2, - RecordBatch = 3, - Tensor = 4, - SparseTensor = 5, - MIN = NONE, - MAX = SparseTensor -}; - -inline const MessageHeader (&EnumValuesMessageHeader())[6] { - static const MessageHeader values[] = { - MessageHeader::NONE, - MessageHeader::Schema, - MessageHeader::DictionaryBatch, - MessageHeader::RecordBatch, - MessageHeader::Tensor, - MessageHeader::SparseTensor - }; - return values; -} - -inline const char * const *EnumNamesMessageHeader() { - static const char * const names[7] = { - "NONE", - "Schema", - "DictionaryBatch", - "RecordBatch", - "Tensor", - "SparseTensor", - nullptr - }; - return names; -} - -inline const char *EnumNameMessageHeader(MessageHeader e) { - if (flatbuffers::IsOutRange(e, MessageHeader::NONE, MessageHeader::SparseTensor)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesMessageHeader()[index]; -} - -template<typename T> struct MessageHeaderTraits { - static const MessageHeader enum_value = MessageHeader::NONE; -}; - -template<> struct MessageHeaderTraits<org::apache::arrow::flatbuf::Schema> { - static const MessageHeader enum_value = MessageHeader::Schema; -}; - -template<> struct MessageHeaderTraits<org::apache::arrow::flatbuf::DictionaryBatch> { - static const MessageHeader enum_value = MessageHeader::DictionaryBatch; -}; - -template<> struct MessageHeaderTraits<org::apache::arrow::flatbuf::RecordBatch> { - static const MessageHeader enum_value = MessageHeader::RecordBatch; -}; - -template<> struct MessageHeaderTraits<org::apache::arrow::flatbuf::Tensor> { - static const MessageHeader enum_value = MessageHeader::Tensor; -}; - -template<> struct MessageHeaderTraits<org::apache::arrow::flatbuf::SparseTensor> { - static const MessageHeader enum_value = MessageHeader::SparseTensor; -}; - -bool VerifyMessageHeader(flatbuffers::Verifier &verifier, const void *obj, MessageHeader type); -bool VerifyMessageHeaderVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types); - -/// ---------------------------------------------------------------------- -/// Data structures for describing a table row batch (a collection of -/// equal-length Arrow arrays) -/// Metadata about a field at some level of a nested type tree (but not -/// its children). -/// -/// For example, a List<Int16> with values [[1, 2, 3], null, [4], [5, 6], null] -/// would have {length: 5, null_count: 2} for its List node, and {length: 6, -/// null_count: 0} for its Int16 node, as separate FieldNode structs -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) FieldNode FLATBUFFERS_FINAL_CLASS { - private: - int64_t length_; - int64_t null_count_; - - public: - FieldNode() { - memset(static_cast<void *>(this), 0, sizeof(FieldNode)); - } - FieldNode(int64_t _length, int64_t _null_count) - : length_(flatbuffers::EndianScalar(_length)), - null_count_(flatbuffers::EndianScalar(_null_count)) { - } - /// The number of value slots in the Arrow array at this level of a nested - /// tree - int64_t length() const { - return flatbuffers::EndianScalar(length_); - } - /// The number of observed nulls. Fields with null_count == 0 may choose not - /// to write their physical validity bitmap out as a materialized buffer, - /// instead setting the length of the bitmap buffer to 0. - int64_t null_count() const { - return flatbuffers::EndianScalar(null_count_); - } -}; -FLATBUFFERS_STRUCT_END(FieldNode, 16); - -/// Optional compression for the memory buffers constituting IPC message -/// bodies. Intended for use with RecordBatch but could be used for other -/// message types -struct BodyCompression FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef BodyCompressionBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_CODEC = 4, - VT_METHOD = 6 - }; - /// Compressor library - org::apache::arrow::flatbuf::CompressionType codec() const { - return static_cast<org::apache::arrow::flatbuf::CompressionType>(GetField<int8_t>(VT_CODEC, 0)); - } - /// Indicates the way the record batch body was compressed - org::apache::arrow::flatbuf::BodyCompressionMethod method() const { - return static_cast<org::apache::arrow::flatbuf::BodyCompressionMethod>(GetField<int8_t>(VT_METHOD, 0)); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int8_t>(verifier, VT_CODEC) && - VerifyField<int8_t>(verifier, VT_METHOD) && - verifier.EndTable(); - } -}; - -struct BodyCompressionBuilder { - typedef BodyCompression Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_codec(org::apache::arrow::flatbuf::CompressionType codec) { - fbb_.AddElement<int8_t>(BodyCompression::VT_CODEC, static_cast<int8_t>(codec), 0); - } - void add_method(org::apache::arrow::flatbuf::BodyCompressionMethod method) { - fbb_.AddElement<int8_t>(BodyCompression::VT_METHOD, static_cast<int8_t>(method), 0); - } - explicit BodyCompressionBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - BodyCompressionBuilder &operator=(const BodyCompressionBuilder &); - flatbuffers::Offset<BodyCompression> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<BodyCompression>(end); - return o; - } -}; - -inline flatbuffers::Offset<BodyCompression> CreateBodyCompression( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::CompressionType codec = org::apache::arrow::flatbuf::CompressionType::LZ4_FRAME, - org::apache::arrow::flatbuf::BodyCompressionMethod method = org::apache::arrow::flatbuf::BodyCompressionMethod::BUFFER) { - BodyCompressionBuilder builder_(_fbb); - builder_.add_method(method); - builder_.add_codec(codec); - return builder_.Finish(); -} - -/// A data header describing the shared memory layout of a "record" or "row" -/// batch. Some systems call this a "row batch" internally and others a "record -/// batch". -struct RecordBatch FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef RecordBatchBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_LENGTH = 4, - VT_NODES = 6, - VT_BUFFERS = 8, - VT_COMPRESSION = 10 - }; - /// number of records / rows. The arrays in the batch should all have this - /// length - int64_t length() const { - return GetField<int64_t>(VT_LENGTH, 0); - } - /// Nodes correspond to the pre-ordered flattened logical schema - const flatbuffers::Vector<const org::apache::arrow::flatbuf::FieldNode *> *nodes() const { - return GetPointer<const flatbuffers::Vector<const org::apache::arrow::flatbuf::FieldNode *> *>(VT_NODES); - } - /// Buffers correspond to the pre-ordered flattened buffer tree - /// - /// The number of buffers appended to this list depends on the schema. For - /// example, most primitive arrays will have 2 buffers, 1 for the validity - /// bitmap and 1 for the values. For struct arrays, there will only be a - /// single buffer for the validity (nulls) bitmap - const flatbuffers::Vector<const org::apache::arrow::flatbuf::Buffer *> *buffers() const { - return GetPointer<const flatbuffers::Vector<const org::apache::arrow::flatbuf::Buffer *> *>(VT_BUFFERS); - } - /// Optional compression of the message body - const org::apache::arrow::flatbuf::BodyCompression *compression() const { - return GetPointer<const org::apache::arrow::flatbuf::BodyCompression *>(VT_COMPRESSION); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int64_t>(verifier, VT_LENGTH) && - VerifyOffset(verifier, VT_NODES) && - verifier.VerifyVector(nodes()) && - VerifyOffset(verifier, VT_BUFFERS) && - verifier.VerifyVector(buffers()) && - VerifyOffset(verifier, VT_COMPRESSION) && - verifier.VerifyTable(compression()) && - verifier.EndTable(); - } -}; - -struct RecordBatchBuilder { - typedef RecordBatch Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_length(int64_t length) { - fbb_.AddElement<int64_t>(RecordBatch::VT_LENGTH, length, 0); - } - void add_nodes(flatbuffers::Offset<flatbuffers::Vector<const org::apache::arrow::flatbuf::FieldNode *>> nodes) { - fbb_.AddOffset(RecordBatch::VT_NODES, nodes); - } - void add_buffers(flatbuffers::Offset<flatbuffers::Vector<const org::apache::arrow::flatbuf::Buffer *>> buffers) { - fbb_.AddOffset(RecordBatch::VT_BUFFERS, buffers); - } - void add_compression(flatbuffers::Offset<org::apache::arrow::flatbuf::BodyCompression> compression) { - fbb_.AddOffset(RecordBatch::VT_COMPRESSION, compression); - } - explicit RecordBatchBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - RecordBatchBuilder &operator=(const RecordBatchBuilder &); - flatbuffers::Offset<RecordBatch> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<RecordBatch>(end); - return o; - } -}; - -inline flatbuffers::Offset<RecordBatch> CreateRecordBatch( - flatbuffers::FlatBufferBuilder &_fbb, - int64_t length = 0, - flatbuffers::Offset<flatbuffers::Vector<const org::apache::arrow::flatbuf::FieldNode *>> nodes = 0, - flatbuffers::Offset<flatbuffers::Vector<const org::apache::arrow::flatbuf::Buffer *>> buffers = 0, - flatbuffers::Offset<org::apache::arrow::flatbuf::BodyCompression> compression = 0) { - RecordBatchBuilder builder_(_fbb); - builder_.add_length(length); - builder_.add_compression(compression); - builder_.add_buffers(buffers); - builder_.add_nodes(nodes); - return builder_.Finish(); -} - -inline flatbuffers::Offset<RecordBatch> CreateRecordBatchDirect( - flatbuffers::FlatBufferBuilder &_fbb, - int64_t length = 0, - const std::vector<org::apache::arrow::flatbuf::FieldNode> *nodes = nullptr, - const std::vector<org::apache::arrow::flatbuf::Buffer> *buffers = nullptr, - flatbuffers::Offset<org::apache::arrow::flatbuf::BodyCompression> compression = 0) { - auto nodes__ = nodes ? _fbb.CreateVectorOfStructs<org::apache::arrow::flatbuf::FieldNode>(*nodes) : 0; - auto buffers__ = buffers ? _fbb.CreateVectorOfStructs<org::apache::arrow::flatbuf::Buffer>(*buffers) : 0; - return org::apache::arrow::flatbuf::CreateRecordBatch( - _fbb, - length, - nodes__, - buffers__, - compression); -} - -/// For sending dictionary encoding information. Any Field can be -/// dictionary-encoded, but in this case none of its children may be -/// dictionary-encoded. -/// There is one vector / column per dictionary, but that vector / column -/// may be spread across multiple dictionary batches by using the isDelta -/// flag -struct DictionaryBatch FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef DictionaryBatchBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ID = 4, - VT_DATA = 6, - VT_ISDELTA = 8 - }; - int64_t id() const { - return GetField<int64_t>(VT_ID, 0); - } - const org::apache::arrow::flatbuf::RecordBatch *data() const { - return GetPointer<const org::apache::arrow::flatbuf::RecordBatch *>(VT_DATA); - } - /// If isDelta is true the values in the dictionary are to be appended to a - /// dictionary with the indicated id. If isDelta is false this dictionary - /// should replace the existing dictionary. - bool isDelta() const { - return GetField<uint8_t>(VT_ISDELTA, 0) != 0; - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int64_t>(verifier, VT_ID) && - VerifyOffset(verifier, VT_DATA) && - verifier.VerifyTable(data()) && - VerifyField<uint8_t>(verifier, VT_ISDELTA) && - verifier.EndTable(); - } -}; - -struct DictionaryBatchBuilder { - typedef DictionaryBatch Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_id(int64_t id) { - fbb_.AddElement<int64_t>(DictionaryBatch::VT_ID, id, 0); - } - void add_data(flatbuffers::Offset<org::apache::arrow::flatbuf::RecordBatch> data) { - fbb_.AddOffset(DictionaryBatch::VT_DATA, data); - } - void add_isDelta(bool isDelta) { - fbb_.AddElement<uint8_t>(DictionaryBatch::VT_ISDELTA, static_cast<uint8_t>(isDelta), 0); - } - explicit DictionaryBatchBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - DictionaryBatchBuilder &operator=(const DictionaryBatchBuilder &); - flatbuffers::Offset<DictionaryBatch> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<DictionaryBatch>(end); - return o; - } -}; - -inline flatbuffers::Offset<DictionaryBatch> CreateDictionaryBatch( - flatbuffers::FlatBufferBuilder &_fbb, - int64_t id = 0, - flatbuffers::Offset<org::apache::arrow::flatbuf::RecordBatch> data = 0, - bool isDelta = false) { - DictionaryBatchBuilder builder_(_fbb); - builder_.add_id(id); - builder_.add_data(data); - builder_.add_isDelta(isDelta); - return builder_.Finish(); -} - -struct Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef MessageBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_VERSION = 4, - VT_HEADER_TYPE = 6, - VT_HEADER = 8, - VT_BODYLENGTH = 10, - VT_CUSTOM_METADATA = 12 - }; - org::apache::arrow::flatbuf::MetadataVersion version() const { - return static_cast<org::apache::arrow::flatbuf::MetadataVersion>(GetField<int16_t>(VT_VERSION, 0)); - } - org::apache::arrow::flatbuf::MessageHeader header_type() const { - return static_cast<org::apache::arrow::flatbuf::MessageHeader>(GetField<uint8_t>(VT_HEADER_TYPE, 0)); - } - const void *header() const { - return GetPointer<const void *>(VT_HEADER); - } - template<typename T> const T *header_as() const; - const org::apache::arrow::flatbuf::Schema *header_as_Schema() const { - return header_type() == org::apache::arrow::flatbuf::MessageHeader::Schema ? static_cast<const org::apache::arrow::flatbuf::Schema *>(header()) : nullptr; - } - const org::apache::arrow::flatbuf::DictionaryBatch *header_as_DictionaryBatch() const { - return header_type() == org::apache::arrow::flatbuf::MessageHeader::DictionaryBatch ? static_cast<const org::apache::arrow::flatbuf::DictionaryBatch *>(header()) : nullptr; - } - const org::apache::arrow::flatbuf::RecordBatch *header_as_RecordBatch() const { - return header_type() == org::apache::arrow::flatbuf::MessageHeader::RecordBatch ? static_cast<const org::apache::arrow::flatbuf::RecordBatch *>(header()) : nullptr; - } - const org::apache::arrow::flatbuf::Tensor *header_as_Tensor() const { - return header_type() == org::apache::arrow::flatbuf::MessageHeader::Tensor ? static_cast<const org::apache::arrow::flatbuf::Tensor *>(header()) : nullptr; - } - const org::apache::arrow::flatbuf::SparseTensor *header_as_SparseTensor() const { - return header_type() == org::apache::arrow::flatbuf::MessageHeader::SparseTensor ? static_cast<const org::apache::arrow::flatbuf::SparseTensor *>(header()) : nullptr; - } - int64_t bodyLength() const { - return GetField<int64_t>(VT_BODYLENGTH, 0); - } - const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>> *custom_metadata() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>> *>(VT_CUSTOM_METADATA); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int16_t>(verifier, VT_VERSION) && - VerifyField<uint8_t>(verifier, VT_HEADER_TYPE) && - VerifyOffset(verifier, VT_HEADER) && - VerifyMessageHeader(verifier, header(), header_type()) && - VerifyField<int64_t>(verifier, VT_BODYLENGTH) && - VerifyOffset(verifier, VT_CUSTOM_METADATA) && - verifier.VerifyVector(custom_metadata()) && - verifier.VerifyVectorOfTables(custom_metadata()) && - verifier.EndTable(); - } -}; - -template<> inline const org::apache::arrow::flatbuf::Schema *Message::header_as<org::apache::arrow::flatbuf::Schema>() const { - return header_as_Schema(); -} - -template<> inline const org::apache::arrow::flatbuf::DictionaryBatch *Message::header_as<org::apache::arrow::flatbuf::DictionaryBatch>() const { - return header_as_DictionaryBatch(); -} - -template<> inline const org::apache::arrow::flatbuf::RecordBatch *Message::header_as<org::apache::arrow::flatbuf::RecordBatch>() const { - return header_as_RecordBatch(); -} - -template<> inline const org::apache::arrow::flatbuf::Tensor *Message::header_as<org::apache::arrow::flatbuf::Tensor>() const { - return header_as_Tensor(); -} - -template<> inline const org::apache::arrow::flatbuf::SparseTensor *Message::header_as<org::apache::arrow::flatbuf::SparseTensor>() const { - return header_as_SparseTensor(); -} - -struct MessageBuilder { - typedef Message Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_version(org::apache::arrow::flatbuf::MetadataVersion version) { - fbb_.AddElement<int16_t>(Message::VT_VERSION, static_cast<int16_t>(version), 0); - } - void add_header_type(org::apache::arrow::flatbuf::MessageHeader header_type) { - fbb_.AddElement<uint8_t>(Message::VT_HEADER_TYPE, static_cast<uint8_t>(header_type), 0); - } - void add_header(flatbuffers::Offset<void> header) { - fbb_.AddOffset(Message::VT_HEADER, header); - } - void add_bodyLength(int64_t bodyLength) { - fbb_.AddElement<int64_t>(Message::VT_BODYLENGTH, bodyLength, 0); - } - void add_custom_metadata(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>>> custom_metadata) { - fbb_.AddOffset(Message::VT_CUSTOM_METADATA, custom_metadata); - } - explicit MessageBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - MessageBuilder &operator=(const MessageBuilder &); - flatbuffers::Offset<Message> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Message>(end); - return o; - } -}; - -inline flatbuffers::Offset<Message> CreateMessage( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::MetadataVersion version = org::apache::arrow::flatbuf::MetadataVersion::V1, - org::apache::arrow::flatbuf::MessageHeader header_type = org::apache::arrow::flatbuf::MessageHeader::NONE, - flatbuffers::Offset<void> header = 0, - int64_t bodyLength = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>>> custom_metadata = 0) { - MessageBuilder builder_(_fbb); - builder_.add_bodyLength(bodyLength); - builder_.add_custom_metadata(custom_metadata); - builder_.add_header(header); - builder_.add_version(version); - builder_.add_header_type(header_type); - return builder_.Finish(); -} - -inline flatbuffers::Offset<Message> CreateMessageDirect( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::MetadataVersion version = org::apache::arrow::flatbuf::MetadataVersion::V1, - org::apache::arrow::flatbuf::MessageHeader header_type = org::apache::arrow::flatbuf::MessageHeader::NONE, - flatbuffers::Offset<void> header = 0, - int64_t bodyLength = 0, - const std::vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>> *custom_metadata = nullptr) { - auto custom_metadata__ = custom_metadata ? _fbb.CreateVector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>>(*custom_metadata) : 0; - return org::apache::arrow::flatbuf::CreateMessage( - _fbb, - version, - header_type, - header, - bodyLength, - custom_metadata__); -} - -inline bool VerifyMessageHeader(flatbuffers::Verifier &verifier, const void *obj, MessageHeader type) { - switch (type) { - case MessageHeader::NONE: { - return true; - } - case MessageHeader::Schema: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Schema *>(obj); - return verifier.VerifyTable(ptr); - } - case MessageHeader::DictionaryBatch: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::DictionaryBatch *>(obj); - return verifier.VerifyTable(ptr); - } - case MessageHeader::RecordBatch: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::RecordBatch *>(obj); - return verifier.VerifyTable(ptr); - } - case MessageHeader::Tensor: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Tensor *>(obj); - return verifier.VerifyTable(ptr); - } - case MessageHeader::SparseTensor: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::SparseTensor *>(obj); - return verifier.VerifyTable(ptr); - } - default: return true; - } -} - -inline bool VerifyMessageHeaderVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *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 (!VerifyMessageHeader( - verifier, values->Get(i), types->GetEnum<MessageHeader>(i))) { - return false; - } - } - return true; -} - -inline const org::apache::arrow::flatbuf::Message *GetMessage(const void *buf) { - return flatbuffers::GetRoot<org::apache::arrow::flatbuf::Message>(buf); -} - -inline const org::apache::arrow::flatbuf::Message *GetSizePrefixedMessage(const void *buf) { - return flatbuffers::GetSizePrefixedRoot<org::apache::arrow::flatbuf::Message>(buf); -} - -inline bool VerifyMessageBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer<org::apache::arrow::flatbuf::Message>(nullptr); -} - -inline bool VerifySizePrefixedMessageBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifySizePrefixedBuffer<org::apache::arrow::flatbuf::Message>(nullptr); -} - -inline void FinishMessageBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<org::apache::arrow::flatbuf::Message> root) { - fbb.Finish(root); -} - -inline void FinishSizePrefixedMessageBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<org::apache::arrow::flatbuf::Message> root) { - fbb.FinishSizePrefixed(root); -} - -} // namespace flatbuf -} // namespace arrow -} // namespace apache -} // namespace org - -#endif // FLATBUFFERS_GENERATED_MESSAGE_ORG_APACHE_ARROW_FLATBUF_H_ diff --git a/contrib/libs/apache/arrow/cpp/src/generated/Schema.fbs b/contrib/libs/apache/arrow/cpp/src/generated/Schema.fbs new file mode 100644 index 0000000000..e19e8bac28 --- /dev/null +++ b/contrib/libs/apache/arrow/cpp/src/generated/Schema.fbs @@ -0,0 +1,430 @@ +// 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. + +/// Logical types, vector layouts, and schemas + +namespace org.apache.arrow.flatbuf; + +enum MetadataVersion:short { + /// 0.1.0 (October 2016). + V1, + + /// 0.2.0 (February 2017). Non-backwards compatible with V1. + V2, + + /// 0.3.0 -> 0.7.1 (May - December 2017). Non-backwards compatible with V2. + V3, + + /// >= 0.8.0 (December 2017). Non-backwards compatible with V3. + V4, + + /// >= 1.0.0 (July 2020. Backwards compatible with V4 (V5 readers can read V4 + /// metadata and IPC messages). Implementations are recommended to provide a + /// V4 compatibility mode with V5 format changes disabled. + /// + /// Incompatible changes between V4 and V5: + /// - Union buffer layout has changed. In V5, Unions don't have a validity + /// bitmap buffer. + V5, +} + +/// Represents Arrow Features that might not have full support +/// within implementations. This is intended to be used in +/// two scenarios: +/// 1. A mechanism for readers of Arrow Streams +/// and files to understand that the stream or file makes +/// use of a feature that isn't supported or unknown to +/// the implementation (and therefore can meet the Arrow +/// forward compatibility guarantees). +/// 2. A means of negotiating between a client and server +/// what features a stream is allowed to use. The enums +/// values here are intented to represent higher level +/// features, additional details maybe negotiated +/// with key-value pairs specific to the protocol. +/// +/// Enums added to this list should be assigned power-of-two values +/// to facilitate exchanging and comparing bitmaps for supported +/// features. +enum Feature : long { + /// Needed to make flatbuffers happy. + UNUSED = 0, + /// The stream makes use of multiple full dictionaries with the + /// same ID and assumes clients implement dictionary replacement + /// correctly. + DICTIONARY_REPLACEMENT = 1, + /// The stream makes use of compressed bodies as described + /// in Message.fbs. + COMPRESSED_BODY = 2 +} + +/// These are stored in the flatbuffer in the Type union below + +table Null { +} + +/// A Struct_ in the flatbuffer metadata is the same as an Arrow Struct +/// (according to the physical memory layout). We used Struct_ here as +/// Struct is a reserved word in Flatbuffers +table Struct_ { +} + +table List { +} + +/// Same as List, but with 64-bit offsets, allowing to represent +/// extremely large data values. +table LargeList { +} + +table FixedSizeList { + /// Number of list items per value + listSize: int; +} + +/// A Map is a logical nested type that is represented as +/// +/// List<entries: Struct<key: K, value: V>> +/// +/// In this layout, the keys and values are each respectively contiguous. We do +/// not constrain the key and value types, so the application is responsible +/// for ensuring that the keys are hashable and unique. Whether the keys are sorted +/// may be set in the metadata for this field. +/// +/// In a field with Map type, the field has a child Struct field, which then +/// has two children: key type and the second the value type. The names of the +/// child fields may be respectively "entries", "key", and "value", but this is +/// not enforced. +/// +/// Map +/// ```text +/// - child[0] entries: Struct +/// - child[0] key: K +/// - child[1] value: V +/// ``` +/// Neither the "entries" field nor the "key" field may be nullable. +/// +/// The metadata is structured so that Arrow systems without special handling +/// for Map can make Map an alias for List. The "layout" attribute for the Map +/// field must have the same contents as a List. +table Map { + /// Set to true if the keys within each value are sorted + keysSorted: bool; +} + +enum UnionMode:short { Sparse, Dense } + +/// A union is a complex type with children in Field +/// By default ids in the type vector refer to the offsets in the children +/// optionally typeIds provides an indirection between the child offset and the type id +/// for each child `typeIds[offset]` is the id used in the type vector +table Union { + mode: UnionMode; + typeIds: [ int ]; // optional, describes typeid of each child. +} + +table Int { + bitWidth: int; // restricted to 8, 16, 32, and 64 in v1 + is_signed: bool; +} + +enum Precision:short {HALF, SINGLE, DOUBLE} + +table FloatingPoint { + precision: Precision; +} + +/// Unicode with UTF-8 encoding +table Utf8 { +} + +/// Opaque binary data +table Binary { +} + +/// Same as Utf8, but with 64-bit offsets, allowing to represent +/// extremely large data values. +table LargeUtf8 { +} + +/// Same as Binary, but with 64-bit offsets, allowing to represent +/// extremely large data values. +table LargeBinary { +} + +table FixedSizeBinary { + /// Number of bytes per value + byteWidth: int; +} + +table Bool { +} + +/// Exact decimal value represented as an integer value in two's +/// complement. Currently only 128-bit (16-byte) and 256-bit (32-byte) integers +/// are used. The representation uses the endianness indicated +/// in the Schema. +table Decimal { + /// Total number of decimal digits + precision: int; + + /// Number of digits after the decimal point "." + scale: int; + + /// Number of bits per value. The only accepted widths are 128 and 256. + /// We use bitWidth for consistency with Int::bitWidth. + bitWidth: int = 128; +} + +enum DateUnit: short { + DAY, + MILLISECOND +} + +/// Date is either a 32-bit or 64-bit type representing elapsed time since UNIX +/// epoch (1970-01-01), stored in either of two units: +/// +/// * Milliseconds (64 bits) indicating UNIX time elapsed since the epoch (no +/// leap seconds), where the values are evenly divisible by 86400000 +/// * Days (32 bits) since the UNIX epoch +table Date { + unit: DateUnit = MILLISECOND; +} + +enum TimeUnit: short { SECOND, MILLISECOND, MICROSECOND, NANOSECOND } + +/// Time type. The physical storage type depends on the unit +/// - SECOND and MILLISECOND: 32 bits +/// - MICROSECOND and NANOSECOND: 64 bits +table Time { + unit: TimeUnit = MILLISECOND; + bitWidth: int = 32; +} + +/// Time elapsed from the Unix epoch, 00:00:00.000 on 1 January 1970, excluding +/// leap seconds, as a 64-bit integer. Note that UNIX time does not include +/// leap seconds. +/// +/// Date & time libraries often have multiple different data types for temporal +/// data. In order to ease interoperability between different implementations the +/// Arrow project has some recommendations for encoding these types into a Timestamp +/// column. +/// +/// An "instant" represents a single moment in time that has no meaningful time zone +/// or the time zone is unknown. A column of instants can also contain values from +/// multiple time zones. To encode an instant set the timezone string to "UTC". +/// +/// A "zoned date-time" represents a single moment in time that has a meaningful +/// reference time zone. To encode a zoned date-time as a Timestamp set the timezone +/// string to the name of the timezone. There is some ambiguity between an instant +/// and a zoned date-time with the UTC time zone. Both of these are stored the same. +/// Typically, this distinction does not matter. If it does, then an application should +/// use custom metadata or an extension type to distinguish between the two cases. +/// +/// An "offset date-time" represents a single moment in time combined with a meaningful +/// offset from UTC. To encode an offset date-time as a Timestamp set the timezone string +/// to the numeric time zone offset string (e.g. "+03:00"). +/// +/// A "local date-time" does not represent a single moment in time. It represents a wall +/// clock time combined with a date. Because of daylight savings time there may multiple +/// instants that correspond to a single local date-time in any given time zone. A +/// local date-time is often stored as a struct or a Date32/Time64 pair. However, it can +/// also be encoded into a Timestamp column. To do so the value should be the the time +/// elapsed from the Unix epoch so that a wall clock in UTC would display the desired time. +/// The timezone string should be set to null or the empty string. +table Timestamp { + unit: TimeUnit; + + /// The time zone is a string indicating the name of a time zone, one of: + /// + /// * As used in the Olson time zone database (the "tz database" or + /// "tzdata"), such as "America/New_York" + /// * An absolute time zone offset of the form +XX:XX or -XX:XX, such as +07:30 + /// + /// Whether a timezone string is present indicates different semantics about + /// the data: + /// + /// * If the time zone is null or an empty string, the data is a local date-time + /// and does not represent a single moment in time. Instead it represents a wall clock + /// time and care should be taken to avoid interpreting it semantically as an instant. + /// + /// * If the time zone is set to a valid value, values can be displayed as + /// "localized" to that time zone, even though the underlying 64-bit + /// integers are identical to the same data stored in UTC. Converting + /// between time zones is a metadata-only operation and does not change the + /// underlying values + time_zone: string; +} + +enum IntervalUnit: short { YEAR_MONTH, DAY_TIME} +// A "calendar" interval which models types that don't necessarily +// have a precise duration without the context of a base timestamp (e.g. +// days can differ in length during day light savings time transitions). +// YEAR_MONTH - Indicates the number of elapsed whole months, stored as +// 4-byte integers. +// DAY_TIME - Indicates the number of elapsed days and milliseconds, +// stored as 2 contiguous 32-bit integers (8-bytes in total). Support +// of this IntervalUnit is not required for full arrow compatibility. +table Interval { + unit: IntervalUnit; +} + +// An absolute length of time unrelated to any calendar artifacts. +// +// For the purposes of Arrow Implementations, adding this value to a Timestamp +// ("t1") naively (i.e. simply summing the two number) is acceptable even +// though in some cases the resulting Timestamp (t2) would not account for +// leap-seconds during the elapsed time between "t1" and "t2". Similarly, +// representing the difference between two Unix timestamp is acceptable, but +// would yield a value that is possibly a few seconds off from the true elapsed +// time. +// +// The resolution defaults to millisecond, but can be any of the other +// supported TimeUnit values as with Timestamp and Time types. This type is +// always represented as an 8-byte integer. +table Duration { + unit: TimeUnit = MILLISECOND; +} + +/// ---------------------------------------------------------------------- +/// Top-level Type value, enabling extensible type-specific metadata. We can +/// add new logical types to Type without breaking backwards compatibility + +union Type { + Null, + Int, + FloatingPoint, + Binary, + Utf8, + Bool, + Decimal, + Date, + Time, + Timestamp, + Interval, + List, + Struct_, + Union, + FixedSizeBinary, + FixedSizeList, + Map, + Duration, + LargeBinary, + LargeUtf8, + LargeList, +} + +/// ---------------------------------------------------------------------- +/// user defined key value pairs to add custom metadata to arrow +/// key namespacing is the responsibility of the user + +table KeyValue { + key: string; + value: string; +} + +/// ---------------------------------------------------------------------- +/// Dictionary encoding metadata +/// Maintained for forwards compatibility, in the future +/// Dictionaries might be explicit maps between integers and values +/// allowing for non-contiguous index values +enum DictionaryKind : short { DenseArray } +table DictionaryEncoding { + /// The known dictionary id in the application where this data is used. In + /// the file or streaming formats, the dictionary ids are found in the + /// DictionaryBatch messages + id: long; + + /// The dictionary indices are constrained to be non-negative integers. If + /// this field is null, the indices must be signed int32. To maximize + /// cross-language compatibility and performance, implementations are + /// recommended to prefer signed integer types over unsigned integer types + /// and to avoid uint64 indices unless they are required by an application. + indexType: Int; + + /// By default, dictionaries are not ordered, or the order does not have + /// semantic meaning. In some statistical, applications, dictionary-encoding + /// is used to represent ordered categorical data, and we provide a way to + /// preserve that metadata here + isOrdered: bool; + + dictionaryKind: DictionaryKind; +} + +/// ---------------------------------------------------------------------- +/// A field represents a named column in a record / row batch or child of a +/// nested type. + +table Field { + /// Name is not required, in i.e. a List + name: string; + + /// Whether or not this field can contain nulls. Should be true in general. + nullable: bool; + + /// This is the type of the decoded value if the field is dictionary encoded. + type: Type; + + /// Present only if the field is dictionary encoded. + dictionary: DictionaryEncoding; + + /// children apply only to nested data types like Struct, List and Union. For + /// primitive types children will have length 0. + children: [ Field ]; + + /// User-defined metadata + custom_metadata: [ KeyValue ]; +} + +/// ---------------------------------------------------------------------- +/// Endianness of the platform producing the data + +enum Endianness:short { Little, Big } + +/// ---------------------------------------------------------------------- +/// A Buffer represents a single contiguous memory segment +struct Buffer { + /// The relative offset into the shared memory page where the bytes for this + /// buffer starts + offset: long; + + /// The absolute length (in bytes) of the memory buffer. The memory is found + /// from offset (inclusive) to offset + length (non-inclusive). When building + /// messages using the encapsulated IPC message, padding bytes may be written + /// after a buffer, but such padding bytes do not need to be accounted for in + /// the size here. + length: long; +} + +/// ---------------------------------------------------------------------- +/// A Schema describes the columns in a row batch + +table Schema { + + /// endianness of the buffer + /// it is Little Endian by default + /// if endianness doesn't match the underlying system then the vectors need to be converted + endianness: Endianness=Little; + + fields: [Field]; + // User-defined metadata + custom_metadata: [ KeyValue ]; + + /// Features used in the stream/file. + features : [ Feature ]; +} + +root_type Schema; diff --git a/contrib/libs/apache/arrow/cpp/src/generated/Schema_generated.h b/contrib/libs/apache/arrow/cpp/src/generated/Schema_generated.h deleted file mode 100644 index 91e01d3375..0000000000 --- a/contrib/libs/apache/arrow/cpp/src/generated/Schema_generated.h +++ /dev/null @@ -1,2265 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_SCHEMA_ORG_APACHE_ARROW_FLATBUF_H_ -#define FLATBUFFERS_GENERATED_SCHEMA_ORG_APACHE_ARROW_FLATBUF_H_ - -#include "flatbuffers/flatbuffers.h" - -namespace org { -namespace apache { -namespace arrow { -namespace flatbuf { - -struct Null; -struct NullBuilder; - -struct Struct_; -struct Struct_Builder; - -struct List; -struct ListBuilder; - -struct LargeList; -struct LargeListBuilder; - -struct FixedSizeList; -struct FixedSizeListBuilder; - -struct Map; -struct MapBuilder; - -struct Union; -struct UnionBuilder; - -struct Int; -struct IntBuilder; - -struct FloatingPoint; -struct FloatingPointBuilder; - -struct Utf8; -struct Utf8Builder; - -struct Binary; -struct BinaryBuilder; - -struct LargeUtf8; -struct LargeUtf8Builder; - -struct LargeBinary; -struct LargeBinaryBuilder; - -struct FixedSizeBinary; -struct FixedSizeBinaryBuilder; - -struct Bool; -struct BoolBuilder; - -struct Decimal; -struct DecimalBuilder; - -struct Date; -struct DateBuilder; - -struct Time; -struct TimeBuilder; - -struct Timestamp; -struct TimestampBuilder; - -struct Interval; -struct IntervalBuilder; - -struct Duration; -struct DurationBuilder; - -struct KeyValue; -struct KeyValueBuilder; - -struct DictionaryEncoding; -struct DictionaryEncodingBuilder; - -struct Field; -struct FieldBuilder; - -struct Buffer; - -struct Schema; -struct SchemaBuilder; - -enum class MetadataVersion : int16_t { - /// 0.1.0 (October 2016). - V1 = 0, - /// 0.2.0 (February 2017). Non-backwards compatible with V1. - V2 = 1, - /// 0.3.0 -> 0.7.1 (May - December 2017). Non-backwards compatible with V2. - V3 = 2, - /// >= 0.8.0 (December 2017). Non-backwards compatible with V3. - V4 = 3, - /// >= 1.0.0 (July 2020. Backwards compatible with V4 (V5 readers can read V4 - /// metadata and IPC messages). Implementations are recommended to provide a - /// V4 compatibility mode with V5 format changes disabled. - /// - /// Incompatible changes between V4 and V5: - /// - Union buffer layout has changed. In V5, Unions don't have a validity - /// bitmap buffer. - V5 = 4, - MIN = V1, - MAX = V5 -}; - -inline const MetadataVersion (&EnumValuesMetadataVersion())[5] { - static const MetadataVersion values[] = { - MetadataVersion::V1, - MetadataVersion::V2, - MetadataVersion::V3, - MetadataVersion::V4, - MetadataVersion::V5 - }; - return values; -} - -inline const char * const *EnumNamesMetadataVersion() { - static const char * const names[6] = { - "V1", - "V2", - "V3", - "V4", - "V5", - nullptr - }; - return names; -} - -inline const char *EnumNameMetadataVersion(MetadataVersion e) { - if (flatbuffers::IsOutRange(e, MetadataVersion::V1, MetadataVersion::V5)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesMetadataVersion()[index]; -} - -/// Represents Arrow Features that might not have full support -/// within implementations. This is intended to be used in -/// two scenarios: -/// 1. A mechanism for readers of Arrow Streams -/// and files to understand that the stream or file makes -/// use of a feature that isn't supported or unknown to -/// the implementation (and therefore can meet the Arrow -/// forward compatibility guarantees). -/// 2. A means of negotiating between a client and server -/// what features a stream is allowed to use. The enums -/// values here are intented to represent higher level -/// features, additional details maybe negotiated -/// with key-value pairs specific to the protocol. -/// -/// Enums added to this list should be assigned power-of-two values -/// to facilitate exchanging and comparing bitmaps for supported -/// features. -enum class Feature : int64_t { - /// Needed to make flatbuffers happy. - UNUSED = 0, - /// The stream makes use of multiple full dictionaries with the - /// same ID and assumes clients implement dictionary replacement - /// correctly. - DICTIONARY_REPLACEMENT = 1LL, - /// The stream makes use of compressed bodies as described - /// in Message.fbs. - COMPRESSED_BODY = 2LL, - MIN = UNUSED, - MAX = COMPRESSED_BODY -}; - -inline const Feature (&EnumValuesFeature())[3] { - static const Feature values[] = { - Feature::UNUSED, - Feature::DICTIONARY_REPLACEMENT, - Feature::COMPRESSED_BODY - }; - return values; -} - -inline const char * const *EnumNamesFeature() { - static const char * const names[4] = { - "UNUSED", - "DICTIONARY_REPLACEMENT", - "COMPRESSED_BODY", - nullptr - }; - return names; -} - -inline const char *EnumNameFeature(Feature e) { - if (flatbuffers::IsOutRange(e, Feature::UNUSED, Feature::COMPRESSED_BODY)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesFeature()[index]; -} - -enum class UnionMode : int16_t { - Sparse = 0, - Dense = 1, - MIN = Sparse, - MAX = Dense -}; - -inline const UnionMode (&EnumValuesUnionMode())[2] { - static const UnionMode values[] = { - UnionMode::Sparse, - UnionMode::Dense - }; - return values; -} - -inline const char * const *EnumNamesUnionMode() { - static const char * const names[3] = { - "Sparse", - "Dense", - nullptr - }; - return names; -} - -inline const char *EnumNameUnionMode(UnionMode e) { - if (flatbuffers::IsOutRange(e, UnionMode::Sparse, UnionMode::Dense)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesUnionMode()[index]; -} - -enum class Precision : int16_t { - HALF = 0, - SINGLE = 1, - DOUBLE = 2, - MIN = HALF, - MAX = DOUBLE -}; - -inline const Precision (&EnumValuesPrecision())[3] { - static const Precision values[] = { - Precision::HALF, - Precision::SINGLE, - Precision::DOUBLE - }; - return values; -} - -inline const char * const *EnumNamesPrecision() { - static const char * const names[4] = { - "HALF", - "SINGLE", - "DOUBLE", - nullptr - }; - return names; -} - -inline const char *EnumNamePrecision(Precision e) { - if (flatbuffers::IsOutRange(e, Precision::HALF, Precision::DOUBLE)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesPrecision()[index]; -} - -enum class DateUnit : int16_t { - DAY = 0, - MILLISECOND = 1, - MIN = DAY, - MAX = MILLISECOND -}; - -inline const DateUnit (&EnumValuesDateUnit())[2] { - static const DateUnit values[] = { - DateUnit::DAY, - DateUnit::MILLISECOND - }; - return values; -} - -inline const char * const *EnumNamesDateUnit() { - static const char * const names[3] = { - "DAY", - "MILLISECOND", - nullptr - }; - return names; -} - -inline const char *EnumNameDateUnit(DateUnit e) { - if (flatbuffers::IsOutRange(e, DateUnit::DAY, DateUnit::MILLISECOND)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesDateUnit()[index]; -} - -enum class TimeUnit : int16_t { - SECOND = 0, - MILLISECOND = 1, - MICROSECOND = 2, - NANOSECOND = 3, - MIN = SECOND, - MAX = NANOSECOND -}; - -inline const TimeUnit (&EnumValuesTimeUnit())[4] { - static const TimeUnit values[] = { - TimeUnit::SECOND, - TimeUnit::MILLISECOND, - TimeUnit::MICROSECOND, - TimeUnit::NANOSECOND - }; - return values; -} - -inline const char * const *EnumNamesTimeUnit() { - static const char * const names[5] = { - "SECOND", - "MILLISECOND", - "MICROSECOND", - "NANOSECOND", - nullptr - }; - return names; -} - -inline const char *EnumNameTimeUnit(TimeUnit e) { - if (flatbuffers::IsOutRange(e, TimeUnit::SECOND, TimeUnit::NANOSECOND)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesTimeUnit()[index]; -} - -enum class IntervalUnit : int16_t { - YEAR_MONTH = 0, - DAY_TIME = 1, - MIN = YEAR_MONTH, - MAX = DAY_TIME -}; - -inline const IntervalUnit (&EnumValuesIntervalUnit())[2] { - static const IntervalUnit values[] = { - IntervalUnit::YEAR_MONTH, - IntervalUnit::DAY_TIME - }; - return values; -} - -inline const char * const *EnumNamesIntervalUnit() { - static const char * const names[3] = { - "YEAR_MONTH", - "DAY_TIME", - nullptr - }; - return names; -} - -inline const char *EnumNameIntervalUnit(IntervalUnit e) { - if (flatbuffers::IsOutRange(e, IntervalUnit::YEAR_MONTH, IntervalUnit::DAY_TIME)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesIntervalUnit()[index]; -} - -/// ---------------------------------------------------------------------- -/// Top-level Type value, enabling extensible type-specific metadata. We can -/// add new logical types to Type without breaking backwards compatibility -enum class Type : uint8_t { - NONE = 0, - Null = 1, - Int = 2, - FloatingPoint = 3, - Binary = 4, - Utf8 = 5, - Bool = 6, - Decimal = 7, - Date = 8, - Time = 9, - Timestamp = 10, - Interval = 11, - List = 12, - Struct_ = 13, - Union = 14, - FixedSizeBinary = 15, - FixedSizeList = 16, - Map = 17, - Duration = 18, - LargeBinary = 19, - LargeUtf8 = 20, - LargeList = 21, - MIN = NONE, - MAX = LargeList -}; - -inline const Type (&EnumValuesType())[22] { - static const Type values[] = { - Type::NONE, - Type::Null, - Type::Int, - Type::FloatingPoint, - Type::Binary, - Type::Utf8, - Type::Bool, - Type::Decimal, - Type::Date, - Type::Time, - Type::Timestamp, - Type::Interval, - Type::List, - Type::Struct_, - Type::Union, - Type::FixedSizeBinary, - Type::FixedSizeList, - Type::Map, - Type::Duration, - Type::LargeBinary, - Type::LargeUtf8, - Type::LargeList - }; - return values; -} - -inline const char * const *EnumNamesType() { - static const char * const names[23] = { - "NONE", - "Null", - "Int", - "FloatingPoint", - "Binary", - "Utf8", - "Bool", - "Decimal", - "Date", - "Time", - "Timestamp", - "Interval", - "List", - "Struct_", - "Union", - "FixedSizeBinary", - "FixedSizeList", - "Map", - "Duration", - "LargeBinary", - "LargeUtf8", - "LargeList", - nullptr - }; - return names; -} - -inline const char *EnumNameType(Type e) { - if (flatbuffers::IsOutRange(e, Type::NONE, Type::LargeList)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesType()[index]; -} - -template<typename T> struct TypeTraits { - static const Type enum_value = Type::NONE; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::Null> { - static const Type enum_value = Type::Null; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::Int> { - static const Type enum_value = Type::Int; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::FloatingPoint> { - static const Type enum_value = Type::FloatingPoint; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::Binary> { - static const Type enum_value = Type::Binary; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::Utf8> { - static const Type enum_value = Type::Utf8; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::Bool> { - static const Type enum_value = Type::Bool; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::Decimal> { - static const Type enum_value = Type::Decimal; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::Date> { - static const Type enum_value = Type::Date; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::Time> { - static const Type enum_value = Type::Time; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::Timestamp> { - static const Type enum_value = Type::Timestamp; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::Interval> { - static const Type enum_value = Type::Interval; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::List> { - static const Type enum_value = Type::List; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::Struct_> { - static const Type enum_value = Type::Struct_; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::Union> { - static const Type enum_value = Type::Union; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::FixedSizeBinary> { - static const Type enum_value = Type::FixedSizeBinary; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::FixedSizeList> { - static const Type enum_value = Type::FixedSizeList; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::Map> { - static const Type enum_value = Type::Map; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::Duration> { - static const Type enum_value = Type::Duration; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::LargeBinary> { - static const Type enum_value = Type::LargeBinary; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::LargeUtf8> { - static const Type enum_value = Type::LargeUtf8; -}; - -template<> struct TypeTraits<org::apache::arrow::flatbuf::LargeList> { - static const Type enum_value = Type::LargeList; -}; - -bool VerifyType(flatbuffers::Verifier &verifier, const void *obj, Type type); -bool VerifyTypeVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types); - -/// ---------------------------------------------------------------------- -/// Dictionary encoding metadata -/// Maintained for forwards compatibility, in the future -/// Dictionaries might be explicit maps between integers and values -/// allowing for non-contiguous index values -enum class DictionaryKind : int16_t { - DenseArray = 0, - MIN = DenseArray, - MAX = DenseArray -}; - -inline const DictionaryKind (&EnumValuesDictionaryKind())[1] { - static const DictionaryKind values[] = { - DictionaryKind::DenseArray - }; - return values; -} - -inline const char * const *EnumNamesDictionaryKind() { - static const char * const names[2] = { - "DenseArray", - nullptr - }; - return names; -} - -inline const char *EnumNameDictionaryKind(DictionaryKind e) { - if (flatbuffers::IsOutRange(e, DictionaryKind::DenseArray, DictionaryKind::DenseArray)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesDictionaryKind()[index]; -} - -/// ---------------------------------------------------------------------- -/// Endianness of the platform producing the data -enum class Endianness : int16_t { - Little = 0, - Big = 1, - MIN = Little, - MAX = Big -}; - -inline const Endianness (&EnumValuesEndianness())[2] { - static const Endianness values[] = { - Endianness::Little, - Endianness::Big - }; - return values; -} - -inline const char * const *EnumNamesEndianness() { - static const char * const names[3] = { - "Little", - "Big", - nullptr - }; - return names; -} - -inline const char *EnumNameEndianness(Endianness e) { - if (flatbuffers::IsOutRange(e, Endianness::Little, Endianness::Big)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesEndianness()[index]; -} - -/// ---------------------------------------------------------------------- -/// A Buffer represents a single contiguous memory segment -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Buffer FLATBUFFERS_FINAL_CLASS { - private: - int64_t offset_; - int64_t length_; - - public: - Buffer() { - memset(static_cast<void *>(this), 0, sizeof(Buffer)); - } - Buffer(int64_t _offset, int64_t _length) - : offset_(flatbuffers::EndianScalar(_offset)), - length_(flatbuffers::EndianScalar(_length)) { - } - /// The relative offset into the shared memory page where the bytes for this - /// buffer starts - int64_t offset() const { - return flatbuffers::EndianScalar(offset_); - } - /// The absolute length (in bytes) of the memory buffer. The memory is found - /// from offset (inclusive) to offset + length (non-inclusive). When building - /// messages using the encapsulated IPC message, padding bytes may be written - /// after a buffer, but such padding bytes do not need to be accounted for in - /// the size here. - int64_t length() const { - return flatbuffers::EndianScalar(length_); - } -}; -FLATBUFFERS_STRUCT_END(Buffer, 16); - -/// These are stored in the flatbuffer in the Type union below -struct Null FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef NullBuilder Builder; - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - verifier.EndTable(); - } -}; - -struct NullBuilder { - typedef Null Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - explicit NullBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - NullBuilder &operator=(const NullBuilder &); - flatbuffers::Offset<Null> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Null>(end); - return o; - } -}; - -inline flatbuffers::Offset<Null> CreateNull( - flatbuffers::FlatBufferBuilder &_fbb) { - NullBuilder builder_(_fbb); - return builder_.Finish(); -} - -/// A Struct_ in the flatbuffer metadata is the same as an Arrow Struct -/// (according to the physical memory layout). We used Struct_ here as -/// Struct is a reserved word in Flatbuffers -struct Struct_ FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Struct_Builder Builder; - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - verifier.EndTable(); - } -}; - -struct Struct_Builder { - typedef Struct_ Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - explicit Struct_Builder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - Struct_Builder &operator=(const Struct_Builder &); - flatbuffers::Offset<Struct_> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Struct_>(end); - return o; - } -}; - -inline flatbuffers::Offset<Struct_> CreateStruct_( - flatbuffers::FlatBufferBuilder &_fbb) { - Struct_Builder builder_(_fbb); - return builder_.Finish(); -} - -struct List FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef ListBuilder Builder; - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - verifier.EndTable(); - } -}; - -struct ListBuilder { - typedef List Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - explicit ListBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - ListBuilder &operator=(const ListBuilder &); - flatbuffers::Offset<List> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<List>(end); - return o; - } -}; - -inline flatbuffers::Offset<List> CreateList( - flatbuffers::FlatBufferBuilder &_fbb) { - ListBuilder builder_(_fbb); - return builder_.Finish(); -} - -/// Same as List, but with 64-bit offsets, allowing to represent -/// extremely large data values. -struct LargeList FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef LargeListBuilder Builder; - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - verifier.EndTable(); - } -}; - -struct LargeListBuilder { - typedef LargeList Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - explicit LargeListBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - LargeListBuilder &operator=(const LargeListBuilder &); - flatbuffers::Offset<LargeList> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<LargeList>(end); - return o; - } -}; - -inline flatbuffers::Offset<LargeList> CreateLargeList( - flatbuffers::FlatBufferBuilder &_fbb) { - LargeListBuilder builder_(_fbb); - return builder_.Finish(); -} - -struct FixedSizeList FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef FixedSizeListBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_LISTSIZE = 4 - }; - /// Number of list items per value - int32_t listSize() const { - return GetField<int32_t>(VT_LISTSIZE, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int32_t>(verifier, VT_LISTSIZE) && - verifier.EndTable(); - } -}; - -struct FixedSizeListBuilder { - typedef FixedSizeList Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_listSize(int32_t listSize) { - fbb_.AddElement<int32_t>(FixedSizeList::VT_LISTSIZE, listSize, 0); - } - explicit FixedSizeListBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - FixedSizeListBuilder &operator=(const FixedSizeListBuilder &); - flatbuffers::Offset<FixedSizeList> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<FixedSizeList>(end); - return o; - } -}; - -inline flatbuffers::Offset<FixedSizeList> CreateFixedSizeList( - flatbuffers::FlatBufferBuilder &_fbb, - int32_t listSize = 0) { - FixedSizeListBuilder builder_(_fbb); - builder_.add_listSize(listSize); - return builder_.Finish(); -} - -/// A Map is a logical nested type that is represented as -/// -/// List<entries: Struct<key: K, value: V>> -/// -/// In this layout, the keys and values are each respectively contiguous. We do -/// not constrain the key and value types, so the application is responsible -/// for ensuring that the keys are hashable and unique. Whether the keys are sorted -/// may be set in the metadata for this field. -/// -/// In a field with Map type, the field has a child Struct field, which then -/// has two children: key type and the second the value type. The names of the -/// child fields may be respectively "entries", "key", and "value", but this is -/// not enforced. -/// -/// Map -/// - child[0] entries: Struct -/// - child[0] key: K -/// - child[1] value: V -/// -/// Neither the "entries" field nor the "key" field may be nullable. -/// -/// The metadata is structured so that Arrow systems without special handling -/// for Map can make Map an alias for List. The "layout" attribute for the Map -/// field must have the same contents as a List. -struct Map FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef MapBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_KEYSSORTED = 4 - }; - /// Set to true if the keys within each value are sorted - bool keysSorted() const { - return GetField<uint8_t>(VT_KEYSSORTED, 0) != 0; - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<uint8_t>(verifier, VT_KEYSSORTED) && - verifier.EndTable(); - } -}; - -struct MapBuilder { - typedef Map Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_keysSorted(bool keysSorted) { - fbb_.AddElement<uint8_t>(Map::VT_KEYSSORTED, static_cast<uint8_t>(keysSorted), 0); - } - explicit MapBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - MapBuilder &operator=(const MapBuilder &); - flatbuffers::Offset<Map> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Map>(end); - return o; - } -}; - -inline flatbuffers::Offset<Map> CreateMap( - flatbuffers::FlatBufferBuilder &_fbb, - bool keysSorted = false) { - MapBuilder builder_(_fbb); - builder_.add_keysSorted(keysSorted); - return builder_.Finish(); -} - -/// A union is a complex type with children in Field -/// By default ids in the type vector refer to the offsets in the children -/// optionally typeIds provides an indirection between the child offset and the type id -/// for each child typeIds[offset] is the id used in the type vector -struct Union FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef UnionBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_MODE = 4, - VT_TYPEIDS = 6 - }; - org::apache::arrow::flatbuf::UnionMode mode() const { - return static_cast<org::apache::arrow::flatbuf::UnionMode>(GetField<int16_t>(VT_MODE, 0)); - } - const flatbuffers::Vector<int32_t> *typeIds() const { - return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_TYPEIDS); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int16_t>(verifier, VT_MODE) && - VerifyOffset(verifier, VT_TYPEIDS) && - verifier.VerifyVector(typeIds()) && - verifier.EndTable(); - } -}; - -struct UnionBuilder { - typedef Union Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_mode(org::apache::arrow::flatbuf::UnionMode mode) { - fbb_.AddElement<int16_t>(Union::VT_MODE, static_cast<int16_t>(mode), 0); - } - void add_typeIds(flatbuffers::Offset<flatbuffers::Vector<int32_t>> typeIds) { - fbb_.AddOffset(Union::VT_TYPEIDS, typeIds); - } - explicit UnionBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - UnionBuilder &operator=(const UnionBuilder &); - flatbuffers::Offset<Union> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Union>(end); - return o; - } -}; - -inline flatbuffers::Offset<Union> CreateUnion( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::UnionMode mode = org::apache::arrow::flatbuf::UnionMode::Sparse, - flatbuffers::Offset<flatbuffers::Vector<int32_t>> typeIds = 0) { - UnionBuilder builder_(_fbb); - builder_.add_typeIds(typeIds); - builder_.add_mode(mode); - return builder_.Finish(); -} - -inline flatbuffers::Offset<Union> CreateUnionDirect( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::UnionMode mode = org::apache::arrow::flatbuf::UnionMode::Sparse, - const std::vector<int32_t> *typeIds = nullptr) { - auto typeIds__ = typeIds ? _fbb.CreateVector<int32_t>(*typeIds) : 0; - return org::apache::arrow::flatbuf::CreateUnion( - _fbb, - mode, - typeIds__); -} - -struct Int FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef IntBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_BITWIDTH = 4, - VT_IS_SIGNED = 6 - }; - int32_t bitWidth() const { - return GetField<int32_t>(VT_BITWIDTH, 0); - } - bool is_signed() const { - return GetField<uint8_t>(VT_IS_SIGNED, 0) != 0; - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int32_t>(verifier, VT_BITWIDTH) && - VerifyField<uint8_t>(verifier, VT_IS_SIGNED) && - verifier.EndTable(); - } -}; - -struct IntBuilder { - typedef Int Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_bitWidth(int32_t bitWidth) { - fbb_.AddElement<int32_t>(Int::VT_BITWIDTH, bitWidth, 0); - } - void add_is_signed(bool is_signed) { - fbb_.AddElement<uint8_t>(Int::VT_IS_SIGNED, static_cast<uint8_t>(is_signed), 0); - } - explicit IntBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - IntBuilder &operator=(const IntBuilder &); - flatbuffers::Offset<Int> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Int>(end); - return o; - } -}; - -inline flatbuffers::Offset<Int> CreateInt( - flatbuffers::FlatBufferBuilder &_fbb, - int32_t bitWidth = 0, - bool is_signed = false) { - IntBuilder builder_(_fbb); - builder_.add_bitWidth(bitWidth); - builder_.add_is_signed(is_signed); - return builder_.Finish(); -} - -struct FloatingPoint FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef FloatingPointBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_PRECISION = 4 - }; - org::apache::arrow::flatbuf::Precision precision() const { - return static_cast<org::apache::arrow::flatbuf::Precision>(GetField<int16_t>(VT_PRECISION, 0)); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int16_t>(verifier, VT_PRECISION) && - verifier.EndTable(); - } -}; - -struct FloatingPointBuilder { - typedef FloatingPoint Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_precision(org::apache::arrow::flatbuf::Precision precision) { - fbb_.AddElement<int16_t>(FloatingPoint::VT_PRECISION, static_cast<int16_t>(precision), 0); - } - explicit FloatingPointBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - FloatingPointBuilder &operator=(const FloatingPointBuilder &); - flatbuffers::Offset<FloatingPoint> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<FloatingPoint>(end); - return o; - } -}; - -inline flatbuffers::Offset<FloatingPoint> CreateFloatingPoint( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::Precision precision = org::apache::arrow::flatbuf::Precision::HALF) { - FloatingPointBuilder builder_(_fbb); - builder_.add_precision(precision); - return builder_.Finish(); -} - -/// Unicode with UTF-8 encoding -struct Utf8 FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Utf8Builder Builder; - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - verifier.EndTable(); - } -}; - -struct Utf8Builder { - typedef Utf8 Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - explicit Utf8Builder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - Utf8Builder &operator=(const Utf8Builder &); - flatbuffers::Offset<Utf8> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Utf8>(end); - return o; - } -}; - -inline flatbuffers::Offset<Utf8> CreateUtf8( - flatbuffers::FlatBufferBuilder &_fbb) { - Utf8Builder builder_(_fbb); - return builder_.Finish(); -} - -/// Opaque binary data -struct Binary FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef BinaryBuilder Builder; - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - verifier.EndTable(); - } -}; - -struct BinaryBuilder { - typedef Binary Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - explicit BinaryBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - BinaryBuilder &operator=(const BinaryBuilder &); - flatbuffers::Offset<Binary> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Binary>(end); - return o; - } -}; - -inline flatbuffers::Offset<Binary> CreateBinary( - flatbuffers::FlatBufferBuilder &_fbb) { - BinaryBuilder builder_(_fbb); - return builder_.Finish(); -} - -/// Same as Utf8, but with 64-bit offsets, allowing to represent -/// extremely large data values. -struct LargeUtf8 FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef LargeUtf8Builder Builder; - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - verifier.EndTable(); - } -}; - -struct LargeUtf8Builder { - typedef LargeUtf8 Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - explicit LargeUtf8Builder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - LargeUtf8Builder &operator=(const LargeUtf8Builder &); - flatbuffers::Offset<LargeUtf8> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<LargeUtf8>(end); - return o; - } -}; - -inline flatbuffers::Offset<LargeUtf8> CreateLargeUtf8( - flatbuffers::FlatBufferBuilder &_fbb) { - LargeUtf8Builder builder_(_fbb); - return builder_.Finish(); -} - -/// Same as Binary, but with 64-bit offsets, allowing to represent -/// extremely large data values. -struct LargeBinary FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef LargeBinaryBuilder Builder; - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - verifier.EndTable(); - } -}; - -struct LargeBinaryBuilder { - typedef LargeBinary Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - explicit LargeBinaryBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - LargeBinaryBuilder &operator=(const LargeBinaryBuilder &); - flatbuffers::Offset<LargeBinary> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<LargeBinary>(end); - return o; - } -}; - -inline flatbuffers::Offset<LargeBinary> CreateLargeBinary( - flatbuffers::FlatBufferBuilder &_fbb) { - LargeBinaryBuilder builder_(_fbb); - return builder_.Finish(); -} - -struct FixedSizeBinary FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef FixedSizeBinaryBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_BYTEWIDTH = 4 - }; - /// Number of bytes per value - int32_t byteWidth() const { - return GetField<int32_t>(VT_BYTEWIDTH, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int32_t>(verifier, VT_BYTEWIDTH) && - verifier.EndTable(); - } -}; - -struct FixedSizeBinaryBuilder { - typedef FixedSizeBinary Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_byteWidth(int32_t byteWidth) { - fbb_.AddElement<int32_t>(FixedSizeBinary::VT_BYTEWIDTH, byteWidth, 0); - } - explicit FixedSizeBinaryBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - FixedSizeBinaryBuilder &operator=(const FixedSizeBinaryBuilder &); - flatbuffers::Offset<FixedSizeBinary> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<FixedSizeBinary>(end); - return o; - } -}; - -inline flatbuffers::Offset<FixedSizeBinary> CreateFixedSizeBinary( - flatbuffers::FlatBufferBuilder &_fbb, - int32_t byteWidth = 0) { - FixedSizeBinaryBuilder builder_(_fbb); - builder_.add_byteWidth(byteWidth); - return builder_.Finish(); -} - -struct Bool FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef BoolBuilder Builder; - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - verifier.EndTable(); - } -}; - -struct BoolBuilder { - typedef Bool Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - explicit BoolBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - BoolBuilder &operator=(const BoolBuilder &); - flatbuffers::Offset<Bool> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Bool>(end); - return o; - } -}; - -inline flatbuffers::Offset<Bool> CreateBool( - flatbuffers::FlatBufferBuilder &_fbb) { - BoolBuilder builder_(_fbb); - return builder_.Finish(); -} - -/// Exact decimal value represented as an integer value in two's -/// complement. Currently only 128-bit (16-byte) integers are used but this may -/// be expanded in the future. The representation uses the endianness indicated -/// in the Schema. -struct Decimal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef DecimalBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_PRECISION = 4, - VT_SCALE = 6, - VT_BITWIDTH = 8 - }; - /// Total number of decimal digits - int32_t precision() const { - return GetField<int32_t>(VT_PRECISION, 0); - } - /// Number of digits after the decimal point "." - int32_t scale() const { - return GetField<int32_t>(VT_SCALE, 0); - } - /// Number of bits per value. The only accepted width right now is 128 but - /// this field exists for forward compatibility so that other bit widths may - /// be supported in future format versions. We use bitWidth for consistency - /// with Int::bitWidth. - int32_t bitWidth() const { - return GetField<int32_t>(VT_BITWIDTH, 128); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int32_t>(verifier, VT_PRECISION) && - VerifyField<int32_t>(verifier, VT_SCALE) && - VerifyField<int32_t>(verifier, VT_BITWIDTH) && - verifier.EndTable(); - } -}; - -struct DecimalBuilder { - typedef Decimal Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_precision(int32_t precision) { - fbb_.AddElement<int32_t>(Decimal::VT_PRECISION, precision, 0); - } - void add_scale(int32_t scale) { - fbb_.AddElement<int32_t>(Decimal::VT_SCALE, scale, 0); - } - void add_bitWidth(int32_t bitWidth) { - fbb_.AddElement<int32_t>(Decimal::VT_BITWIDTH, bitWidth, 128); - } - explicit DecimalBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - DecimalBuilder &operator=(const DecimalBuilder &); - flatbuffers::Offset<Decimal> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Decimal>(end); - return o; - } -}; - -inline flatbuffers::Offset<Decimal> CreateDecimal( - flatbuffers::FlatBufferBuilder &_fbb, - int32_t precision = 0, - int32_t scale = 0, - int32_t bitWidth = 128) { - DecimalBuilder builder_(_fbb); - builder_.add_bitWidth(bitWidth); - builder_.add_scale(scale); - builder_.add_precision(precision); - return builder_.Finish(); -} - -/// Date is either a 32-bit or 64-bit type representing elapsed time since UNIX -/// epoch (1970-01-01), stored in either of two units: -/// -/// * Milliseconds (64 bits) indicating UNIX time elapsed since the epoch (no -/// leap seconds), where the values are evenly divisible by 86400000 -/// * Days (32 bits) since the UNIX epoch -struct Date FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef DateBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_UNIT = 4 - }; - org::apache::arrow::flatbuf::DateUnit unit() const { - return static_cast<org::apache::arrow::flatbuf::DateUnit>(GetField<int16_t>(VT_UNIT, 1)); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int16_t>(verifier, VT_UNIT) && - verifier.EndTable(); - } -}; - -struct DateBuilder { - typedef Date Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_unit(org::apache::arrow::flatbuf::DateUnit unit) { - fbb_.AddElement<int16_t>(Date::VT_UNIT, static_cast<int16_t>(unit), 1); - } - explicit DateBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - DateBuilder &operator=(const DateBuilder &); - flatbuffers::Offset<Date> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Date>(end); - return o; - } -}; - -inline flatbuffers::Offset<Date> CreateDate( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::DateUnit unit = org::apache::arrow::flatbuf::DateUnit::MILLISECOND) { - DateBuilder builder_(_fbb); - builder_.add_unit(unit); - return builder_.Finish(); -} - -/// Time type. The physical storage type depends on the unit -/// - SECOND and MILLISECOND: 32 bits -/// - MICROSECOND and NANOSECOND: 64 bits -struct Time FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef TimeBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_UNIT = 4, - VT_BITWIDTH = 6 - }; - org::apache::arrow::flatbuf::TimeUnit unit() const { - return static_cast<org::apache::arrow::flatbuf::TimeUnit>(GetField<int16_t>(VT_UNIT, 1)); - } - int32_t bitWidth() const { - return GetField<int32_t>(VT_BITWIDTH, 32); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int16_t>(verifier, VT_UNIT) && - VerifyField<int32_t>(verifier, VT_BITWIDTH) && - verifier.EndTable(); - } -}; - -struct TimeBuilder { - typedef Time Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_unit(org::apache::arrow::flatbuf::TimeUnit unit) { - fbb_.AddElement<int16_t>(Time::VT_UNIT, static_cast<int16_t>(unit), 1); - } - void add_bitWidth(int32_t bitWidth) { - fbb_.AddElement<int32_t>(Time::VT_BITWIDTH, bitWidth, 32); - } - explicit TimeBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - TimeBuilder &operator=(const TimeBuilder &); - flatbuffers::Offset<Time> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Time>(end); - return o; - } -}; - -inline flatbuffers::Offset<Time> CreateTime( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::TimeUnit unit = org::apache::arrow::flatbuf::TimeUnit::MILLISECOND, - int32_t bitWidth = 32) { - TimeBuilder builder_(_fbb); - builder_.add_bitWidth(bitWidth); - builder_.add_unit(unit); - return builder_.Finish(); -} - -/// Time elapsed from the Unix epoch, 00:00:00.000 on 1 January 1970, excluding -/// leap seconds, as a 64-bit integer. Note that UNIX time does not include -/// leap seconds. -/// -/// The Timestamp metadata supports both "time zone naive" and "time zone -/// aware" timestamps. Read about the timezone attribute for more detail -struct Timestamp FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef TimestampBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_UNIT = 4, - VT_TIMEZONE = 6 - }; - org::apache::arrow::flatbuf::TimeUnit unit() const { - return static_cast<org::apache::arrow::flatbuf::TimeUnit>(GetField<int16_t>(VT_UNIT, 0)); - } - /// The time zone is a string indicating the name of a time zone, one of: - /// - /// * As used in the Olson time zone database (the "tz database" or - /// "tzdata"), such as "America/New_York" - /// * An absolute time zone offset of the form +XX:XX or -XX:XX, such as +07:30 - /// - /// Whether a timezone string is present indicates different semantics about - /// the data: - /// - /// * If the time zone is null or equal to an empty string, the data is "time - /// zone naive" and shall be displayed *as is* to the user, not localized - /// to the locale of the user. This data can be though of as UTC but - /// without having "UTC" as the time zone, it is not considered to be - /// localized to any time zone - /// - /// * If the time zone is set to a valid value, values can be displayed as - /// "localized" to that time zone, even though the underlying 64-bit - /// integers are identical to the same data stored in UTC. Converting - /// between time zones is a metadata-only operation and does not change the - /// underlying values - const flatbuffers::String *timezone() const { - return GetPointer<const flatbuffers::String *>(VT_TIMEZONE); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int16_t>(verifier, VT_UNIT) && - VerifyOffset(verifier, VT_TIMEZONE) && - verifier.VerifyString(timezone()) && - verifier.EndTable(); - } -}; - -struct TimestampBuilder { - typedef Timestamp Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_unit(org::apache::arrow::flatbuf::TimeUnit unit) { - fbb_.AddElement<int16_t>(Timestamp::VT_UNIT, static_cast<int16_t>(unit), 0); - } - void add_timezone(flatbuffers::Offset<flatbuffers::String> timezone) { - fbb_.AddOffset(Timestamp::VT_TIMEZONE, timezone); - } - explicit TimestampBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - TimestampBuilder &operator=(const TimestampBuilder &); - flatbuffers::Offset<Timestamp> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Timestamp>(end); - return o; - } -}; - -inline flatbuffers::Offset<Timestamp> CreateTimestamp( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::TimeUnit unit = org::apache::arrow::flatbuf::TimeUnit::SECOND, - flatbuffers::Offset<flatbuffers::String> timezone = 0) { - TimestampBuilder builder_(_fbb); - builder_.add_timezone(timezone); - builder_.add_unit(unit); - return builder_.Finish(); -} - -inline flatbuffers::Offset<Timestamp> CreateTimestampDirect( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::TimeUnit unit = org::apache::arrow::flatbuf::TimeUnit::SECOND, - const char *timezone = nullptr) { - auto timezone__ = timezone ? _fbb.CreateString(timezone) : 0; - return org::apache::arrow::flatbuf::CreateTimestamp( - _fbb, - unit, - timezone__); -} - -struct Interval FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef IntervalBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_UNIT = 4 - }; - org::apache::arrow::flatbuf::IntervalUnit unit() const { - return static_cast<org::apache::arrow::flatbuf::IntervalUnit>(GetField<int16_t>(VT_UNIT, 0)); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int16_t>(verifier, VT_UNIT) && - verifier.EndTable(); - } -}; - -struct IntervalBuilder { - typedef Interval Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_unit(org::apache::arrow::flatbuf::IntervalUnit unit) { - fbb_.AddElement<int16_t>(Interval::VT_UNIT, static_cast<int16_t>(unit), 0); - } - explicit IntervalBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - IntervalBuilder &operator=(const IntervalBuilder &); - flatbuffers::Offset<Interval> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Interval>(end); - return o; - } -}; - -inline flatbuffers::Offset<Interval> CreateInterval( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::IntervalUnit unit = org::apache::arrow::flatbuf::IntervalUnit::YEAR_MONTH) { - IntervalBuilder builder_(_fbb); - builder_.add_unit(unit); - return builder_.Finish(); -} - -struct Duration FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef DurationBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_UNIT = 4 - }; - org::apache::arrow::flatbuf::TimeUnit unit() const { - return static_cast<org::apache::arrow::flatbuf::TimeUnit>(GetField<int16_t>(VT_UNIT, 1)); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int16_t>(verifier, VT_UNIT) && - verifier.EndTable(); - } -}; - -struct DurationBuilder { - typedef Duration Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_unit(org::apache::arrow::flatbuf::TimeUnit unit) { - fbb_.AddElement<int16_t>(Duration::VT_UNIT, static_cast<int16_t>(unit), 1); - } - explicit DurationBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - DurationBuilder &operator=(const DurationBuilder &); - flatbuffers::Offset<Duration> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Duration>(end); - return o; - } -}; - -inline flatbuffers::Offset<Duration> CreateDuration( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::TimeUnit unit = org::apache::arrow::flatbuf::TimeUnit::MILLISECOND) { - DurationBuilder builder_(_fbb); - builder_.add_unit(unit); - return builder_.Finish(); -} - -/// ---------------------------------------------------------------------- -/// user defined key value pairs to add custom metadata to arrow -/// key namespacing is the responsibility of the user -struct KeyValue FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef KeyValueBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_KEY = 4, - VT_VALUE = 6 - }; - const flatbuffers::String *key() const { - return GetPointer<const flatbuffers::String *>(VT_KEY); - } - const flatbuffers::String *value() const { - return GetPointer<const flatbuffers::String *>(VT_VALUE); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_KEY) && - verifier.VerifyString(key()) && - VerifyOffset(verifier, VT_VALUE) && - verifier.VerifyString(value()) && - verifier.EndTable(); - } -}; - -struct KeyValueBuilder { - typedef KeyValue Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_key(flatbuffers::Offset<flatbuffers::String> key) { - fbb_.AddOffset(KeyValue::VT_KEY, key); - } - void add_value(flatbuffers::Offset<flatbuffers::String> value) { - fbb_.AddOffset(KeyValue::VT_VALUE, value); - } - explicit KeyValueBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - KeyValueBuilder &operator=(const KeyValueBuilder &); - flatbuffers::Offset<KeyValue> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<KeyValue>(end); - return o; - } -}; - -inline flatbuffers::Offset<KeyValue> CreateKeyValue( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> key = 0, - flatbuffers::Offset<flatbuffers::String> value = 0) { - KeyValueBuilder builder_(_fbb); - builder_.add_value(value); - builder_.add_key(key); - return builder_.Finish(); -} - -inline flatbuffers::Offset<KeyValue> CreateKeyValueDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *key = nullptr, - const char *value = nullptr) { - auto key__ = key ? _fbb.CreateString(key) : 0; - auto value__ = value ? _fbb.CreateString(value) : 0; - return org::apache::arrow::flatbuf::CreateKeyValue( - _fbb, - key__, - value__); -} - -struct DictionaryEncoding FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef DictionaryEncodingBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ID = 4, - VT_INDEXTYPE = 6, - VT_ISORDERED = 8, - VT_DICTIONARYKIND = 10 - }; - /// The known dictionary id in the application where this data is used. In - /// the file or streaming formats, the dictionary ids are found in the - /// DictionaryBatch messages - int64_t id() const { - return GetField<int64_t>(VT_ID, 0); - } - /// The dictionary indices are constrained to be non-negative integers. If - /// this field is null, the indices must be signed int32. To maximize - /// cross-language compatibility and performance, implementations are - /// recommended to prefer signed integer types over unsigned integer types - /// and to avoid uint64 indices unless they are required by an application. - const org::apache::arrow::flatbuf::Int *indexType() const { - return GetPointer<const org::apache::arrow::flatbuf::Int *>(VT_INDEXTYPE); - } - /// By default, dictionaries are not ordered, or the order does not have - /// semantic meaning. In some statistical, applications, dictionary-encoding - /// is used to represent ordered categorical data, and we provide a way to - /// preserve that metadata here - bool isOrdered() const { - return GetField<uint8_t>(VT_ISORDERED, 0) != 0; - } - org::apache::arrow::flatbuf::DictionaryKind dictionaryKind() const { - return static_cast<org::apache::arrow::flatbuf::DictionaryKind>(GetField<int16_t>(VT_DICTIONARYKIND, 0)); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int64_t>(verifier, VT_ID) && - VerifyOffset(verifier, VT_INDEXTYPE) && - verifier.VerifyTable(indexType()) && - VerifyField<uint8_t>(verifier, VT_ISORDERED) && - VerifyField<int16_t>(verifier, VT_DICTIONARYKIND) && - verifier.EndTable(); - } -}; - -struct DictionaryEncodingBuilder { - typedef DictionaryEncoding Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_id(int64_t id) { - fbb_.AddElement<int64_t>(DictionaryEncoding::VT_ID, id, 0); - } - void add_indexType(flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indexType) { - fbb_.AddOffset(DictionaryEncoding::VT_INDEXTYPE, indexType); - } - void add_isOrdered(bool isOrdered) { - fbb_.AddElement<uint8_t>(DictionaryEncoding::VT_ISORDERED, static_cast<uint8_t>(isOrdered), 0); - } - void add_dictionaryKind(org::apache::arrow::flatbuf::DictionaryKind dictionaryKind) { - fbb_.AddElement<int16_t>(DictionaryEncoding::VT_DICTIONARYKIND, static_cast<int16_t>(dictionaryKind), 0); - } - explicit DictionaryEncodingBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - DictionaryEncodingBuilder &operator=(const DictionaryEncodingBuilder &); - flatbuffers::Offset<DictionaryEncoding> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<DictionaryEncoding>(end); - return o; - } -}; - -inline flatbuffers::Offset<DictionaryEncoding> CreateDictionaryEncoding( - flatbuffers::FlatBufferBuilder &_fbb, - int64_t id = 0, - flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indexType = 0, - bool isOrdered = false, - org::apache::arrow::flatbuf::DictionaryKind dictionaryKind = org::apache::arrow::flatbuf::DictionaryKind::DenseArray) { - DictionaryEncodingBuilder builder_(_fbb); - builder_.add_id(id); - builder_.add_indexType(indexType); - builder_.add_dictionaryKind(dictionaryKind); - builder_.add_isOrdered(isOrdered); - return builder_.Finish(); -} - -/// ---------------------------------------------------------------------- -/// A field represents a named column in a record / row batch or child of a -/// nested type. -struct Field FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef FieldBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_NAME = 4, - VT_NULLABLE = 6, - VT_TYPE_TYPE = 8, - VT_TYPE = 10, - VT_DICTIONARY = 12, - VT_CHILDREN = 14, - VT_CUSTOM_METADATA = 16 - }; - /// Name is not required, in i.e. a List - const flatbuffers::String *name() const { - return GetPointer<const flatbuffers::String *>(VT_NAME); - } - /// Whether or not this field can contain nulls. Should be true in general. - bool nullable() const { - return GetField<uint8_t>(VT_NULLABLE, 0) != 0; - } - org::apache::arrow::flatbuf::Type type_type() const { - return static_cast<org::apache::arrow::flatbuf::Type>(GetField<uint8_t>(VT_TYPE_TYPE, 0)); - } - /// This is the type of the decoded value if the field is dictionary encoded. - const void *type() const { - return GetPointer<const void *>(VT_TYPE); - } - template<typename T> const T *type_as() const; - const org::apache::arrow::flatbuf::Null *type_as_Null() const { - return type_type() == org::apache::arrow::flatbuf::Type::Null ? static_cast<const org::apache::arrow::flatbuf::Null *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Int *type_as_Int() const { - return type_type() == org::apache::arrow::flatbuf::Type::Int ? static_cast<const org::apache::arrow::flatbuf::Int *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::FloatingPoint *type_as_FloatingPoint() const { - return type_type() == org::apache::arrow::flatbuf::Type::FloatingPoint ? static_cast<const org::apache::arrow::flatbuf::FloatingPoint *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Binary *type_as_Binary() const { - return type_type() == org::apache::arrow::flatbuf::Type::Binary ? static_cast<const org::apache::arrow::flatbuf::Binary *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Utf8 *type_as_Utf8() const { - return type_type() == org::apache::arrow::flatbuf::Type::Utf8 ? static_cast<const org::apache::arrow::flatbuf::Utf8 *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Bool *type_as_Bool() const { - return type_type() == org::apache::arrow::flatbuf::Type::Bool ? static_cast<const org::apache::arrow::flatbuf::Bool *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Decimal *type_as_Decimal() const { - return type_type() == org::apache::arrow::flatbuf::Type::Decimal ? static_cast<const org::apache::arrow::flatbuf::Decimal *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Date *type_as_Date() const { - return type_type() == org::apache::arrow::flatbuf::Type::Date ? static_cast<const org::apache::arrow::flatbuf::Date *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Time *type_as_Time() const { - return type_type() == org::apache::arrow::flatbuf::Type::Time ? static_cast<const org::apache::arrow::flatbuf::Time *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Timestamp *type_as_Timestamp() const { - return type_type() == org::apache::arrow::flatbuf::Type::Timestamp ? static_cast<const org::apache::arrow::flatbuf::Timestamp *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Interval *type_as_Interval() const { - return type_type() == org::apache::arrow::flatbuf::Type::Interval ? static_cast<const org::apache::arrow::flatbuf::Interval *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::List *type_as_List() const { - return type_type() == org::apache::arrow::flatbuf::Type::List ? static_cast<const org::apache::arrow::flatbuf::List *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Struct_ *type_as_Struct_() const { - return type_type() == org::apache::arrow::flatbuf::Type::Struct_ ? static_cast<const org::apache::arrow::flatbuf::Struct_ *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Union *type_as_Union() const { - return type_type() == org::apache::arrow::flatbuf::Type::Union ? static_cast<const org::apache::arrow::flatbuf::Union *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::FixedSizeBinary *type_as_FixedSizeBinary() const { - return type_type() == org::apache::arrow::flatbuf::Type::FixedSizeBinary ? static_cast<const org::apache::arrow::flatbuf::FixedSizeBinary *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::FixedSizeList *type_as_FixedSizeList() const { - return type_type() == org::apache::arrow::flatbuf::Type::FixedSizeList ? static_cast<const org::apache::arrow::flatbuf::FixedSizeList *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Map *type_as_Map() const { - return type_type() == org::apache::arrow::flatbuf::Type::Map ? static_cast<const org::apache::arrow::flatbuf::Map *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Duration *type_as_Duration() const { - return type_type() == org::apache::arrow::flatbuf::Type::Duration ? static_cast<const org::apache::arrow::flatbuf::Duration *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::LargeBinary *type_as_LargeBinary() const { - return type_type() == org::apache::arrow::flatbuf::Type::LargeBinary ? static_cast<const org::apache::arrow::flatbuf::LargeBinary *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::LargeUtf8 *type_as_LargeUtf8() const { - return type_type() == org::apache::arrow::flatbuf::Type::LargeUtf8 ? static_cast<const org::apache::arrow::flatbuf::LargeUtf8 *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::LargeList *type_as_LargeList() const { - return type_type() == org::apache::arrow::flatbuf::Type::LargeList ? static_cast<const org::apache::arrow::flatbuf::LargeList *>(type()) : nullptr; - } - /// Present only if the field is dictionary encoded. - const org::apache::arrow::flatbuf::DictionaryEncoding *dictionary() const { - return GetPointer<const org::apache::arrow::flatbuf::DictionaryEncoding *>(VT_DICTIONARY); - } - /// children apply only to nested data types like Struct, List and Union. For - /// primitive types children will have length 0. - const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::Field>> *children() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::Field>> *>(VT_CHILDREN); - } - /// User-defined metadata - const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>> *custom_metadata() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>> *>(VT_CUSTOM_METADATA); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_NAME) && - verifier.VerifyString(name()) && - VerifyField<uint8_t>(verifier, VT_NULLABLE) && - VerifyField<uint8_t>(verifier, VT_TYPE_TYPE) && - VerifyOffset(verifier, VT_TYPE) && - VerifyType(verifier, type(), type_type()) && - VerifyOffset(verifier, VT_DICTIONARY) && - verifier.VerifyTable(dictionary()) && - VerifyOffset(verifier, VT_CHILDREN) && - verifier.VerifyVector(children()) && - verifier.VerifyVectorOfTables(children()) && - VerifyOffset(verifier, VT_CUSTOM_METADATA) && - verifier.VerifyVector(custom_metadata()) && - verifier.VerifyVectorOfTables(custom_metadata()) && - verifier.EndTable(); - } -}; - -template<> inline const org::apache::arrow::flatbuf::Null *Field::type_as<org::apache::arrow::flatbuf::Null>() const { - return type_as_Null(); -} - -template<> inline const org::apache::arrow::flatbuf::Int *Field::type_as<org::apache::arrow::flatbuf::Int>() const { - return type_as_Int(); -} - -template<> inline const org::apache::arrow::flatbuf::FloatingPoint *Field::type_as<org::apache::arrow::flatbuf::FloatingPoint>() const { - return type_as_FloatingPoint(); -} - -template<> inline const org::apache::arrow::flatbuf::Binary *Field::type_as<org::apache::arrow::flatbuf::Binary>() const { - return type_as_Binary(); -} - -template<> inline const org::apache::arrow::flatbuf::Utf8 *Field::type_as<org::apache::arrow::flatbuf::Utf8>() const { - return type_as_Utf8(); -} - -template<> inline const org::apache::arrow::flatbuf::Bool *Field::type_as<org::apache::arrow::flatbuf::Bool>() const { - return type_as_Bool(); -} - -template<> inline const org::apache::arrow::flatbuf::Decimal *Field::type_as<org::apache::arrow::flatbuf::Decimal>() const { - return type_as_Decimal(); -} - -template<> inline const org::apache::arrow::flatbuf::Date *Field::type_as<org::apache::arrow::flatbuf::Date>() const { - return type_as_Date(); -} - -template<> inline const org::apache::arrow::flatbuf::Time *Field::type_as<org::apache::arrow::flatbuf::Time>() const { - return type_as_Time(); -} - -template<> inline const org::apache::arrow::flatbuf::Timestamp *Field::type_as<org::apache::arrow::flatbuf::Timestamp>() const { - return type_as_Timestamp(); -} - -template<> inline const org::apache::arrow::flatbuf::Interval *Field::type_as<org::apache::arrow::flatbuf::Interval>() const { - return type_as_Interval(); -} - -template<> inline const org::apache::arrow::flatbuf::List *Field::type_as<org::apache::arrow::flatbuf::List>() const { - return type_as_List(); -} - -template<> inline const org::apache::arrow::flatbuf::Struct_ *Field::type_as<org::apache::arrow::flatbuf::Struct_>() const { - return type_as_Struct_(); -} - -template<> inline const org::apache::arrow::flatbuf::Union *Field::type_as<org::apache::arrow::flatbuf::Union>() const { - return type_as_Union(); -} - -template<> inline const org::apache::arrow::flatbuf::FixedSizeBinary *Field::type_as<org::apache::arrow::flatbuf::FixedSizeBinary>() const { - return type_as_FixedSizeBinary(); -} - -template<> inline const org::apache::arrow::flatbuf::FixedSizeList *Field::type_as<org::apache::arrow::flatbuf::FixedSizeList>() const { - return type_as_FixedSizeList(); -} - -template<> inline const org::apache::arrow::flatbuf::Map *Field::type_as<org::apache::arrow::flatbuf::Map>() const { - return type_as_Map(); -} - -template<> inline const org::apache::arrow::flatbuf::Duration *Field::type_as<org::apache::arrow::flatbuf::Duration>() const { - return type_as_Duration(); -} - -template<> inline const org::apache::arrow::flatbuf::LargeBinary *Field::type_as<org::apache::arrow::flatbuf::LargeBinary>() const { - return type_as_LargeBinary(); -} - -template<> inline const org::apache::arrow::flatbuf::LargeUtf8 *Field::type_as<org::apache::arrow::flatbuf::LargeUtf8>() const { - return type_as_LargeUtf8(); -} - -template<> inline const org::apache::arrow::flatbuf::LargeList *Field::type_as<org::apache::arrow::flatbuf::LargeList>() const { - return type_as_LargeList(); -} - -struct FieldBuilder { - typedef Field Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset<flatbuffers::String> name) { - fbb_.AddOffset(Field::VT_NAME, name); - } - void add_nullable(bool nullable) { - fbb_.AddElement<uint8_t>(Field::VT_NULLABLE, static_cast<uint8_t>(nullable), 0); - } - void add_type_type(org::apache::arrow::flatbuf::Type type_type) { - fbb_.AddElement<uint8_t>(Field::VT_TYPE_TYPE, static_cast<uint8_t>(type_type), 0); - } - void add_type(flatbuffers::Offset<void> type) { - fbb_.AddOffset(Field::VT_TYPE, type); - } - void add_dictionary(flatbuffers::Offset<org::apache::arrow::flatbuf::DictionaryEncoding> dictionary) { - fbb_.AddOffset(Field::VT_DICTIONARY, dictionary); - } - void add_children(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::Field>>> children) { - fbb_.AddOffset(Field::VT_CHILDREN, children); - } - void add_custom_metadata(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>>> custom_metadata) { - fbb_.AddOffset(Field::VT_CUSTOM_METADATA, custom_metadata); - } - explicit FieldBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - FieldBuilder &operator=(const FieldBuilder &); - flatbuffers::Offset<Field> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Field>(end); - return o; - } -}; - -inline flatbuffers::Offset<Field> CreateField( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> name = 0, - bool nullable = false, - org::apache::arrow::flatbuf::Type type_type = org::apache::arrow::flatbuf::Type::NONE, - flatbuffers::Offset<void> type = 0, - flatbuffers::Offset<org::apache::arrow::flatbuf::DictionaryEncoding> dictionary = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::Field>>> children = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>>> custom_metadata = 0) { - FieldBuilder builder_(_fbb); - builder_.add_custom_metadata(custom_metadata); - builder_.add_children(children); - builder_.add_dictionary(dictionary); - builder_.add_type(type); - builder_.add_name(name); - builder_.add_type_type(type_type); - builder_.add_nullable(nullable); - return builder_.Finish(); -} - -inline flatbuffers::Offset<Field> CreateFieldDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *name = nullptr, - bool nullable = false, - org::apache::arrow::flatbuf::Type type_type = org::apache::arrow::flatbuf::Type::NONE, - flatbuffers::Offset<void> type = 0, - flatbuffers::Offset<org::apache::arrow::flatbuf::DictionaryEncoding> dictionary = 0, - const std::vector<flatbuffers::Offset<org::apache::arrow::flatbuf::Field>> *children = nullptr, - const std::vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>> *custom_metadata = nullptr) { - auto name__ = name ? _fbb.CreateString(name) : 0; - auto children__ = children ? _fbb.CreateVector<flatbuffers::Offset<org::apache::arrow::flatbuf::Field>>(*children) : 0; - auto custom_metadata__ = custom_metadata ? _fbb.CreateVector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>>(*custom_metadata) : 0; - return org::apache::arrow::flatbuf::CreateField( - _fbb, - name__, - nullable, - type_type, - type, - dictionary, - children__, - custom_metadata__); -} - -/// ---------------------------------------------------------------------- -/// A Schema describes the columns in a row batch -struct Schema FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef SchemaBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ENDIANNESS = 4, - VT_FIELDS = 6, - VT_CUSTOM_METADATA = 8, - VT_FEATURES = 10 - }; - /// endianness of the buffer - /// it is Little Endian by default - /// if endianness doesn't match the underlying system then the vectors need to be converted - org::apache::arrow::flatbuf::Endianness endianness() const { - return static_cast<org::apache::arrow::flatbuf::Endianness>(GetField<int16_t>(VT_ENDIANNESS, 0)); - } - const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::Field>> *fields() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::Field>> *>(VT_FIELDS); - } - const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>> *custom_metadata() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>> *>(VT_CUSTOM_METADATA); - } - /// Features used in the stream/file. - const flatbuffers::Vector<int64_t> *features() const { - return GetPointer<const flatbuffers::Vector<int64_t> *>(VT_FEATURES); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int16_t>(verifier, VT_ENDIANNESS) && - VerifyOffset(verifier, VT_FIELDS) && - verifier.VerifyVector(fields()) && - verifier.VerifyVectorOfTables(fields()) && - VerifyOffset(verifier, VT_CUSTOM_METADATA) && - verifier.VerifyVector(custom_metadata()) && - verifier.VerifyVectorOfTables(custom_metadata()) && - VerifyOffset(verifier, VT_FEATURES) && - verifier.VerifyVector(features()) && - verifier.EndTable(); - } -}; - -struct SchemaBuilder { - typedef Schema Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_endianness(org::apache::arrow::flatbuf::Endianness endianness) { - fbb_.AddElement<int16_t>(Schema::VT_ENDIANNESS, static_cast<int16_t>(endianness), 0); - } - void add_fields(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::Field>>> fields) { - fbb_.AddOffset(Schema::VT_FIELDS, fields); - } - void add_custom_metadata(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>>> custom_metadata) { - fbb_.AddOffset(Schema::VT_CUSTOM_METADATA, custom_metadata); - } - void add_features(flatbuffers::Offset<flatbuffers::Vector<int64_t>> features) { - fbb_.AddOffset(Schema::VT_FEATURES, features); - } - explicit SchemaBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - SchemaBuilder &operator=(const SchemaBuilder &); - flatbuffers::Offset<Schema> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Schema>(end); - return o; - } -}; - -inline flatbuffers::Offset<Schema> CreateSchema( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::Endianness endianness = org::apache::arrow::flatbuf::Endianness::Little, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::Field>>> fields = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>>> custom_metadata = 0, - flatbuffers::Offset<flatbuffers::Vector<int64_t>> features = 0) { - SchemaBuilder builder_(_fbb); - builder_.add_features(features); - builder_.add_custom_metadata(custom_metadata); - builder_.add_fields(fields); - builder_.add_endianness(endianness); - return builder_.Finish(); -} - -inline flatbuffers::Offset<Schema> CreateSchemaDirect( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::Endianness endianness = org::apache::arrow::flatbuf::Endianness::Little, - const std::vector<flatbuffers::Offset<org::apache::arrow::flatbuf::Field>> *fields = nullptr, - const std::vector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>> *custom_metadata = nullptr, - const std::vector<int64_t> *features = nullptr) { - auto fields__ = fields ? _fbb.CreateVector<flatbuffers::Offset<org::apache::arrow::flatbuf::Field>>(*fields) : 0; - auto custom_metadata__ = custom_metadata ? _fbb.CreateVector<flatbuffers::Offset<org::apache::arrow::flatbuf::KeyValue>>(*custom_metadata) : 0; - auto features__ = features ? _fbb.CreateVector<int64_t>(*features) : 0; - return org::apache::arrow::flatbuf::CreateSchema( - _fbb, - endianness, - fields__, - custom_metadata__, - features__); -} - -inline bool VerifyType(flatbuffers::Verifier &verifier, const void *obj, Type type) { - switch (type) { - case Type::NONE: { - return true; - } - case Type::Null: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Null *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::Int: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Int *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::FloatingPoint: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::FloatingPoint *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::Binary: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Binary *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::Utf8: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Utf8 *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::Bool: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Bool *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::Decimal: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Decimal *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::Date: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Date *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::Time: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Time *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::Timestamp: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Timestamp *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::Interval: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Interval *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::List: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::List *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::Struct_: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Struct_ *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::Union: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Union *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::FixedSizeBinary: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::FixedSizeBinary *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::FixedSizeList: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::FixedSizeList *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::Map: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Map *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::Duration: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::Duration *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::LargeBinary: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::LargeBinary *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::LargeUtf8: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::LargeUtf8 *>(obj); - return verifier.VerifyTable(ptr); - } - case Type::LargeList: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::LargeList *>(obj); - return verifier.VerifyTable(ptr); - } - default: return true; - } -} - -inline bool VerifyTypeVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *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 (!VerifyType( - verifier, values->Get(i), types->GetEnum<Type>(i))) { - return false; - } - } - return true; -} - -inline const org::apache::arrow::flatbuf::Schema *GetSchema(const void *buf) { - return flatbuffers::GetRoot<org::apache::arrow::flatbuf::Schema>(buf); -} - -inline const org::apache::arrow::flatbuf::Schema *GetSizePrefixedSchema(const void *buf) { - return flatbuffers::GetSizePrefixedRoot<org::apache::arrow::flatbuf::Schema>(buf); -} - -inline bool VerifySchemaBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer<org::apache::arrow::flatbuf::Schema>(nullptr); -} - -inline bool VerifySizePrefixedSchemaBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifySizePrefixedBuffer<org::apache::arrow::flatbuf::Schema>(nullptr); -} - -inline void FinishSchemaBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<org::apache::arrow::flatbuf::Schema> root) { - fbb.Finish(root); -} - -inline void FinishSizePrefixedSchemaBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<org::apache::arrow::flatbuf::Schema> root) { - fbb.FinishSizePrefixed(root); -} - -} // namespace flatbuf -} // namespace arrow -} // namespace apache -} // namespace org - -#endif // FLATBUFFERS_GENERATED_SCHEMA_ORG_APACHE_ARROW_FLATBUF_H_ diff --git a/contrib/libs/apache/arrow/cpp/src/generated/SparseTensor.fbs b/contrib/libs/apache/arrow/cpp/src/generated/SparseTensor.fbs new file mode 100644 index 0000000000..a6fd2f9e74 --- /dev/null +++ b/contrib/libs/apache/arrow/cpp/src/generated/SparseTensor.fbs @@ -0,0 +1,228 @@ +// 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. + +/// EXPERIMENTAL: Metadata for n-dimensional sparse arrays, aka "sparse tensors". +/// Arrow implementations in general are not required to implement this type + +include "Tensor.fbs"; + +namespace org.apache.arrow.flatbuf; + +/// ---------------------------------------------------------------------- +/// EXPERIMENTAL: Data structures for sparse tensors + +/// Coordinate (COO) format of sparse tensor index. +/// +/// COO's index list are represented as a NxM matrix, +/// where N is the number of non-zero values, +/// and M is the number of dimensions of a sparse tensor. +/// +/// indicesBuffer stores the location and size of the data of this indices +/// matrix. The value type and the stride of the indices matrix is +/// specified in indicesType and indicesStrides fields. +/// +/// For example, let X be a 2x3x4x5 tensor, and it has the following +/// 6 non-zero values: +/// ```text +/// X[0, 1, 2, 0] := 1 +/// X[1, 1, 2, 3] := 2 +/// X[0, 2, 1, 0] := 3 +/// X[0, 1, 3, 0] := 4 +/// X[0, 1, 2, 1] := 5 +/// X[1, 2, 0, 4] := 6 +/// ``` +/// In COO format, the index matrix of X is the following 4x6 matrix: +/// ```text +/// [[0, 0, 0, 0, 1, 1], +/// [1, 1, 1, 2, 1, 2], +/// [2, 2, 3, 1, 2, 0], +/// [0, 1, 0, 0, 3, 4]] +/// ``` +/// When isCanonical is true, the indices is sorted in lexicographical order +/// (row-major order), and it does not have duplicated entries. Otherwise, +/// the indices may not be sorted, or may have duplicated entries. +table SparseTensorIndexCOO { + /// The type of values in indicesBuffer + indicesType: Int (required); + + /// Non-negative byte offsets to advance one value cell along each dimension + /// If omitted, default to row-major order (C-like). + indicesStrides: [long]; + + /// The location and size of the indices matrix's data + indicesBuffer: Buffer (required); + + /// This flag is true if and only if the indices matrix is sorted in + /// row-major order, and does not have duplicated entries. + /// This sort order is the same as of Tensorflow's SparseTensor, + /// but it is inverse order of SciPy's canonical coo_matrix + /// (SciPy employs column-major order for its coo_matrix). + isCanonical: bool; +} + +enum SparseMatrixCompressedAxis: short { Row, Column } + +/// Compressed Sparse format, that is matrix-specific. +table SparseMatrixIndexCSX { + /// Which axis, row or column, is compressed + compressedAxis: SparseMatrixCompressedAxis; + + /// The type of values in indptrBuffer + indptrType: Int (required); + + /// indptrBuffer stores the location and size of indptr array that + /// represents the range of the rows. + /// The i-th row spans from `indptr[i]` to `indptr[i+1]` in the data. + /// The length of this array is 1 + (the number of rows), and the type + /// of index value is long. + /// + /// For example, let X be the following 6x4 matrix: + /// ```text + /// X := [[0, 1, 2, 0], + /// [0, 0, 3, 0], + /// [0, 4, 0, 5], + /// [0, 0, 0, 0], + /// [6, 0, 7, 8], + /// [0, 9, 0, 0]]. + /// ``` + /// The array of non-zero values in X is: + /// ```text + /// values(X) = [1, 2, 3, 4, 5, 6, 7, 8, 9]. + /// ``` + /// And the indptr of X is: + /// ```text + /// indptr(X) = [0, 2, 3, 5, 5, 8, 10]. + /// ``` + indptrBuffer: Buffer (required); + + /// The type of values in indicesBuffer + indicesType: Int (required); + + /// indicesBuffer stores the location and size of the array that + /// contains the column indices of the corresponding non-zero values. + /// The type of index value is long. + /// + /// For example, the indices of the above X is: + /// ```text + /// indices(X) = [1, 2, 2, 1, 3, 0, 2, 3, 1]. + /// ``` + /// Note that the indices are sorted in lexicographical order for each row. + indicesBuffer: Buffer (required); +} + +/// Compressed Sparse Fiber (CSF) sparse tensor index. +table SparseTensorIndexCSF { + /// CSF is a generalization of compressed sparse row (CSR) index. + /// See [smith2017knl](http://shaden.io/pub-files/smith2017knl.pdf) + /// + /// CSF index recursively compresses each dimension of a tensor into a set + /// of prefix trees. Each path from a root to leaf forms one tensor + /// non-zero index. CSF is implemented with two arrays of buffers and one + /// arrays of integers. + /// + /// For example, let X be a 2x3x4x5 tensor and let it have the following + /// 8 non-zero values: + /// ```text + /// X[0, 0, 0, 1] := 1 + /// X[0, 0, 0, 2] := 2 + /// X[0, 1, 0, 0] := 3 + /// X[0, 1, 0, 2] := 4 + /// X[0, 1, 1, 0] := 5 + /// X[1, 1, 1, 0] := 6 + /// X[1, 1, 1, 1] := 7 + /// X[1, 1, 1, 2] := 8 + /// ``` + /// As a prefix tree this would be represented as: + /// ```text + /// 0 1 + /// / \ | + /// 0 1 1 + /// / / \ | + /// 0 0 1 1 + /// /| /| | /| | + /// 1 2 0 2 0 0 1 2 + /// ``` + /// The type of values in indptrBuffers + indptrType: Int (required); + + /// indptrBuffers stores the sparsity structure. + /// Each two consecutive dimensions in a tensor correspond to a buffer in + /// indptrBuffers. A pair of consecutive values at `indptrBuffers[dim][i]` + /// and `indptrBuffers[dim][i + 1]` signify a range of nodes in + /// `indicesBuffers[dim + 1]` who are children of `indicesBuffers[dim][i]` node. + /// + /// For example, the indptrBuffers for the above X is: + /// ```text + /// indptrBuffer(X) = [ + /// [0, 2, 3], + /// [0, 1, 3, 4], + /// [0, 2, 4, 5, 8] + /// ]. + /// ``` + indptrBuffers: [Buffer] (required); + + /// The type of values in indicesBuffers + indicesType: Int (required); + + /// indicesBuffers stores values of nodes. + /// Each tensor dimension corresponds to a buffer in indicesBuffers. + /// For example, the indicesBuffers for the above X is: + /// ```text + /// indicesBuffer(X) = [ + /// [0, 1], + /// [0, 1, 1], + /// [0, 0, 1, 1], + /// [1, 2, 0, 2, 0, 0, 1, 2] + /// ]. + /// ``` + indicesBuffers: [Buffer] (required); + + /// axisOrder stores the sequence in which dimensions were traversed to + /// produce the prefix tree. + /// For example, the axisOrder for the above X is: + /// ```text + /// axisOrder(X) = [0, 1, 2, 3]. + /// ``` + axisOrder: [int] (required); +} + +union SparseTensorIndex { + SparseTensorIndexCOO, + SparseMatrixIndexCSX, + SparseTensorIndexCSF +} + +table SparseTensor { + /// The type of data contained in a value cell. + /// Currently only fixed-width value types are supported, + /// no strings or nested types. + type: Type (required); + + /// The dimensions of the tensor, optionally named. + shape: [TensorDim] (required); + + /// The number of non-zero values in a sparse tensor. + non_zero_length: long; + + /// Sparse tensor index + sparseIndex: SparseTensorIndex (required); + + /// The location and size of the tensor's data + data: Buffer (required); +} + +root_type SparseTensor; diff --git a/contrib/libs/apache/arrow/cpp/src/generated/SparseTensor_generated.h b/contrib/libs/apache/arrow/cpp/src/generated/SparseTensor_generated.h deleted file mode 100644 index ec4d414d4f..0000000000 --- a/contrib/libs/apache/arrow/cpp/src/generated/SparseTensor_generated.h +++ /dev/null @@ -1,913 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_SPARSETENSOR_ORG_APACHE_ARROW_FLATBUF_H_ -#define FLATBUFFERS_GENERATED_SPARSETENSOR_ORG_APACHE_ARROW_FLATBUF_H_ - -#include "flatbuffers/flatbuffers.h" - -#include "Schema_generated.h" -#include "Tensor_generated.h" - -namespace org { -namespace apache { -namespace arrow { -namespace flatbuf { - -struct SparseTensorIndexCOO; -struct SparseTensorIndexCOOBuilder; - -struct SparseMatrixIndexCSX; -struct SparseMatrixIndexCSXBuilder; - -struct SparseTensorIndexCSF; -struct SparseTensorIndexCSFBuilder; - -struct SparseTensor; -struct SparseTensorBuilder; - -enum class SparseMatrixCompressedAxis : int16_t { - Row = 0, - Column = 1, - MIN = Row, - MAX = Column -}; - -inline const SparseMatrixCompressedAxis (&EnumValuesSparseMatrixCompressedAxis())[2] { - static const SparseMatrixCompressedAxis values[] = { - SparseMatrixCompressedAxis::Row, - SparseMatrixCompressedAxis::Column - }; - return values; -} - -inline const char * const *EnumNamesSparseMatrixCompressedAxis() { - static const char * const names[3] = { - "Row", - "Column", - nullptr - }; - return names; -} - -inline const char *EnumNameSparseMatrixCompressedAxis(SparseMatrixCompressedAxis e) { - if (flatbuffers::IsOutRange(e, SparseMatrixCompressedAxis::Row, SparseMatrixCompressedAxis::Column)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesSparseMatrixCompressedAxis()[index]; -} - -enum class SparseTensorIndex : uint8_t { - NONE = 0, - SparseTensorIndexCOO = 1, - SparseMatrixIndexCSX = 2, - SparseTensorIndexCSF = 3, - MIN = NONE, - MAX = SparseTensorIndexCSF -}; - -inline const SparseTensorIndex (&EnumValuesSparseTensorIndex())[4] { - static const SparseTensorIndex values[] = { - SparseTensorIndex::NONE, - SparseTensorIndex::SparseTensorIndexCOO, - SparseTensorIndex::SparseMatrixIndexCSX, - SparseTensorIndex::SparseTensorIndexCSF - }; - return values; -} - -inline const char * const *EnumNamesSparseTensorIndex() { - static const char * const names[5] = { - "NONE", - "SparseTensorIndexCOO", - "SparseMatrixIndexCSX", - "SparseTensorIndexCSF", - nullptr - }; - return names; -} - -inline const char *EnumNameSparseTensorIndex(SparseTensorIndex e) { - if (flatbuffers::IsOutRange(e, SparseTensorIndex::NONE, SparseTensorIndex::SparseTensorIndexCSF)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesSparseTensorIndex()[index]; -} - -template<typename T> struct SparseTensorIndexTraits { - static const SparseTensorIndex enum_value = SparseTensorIndex::NONE; -}; - -template<> struct SparseTensorIndexTraits<org::apache::arrow::flatbuf::SparseTensorIndexCOO> { - static const SparseTensorIndex enum_value = SparseTensorIndex::SparseTensorIndexCOO; -}; - -template<> struct SparseTensorIndexTraits<org::apache::arrow::flatbuf::SparseMatrixIndexCSX> { - static const SparseTensorIndex enum_value = SparseTensorIndex::SparseMatrixIndexCSX; -}; - -template<> struct SparseTensorIndexTraits<org::apache::arrow::flatbuf::SparseTensorIndexCSF> { - static const SparseTensorIndex enum_value = SparseTensorIndex::SparseTensorIndexCSF; -}; - -bool VerifySparseTensorIndex(flatbuffers::Verifier &verifier, const void *obj, SparseTensorIndex type); -bool VerifySparseTensorIndexVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types); - -/// ---------------------------------------------------------------------- -/// EXPERIMENTAL: Data structures for sparse tensors -/// Coordinate (COO) format of sparse tensor index. -/// -/// COO's index list are represented as a NxM matrix, -/// where N is the number of non-zero values, -/// and M is the number of dimensions of a sparse tensor. -/// -/// indicesBuffer stores the location and size of the data of this indices -/// matrix. The value type and the stride of the indices matrix is -/// specified in indicesType and indicesStrides fields. -/// -/// For example, let X be a 2x3x4x5 tensor, and it has the following -/// 6 non-zero values: -/// -/// X[0, 1, 2, 0] := 1 -/// X[1, 1, 2, 3] := 2 -/// X[0, 2, 1, 0] := 3 -/// X[0, 1, 3, 0] := 4 -/// X[0, 1, 2, 1] := 5 -/// X[1, 2, 0, 4] := 6 -/// -/// In COO format, the index matrix of X is the following 4x6 matrix: -/// -/// [[0, 0, 0, 0, 1, 1], -/// [1, 1, 1, 2, 1, 2], -/// [2, 2, 3, 1, 2, 0], -/// [0, 1, 0, 0, 3, 4]] -/// -/// Note that the indices are sorted in lexicographical order. -struct SparseTensorIndexCOO FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef SparseTensorIndexCOOBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_INDICESTYPE = 4, - VT_INDICESSTRIDES = 6, - VT_INDICESBUFFER = 8, - VT_ISCANONICAL = 10 - }; - /// The type of values in indicesBuffer - const org::apache::arrow::flatbuf::Int *indicesType() const { - return GetPointer<const org::apache::arrow::flatbuf::Int *>(VT_INDICESTYPE); - } - /// Non-negative byte offsets to advance one value cell along each dimension - /// If omitted, default to row-major order (C-like). - const flatbuffers::Vector<int64_t> *indicesStrides() const { - return GetPointer<const flatbuffers::Vector<int64_t> *>(VT_INDICESSTRIDES); - } - /// The location and size of the indices matrix's data - const org::apache::arrow::flatbuf::Buffer *indicesBuffer() const { - return GetStruct<const org::apache::arrow::flatbuf::Buffer *>(VT_INDICESBUFFER); - } - /// The canonicality flag - bool isCanonical() const { - return GetField<uint8_t>(VT_ISCANONICAL, 0) != 0; - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_INDICESTYPE) && - verifier.VerifyTable(indicesType()) && - VerifyOffset(verifier, VT_INDICESSTRIDES) && - verifier.VerifyVector(indicesStrides()) && - VerifyFieldRequired<org::apache::arrow::flatbuf::Buffer>(verifier, VT_INDICESBUFFER) && - VerifyField<uint8_t>(verifier, VT_ISCANONICAL) && - verifier.EndTable(); - } -}; - -struct SparseTensorIndexCOOBuilder { - typedef SparseTensorIndexCOO Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_indicesType(flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indicesType) { - fbb_.AddOffset(SparseTensorIndexCOO::VT_INDICESTYPE, indicesType); - } - void add_indicesStrides(flatbuffers::Offset<flatbuffers::Vector<int64_t>> indicesStrides) { - fbb_.AddOffset(SparseTensorIndexCOO::VT_INDICESSTRIDES, indicesStrides); - } - void add_indicesBuffer(const org::apache::arrow::flatbuf::Buffer *indicesBuffer) { - fbb_.AddStruct(SparseTensorIndexCOO::VT_INDICESBUFFER, indicesBuffer); - } - void add_isCanonical(bool isCanonical) { - fbb_.AddElement<uint8_t>(SparseTensorIndexCOO::VT_ISCANONICAL, static_cast<uint8_t>(isCanonical), 0); - } - explicit SparseTensorIndexCOOBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - SparseTensorIndexCOOBuilder &operator=(const SparseTensorIndexCOOBuilder &); - flatbuffers::Offset<SparseTensorIndexCOO> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<SparseTensorIndexCOO>(end); - fbb_.Required(o, SparseTensorIndexCOO::VT_INDICESTYPE); - fbb_.Required(o, SparseTensorIndexCOO::VT_INDICESBUFFER); - return o; - } -}; - -inline flatbuffers::Offset<SparseTensorIndexCOO> CreateSparseTensorIndexCOO( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indicesType = 0, - flatbuffers::Offset<flatbuffers::Vector<int64_t>> indicesStrides = 0, - const org::apache::arrow::flatbuf::Buffer *indicesBuffer = 0, - bool isCanonical = false) { - SparseTensorIndexCOOBuilder builder_(_fbb); - builder_.add_indicesBuffer(indicesBuffer); - builder_.add_indicesStrides(indicesStrides); - builder_.add_indicesType(indicesType); - builder_.add_isCanonical(isCanonical); - return builder_.Finish(); -} - -inline flatbuffers::Offset<SparseTensorIndexCOO> CreateSparseTensorIndexCOODirect( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indicesType = 0, - const std::vector<int64_t> *indicesStrides = nullptr, - const org::apache::arrow::flatbuf::Buffer *indicesBuffer = 0, - bool isCanonical = false) { - auto indicesStrides__ = indicesStrides ? _fbb.CreateVector<int64_t>(*indicesStrides) : 0; - return org::apache::arrow::flatbuf::CreateSparseTensorIndexCOO( - _fbb, - indicesType, - indicesStrides__, - indicesBuffer, - isCanonical); -} - -/// Compressed Sparse format, that is matrix-specific. -struct SparseMatrixIndexCSX FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef SparseMatrixIndexCSXBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_COMPRESSEDAXIS = 4, - VT_INDPTRTYPE = 6, - VT_INDPTRBUFFER = 8, - VT_INDICESTYPE = 10, - VT_INDICESBUFFER = 12 - }; - /// Which axis, row or column, is compressed - org::apache::arrow::flatbuf::SparseMatrixCompressedAxis compressedAxis() const { - return static_cast<org::apache::arrow::flatbuf::SparseMatrixCompressedAxis>(GetField<int16_t>(VT_COMPRESSEDAXIS, 0)); - } - /// The type of values in indptrBuffer - const org::apache::arrow::flatbuf::Int *indptrType() const { - return GetPointer<const org::apache::arrow::flatbuf::Int *>(VT_INDPTRTYPE); - } - /// indptrBuffer stores the location and size of indptr array that - /// represents the range of the rows. - /// The i-th row spans from indptr[i] to indptr[i+1] in the data. - /// The length of this array is 1 + (the number of rows), and the type - /// of index value is long. - /// - /// For example, let X be the following 6x4 matrix: - /// - /// X := [[0, 1, 2, 0], - /// [0, 0, 3, 0], - /// [0, 4, 0, 5], - /// [0, 0, 0, 0], - /// [6, 0, 7, 8], - /// [0, 9, 0, 0]]. - /// - /// The array of non-zero values in X is: - /// - /// values(X) = [1, 2, 3, 4, 5, 6, 7, 8, 9]. - /// - /// And the indptr of X is: - /// - /// indptr(X) = [0, 2, 3, 5, 5, 8, 10]. - const org::apache::arrow::flatbuf::Buffer *indptrBuffer() const { - return GetStruct<const org::apache::arrow::flatbuf::Buffer *>(VT_INDPTRBUFFER); - } - /// The type of values in indicesBuffer - const org::apache::arrow::flatbuf::Int *indicesType() const { - return GetPointer<const org::apache::arrow::flatbuf::Int *>(VT_INDICESTYPE); - } - /// indicesBuffer stores the location and size of the array that - /// contains the column indices of the corresponding non-zero values. - /// The type of index value is long. - /// - /// For example, the indices of the above X is: - /// - /// indices(X) = [1, 2, 2, 1, 3, 0, 2, 3, 1]. - /// - /// Note that the indices are sorted in lexicographical order for each row. - const org::apache::arrow::flatbuf::Buffer *indicesBuffer() const { - return GetStruct<const org::apache::arrow::flatbuf::Buffer *>(VT_INDICESBUFFER); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int16_t>(verifier, VT_COMPRESSEDAXIS) && - VerifyOffsetRequired(verifier, VT_INDPTRTYPE) && - verifier.VerifyTable(indptrType()) && - VerifyFieldRequired<org::apache::arrow::flatbuf::Buffer>(verifier, VT_INDPTRBUFFER) && - VerifyOffsetRequired(verifier, VT_INDICESTYPE) && - verifier.VerifyTable(indicesType()) && - VerifyFieldRequired<org::apache::arrow::flatbuf::Buffer>(verifier, VT_INDICESBUFFER) && - verifier.EndTable(); - } -}; - -struct SparseMatrixIndexCSXBuilder { - typedef SparseMatrixIndexCSX Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_compressedAxis(org::apache::arrow::flatbuf::SparseMatrixCompressedAxis compressedAxis) { - fbb_.AddElement<int16_t>(SparseMatrixIndexCSX::VT_COMPRESSEDAXIS, static_cast<int16_t>(compressedAxis), 0); - } - void add_indptrType(flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indptrType) { - fbb_.AddOffset(SparseMatrixIndexCSX::VT_INDPTRTYPE, indptrType); - } - void add_indptrBuffer(const org::apache::arrow::flatbuf::Buffer *indptrBuffer) { - fbb_.AddStruct(SparseMatrixIndexCSX::VT_INDPTRBUFFER, indptrBuffer); - } - void add_indicesType(flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indicesType) { - fbb_.AddOffset(SparseMatrixIndexCSX::VT_INDICESTYPE, indicesType); - } - void add_indicesBuffer(const org::apache::arrow::flatbuf::Buffer *indicesBuffer) { - fbb_.AddStruct(SparseMatrixIndexCSX::VT_INDICESBUFFER, indicesBuffer); - } - explicit SparseMatrixIndexCSXBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - SparseMatrixIndexCSXBuilder &operator=(const SparseMatrixIndexCSXBuilder &); - flatbuffers::Offset<SparseMatrixIndexCSX> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<SparseMatrixIndexCSX>(end); - fbb_.Required(o, SparseMatrixIndexCSX::VT_INDPTRTYPE); - fbb_.Required(o, SparseMatrixIndexCSX::VT_INDPTRBUFFER); - fbb_.Required(o, SparseMatrixIndexCSX::VT_INDICESTYPE); - fbb_.Required(o, SparseMatrixIndexCSX::VT_INDICESBUFFER); - return o; - } -}; - -inline flatbuffers::Offset<SparseMatrixIndexCSX> CreateSparseMatrixIndexCSX( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::SparseMatrixCompressedAxis compressedAxis = org::apache::arrow::flatbuf::SparseMatrixCompressedAxis::Row, - flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indptrType = 0, - const org::apache::arrow::flatbuf::Buffer *indptrBuffer = 0, - flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indicesType = 0, - const org::apache::arrow::flatbuf::Buffer *indicesBuffer = 0) { - SparseMatrixIndexCSXBuilder builder_(_fbb); - builder_.add_indicesBuffer(indicesBuffer); - builder_.add_indicesType(indicesType); - builder_.add_indptrBuffer(indptrBuffer); - builder_.add_indptrType(indptrType); - builder_.add_compressedAxis(compressedAxis); - return builder_.Finish(); -} - -/// Compressed Sparse Fiber (CSF) sparse tensor index. -struct SparseTensorIndexCSF FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef SparseTensorIndexCSFBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_INDPTRTYPE = 4, - VT_INDPTRBUFFERS = 6, - VT_INDICESTYPE = 8, - VT_INDICESBUFFERS = 10, - VT_AXISORDER = 12 - }; - /// CSF is a generalization of compressed sparse row (CSR) index. - /// See [smith2017knl]: http://shaden.io/pub-files/smith2017knl.pdf - /// - /// CSF index recursively compresses each dimension of a tensor into a set - /// of prefix trees. Each path from a root to leaf forms one tensor - /// non-zero index. CSF is implemented with two arrays of buffers and one - /// arrays of integers. - /// - /// For example, let X be a 2x3x4x5 tensor and let it have the following - /// 8 non-zero values: - /// - /// X[0, 0, 0, 1] := 1 - /// X[0, 0, 0, 2] := 2 - /// X[0, 1, 0, 0] := 3 - /// X[0, 1, 0, 2] := 4 - /// X[0, 1, 1, 0] := 5 - /// X[1, 1, 1, 0] := 6 - /// X[1, 1, 1, 1] := 7 - /// X[1, 1, 1, 2] := 8 - /// - /// As a prefix tree this would be represented as: - /// - /// 0 1 - /// / \ | - /// 0 1 1 - /// / / \ | - /// 0 0 1 1 - /// /| /| | /| | - /// 1 2 0 2 0 0 1 2 - /// The type of values in indptrBuffers - const org::apache::arrow::flatbuf::Int *indptrType() const { - return GetPointer<const org::apache::arrow::flatbuf::Int *>(VT_INDPTRTYPE); - } - /// indptrBuffers stores the sparsity structure. - /// Each two consecutive dimensions in a tensor correspond to a buffer in - /// indptrBuffers. A pair of consecutive values at indptrBuffers[dim][i] - /// and indptrBuffers[dim][i + 1] signify a range of nodes in - /// indicesBuffers[dim + 1] who are children of indicesBuffers[dim][i] node. - /// - /// For example, the indptrBuffers for the above X is: - /// - /// indptrBuffer(X) = [ - /// [0, 2, 3], - /// [0, 1, 3, 4], - /// [0, 2, 4, 5, 8] - /// ]. - /// - const flatbuffers::Vector<const org::apache::arrow::flatbuf::Buffer *> *indptrBuffers() const { - return GetPointer<const flatbuffers::Vector<const org::apache::arrow::flatbuf::Buffer *> *>(VT_INDPTRBUFFERS); - } - /// The type of values in indicesBuffers - const org::apache::arrow::flatbuf::Int *indicesType() const { - return GetPointer<const org::apache::arrow::flatbuf::Int *>(VT_INDICESTYPE); - } - /// indicesBuffers stores values of nodes. - /// Each tensor dimension corresponds to a buffer in indicesBuffers. - /// For example, the indicesBuffers for the above X is: - /// - /// indicesBuffer(X) = [ - /// [0, 1], - /// [0, 1, 1], - /// [0, 0, 1, 1], - /// [1, 2, 0, 2, 0, 0, 1, 2] - /// ]. - /// - const flatbuffers::Vector<const org::apache::arrow::flatbuf::Buffer *> *indicesBuffers() const { - return GetPointer<const flatbuffers::Vector<const org::apache::arrow::flatbuf::Buffer *> *>(VT_INDICESBUFFERS); - } - /// axisOrder stores the sequence in which dimensions were traversed to - /// produce the prefix tree. - /// For example, the axisOrder for the above X is: - /// - /// axisOrder(X) = [0, 1, 2, 3]. - /// - const flatbuffers::Vector<int32_t> *axisOrder() const { - return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_AXISORDER); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffsetRequired(verifier, VT_INDPTRTYPE) && - verifier.VerifyTable(indptrType()) && - VerifyOffsetRequired(verifier, VT_INDPTRBUFFERS) && - verifier.VerifyVector(indptrBuffers()) && - VerifyOffsetRequired(verifier, VT_INDICESTYPE) && - verifier.VerifyTable(indicesType()) && - VerifyOffsetRequired(verifier, VT_INDICESBUFFERS) && - verifier.VerifyVector(indicesBuffers()) && - VerifyOffsetRequired(verifier, VT_AXISORDER) && - verifier.VerifyVector(axisOrder()) && - verifier.EndTable(); - } -}; - -struct SparseTensorIndexCSFBuilder { - typedef SparseTensorIndexCSF Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_indptrType(flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indptrType) { - fbb_.AddOffset(SparseTensorIndexCSF::VT_INDPTRTYPE, indptrType); - } - void add_indptrBuffers(flatbuffers::Offset<flatbuffers::Vector<const org::apache::arrow::flatbuf::Buffer *>> indptrBuffers) { - fbb_.AddOffset(SparseTensorIndexCSF::VT_INDPTRBUFFERS, indptrBuffers); - } - void add_indicesType(flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indicesType) { - fbb_.AddOffset(SparseTensorIndexCSF::VT_INDICESTYPE, indicesType); - } - void add_indicesBuffers(flatbuffers::Offset<flatbuffers::Vector<const org::apache::arrow::flatbuf::Buffer *>> indicesBuffers) { - fbb_.AddOffset(SparseTensorIndexCSF::VT_INDICESBUFFERS, indicesBuffers); - } - void add_axisOrder(flatbuffers::Offset<flatbuffers::Vector<int32_t>> axisOrder) { - fbb_.AddOffset(SparseTensorIndexCSF::VT_AXISORDER, axisOrder); - } - explicit SparseTensorIndexCSFBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - SparseTensorIndexCSFBuilder &operator=(const SparseTensorIndexCSFBuilder &); - flatbuffers::Offset<SparseTensorIndexCSF> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<SparseTensorIndexCSF>(end); - fbb_.Required(o, SparseTensorIndexCSF::VT_INDPTRTYPE); - fbb_.Required(o, SparseTensorIndexCSF::VT_INDPTRBUFFERS); - fbb_.Required(o, SparseTensorIndexCSF::VT_INDICESTYPE); - fbb_.Required(o, SparseTensorIndexCSF::VT_INDICESBUFFERS); - fbb_.Required(o, SparseTensorIndexCSF::VT_AXISORDER); - return o; - } -}; - -inline flatbuffers::Offset<SparseTensorIndexCSF> CreateSparseTensorIndexCSF( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indptrType = 0, - flatbuffers::Offset<flatbuffers::Vector<const org::apache::arrow::flatbuf::Buffer *>> indptrBuffers = 0, - flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indicesType = 0, - flatbuffers::Offset<flatbuffers::Vector<const org::apache::arrow::flatbuf::Buffer *>> indicesBuffers = 0, - flatbuffers::Offset<flatbuffers::Vector<int32_t>> axisOrder = 0) { - SparseTensorIndexCSFBuilder builder_(_fbb); - builder_.add_axisOrder(axisOrder); - builder_.add_indicesBuffers(indicesBuffers); - builder_.add_indicesType(indicesType); - builder_.add_indptrBuffers(indptrBuffers); - builder_.add_indptrType(indptrType); - return builder_.Finish(); -} - -inline flatbuffers::Offset<SparseTensorIndexCSF> CreateSparseTensorIndexCSFDirect( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indptrType = 0, - const std::vector<org::apache::arrow::flatbuf::Buffer> *indptrBuffers = nullptr, - flatbuffers::Offset<org::apache::arrow::flatbuf::Int> indicesType = 0, - const std::vector<org::apache::arrow::flatbuf::Buffer> *indicesBuffers = nullptr, - const std::vector<int32_t> *axisOrder = nullptr) { - auto indptrBuffers__ = indptrBuffers ? _fbb.CreateVectorOfStructs<org::apache::arrow::flatbuf::Buffer>(*indptrBuffers) : 0; - auto indicesBuffers__ = indicesBuffers ? _fbb.CreateVectorOfStructs<org::apache::arrow::flatbuf::Buffer>(*indicesBuffers) : 0; - auto axisOrder__ = axisOrder ? _fbb.CreateVector<int32_t>(*axisOrder) : 0; - return org::apache::arrow::flatbuf::CreateSparseTensorIndexCSF( - _fbb, - indptrType, - indptrBuffers__, - indicesType, - indicesBuffers__, - axisOrder__); -} - -struct SparseTensor FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef SparseTensorBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_TYPE_TYPE = 4, - VT_TYPE = 6, - VT_SHAPE = 8, - VT_NON_ZERO_LENGTH = 10, - VT_SPARSEINDEX_TYPE = 12, - VT_SPARSEINDEX = 14, - VT_DATA = 16 - }; - org::apache::arrow::flatbuf::Type type_type() const { - return static_cast<org::apache::arrow::flatbuf::Type>(GetField<uint8_t>(VT_TYPE_TYPE, 0)); - } - /// The type of data contained in a value cell. - /// Currently only fixed-width value types are supported, - /// no strings or nested types. - const void *type() const { - return GetPointer<const void *>(VT_TYPE); - } - template<typename T> const T *type_as() const; - const org::apache::arrow::flatbuf::Null *type_as_Null() const { - return type_type() == org::apache::arrow::flatbuf::Type::Null ? static_cast<const org::apache::arrow::flatbuf::Null *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Int *type_as_Int() const { - return type_type() == org::apache::arrow::flatbuf::Type::Int ? static_cast<const org::apache::arrow::flatbuf::Int *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::FloatingPoint *type_as_FloatingPoint() const { - return type_type() == org::apache::arrow::flatbuf::Type::FloatingPoint ? static_cast<const org::apache::arrow::flatbuf::FloatingPoint *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Binary *type_as_Binary() const { - return type_type() == org::apache::arrow::flatbuf::Type::Binary ? static_cast<const org::apache::arrow::flatbuf::Binary *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Utf8 *type_as_Utf8() const { - return type_type() == org::apache::arrow::flatbuf::Type::Utf8 ? static_cast<const org::apache::arrow::flatbuf::Utf8 *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Bool *type_as_Bool() const { - return type_type() == org::apache::arrow::flatbuf::Type::Bool ? static_cast<const org::apache::arrow::flatbuf::Bool *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Decimal *type_as_Decimal() const { - return type_type() == org::apache::arrow::flatbuf::Type::Decimal ? static_cast<const org::apache::arrow::flatbuf::Decimal *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Date *type_as_Date() const { - return type_type() == org::apache::arrow::flatbuf::Type::Date ? static_cast<const org::apache::arrow::flatbuf::Date *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Time *type_as_Time() const { - return type_type() == org::apache::arrow::flatbuf::Type::Time ? static_cast<const org::apache::arrow::flatbuf::Time *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Timestamp *type_as_Timestamp() const { - return type_type() == org::apache::arrow::flatbuf::Type::Timestamp ? static_cast<const org::apache::arrow::flatbuf::Timestamp *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Interval *type_as_Interval() const { - return type_type() == org::apache::arrow::flatbuf::Type::Interval ? static_cast<const org::apache::arrow::flatbuf::Interval *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::List *type_as_List() const { - return type_type() == org::apache::arrow::flatbuf::Type::List ? static_cast<const org::apache::arrow::flatbuf::List *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Struct_ *type_as_Struct_() const { - return type_type() == org::apache::arrow::flatbuf::Type::Struct_ ? static_cast<const org::apache::arrow::flatbuf::Struct_ *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Union *type_as_Union() const { - return type_type() == org::apache::arrow::flatbuf::Type::Union ? static_cast<const org::apache::arrow::flatbuf::Union *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::FixedSizeBinary *type_as_FixedSizeBinary() const { - return type_type() == org::apache::arrow::flatbuf::Type::FixedSizeBinary ? static_cast<const org::apache::arrow::flatbuf::FixedSizeBinary *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::FixedSizeList *type_as_FixedSizeList() const { - return type_type() == org::apache::arrow::flatbuf::Type::FixedSizeList ? static_cast<const org::apache::arrow::flatbuf::FixedSizeList *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Map *type_as_Map() const { - return type_type() == org::apache::arrow::flatbuf::Type::Map ? static_cast<const org::apache::arrow::flatbuf::Map *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Duration *type_as_Duration() const { - return type_type() == org::apache::arrow::flatbuf::Type::Duration ? static_cast<const org::apache::arrow::flatbuf::Duration *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::LargeBinary *type_as_LargeBinary() const { - return type_type() == org::apache::arrow::flatbuf::Type::LargeBinary ? static_cast<const org::apache::arrow::flatbuf::LargeBinary *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::LargeUtf8 *type_as_LargeUtf8() const { - return type_type() == org::apache::arrow::flatbuf::Type::LargeUtf8 ? static_cast<const org::apache::arrow::flatbuf::LargeUtf8 *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::LargeList *type_as_LargeList() const { - return type_type() == org::apache::arrow::flatbuf::Type::LargeList ? static_cast<const org::apache::arrow::flatbuf::LargeList *>(type()) : nullptr; - } - /// The dimensions of the tensor, optionally named. - const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::TensorDim>> *shape() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::TensorDim>> *>(VT_SHAPE); - } - /// The number of non-zero values in a sparse tensor. - int64_t non_zero_length() const { - return GetField<int64_t>(VT_NON_ZERO_LENGTH, 0); - } - org::apache::arrow::flatbuf::SparseTensorIndex sparseIndex_type() const { - return static_cast<org::apache::arrow::flatbuf::SparseTensorIndex>(GetField<uint8_t>(VT_SPARSEINDEX_TYPE, 0)); - } - /// Sparse tensor index - const void *sparseIndex() const { - return GetPointer<const void *>(VT_SPARSEINDEX); - } - template<typename T> const T *sparseIndex_as() const; - const org::apache::arrow::flatbuf::SparseTensorIndexCOO *sparseIndex_as_SparseTensorIndexCOO() const { - return sparseIndex_type() == org::apache::arrow::flatbuf::SparseTensorIndex::SparseTensorIndexCOO ? static_cast<const org::apache::arrow::flatbuf::SparseTensorIndexCOO *>(sparseIndex()) : nullptr; - } - const org::apache::arrow::flatbuf::SparseMatrixIndexCSX *sparseIndex_as_SparseMatrixIndexCSX() const { - return sparseIndex_type() == org::apache::arrow::flatbuf::SparseTensorIndex::SparseMatrixIndexCSX ? static_cast<const org::apache::arrow::flatbuf::SparseMatrixIndexCSX *>(sparseIndex()) : nullptr; - } - const org::apache::arrow::flatbuf::SparseTensorIndexCSF *sparseIndex_as_SparseTensorIndexCSF() const { - return sparseIndex_type() == org::apache::arrow::flatbuf::SparseTensorIndex::SparseTensorIndexCSF ? static_cast<const org::apache::arrow::flatbuf::SparseTensorIndexCSF *>(sparseIndex()) : nullptr; - } - /// The location and size of the tensor's data - const org::apache::arrow::flatbuf::Buffer *data() const { - return GetStruct<const org::apache::arrow::flatbuf::Buffer *>(VT_DATA); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<uint8_t>(verifier, VT_TYPE_TYPE) && - VerifyOffsetRequired(verifier, VT_TYPE) && - VerifyType(verifier, type(), type_type()) && - VerifyOffsetRequired(verifier, VT_SHAPE) && - verifier.VerifyVector(shape()) && - verifier.VerifyVectorOfTables(shape()) && - VerifyField<int64_t>(verifier, VT_NON_ZERO_LENGTH) && - VerifyField<uint8_t>(verifier, VT_SPARSEINDEX_TYPE) && - VerifyOffsetRequired(verifier, VT_SPARSEINDEX) && - VerifySparseTensorIndex(verifier, sparseIndex(), sparseIndex_type()) && - VerifyFieldRequired<org::apache::arrow::flatbuf::Buffer>(verifier, VT_DATA) && - verifier.EndTable(); - } -}; - -template<> inline const org::apache::arrow::flatbuf::Null *SparseTensor::type_as<org::apache::arrow::flatbuf::Null>() const { - return type_as_Null(); -} - -template<> inline const org::apache::arrow::flatbuf::Int *SparseTensor::type_as<org::apache::arrow::flatbuf::Int>() const { - return type_as_Int(); -} - -template<> inline const org::apache::arrow::flatbuf::FloatingPoint *SparseTensor::type_as<org::apache::arrow::flatbuf::FloatingPoint>() const { - return type_as_FloatingPoint(); -} - -template<> inline const org::apache::arrow::flatbuf::Binary *SparseTensor::type_as<org::apache::arrow::flatbuf::Binary>() const { - return type_as_Binary(); -} - -template<> inline const org::apache::arrow::flatbuf::Utf8 *SparseTensor::type_as<org::apache::arrow::flatbuf::Utf8>() const { - return type_as_Utf8(); -} - -template<> inline const org::apache::arrow::flatbuf::Bool *SparseTensor::type_as<org::apache::arrow::flatbuf::Bool>() const { - return type_as_Bool(); -} - -template<> inline const org::apache::arrow::flatbuf::Decimal *SparseTensor::type_as<org::apache::arrow::flatbuf::Decimal>() const { - return type_as_Decimal(); -} - -template<> inline const org::apache::arrow::flatbuf::Date *SparseTensor::type_as<org::apache::arrow::flatbuf::Date>() const { - return type_as_Date(); -} - -template<> inline const org::apache::arrow::flatbuf::Time *SparseTensor::type_as<org::apache::arrow::flatbuf::Time>() const { - return type_as_Time(); -} - -template<> inline const org::apache::arrow::flatbuf::Timestamp *SparseTensor::type_as<org::apache::arrow::flatbuf::Timestamp>() const { - return type_as_Timestamp(); -} - -template<> inline const org::apache::arrow::flatbuf::Interval *SparseTensor::type_as<org::apache::arrow::flatbuf::Interval>() const { - return type_as_Interval(); -} - -template<> inline const org::apache::arrow::flatbuf::List *SparseTensor::type_as<org::apache::arrow::flatbuf::List>() const { - return type_as_List(); -} - -template<> inline const org::apache::arrow::flatbuf::Struct_ *SparseTensor::type_as<org::apache::arrow::flatbuf::Struct_>() const { - return type_as_Struct_(); -} - -template<> inline const org::apache::arrow::flatbuf::Union *SparseTensor::type_as<org::apache::arrow::flatbuf::Union>() const { - return type_as_Union(); -} - -template<> inline const org::apache::arrow::flatbuf::FixedSizeBinary *SparseTensor::type_as<org::apache::arrow::flatbuf::FixedSizeBinary>() const { - return type_as_FixedSizeBinary(); -} - -template<> inline const org::apache::arrow::flatbuf::FixedSizeList *SparseTensor::type_as<org::apache::arrow::flatbuf::FixedSizeList>() const { - return type_as_FixedSizeList(); -} - -template<> inline const org::apache::arrow::flatbuf::Map *SparseTensor::type_as<org::apache::arrow::flatbuf::Map>() const { - return type_as_Map(); -} - -template<> inline const org::apache::arrow::flatbuf::Duration *SparseTensor::type_as<org::apache::arrow::flatbuf::Duration>() const { - return type_as_Duration(); -} - -template<> inline const org::apache::arrow::flatbuf::LargeBinary *SparseTensor::type_as<org::apache::arrow::flatbuf::LargeBinary>() const { - return type_as_LargeBinary(); -} - -template<> inline const org::apache::arrow::flatbuf::LargeUtf8 *SparseTensor::type_as<org::apache::arrow::flatbuf::LargeUtf8>() const { - return type_as_LargeUtf8(); -} - -template<> inline const org::apache::arrow::flatbuf::LargeList *SparseTensor::type_as<org::apache::arrow::flatbuf::LargeList>() const { - return type_as_LargeList(); -} - -template<> inline const org::apache::arrow::flatbuf::SparseTensorIndexCOO *SparseTensor::sparseIndex_as<org::apache::arrow::flatbuf::SparseTensorIndexCOO>() const { - return sparseIndex_as_SparseTensorIndexCOO(); -} - -template<> inline const org::apache::arrow::flatbuf::SparseMatrixIndexCSX *SparseTensor::sparseIndex_as<org::apache::arrow::flatbuf::SparseMatrixIndexCSX>() const { - return sparseIndex_as_SparseMatrixIndexCSX(); -} - -template<> inline const org::apache::arrow::flatbuf::SparseTensorIndexCSF *SparseTensor::sparseIndex_as<org::apache::arrow::flatbuf::SparseTensorIndexCSF>() const { - return sparseIndex_as_SparseTensorIndexCSF(); -} - -struct SparseTensorBuilder { - typedef SparseTensor Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_type_type(org::apache::arrow::flatbuf::Type type_type) { - fbb_.AddElement<uint8_t>(SparseTensor::VT_TYPE_TYPE, static_cast<uint8_t>(type_type), 0); - } - void add_type(flatbuffers::Offset<void> type) { - fbb_.AddOffset(SparseTensor::VT_TYPE, type); - } - void add_shape(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::TensorDim>>> shape) { - fbb_.AddOffset(SparseTensor::VT_SHAPE, shape); - } - void add_non_zero_length(int64_t non_zero_length) { - fbb_.AddElement<int64_t>(SparseTensor::VT_NON_ZERO_LENGTH, non_zero_length, 0); - } - void add_sparseIndex_type(org::apache::arrow::flatbuf::SparseTensorIndex sparseIndex_type) { - fbb_.AddElement<uint8_t>(SparseTensor::VT_SPARSEINDEX_TYPE, static_cast<uint8_t>(sparseIndex_type), 0); - } - void add_sparseIndex(flatbuffers::Offset<void> sparseIndex) { - fbb_.AddOffset(SparseTensor::VT_SPARSEINDEX, sparseIndex); - } - void add_data(const org::apache::arrow::flatbuf::Buffer *data) { - fbb_.AddStruct(SparseTensor::VT_DATA, data); - } - explicit SparseTensorBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - SparseTensorBuilder &operator=(const SparseTensorBuilder &); - flatbuffers::Offset<SparseTensor> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<SparseTensor>(end); - fbb_.Required(o, SparseTensor::VT_TYPE); - fbb_.Required(o, SparseTensor::VT_SHAPE); - fbb_.Required(o, SparseTensor::VT_SPARSEINDEX); - fbb_.Required(o, SparseTensor::VT_DATA); - return o; - } -}; - -inline flatbuffers::Offset<SparseTensor> CreateSparseTensor( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::Type type_type = org::apache::arrow::flatbuf::Type::NONE, - flatbuffers::Offset<void> type = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::TensorDim>>> shape = 0, - int64_t non_zero_length = 0, - org::apache::arrow::flatbuf::SparseTensorIndex sparseIndex_type = org::apache::arrow::flatbuf::SparseTensorIndex::NONE, - flatbuffers::Offset<void> sparseIndex = 0, - const org::apache::arrow::flatbuf::Buffer *data = 0) { - SparseTensorBuilder builder_(_fbb); - builder_.add_non_zero_length(non_zero_length); - builder_.add_data(data); - builder_.add_sparseIndex(sparseIndex); - builder_.add_shape(shape); - builder_.add_type(type); - builder_.add_sparseIndex_type(sparseIndex_type); - builder_.add_type_type(type_type); - return builder_.Finish(); -} - -inline flatbuffers::Offset<SparseTensor> CreateSparseTensorDirect( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::Type type_type = org::apache::arrow::flatbuf::Type::NONE, - flatbuffers::Offset<void> type = 0, - const std::vector<flatbuffers::Offset<org::apache::arrow::flatbuf::TensorDim>> *shape = nullptr, - int64_t non_zero_length = 0, - org::apache::arrow::flatbuf::SparseTensorIndex sparseIndex_type = org::apache::arrow::flatbuf::SparseTensorIndex::NONE, - flatbuffers::Offset<void> sparseIndex = 0, - const org::apache::arrow::flatbuf::Buffer *data = 0) { - auto shape__ = shape ? _fbb.CreateVector<flatbuffers::Offset<org::apache::arrow::flatbuf::TensorDim>>(*shape) : 0; - return org::apache::arrow::flatbuf::CreateSparseTensor( - _fbb, - type_type, - type, - shape__, - non_zero_length, - sparseIndex_type, - sparseIndex, - data); -} - -inline bool VerifySparseTensorIndex(flatbuffers::Verifier &verifier, const void *obj, SparseTensorIndex type) { - switch (type) { - case SparseTensorIndex::NONE: { - return true; - } - case SparseTensorIndex::SparseTensorIndexCOO: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::SparseTensorIndexCOO *>(obj); - return verifier.VerifyTable(ptr); - } - case SparseTensorIndex::SparseMatrixIndexCSX: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::SparseMatrixIndexCSX *>(obj); - return verifier.VerifyTable(ptr); - } - case SparseTensorIndex::SparseTensorIndexCSF: { - auto ptr = reinterpret_cast<const org::apache::arrow::flatbuf::SparseTensorIndexCSF *>(obj); - return verifier.VerifyTable(ptr); - } - default: return true; - } -} - -inline bool VerifySparseTensorIndexVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *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 (!VerifySparseTensorIndex( - verifier, values->Get(i), types->GetEnum<SparseTensorIndex>(i))) { - return false; - } - } - return true; -} - -inline const org::apache::arrow::flatbuf::SparseTensor *GetSparseTensor(const void *buf) { - return flatbuffers::GetRoot<org::apache::arrow::flatbuf::SparseTensor>(buf); -} - -inline const org::apache::arrow::flatbuf::SparseTensor *GetSizePrefixedSparseTensor(const void *buf) { - return flatbuffers::GetSizePrefixedRoot<org::apache::arrow::flatbuf::SparseTensor>(buf); -} - -inline bool VerifySparseTensorBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer<org::apache::arrow::flatbuf::SparseTensor>(nullptr); -} - -inline bool VerifySizePrefixedSparseTensorBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifySizePrefixedBuffer<org::apache::arrow::flatbuf::SparseTensor>(nullptr); -} - -inline void FinishSparseTensorBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<org::apache::arrow::flatbuf::SparseTensor> root) { - fbb.Finish(root); -} - -inline void FinishSizePrefixedSparseTensorBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<org::apache::arrow::flatbuf::SparseTensor> root) { - fbb.FinishSizePrefixed(root); -} - -} // namespace flatbuf -} // namespace arrow -} // namespace apache -} // namespace org - -#endif // FLATBUFFERS_GENERATED_SPARSETENSOR_ORG_APACHE_ARROW_FLATBUF_H_ diff --git a/contrib/libs/apache/arrow/cpp/src/generated/Tensor.fbs b/contrib/libs/apache/arrow/cpp/src/generated/Tensor.fbs new file mode 100644 index 0000000000..409297ccf8 --- /dev/null +++ b/contrib/libs/apache/arrow/cpp/src/generated/Tensor.fbs @@ -0,0 +1,54 @@ +// 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. + +/// EXPERIMENTAL: Metadata for n-dimensional arrays, aka "tensors" or +/// "ndarrays". Arrow implementations in general are not required to implement +/// this type + +include "Schema.fbs"; + +namespace org.apache.arrow.flatbuf; + +/// ---------------------------------------------------------------------- +/// Data structures for dense tensors + +/// Shape data for a single axis in a tensor +table TensorDim { + /// Length of dimension + size: long; + + /// Name of the dimension, optional + name: string; +} + +table Tensor { + /// The type of data contained in a value cell. Currently only fixed-width + /// value types are supported, no strings or nested types + type: Type (required); + + /// The dimensions of the tensor, optionally named + shape: [TensorDim] (required); + + /// Non-negative byte offsets to advance one value cell along each dimension + /// If omitted, default to row-major order (C-like). + strides: [long]; + + /// The location and size of the tensor's data + data: Buffer (required); +} + +root_type Tensor; diff --git a/contrib/libs/apache/arrow/cpp/src/generated/Tensor_generated.h b/contrib/libs/apache/arrow/cpp/src/generated/Tensor_generated.h deleted file mode 100644 index 062a3b91aa..0000000000 --- a/contrib/libs/apache/arrow/cpp/src/generated/Tensor_generated.h +++ /dev/null @@ -1,387 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_TENSOR_ORG_APACHE_ARROW_FLATBUF_H_ -#define FLATBUFFERS_GENERATED_TENSOR_ORG_APACHE_ARROW_FLATBUF_H_ - -#include "flatbuffers/flatbuffers.h" - -#include "Schema_generated.h" - -namespace org { -namespace apache { -namespace arrow { -namespace flatbuf { - -struct TensorDim; -struct TensorDimBuilder; - -struct Tensor; -struct TensorBuilder; - -/// ---------------------------------------------------------------------- -/// Data structures for dense tensors -/// Shape data for a single axis in a tensor -struct TensorDim FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef TensorDimBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_SIZE = 4, - VT_NAME = 6 - }; - /// Length of dimension - int64_t size() const { - return GetField<int64_t>(VT_SIZE, 0); - } - /// Name of the dimension, optional - const flatbuffers::String *name() const { - return GetPointer<const flatbuffers::String *>(VT_NAME); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int64_t>(verifier, VT_SIZE) && - VerifyOffset(verifier, VT_NAME) && - verifier.VerifyString(name()) && - verifier.EndTable(); - } -}; - -struct TensorDimBuilder { - typedef TensorDim Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_size(int64_t size) { - fbb_.AddElement<int64_t>(TensorDim::VT_SIZE, size, 0); - } - void add_name(flatbuffers::Offset<flatbuffers::String> name) { - fbb_.AddOffset(TensorDim::VT_NAME, name); - } - explicit TensorDimBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - TensorDimBuilder &operator=(const TensorDimBuilder &); - flatbuffers::Offset<TensorDim> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<TensorDim>(end); - return o; - } -}; - -inline flatbuffers::Offset<TensorDim> CreateTensorDim( - flatbuffers::FlatBufferBuilder &_fbb, - int64_t size = 0, - flatbuffers::Offset<flatbuffers::String> name = 0) { - TensorDimBuilder builder_(_fbb); - builder_.add_size(size); - builder_.add_name(name); - return builder_.Finish(); -} - -inline flatbuffers::Offset<TensorDim> CreateTensorDimDirect( - flatbuffers::FlatBufferBuilder &_fbb, - int64_t size = 0, - const char *name = nullptr) { - auto name__ = name ? _fbb.CreateString(name) : 0; - return org::apache::arrow::flatbuf::CreateTensorDim( - _fbb, - size, - name__); -} - -struct Tensor FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef TensorBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_TYPE_TYPE = 4, - VT_TYPE = 6, - VT_SHAPE = 8, - VT_STRIDES = 10, - VT_DATA = 12 - }; - org::apache::arrow::flatbuf::Type type_type() const { - return static_cast<org::apache::arrow::flatbuf::Type>(GetField<uint8_t>(VT_TYPE_TYPE, 0)); - } - /// The type of data contained in a value cell. Currently only fixed-width - /// value types are supported, no strings or nested types - const void *type() const { - return GetPointer<const void *>(VT_TYPE); - } - template<typename T> const T *type_as() const; - const org::apache::arrow::flatbuf::Null *type_as_Null() const { - return type_type() == org::apache::arrow::flatbuf::Type::Null ? static_cast<const org::apache::arrow::flatbuf::Null *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Int *type_as_Int() const { - return type_type() == org::apache::arrow::flatbuf::Type::Int ? static_cast<const org::apache::arrow::flatbuf::Int *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::FloatingPoint *type_as_FloatingPoint() const { - return type_type() == org::apache::arrow::flatbuf::Type::FloatingPoint ? static_cast<const org::apache::arrow::flatbuf::FloatingPoint *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Binary *type_as_Binary() const { - return type_type() == org::apache::arrow::flatbuf::Type::Binary ? static_cast<const org::apache::arrow::flatbuf::Binary *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Utf8 *type_as_Utf8() const { - return type_type() == org::apache::arrow::flatbuf::Type::Utf8 ? static_cast<const org::apache::arrow::flatbuf::Utf8 *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Bool *type_as_Bool() const { - return type_type() == org::apache::arrow::flatbuf::Type::Bool ? static_cast<const org::apache::arrow::flatbuf::Bool *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Decimal *type_as_Decimal() const { - return type_type() == org::apache::arrow::flatbuf::Type::Decimal ? static_cast<const org::apache::arrow::flatbuf::Decimal *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Date *type_as_Date() const { - return type_type() == org::apache::arrow::flatbuf::Type::Date ? static_cast<const org::apache::arrow::flatbuf::Date *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Time *type_as_Time() const { - return type_type() == org::apache::arrow::flatbuf::Type::Time ? static_cast<const org::apache::arrow::flatbuf::Time *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Timestamp *type_as_Timestamp() const { - return type_type() == org::apache::arrow::flatbuf::Type::Timestamp ? static_cast<const org::apache::arrow::flatbuf::Timestamp *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Interval *type_as_Interval() const { - return type_type() == org::apache::arrow::flatbuf::Type::Interval ? static_cast<const org::apache::arrow::flatbuf::Interval *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::List *type_as_List() const { - return type_type() == org::apache::arrow::flatbuf::Type::List ? static_cast<const org::apache::arrow::flatbuf::List *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Struct_ *type_as_Struct_() const { - return type_type() == org::apache::arrow::flatbuf::Type::Struct_ ? static_cast<const org::apache::arrow::flatbuf::Struct_ *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Union *type_as_Union() const { - return type_type() == org::apache::arrow::flatbuf::Type::Union ? static_cast<const org::apache::arrow::flatbuf::Union *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::FixedSizeBinary *type_as_FixedSizeBinary() const { - return type_type() == org::apache::arrow::flatbuf::Type::FixedSizeBinary ? static_cast<const org::apache::arrow::flatbuf::FixedSizeBinary *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::FixedSizeList *type_as_FixedSizeList() const { - return type_type() == org::apache::arrow::flatbuf::Type::FixedSizeList ? static_cast<const org::apache::arrow::flatbuf::FixedSizeList *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Map *type_as_Map() const { - return type_type() == org::apache::arrow::flatbuf::Type::Map ? static_cast<const org::apache::arrow::flatbuf::Map *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::Duration *type_as_Duration() const { - return type_type() == org::apache::arrow::flatbuf::Type::Duration ? static_cast<const org::apache::arrow::flatbuf::Duration *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::LargeBinary *type_as_LargeBinary() const { - return type_type() == org::apache::arrow::flatbuf::Type::LargeBinary ? static_cast<const org::apache::arrow::flatbuf::LargeBinary *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::LargeUtf8 *type_as_LargeUtf8() const { - return type_type() == org::apache::arrow::flatbuf::Type::LargeUtf8 ? static_cast<const org::apache::arrow::flatbuf::LargeUtf8 *>(type()) : nullptr; - } - const org::apache::arrow::flatbuf::LargeList *type_as_LargeList() const { - return type_type() == org::apache::arrow::flatbuf::Type::LargeList ? static_cast<const org::apache::arrow::flatbuf::LargeList *>(type()) : nullptr; - } - /// The dimensions of the tensor, optionally named - const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::TensorDim>> *shape() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::TensorDim>> *>(VT_SHAPE); - } - /// Non-negative byte offsets to advance one value cell along each dimension - /// If omitted, default to row-major order (C-like). - const flatbuffers::Vector<int64_t> *strides() const { - return GetPointer<const flatbuffers::Vector<int64_t> *>(VT_STRIDES); - } - /// The location and size of the tensor's data - const org::apache::arrow::flatbuf::Buffer *data() const { - return GetStruct<const org::apache::arrow::flatbuf::Buffer *>(VT_DATA); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<uint8_t>(verifier, VT_TYPE_TYPE) && - VerifyOffsetRequired(verifier, VT_TYPE) && - VerifyType(verifier, type(), type_type()) && - VerifyOffsetRequired(verifier, VT_SHAPE) && - verifier.VerifyVector(shape()) && - verifier.VerifyVectorOfTables(shape()) && - VerifyOffset(verifier, VT_STRIDES) && - verifier.VerifyVector(strides()) && - VerifyFieldRequired<org::apache::arrow::flatbuf::Buffer>(verifier, VT_DATA) && - verifier.EndTable(); - } -}; - -template<> inline const org::apache::arrow::flatbuf::Null *Tensor::type_as<org::apache::arrow::flatbuf::Null>() const { - return type_as_Null(); -} - -template<> inline const org::apache::arrow::flatbuf::Int *Tensor::type_as<org::apache::arrow::flatbuf::Int>() const { - return type_as_Int(); -} - -template<> inline const org::apache::arrow::flatbuf::FloatingPoint *Tensor::type_as<org::apache::arrow::flatbuf::FloatingPoint>() const { - return type_as_FloatingPoint(); -} - -template<> inline const org::apache::arrow::flatbuf::Binary *Tensor::type_as<org::apache::arrow::flatbuf::Binary>() const { - return type_as_Binary(); -} - -template<> inline const org::apache::arrow::flatbuf::Utf8 *Tensor::type_as<org::apache::arrow::flatbuf::Utf8>() const { - return type_as_Utf8(); -} - -template<> inline const org::apache::arrow::flatbuf::Bool *Tensor::type_as<org::apache::arrow::flatbuf::Bool>() const { - return type_as_Bool(); -} - -template<> inline const org::apache::arrow::flatbuf::Decimal *Tensor::type_as<org::apache::arrow::flatbuf::Decimal>() const { - return type_as_Decimal(); -} - -template<> inline const org::apache::arrow::flatbuf::Date *Tensor::type_as<org::apache::arrow::flatbuf::Date>() const { - return type_as_Date(); -} - -template<> inline const org::apache::arrow::flatbuf::Time *Tensor::type_as<org::apache::arrow::flatbuf::Time>() const { - return type_as_Time(); -} - -template<> inline const org::apache::arrow::flatbuf::Timestamp *Tensor::type_as<org::apache::arrow::flatbuf::Timestamp>() const { - return type_as_Timestamp(); -} - -template<> inline const org::apache::arrow::flatbuf::Interval *Tensor::type_as<org::apache::arrow::flatbuf::Interval>() const { - return type_as_Interval(); -} - -template<> inline const org::apache::arrow::flatbuf::List *Tensor::type_as<org::apache::arrow::flatbuf::List>() const { - return type_as_List(); -} - -template<> inline const org::apache::arrow::flatbuf::Struct_ *Tensor::type_as<org::apache::arrow::flatbuf::Struct_>() const { - return type_as_Struct_(); -} - -template<> inline const org::apache::arrow::flatbuf::Union *Tensor::type_as<org::apache::arrow::flatbuf::Union>() const { - return type_as_Union(); -} - -template<> inline const org::apache::arrow::flatbuf::FixedSizeBinary *Tensor::type_as<org::apache::arrow::flatbuf::FixedSizeBinary>() const { - return type_as_FixedSizeBinary(); -} - -template<> inline const org::apache::arrow::flatbuf::FixedSizeList *Tensor::type_as<org::apache::arrow::flatbuf::FixedSizeList>() const { - return type_as_FixedSizeList(); -} - -template<> inline const org::apache::arrow::flatbuf::Map *Tensor::type_as<org::apache::arrow::flatbuf::Map>() const { - return type_as_Map(); -} - -template<> inline const org::apache::arrow::flatbuf::Duration *Tensor::type_as<org::apache::arrow::flatbuf::Duration>() const { - return type_as_Duration(); -} - -template<> inline const org::apache::arrow::flatbuf::LargeBinary *Tensor::type_as<org::apache::arrow::flatbuf::LargeBinary>() const { - return type_as_LargeBinary(); -} - -template<> inline const org::apache::arrow::flatbuf::LargeUtf8 *Tensor::type_as<org::apache::arrow::flatbuf::LargeUtf8>() const { - return type_as_LargeUtf8(); -} - -template<> inline const org::apache::arrow::flatbuf::LargeList *Tensor::type_as<org::apache::arrow::flatbuf::LargeList>() const { - return type_as_LargeList(); -} - -struct TensorBuilder { - typedef Tensor Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_type_type(org::apache::arrow::flatbuf::Type type_type) { - fbb_.AddElement<uint8_t>(Tensor::VT_TYPE_TYPE, static_cast<uint8_t>(type_type), 0); - } - void add_type(flatbuffers::Offset<void> type) { - fbb_.AddOffset(Tensor::VT_TYPE, type); - } - void add_shape(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::TensorDim>>> shape) { - fbb_.AddOffset(Tensor::VT_SHAPE, shape); - } - void add_strides(flatbuffers::Offset<flatbuffers::Vector<int64_t>> strides) { - fbb_.AddOffset(Tensor::VT_STRIDES, strides); - } - void add_data(const org::apache::arrow::flatbuf::Buffer *data) { - fbb_.AddStruct(Tensor::VT_DATA, data); - } - explicit TensorBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - TensorBuilder &operator=(const TensorBuilder &); - flatbuffers::Offset<Tensor> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Tensor>(end); - fbb_.Required(o, Tensor::VT_TYPE); - fbb_.Required(o, Tensor::VT_SHAPE); - fbb_.Required(o, Tensor::VT_DATA); - return o; - } -}; - -inline flatbuffers::Offset<Tensor> CreateTensor( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::Type type_type = org::apache::arrow::flatbuf::Type::NONE, - flatbuffers::Offset<void> type = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::TensorDim>>> shape = 0, - flatbuffers::Offset<flatbuffers::Vector<int64_t>> strides = 0, - const org::apache::arrow::flatbuf::Buffer *data = 0) { - TensorBuilder builder_(_fbb); - builder_.add_data(data); - builder_.add_strides(strides); - builder_.add_shape(shape); - builder_.add_type(type); - builder_.add_type_type(type_type); - return builder_.Finish(); -} - -inline flatbuffers::Offset<Tensor> CreateTensorDirect( - flatbuffers::FlatBufferBuilder &_fbb, - org::apache::arrow::flatbuf::Type type_type = org::apache::arrow::flatbuf::Type::NONE, - flatbuffers::Offset<void> type = 0, - const std::vector<flatbuffers::Offset<org::apache::arrow::flatbuf::TensorDim>> *shape = nullptr, - const std::vector<int64_t> *strides = nullptr, - const org::apache::arrow::flatbuf::Buffer *data = 0) { - auto shape__ = shape ? _fbb.CreateVector<flatbuffers::Offset<org::apache::arrow::flatbuf::TensorDim>>(*shape) : 0; - auto strides__ = strides ? _fbb.CreateVector<int64_t>(*strides) : 0; - return org::apache::arrow::flatbuf::CreateTensor( - _fbb, - type_type, - type, - shape__, - strides__, - data); -} - -inline const org::apache::arrow::flatbuf::Tensor *GetTensor(const void *buf) { - return flatbuffers::GetRoot<org::apache::arrow::flatbuf::Tensor>(buf); -} - -inline const org::apache::arrow::flatbuf::Tensor *GetSizePrefixedTensor(const void *buf) { - return flatbuffers::GetSizePrefixedRoot<org::apache::arrow::flatbuf::Tensor>(buf); -} - -inline bool VerifyTensorBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer<org::apache::arrow::flatbuf::Tensor>(nullptr); -} - -inline bool VerifySizePrefixedTensorBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifySizePrefixedBuffer<org::apache::arrow::flatbuf::Tensor>(nullptr); -} - -inline void FinishTensorBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<org::apache::arrow::flatbuf::Tensor> root) { - fbb.Finish(root); -} - -inline void FinishSizePrefixedTensorBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<org::apache::arrow::flatbuf::Tensor> root) { - fbb.FinishSizePrefixed(root); -} - -} // namespace flatbuf -} // namespace arrow -} // namespace apache -} // namespace org - -#endif // FLATBUFFERS_GENERATED_TENSOR_ORG_APACHE_ARROW_FLATBUF_H_ diff --git a/contrib/libs/apache/arrow/cpp/src/generated/feather.fbs b/contrib/libs/apache/arrow/cpp/src/generated/feather.fbs new file mode 100644 index 0000000000..50cc104199 --- /dev/null +++ b/contrib/libs/apache/arrow/cpp/src/generated/feather.fbs @@ -0,0 +1,156 @@ +// 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. + +/// DEPRECATED: Feather V2 is available starting in version 0.17.0 and does not +/// use this file at all. + +namespace arrow.ipc.feather.fbs; + +/// Feather is an experimental serialization format implemented using +/// techniques from Apache Arrow. It was created as a proof-of-concept of an +/// interoperable file format for storing data frames originating in Python or +/// R. It enabled the developers to sidestep some of the open design questions +/// in Arrow from early 2016 and instead create something simple and useful for +/// the intended use cases. + +enum Type : byte { + BOOL = 0, + + INT8 = 1, + INT16 = 2, + INT32 = 3, + INT64 = 4, + + UINT8 = 5, + UINT16 = 6, + UINT32 = 7, + UINT64 = 8, + + FLOAT = 9, + DOUBLE = 10, + + UTF8 = 11, + + BINARY = 12, + + CATEGORY = 13, + + TIMESTAMP = 14, + DATE = 15, + TIME = 16, + + LARGE_UTF8 = 17, + LARGE_BINARY = 18 +} + +enum Encoding : byte { + PLAIN = 0, + + /// Data is stored dictionary-encoded + /// dictionary size: <INT32 Dictionary size> + /// dictionary data: <TYPE primitive array> + /// dictionary index: <INT32 primitive array> + /// + /// TODO: do we care about storing the index values in a smaller typeclass + DICTIONARY = 1 +} + +enum TimeUnit : byte { + SECOND = 0, + MILLISECOND = 1, + MICROSECOND = 2, + NANOSECOND = 3 +} + +table PrimitiveArray { + type: Type; + + encoding: Encoding = PLAIN; + + /// Relative memory offset of the start of the array data excluding the size + /// of the metadata + offset: long; + + /// The number of logical values in the array + length: long; + + /// The number of observed nulls + null_count: long; + + /// The total size of the actual data in the file + total_bytes: long; + + /// TODO: Compression +} + +table CategoryMetadata { + /// The category codes are presumed to be integers that are valid indexes into + /// the levels array + + levels: PrimitiveArray; + ordered: bool = false; +} + +table TimestampMetadata { + unit: TimeUnit; + + /// Timestamp data is assumed to be UTC, but the time zone is stored here for + /// presentation as localized + time_zone: string; +} + +table DateMetadata { +} + +table TimeMetadata { + unit: TimeUnit; +} + +union TypeMetadata { + CategoryMetadata, + TimestampMetadata, + DateMetadata, + TimeMetadata, +} + +table Column { + name: string; + values: PrimitiveArray; + metadata: TypeMetadata; + + /// This should (probably) be JSON + user_metadata: string; +} + +table CTable { + /// Some text (or a name) metadata about what the file is, optional + description: string; + + num_rows: long; + columns: [Column]; + + /// Version number of the Feather format + /// + /// Internal versions 0, 1, and 2: Implemented in Apache Arrow <= 0.16.0 and + /// wesm/feather. Uses "custom" metadata defined in this file. + version: int; + + /// Table metadata (likely JSON), not yet used + metadata: string; +} + +root_type CTable; diff --git a/contrib/libs/apache/arrow/cpp/src/generated/feather_generated.h b/contrib/libs/apache/arrow/cpp/src/generated/feather_generated.h deleted file mode 100644 index b925eb2bc6..0000000000 --- a/contrib/libs/apache/arrow/cpp/src/generated/feather_generated.h +++ /dev/null @@ -1,863 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_FEATHER_ARROW_IPC_FEATHER_FBS_H_ -#define FLATBUFFERS_GENERATED_FEATHER_ARROW_IPC_FEATHER_FBS_H_ - -#include "flatbuffers/flatbuffers.h" - -namespace arrow { -namespace ipc { -namespace feather { -namespace fbs { - -struct PrimitiveArray; -struct PrimitiveArrayBuilder; - -struct CategoryMetadata; -struct CategoryMetadataBuilder; - -struct TimestampMetadata; -struct TimestampMetadataBuilder; - -struct DateMetadata; -struct DateMetadataBuilder; - -struct TimeMetadata; -struct TimeMetadataBuilder; - -struct Column; -struct ColumnBuilder; - -struct CTable; -struct CTableBuilder; - -/// Feather is an experimental serialization format implemented using -/// techniques from Apache Arrow. It was created as a proof-of-concept of an -/// interoperable file format for storing data frames originating in Python or -/// R. It enabled the developers to sidestep some of the open design questions -/// in Arrow from early 2016 and instead create something simple and useful for -/// the intended use cases. -enum class Type : int8_t { - BOOL = 0, - INT8 = 1, - INT16 = 2, - INT32 = 3, - INT64 = 4, - UINT8 = 5, - UINT16 = 6, - UINT32 = 7, - UINT64 = 8, - FLOAT = 9, - DOUBLE = 10, - UTF8 = 11, - BINARY = 12, - CATEGORY = 13, - TIMESTAMP = 14, - DATE = 15, - TIME = 16, - LARGE_UTF8 = 17, - LARGE_BINARY = 18, - MIN = BOOL, - MAX = LARGE_BINARY -}; - -inline const Type (&EnumValuesType())[19] { - static const Type values[] = { - Type::BOOL, - Type::INT8, - Type::INT16, - Type::INT32, - Type::INT64, - Type::UINT8, - Type::UINT16, - Type::UINT32, - Type::UINT64, - Type::FLOAT, - Type::DOUBLE, - Type::UTF8, - Type::BINARY, - Type::CATEGORY, - Type::TIMESTAMP, - Type::DATE, - Type::TIME, - Type::LARGE_UTF8, - Type::LARGE_BINARY - }; - return values; -} - -inline const char * const *EnumNamesType() { - static const char * const names[20] = { - "BOOL", - "INT8", - "INT16", - "INT32", - "INT64", - "UINT8", - "UINT16", - "UINT32", - "UINT64", - "FLOAT", - "DOUBLE", - "UTF8", - "BINARY", - "CATEGORY", - "TIMESTAMP", - "DATE", - "TIME", - "LARGE_UTF8", - "LARGE_BINARY", - nullptr - }; - return names; -} - -inline const char *EnumNameType(Type e) { - if (flatbuffers::IsOutRange(e, Type::BOOL, Type::LARGE_BINARY)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesType()[index]; -} - -enum class Encoding : int8_t { - PLAIN = 0, - /// Data is stored dictionary-encoded - /// dictionary size: <INT32 Dictionary size> - /// dictionary data: <TYPE primitive array> - /// dictionary index: <INT32 primitive array> - /// - /// TODO: do we care about storing the index values in a smaller typeclass - DICTIONARY = 1, - MIN = PLAIN, - MAX = DICTIONARY -}; - -inline const Encoding (&EnumValuesEncoding())[2] { - static const Encoding values[] = { - Encoding::PLAIN, - Encoding::DICTIONARY - }; - return values; -} - -inline const char * const *EnumNamesEncoding() { - static const char * const names[3] = { - "PLAIN", - "DICTIONARY", - nullptr - }; - return names; -} - -inline const char *EnumNameEncoding(Encoding e) { - if (flatbuffers::IsOutRange(e, Encoding::PLAIN, Encoding::DICTIONARY)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesEncoding()[index]; -} - -enum class TimeUnit : int8_t { - SECOND = 0, - MILLISECOND = 1, - MICROSECOND = 2, - NANOSECOND = 3, - MIN = SECOND, - MAX = NANOSECOND -}; - -inline const TimeUnit (&EnumValuesTimeUnit())[4] { - static const TimeUnit values[] = { - TimeUnit::SECOND, - TimeUnit::MILLISECOND, - TimeUnit::MICROSECOND, - TimeUnit::NANOSECOND - }; - return values; -} - -inline const char * const *EnumNamesTimeUnit() { - static const char * const names[5] = { - "SECOND", - "MILLISECOND", - "MICROSECOND", - "NANOSECOND", - nullptr - }; - return names; -} - -inline const char *EnumNameTimeUnit(TimeUnit e) { - if (flatbuffers::IsOutRange(e, TimeUnit::SECOND, TimeUnit::NANOSECOND)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesTimeUnit()[index]; -} - -enum class TypeMetadata : uint8_t { - NONE = 0, - CategoryMetadata = 1, - TimestampMetadata = 2, - DateMetadata = 3, - TimeMetadata = 4, - MIN = NONE, - MAX = TimeMetadata -}; - -inline const TypeMetadata (&EnumValuesTypeMetadata())[5] { - static const TypeMetadata values[] = { - TypeMetadata::NONE, - TypeMetadata::CategoryMetadata, - TypeMetadata::TimestampMetadata, - TypeMetadata::DateMetadata, - TypeMetadata::TimeMetadata - }; - return values; -} - -inline const char * const *EnumNamesTypeMetadata() { - static const char * const names[6] = { - "NONE", - "CategoryMetadata", - "TimestampMetadata", - "DateMetadata", - "TimeMetadata", - nullptr - }; - return names; -} - -inline const char *EnumNameTypeMetadata(TypeMetadata e) { - if (flatbuffers::IsOutRange(e, TypeMetadata::NONE, TypeMetadata::TimeMetadata)) return ""; - const size_t index = static_cast<size_t>(e); - return EnumNamesTypeMetadata()[index]; -} - -template<typename T> struct TypeMetadataTraits { - static const TypeMetadata enum_value = TypeMetadata::NONE; -}; - -template<> struct TypeMetadataTraits<arrow::ipc::feather::fbs::CategoryMetadata> { - static const TypeMetadata enum_value = TypeMetadata::CategoryMetadata; -}; - -template<> struct TypeMetadataTraits<arrow::ipc::feather::fbs::TimestampMetadata> { - static const TypeMetadata enum_value = TypeMetadata::TimestampMetadata; -}; - -template<> struct TypeMetadataTraits<arrow::ipc::feather::fbs::DateMetadata> { - static const TypeMetadata enum_value = TypeMetadata::DateMetadata; -}; - -template<> struct TypeMetadataTraits<arrow::ipc::feather::fbs::TimeMetadata> { - static const TypeMetadata enum_value = TypeMetadata::TimeMetadata; -}; - -bool VerifyTypeMetadata(flatbuffers::Verifier &verifier, const void *obj, TypeMetadata type); -bool VerifyTypeMetadataVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types); - -struct PrimitiveArray FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef PrimitiveArrayBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_TYPE = 4, - VT_ENCODING = 6, - VT_OFFSET = 8, - VT_LENGTH = 10, - VT_NULL_COUNT = 12, - VT_TOTAL_BYTES = 14 - }; - arrow::ipc::feather::fbs::Type type() const { - return static_cast<arrow::ipc::feather::fbs::Type>(GetField<int8_t>(VT_TYPE, 0)); - } - arrow::ipc::feather::fbs::Encoding encoding() const { - return static_cast<arrow::ipc::feather::fbs::Encoding>(GetField<int8_t>(VT_ENCODING, 0)); - } - /// Relative memory offset of the start of the array data excluding the size - /// of the metadata - int64_t offset() const { - return GetField<int64_t>(VT_OFFSET, 0); - } - /// The number of logical values in the array - int64_t length() const { - return GetField<int64_t>(VT_LENGTH, 0); - } - /// The number of observed nulls - int64_t null_count() const { - return GetField<int64_t>(VT_NULL_COUNT, 0); - } - /// The total size of the actual data in the file - int64_t total_bytes() const { - return GetField<int64_t>(VT_TOTAL_BYTES, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int8_t>(verifier, VT_TYPE) && - VerifyField<int8_t>(verifier, VT_ENCODING) && - VerifyField<int64_t>(verifier, VT_OFFSET) && - VerifyField<int64_t>(verifier, VT_LENGTH) && - VerifyField<int64_t>(verifier, VT_NULL_COUNT) && - VerifyField<int64_t>(verifier, VT_TOTAL_BYTES) && - verifier.EndTable(); - } -}; - -struct PrimitiveArrayBuilder { - typedef PrimitiveArray Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_type(arrow::ipc::feather::fbs::Type type) { - fbb_.AddElement<int8_t>(PrimitiveArray::VT_TYPE, static_cast<int8_t>(type), 0); - } - void add_encoding(arrow::ipc::feather::fbs::Encoding encoding) { - fbb_.AddElement<int8_t>(PrimitiveArray::VT_ENCODING, static_cast<int8_t>(encoding), 0); - } - void add_offset(int64_t offset) { - fbb_.AddElement<int64_t>(PrimitiveArray::VT_OFFSET, offset, 0); - } - void add_length(int64_t length) { - fbb_.AddElement<int64_t>(PrimitiveArray::VT_LENGTH, length, 0); - } - void add_null_count(int64_t null_count) { - fbb_.AddElement<int64_t>(PrimitiveArray::VT_NULL_COUNT, null_count, 0); - } - void add_total_bytes(int64_t total_bytes) { - fbb_.AddElement<int64_t>(PrimitiveArray::VT_TOTAL_BYTES, total_bytes, 0); - } - explicit PrimitiveArrayBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - PrimitiveArrayBuilder &operator=(const PrimitiveArrayBuilder &); - flatbuffers::Offset<PrimitiveArray> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<PrimitiveArray>(end); - return o; - } -}; - -inline flatbuffers::Offset<PrimitiveArray> CreatePrimitiveArray( - flatbuffers::FlatBufferBuilder &_fbb, - arrow::ipc::feather::fbs::Type type = arrow::ipc::feather::fbs::Type::BOOL, - arrow::ipc::feather::fbs::Encoding encoding = arrow::ipc::feather::fbs::Encoding::PLAIN, - int64_t offset = 0, - int64_t length = 0, - int64_t null_count = 0, - int64_t total_bytes = 0) { - PrimitiveArrayBuilder builder_(_fbb); - builder_.add_total_bytes(total_bytes); - builder_.add_null_count(null_count); - builder_.add_length(length); - builder_.add_offset(offset); - builder_.add_encoding(encoding); - builder_.add_type(type); - return builder_.Finish(); -} - -struct CategoryMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef CategoryMetadataBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_LEVELS = 4, - VT_ORDERED = 6 - }; - /// The category codes are presumed to be integers that are valid indexes into - /// the levels array - const arrow::ipc::feather::fbs::PrimitiveArray *levels() const { - return GetPointer<const arrow::ipc::feather::fbs::PrimitiveArray *>(VT_LEVELS); - } - bool ordered() const { - return GetField<uint8_t>(VT_ORDERED, 0) != 0; - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_LEVELS) && - verifier.VerifyTable(levels()) && - VerifyField<uint8_t>(verifier, VT_ORDERED) && - verifier.EndTable(); - } -}; - -struct CategoryMetadataBuilder { - typedef CategoryMetadata Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_levels(flatbuffers::Offset<arrow::ipc::feather::fbs::PrimitiveArray> levels) { - fbb_.AddOffset(CategoryMetadata::VT_LEVELS, levels); - } - void add_ordered(bool ordered) { - fbb_.AddElement<uint8_t>(CategoryMetadata::VT_ORDERED, static_cast<uint8_t>(ordered), 0); - } - explicit CategoryMetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - CategoryMetadataBuilder &operator=(const CategoryMetadataBuilder &); - flatbuffers::Offset<CategoryMetadata> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<CategoryMetadata>(end); - return o; - } -}; - -inline flatbuffers::Offset<CategoryMetadata> CreateCategoryMetadata( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<arrow::ipc::feather::fbs::PrimitiveArray> levels = 0, - bool ordered = false) { - CategoryMetadataBuilder builder_(_fbb); - builder_.add_levels(levels); - builder_.add_ordered(ordered); - return builder_.Finish(); -} - -struct TimestampMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef TimestampMetadataBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_UNIT = 4, - VT_TIMEZONE = 6 - }; - arrow::ipc::feather::fbs::TimeUnit unit() const { - return static_cast<arrow::ipc::feather::fbs::TimeUnit>(GetField<int8_t>(VT_UNIT, 0)); - } - /// Timestamp data is assumed to be UTC, but the time zone is stored here for - /// presentation as localized - const flatbuffers::String *timezone() const { - return GetPointer<const flatbuffers::String *>(VT_TIMEZONE); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int8_t>(verifier, VT_UNIT) && - VerifyOffset(verifier, VT_TIMEZONE) && - verifier.VerifyString(timezone()) && - verifier.EndTable(); - } -}; - -struct TimestampMetadataBuilder { - typedef TimestampMetadata Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_unit(arrow::ipc::feather::fbs::TimeUnit unit) { - fbb_.AddElement<int8_t>(TimestampMetadata::VT_UNIT, static_cast<int8_t>(unit), 0); - } - void add_timezone(flatbuffers::Offset<flatbuffers::String> timezone) { - fbb_.AddOffset(TimestampMetadata::VT_TIMEZONE, timezone); - } - explicit TimestampMetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - TimestampMetadataBuilder &operator=(const TimestampMetadataBuilder &); - flatbuffers::Offset<TimestampMetadata> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<TimestampMetadata>(end); - return o; - } -}; - -inline flatbuffers::Offset<TimestampMetadata> CreateTimestampMetadata( - flatbuffers::FlatBufferBuilder &_fbb, - arrow::ipc::feather::fbs::TimeUnit unit = arrow::ipc::feather::fbs::TimeUnit::SECOND, - flatbuffers::Offset<flatbuffers::String> timezone = 0) { - TimestampMetadataBuilder builder_(_fbb); - builder_.add_timezone(timezone); - builder_.add_unit(unit); - return builder_.Finish(); -} - -inline flatbuffers::Offset<TimestampMetadata> CreateTimestampMetadataDirect( - flatbuffers::FlatBufferBuilder &_fbb, - arrow::ipc::feather::fbs::TimeUnit unit = arrow::ipc::feather::fbs::TimeUnit::SECOND, - const char *timezone = nullptr) { - auto timezone__ = timezone ? _fbb.CreateString(timezone) : 0; - return arrow::ipc::feather::fbs::CreateTimestampMetadata( - _fbb, - unit, - timezone__); -} - -struct DateMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef DateMetadataBuilder Builder; - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - verifier.EndTable(); - } -}; - -struct DateMetadataBuilder { - typedef DateMetadata Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - explicit DateMetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - DateMetadataBuilder &operator=(const DateMetadataBuilder &); - flatbuffers::Offset<DateMetadata> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<DateMetadata>(end); - return o; - } -}; - -inline flatbuffers::Offset<DateMetadata> CreateDateMetadata( - flatbuffers::FlatBufferBuilder &_fbb) { - DateMetadataBuilder builder_(_fbb); - return builder_.Finish(); -} - -struct TimeMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef TimeMetadataBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_UNIT = 4 - }; - arrow::ipc::feather::fbs::TimeUnit unit() const { - return static_cast<arrow::ipc::feather::fbs::TimeUnit>(GetField<int8_t>(VT_UNIT, 0)); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int8_t>(verifier, VT_UNIT) && - verifier.EndTable(); - } -}; - -struct TimeMetadataBuilder { - typedef TimeMetadata Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_unit(arrow::ipc::feather::fbs::TimeUnit unit) { - fbb_.AddElement<int8_t>(TimeMetadata::VT_UNIT, static_cast<int8_t>(unit), 0); - } - explicit TimeMetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - TimeMetadataBuilder &operator=(const TimeMetadataBuilder &); - flatbuffers::Offset<TimeMetadata> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<TimeMetadata>(end); - return o; - } -}; - -inline flatbuffers::Offset<TimeMetadata> CreateTimeMetadata( - flatbuffers::FlatBufferBuilder &_fbb, - arrow::ipc::feather::fbs::TimeUnit unit = arrow::ipc::feather::fbs::TimeUnit::SECOND) { - TimeMetadataBuilder builder_(_fbb); - builder_.add_unit(unit); - return builder_.Finish(); -} - -struct Column FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef ColumnBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_NAME = 4, - VT_VALUES = 6, - VT_METADATA_TYPE = 8, - VT_METADATA = 10, - VT_USER_METADATA = 12 - }; - const flatbuffers::String *name() const { - return GetPointer<const flatbuffers::String *>(VT_NAME); - } - const arrow::ipc::feather::fbs::PrimitiveArray *values() const { - return GetPointer<const arrow::ipc::feather::fbs::PrimitiveArray *>(VT_VALUES); - } - arrow::ipc::feather::fbs::TypeMetadata metadata_type() const { - return static_cast<arrow::ipc::feather::fbs::TypeMetadata>(GetField<uint8_t>(VT_METADATA_TYPE, 0)); - } - const void *metadata() const { - return GetPointer<const void *>(VT_METADATA); - } - template<typename T> const T *metadata_as() const; - const arrow::ipc::feather::fbs::CategoryMetadata *metadata_as_CategoryMetadata() const { - return metadata_type() == arrow::ipc::feather::fbs::TypeMetadata::CategoryMetadata ? static_cast<const arrow::ipc::feather::fbs::CategoryMetadata *>(metadata()) : nullptr; - } - const arrow::ipc::feather::fbs::TimestampMetadata *metadata_as_TimestampMetadata() const { - return metadata_type() == arrow::ipc::feather::fbs::TypeMetadata::TimestampMetadata ? static_cast<const arrow::ipc::feather::fbs::TimestampMetadata *>(metadata()) : nullptr; - } - const arrow::ipc::feather::fbs::DateMetadata *metadata_as_DateMetadata() const { - return metadata_type() == arrow::ipc::feather::fbs::TypeMetadata::DateMetadata ? static_cast<const arrow::ipc::feather::fbs::DateMetadata *>(metadata()) : nullptr; - } - const arrow::ipc::feather::fbs::TimeMetadata *metadata_as_TimeMetadata() const { - return metadata_type() == arrow::ipc::feather::fbs::TypeMetadata::TimeMetadata ? static_cast<const arrow::ipc::feather::fbs::TimeMetadata *>(metadata()) : nullptr; - } - /// This should (probably) be JSON - const flatbuffers::String *user_metadata() const { - return GetPointer<const flatbuffers::String *>(VT_USER_METADATA); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_NAME) && - verifier.VerifyString(name()) && - VerifyOffset(verifier, VT_VALUES) && - verifier.VerifyTable(values()) && - VerifyField<uint8_t>(verifier, VT_METADATA_TYPE) && - VerifyOffset(verifier, VT_METADATA) && - VerifyTypeMetadata(verifier, metadata(), metadata_type()) && - VerifyOffset(verifier, VT_USER_METADATA) && - verifier.VerifyString(user_metadata()) && - verifier.EndTable(); - } -}; - -template<> inline const arrow::ipc::feather::fbs::CategoryMetadata *Column::metadata_as<arrow::ipc::feather::fbs::CategoryMetadata>() const { - return metadata_as_CategoryMetadata(); -} - -template<> inline const arrow::ipc::feather::fbs::TimestampMetadata *Column::metadata_as<arrow::ipc::feather::fbs::TimestampMetadata>() const { - return metadata_as_TimestampMetadata(); -} - -template<> inline const arrow::ipc::feather::fbs::DateMetadata *Column::metadata_as<arrow::ipc::feather::fbs::DateMetadata>() const { - return metadata_as_DateMetadata(); -} - -template<> inline const arrow::ipc::feather::fbs::TimeMetadata *Column::metadata_as<arrow::ipc::feather::fbs::TimeMetadata>() const { - return metadata_as_TimeMetadata(); -} - -struct ColumnBuilder { - typedef Column Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset<flatbuffers::String> name) { - fbb_.AddOffset(Column::VT_NAME, name); - } - void add_values(flatbuffers::Offset<arrow::ipc::feather::fbs::PrimitiveArray> values) { - fbb_.AddOffset(Column::VT_VALUES, values); - } - void add_metadata_type(arrow::ipc::feather::fbs::TypeMetadata metadata_type) { - fbb_.AddElement<uint8_t>(Column::VT_METADATA_TYPE, static_cast<uint8_t>(metadata_type), 0); - } - void add_metadata(flatbuffers::Offset<void> metadata) { - fbb_.AddOffset(Column::VT_METADATA, metadata); - } - void add_user_metadata(flatbuffers::Offset<flatbuffers::String> user_metadata) { - fbb_.AddOffset(Column::VT_USER_METADATA, user_metadata); - } - explicit ColumnBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - ColumnBuilder &operator=(const ColumnBuilder &); - flatbuffers::Offset<Column> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<Column>(end); - return o; - } -}; - -inline flatbuffers::Offset<Column> CreateColumn( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> name = 0, - flatbuffers::Offset<arrow::ipc::feather::fbs::PrimitiveArray> values = 0, - arrow::ipc::feather::fbs::TypeMetadata metadata_type = arrow::ipc::feather::fbs::TypeMetadata::NONE, - flatbuffers::Offset<void> metadata = 0, - flatbuffers::Offset<flatbuffers::String> user_metadata = 0) { - ColumnBuilder builder_(_fbb); - builder_.add_user_metadata(user_metadata); - builder_.add_metadata(metadata); - builder_.add_values(values); - builder_.add_name(name); - builder_.add_metadata_type(metadata_type); - return builder_.Finish(); -} - -inline flatbuffers::Offset<Column> CreateColumnDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *name = nullptr, - flatbuffers::Offset<arrow::ipc::feather::fbs::PrimitiveArray> values = 0, - arrow::ipc::feather::fbs::TypeMetadata metadata_type = arrow::ipc::feather::fbs::TypeMetadata::NONE, - flatbuffers::Offset<void> metadata = 0, - const char *user_metadata = nullptr) { - auto name__ = name ? _fbb.CreateString(name) : 0; - auto user_metadata__ = user_metadata ? _fbb.CreateString(user_metadata) : 0; - return arrow::ipc::feather::fbs::CreateColumn( - _fbb, - name__, - values, - metadata_type, - metadata, - user_metadata__); -} - -struct CTable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef CTableBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_DESCRIPTION = 4, - VT_NUM_ROWS = 6, - VT_COLUMNS = 8, - VT_VERSION = 10, - VT_METADATA = 12 - }; - /// Some text (or a name) metadata about what the file is, optional - const flatbuffers::String *description() const { - return GetPointer<const flatbuffers::String *>(VT_DESCRIPTION); - } - int64_t num_rows() const { - return GetField<int64_t>(VT_NUM_ROWS, 0); - } - const flatbuffers::Vector<flatbuffers::Offset<arrow::ipc::feather::fbs::Column>> *columns() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<arrow::ipc::feather::fbs::Column>> *>(VT_COLUMNS); - } - /// Version number of the Feather format - /// - /// Internal versions 0, 1, and 2: Implemented in Apache Arrow <= 0.16.0 and - /// wesm/feather. Uses "custom" metadata defined in this file. - int32_t version() const { - return GetField<int32_t>(VT_VERSION, 0); - } - /// Table metadata (likely JSON), not yet used - const flatbuffers::String *metadata() const { - return GetPointer<const flatbuffers::String *>(VT_METADATA); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_DESCRIPTION) && - verifier.VerifyString(description()) && - VerifyField<int64_t>(verifier, VT_NUM_ROWS) && - VerifyOffset(verifier, VT_COLUMNS) && - verifier.VerifyVector(columns()) && - verifier.VerifyVectorOfTables(columns()) && - VerifyField<int32_t>(verifier, VT_VERSION) && - VerifyOffset(verifier, VT_METADATA) && - verifier.VerifyString(metadata()) && - verifier.EndTable(); - } -}; - -struct CTableBuilder { - typedef CTable Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_description(flatbuffers::Offset<flatbuffers::String> description) { - fbb_.AddOffset(CTable::VT_DESCRIPTION, description); - } - void add_num_rows(int64_t num_rows) { - fbb_.AddElement<int64_t>(CTable::VT_NUM_ROWS, num_rows, 0); - } - void add_columns(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<arrow::ipc::feather::fbs::Column>>> columns) { - fbb_.AddOffset(CTable::VT_COLUMNS, columns); - } - void add_version(int32_t version) { - fbb_.AddElement<int32_t>(CTable::VT_VERSION, version, 0); - } - void add_metadata(flatbuffers::Offset<flatbuffers::String> metadata) { - fbb_.AddOffset(CTable::VT_METADATA, metadata); - } - explicit CTableBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - CTableBuilder &operator=(const CTableBuilder &); - flatbuffers::Offset<CTable> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<CTable>(end); - return o; - } -}; - -inline flatbuffers::Offset<CTable> CreateCTable( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> description = 0, - int64_t num_rows = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<arrow::ipc::feather::fbs::Column>>> columns = 0, - int32_t version = 0, - flatbuffers::Offset<flatbuffers::String> metadata = 0) { - CTableBuilder builder_(_fbb); - builder_.add_num_rows(num_rows); - builder_.add_metadata(metadata); - builder_.add_version(version); - builder_.add_columns(columns); - builder_.add_description(description); - return builder_.Finish(); -} - -inline flatbuffers::Offset<CTable> CreateCTableDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *description = nullptr, - int64_t num_rows = 0, - const std::vector<flatbuffers::Offset<arrow::ipc::feather::fbs::Column>> *columns = nullptr, - int32_t version = 0, - const char *metadata = nullptr) { - auto description__ = description ? _fbb.CreateString(description) : 0; - auto columns__ = columns ? _fbb.CreateVector<flatbuffers::Offset<arrow::ipc::feather::fbs::Column>>(*columns) : 0; - auto metadata__ = metadata ? _fbb.CreateString(metadata) : 0; - return arrow::ipc::feather::fbs::CreateCTable( - _fbb, - description__, - num_rows, - columns__, - version, - metadata__); -} - -inline bool VerifyTypeMetadata(flatbuffers::Verifier &verifier, const void *obj, TypeMetadata type) { - switch (type) { - case TypeMetadata::NONE: { - return true; - } - case TypeMetadata::CategoryMetadata: { - auto ptr = reinterpret_cast<const arrow::ipc::feather::fbs::CategoryMetadata *>(obj); - return verifier.VerifyTable(ptr); - } - case TypeMetadata::TimestampMetadata: { - auto ptr = reinterpret_cast<const arrow::ipc::feather::fbs::TimestampMetadata *>(obj); - return verifier.VerifyTable(ptr); - } - case TypeMetadata::DateMetadata: { - auto ptr = reinterpret_cast<const arrow::ipc::feather::fbs::DateMetadata *>(obj); - return verifier.VerifyTable(ptr); - } - case TypeMetadata::TimeMetadata: { - auto ptr = reinterpret_cast<const arrow::ipc::feather::fbs::TimeMetadata *>(obj); - return verifier.VerifyTable(ptr); - } - default: return true; - } -} - -inline bool VerifyTypeMetadataVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *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 (!VerifyTypeMetadata( - verifier, values->Get(i), types->GetEnum<TypeMetadata>(i))) { - return false; - } - } - return true; -} - -inline const arrow::ipc::feather::fbs::CTable *GetCTable(const void *buf) { - return flatbuffers::GetRoot<arrow::ipc::feather::fbs::CTable>(buf); -} - -inline const arrow::ipc::feather::fbs::CTable *GetSizePrefixedCTable(const void *buf) { - return flatbuffers::GetSizePrefixedRoot<arrow::ipc::feather::fbs::CTable>(buf); -} - -inline bool VerifyCTableBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer<arrow::ipc::feather::fbs::CTable>(nullptr); -} - -inline bool VerifySizePrefixedCTableBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifySizePrefixedBuffer<arrow::ipc::feather::fbs::CTable>(nullptr); -} - -inline void FinishCTableBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<arrow::ipc::feather::fbs::CTable> root) { - fbb.Finish(root); -} - -inline void FinishSizePrefixedCTableBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<arrow::ipc::feather::fbs::CTable> root) { - fbb.FinishSizePrefixed(root); -} - -} // namespace fbs -} // namespace feather -} // namespace ipc -} // namespace arrow - -#endif // FLATBUFFERS_GENERATED_FEATHER_ARROW_IPC_FEATHER_FBS_H_ diff --git a/contrib/libs/apache/arrow/ya.make b/contrib/libs/apache/arrow/ya.make index 9986f9107c..f4ed4463d1 100644 --- a/contrib/libs/apache/arrow/ya.make +++ b/contrib/libs/apache/arrow/ya.make @@ -41,6 +41,7 @@ PEERDIR( ) ADDINCL( + GLOBAL ${ARCADIA_BUILD_ROOT}/contrib/libs/apache/arrow/cpp/src GLOBAL contrib/libs/apache/arrow/cpp/src GLOBAL contrib/libs/apache/arrow/src contrib/libs/apache/arrow/cpp/src/generated @@ -80,6 +81,8 @@ IF (NOT OS_WINDOWS) ) ENDIF() +FLATC_FLAGS(--scoped-enums) + SRCS( cpp/src/arrow/adapters/orc/adapter.cc cpp/src/arrow/adapters/orc/adapter_util.cc @@ -249,6 +252,12 @@ SRCS( cpp/src/arrow/vendored/datetime/tz.cpp cpp/src/arrow/vendored/musl/strptime.c cpp/src/arrow/visitor.cc + cpp/src/generated/File.fbs + cpp/src/generated/Message.fbs + cpp/src/generated/Schema.fbs + cpp/src/generated/SparseTensor.fbs + cpp/src/generated/Tensor.fbs + cpp/src/generated/feather.fbs cpp/src/generated/parquet_constants.cpp cpp/src/generated/parquet_types.cpp cpp/src/parquet/arrow/path_internal.cc |