mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
arrow headers generated by flatc are moved from src to binary
This commit is contained in:
parent
32995e3ad5
commit
cc13466baa
@ -102,10 +102,16 @@ add_subdirectory(${FLATBUFFERS_SRC_DIR} "${FLATBUFFERS_BINARY_DIR}")
|
||||
set(ARROW_IPC_SRC_DIR ${ARROW_SRC_DIR}/arrow/ipc)
|
||||
set(ARROW_FORMAT_SRC_DIR ${ARROW_SRC_DIR}/../../format)
|
||||
|
||||
set(FLATBUFFERS_COMPILED_OUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cpp/src/arrow/ipc)
|
||||
set(ARROW_GENERATED_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/arrow_gen_headers)
|
||||
set(FLATBUFFERS_COMPILED_OUT_DIR ${ARROW_GENERATED_INCLUDE_DIR}/arrow/ipc)
|
||||
|
||||
set(FBS_OUTPUT_FILES "${FLATBUFFERS_COMPILED_OUT_DIR}/File_generated.h" "${FLATBUFFERS_COMPILED_OUT_DIR}/Message_generated.h"
|
||||
"${FLATBUFFERS_COMPILED_OUT_DIR}/feather_generated.h")
|
||||
set(FBS_OUTPUT_FILES
|
||||
"${FLATBUFFERS_COMPILED_OUT_DIR}/File_generated.h"
|
||||
"${FLATBUFFERS_COMPILED_OUT_DIR}/Message_generated.h"
|
||||
"${FLATBUFFERS_COMPILED_OUT_DIR}/feather_generated.h"
|
||||
"${FLATBUFFERS_COMPILED_OUT_DIR}/Schema_generated.h"
|
||||
"${FLATBUFFERS_COMPILED_OUT_DIR}/SparseTensor_generated.h"
|
||||
"${FLATBUFFERS_COMPILED_OUT_DIR}/Tensor_generated.h")
|
||||
|
||||
set(FBS_SRC
|
||||
${ARROW_FORMAT_SRC_DIR}/Message.fbs
|
||||
@ -137,7 +143,7 @@ add_custom_command(OUTPUT ${FBS_OUTPUT_FILES}
|
||||
add_custom_target(metadata_fbs DEPENDS ${FBS_OUTPUT_FILES})
|
||||
add_dependencies(metadata_fbs flatc)
|
||||
|
||||
# arrow-cmake cmake file calling orc cmake subroutine which detects certain compiler features.
|
||||
# arrow-cmake cmake file calling orc cmake subroutine which detects certain compiler features.
|
||||
# Apple Clang compiler failed to compile this code without specifying c++11 standard.
|
||||
# As result these compiler features detected as absent. In result it failed to compile orc itself.
|
||||
# In orc makefile there is code that sets flags, but arrow-cmake ignores these flags.
|
||||
@ -231,12 +237,10 @@ set(ARROW_SRCS
|
||||
|
||||
${LIBRARY_DIR}/ipc/dictionary.cc
|
||||
${LIBRARY_DIR}/ipc/feather.cc
|
||||
# ${LIBRARY_DIR}/ipc/file_to_stream.cc
|
||||
${LIBRARY_DIR}/ipc/message.cc
|
||||
${LIBRARY_DIR}/ipc/metadata_internal.cc
|
||||
${LIBRARY_DIR}/ipc/options.cc
|
||||
${LIBRARY_DIR}/ipc/reader.cc
|
||||
# ${LIBRARY_DIR}/ipc/stream_to_file.cc
|
||||
${LIBRARY_DIR}/ipc/writer.cc
|
||||
|
||||
${LIBRARY_DIR}/io/buffered.cc
|
||||
@ -249,8 +253,6 @@ set(ARROW_SRCS
|
||||
|
||||
${LIBRARY_DIR}/util/basic_decimal.cc
|
||||
${LIBRARY_DIR}/util/bit_util.cc
|
||||
# ${LIBRARY_DIR}/util/compression_brotli.cc
|
||||
# ${LIBRARY_DIR}/util/compression_bz2.cc
|
||||
${LIBRARY_DIR}/util/compression.cc
|
||||
${LIBRARY_DIR}/util/compression_lz4.cc
|
||||
${LIBRARY_DIR}/util/compression_snappy.cc
|
||||
@ -268,7 +270,6 @@ set(ARROW_SRCS
|
||||
${LIBRARY_DIR}/util/task_group.cc
|
||||
${LIBRARY_DIR}/util/thread_pool.cc
|
||||
${LIBRARY_DIR}/util/trie.cc
|
||||
# ${LIBRARY_DIR}/util/uri.cc
|
||||
${LIBRARY_DIR}/util/utf8.cc
|
||||
|
||||
${LIBRARY_DIR}/vendored/base64.cpp
|
||||
@ -356,6 +357,8 @@ target_include_directories(${ARROW_LIBRARY} PRIVATE SYSTEM ${ORC_BUILD_INCLUDE_D
|
||||
target_include_directories(${ARROW_LIBRARY} PRIVATE SYSTEM ${ORC_ADDITION_SOURCE_DIR})
|
||||
target_include_directories(${ARROW_LIBRARY} PRIVATE SYSTEM ${ARROW_SRC_DIR})
|
||||
target_include_directories(${ARROW_LIBRARY} PRIVATE SYSTEM ${FLATBUFFERS_INCLUDE_DIR})
|
||||
target_include_directories(${ARROW_LIBRARY} PRIVATE SYSTEM ${ARROW_GENERATED_INCLUDE_DIR})
|
||||
|
||||
# === parquet
|
||||
|
||||
set(LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/arrow/cpp/src/parquet)
|
||||
|
@ -1,181 +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 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 metatdata).
|
||||
int64_t bodyLength() const {
|
||||
return flatbuffers::EndianScalar(bodyLength_);
|
||||
}
|
||||
};
|
||||
FLATBUFFERS_STRUCT_END(Block, 24);
|
||||
|
||||
/// ----------------------------------------------------------------------
|
||||
/// Arrow File metadata
|
||||
///
|
||||
struct Footer FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_VERSION = 4,
|
||||
VT_SCHEMA = 6,
|
||||
VT_DICTIONARIES = 8,
|
||||
VT_RECORDBATCHES = 10
|
||||
};
|
||||
MetadataVersion version() const {
|
||||
return static_cast<MetadataVersion>(GetField<int16_t>(VT_VERSION, 0));
|
||||
}
|
||||
const Schema *schema() const {
|
||||
return GetPointer<const Schema *>(VT_SCHEMA);
|
||||
}
|
||||
const flatbuffers::Vector<const Block *> *dictionaries() const {
|
||||
return GetPointer<const flatbuffers::Vector<const Block *> *>(VT_DICTIONARIES);
|
||||
}
|
||||
const flatbuffers::Vector<const Block *> *recordBatches() const {
|
||||
return GetPointer<const flatbuffers::Vector<const Block *> *>(VT_RECORDBATCHES);
|
||||
}
|
||||
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()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct FooterBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_version(MetadataVersion version) {
|
||||
fbb_.AddElement<int16_t>(Footer::VT_VERSION, static_cast<int16_t>(version), 0);
|
||||
}
|
||||
void add_schema(flatbuffers::Offset<Schema> schema) {
|
||||
fbb_.AddOffset(Footer::VT_SCHEMA, schema);
|
||||
}
|
||||
void add_dictionaries(flatbuffers::Offset<flatbuffers::Vector<const Block *>> dictionaries) {
|
||||
fbb_.AddOffset(Footer::VT_DICTIONARIES, dictionaries);
|
||||
}
|
||||
void add_recordBatches(flatbuffers::Offset<flatbuffers::Vector<const Block *>> recordBatches) {
|
||||
fbb_.AddOffset(Footer::VT_RECORDBATCHES, recordBatches);
|
||||
}
|
||||
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,
|
||||
MetadataVersion version = MetadataVersion_V1,
|
||||
flatbuffers::Offset<Schema> schema = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<const Block *>> dictionaries = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<const Block *>> recordBatches = 0) {
|
||||
FooterBuilder builder_(_fbb);
|
||||
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,
|
||||
MetadataVersion version = MetadataVersion_V1,
|
||||
flatbuffers::Offset<Schema> schema = 0,
|
||||
const std::vector<Block> *dictionaries = nullptr,
|
||||
const std::vector<Block> *recordBatches = nullptr) {
|
||||
auto dictionaries__ = dictionaries ? _fbb.CreateVectorOfStructs<Block>(*dictionaries) : 0;
|
||||
auto recordBatches__ = recordBatches ? _fbb.CreateVectorOfStructs<Block>(*recordBatches) : 0;
|
||||
return org::apache::arrow::flatbuf::CreateFooter(
|
||||
_fbb,
|
||||
version,
|
||||
schema,
|
||||
dictionaries__,
|
||||
recordBatches__);
|
||||
}
|
||||
|
||||
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_
|
@ -1,508 +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 RecordBatch;
|
||||
|
||||
struct DictionaryBatch;
|
||||
|
||||
struct Message;
|
||||
|
||||
/// ----------------------------------------------------------------------
|
||||
/// 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 MessageHeader {
|
||||
MessageHeader_NONE = 0,
|
||||
MessageHeader_Schema = 1,
|
||||
MessageHeader_DictionaryBatch = 2,
|
||||
MessageHeader_RecordBatch = 3,
|
||||
MessageHeader_Tensor = 4,
|
||||
MessageHeader_SparseTensor = 5,
|
||||
MessageHeader_MIN = MessageHeader_NONE,
|
||||
MessageHeader_MAX = MessageHeader_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[] = {
|
||||
"NONE",
|
||||
"Schema",
|
||||
"DictionaryBatch",
|
||||
"RecordBatch",
|
||||
"Tensor",
|
||||
"SparseTensor",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameMessageHeader(MessageHeader e) {
|
||||
if (e < MessageHeader_NONE || e > 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<Schema> {
|
||||
static const MessageHeader enum_value = MessageHeader_Schema;
|
||||
};
|
||||
|
||||
template<> struct MessageHeaderTraits<DictionaryBatch> {
|
||||
static const MessageHeader enum_value = MessageHeader_DictionaryBatch;
|
||||
};
|
||||
|
||||
template<> struct MessageHeaderTraits<RecordBatch> {
|
||||
static const MessageHeader enum_value = MessageHeader_RecordBatch;
|
||||
};
|
||||
|
||||
template<> struct MessageHeaderTraits<Tensor> {
|
||||
static const MessageHeader enum_value = MessageHeader_Tensor;
|
||||
};
|
||||
|
||||
template<> struct MessageHeaderTraits<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);
|
||||
|
||||
/// 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 {
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_LENGTH = 4,
|
||||
VT_NODES = 6,
|
||||
VT_BUFFERS = 8
|
||||
};
|
||||
/// 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 FieldNode *> *nodes() const {
|
||||
return GetPointer<const flatbuffers::Vector<const 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 Buffer *> *buffers() const {
|
||||
return GetPointer<const flatbuffers::Vector<const Buffer *> *>(VT_BUFFERS);
|
||||
}
|
||||
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()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct RecordBatchBuilder {
|
||||
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 FieldNode *>> nodes) {
|
||||
fbb_.AddOffset(RecordBatch::VT_NODES, nodes);
|
||||
}
|
||||
void add_buffers(flatbuffers::Offset<flatbuffers::Vector<const Buffer *>> buffers) {
|
||||
fbb_.AddOffset(RecordBatch::VT_BUFFERS, buffers);
|
||||
}
|
||||
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 FieldNode *>> nodes = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<const Buffer *>> buffers = 0) {
|
||||
RecordBatchBuilder builder_(_fbb);
|
||||
builder_.add_length(length);
|
||||
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<FieldNode> *nodes = nullptr,
|
||||
const std::vector<Buffer> *buffers = nullptr) {
|
||||
auto nodes__ = nodes ? _fbb.CreateVectorOfStructs<FieldNode>(*nodes) : 0;
|
||||
auto buffers__ = buffers ? _fbb.CreateVectorOfStructs<Buffer>(*buffers) : 0;
|
||||
return org::apache::arrow::flatbuf::CreateRecordBatch(
|
||||
_fbb,
|
||||
length,
|
||||
nodes__,
|
||||
buffers__);
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
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 RecordBatch *data() const {
|
||||
return GetPointer<const RecordBatch *>(VT_DATA);
|
||||
}
|
||||
/// If isDelta is true the values in the dictionary are to be appended to a
|
||||
/// dictionary with the indicated id
|
||||
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 {
|
||||
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<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<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 {
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_VERSION = 4,
|
||||
VT_HEADER_TYPE = 6,
|
||||
VT_HEADER = 8,
|
||||
VT_BODYLENGTH = 10,
|
||||
VT_CUSTOM_METADATA = 12
|
||||
};
|
||||
MetadataVersion version() const {
|
||||
return static_cast<MetadataVersion>(GetField<int16_t>(VT_VERSION, 0));
|
||||
}
|
||||
MessageHeader header_type() const {
|
||||
return static_cast<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 Schema *header_as_Schema() const {
|
||||
return header_type() == MessageHeader_Schema ? static_cast<const Schema *>(header()) : nullptr;
|
||||
}
|
||||
const DictionaryBatch *header_as_DictionaryBatch() const {
|
||||
return header_type() == MessageHeader_DictionaryBatch ? static_cast<const DictionaryBatch *>(header()) : nullptr;
|
||||
}
|
||||
const RecordBatch *header_as_RecordBatch() const {
|
||||
return header_type() == MessageHeader_RecordBatch ? static_cast<const RecordBatch *>(header()) : nullptr;
|
||||
}
|
||||
const Tensor *header_as_Tensor() const {
|
||||
return header_type() == MessageHeader_Tensor ? static_cast<const Tensor *>(header()) : nullptr;
|
||||
}
|
||||
const SparseTensor *header_as_SparseTensor() const {
|
||||
return header_type() == MessageHeader_SparseTensor ? static_cast<const SparseTensor *>(header()) : nullptr;
|
||||
}
|
||||
int64_t bodyLength() const {
|
||||
return GetField<int64_t>(VT_BODYLENGTH, 0);
|
||||
}
|
||||
const flatbuffers::Vector<flatbuffers::Offset<KeyValue>> *custom_metadata() const {
|
||||
return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<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 Schema *Message::header_as<Schema>() const {
|
||||
return header_as_Schema();
|
||||
}
|
||||
|
||||
template<> inline const DictionaryBatch *Message::header_as<DictionaryBatch>() const {
|
||||
return header_as_DictionaryBatch();
|
||||
}
|
||||
|
||||
template<> inline const RecordBatch *Message::header_as<RecordBatch>() const {
|
||||
return header_as_RecordBatch();
|
||||
}
|
||||
|
||||
template<> inline const Tensor *Message::header_as<Tensor>() const {
|
||||
return header_as_Tensor();
|
||||
}
|
||||
|
||||
template<> inline const SparseTensor *Message::header_as<SparseTensor>() const {
|
||||
return header_as_SparseTensor();
|
||||
}
|
||||
|
||||
struct MessageBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_version(MetadataVersion version) {
|
||||
fbb_.AddElement<int16_t>(Message::VT_VERSION, static_cast<int16_t>(version), 0);
|
||||
}
|
||||
void add_header_type(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<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,
|
||||
MetadataVersion version = MetadataVersion_V1,
|
||||
MessageHeader header_type = MessageHeader_NONE,
|
||||
flatbuffers::Offset<void> header = 0,
|
||||
int64_t bodyLength = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<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,
|
||||
MetadataVersion version = MetadataVersion_V1,
|
||||
MessageHeader header_type = MessageHeader_NONE,
|
||||
flatbuffers::Offset<void> header = 0,
|
||||
int64_t bodyLength = 0,
|
||||
const std::vector<flatbuffers::Offset<KeyValue>> *custom_metadata = nullptr) {
|
||||
auto custom_metadata__ = custom_metadata ? _fbb.CreateVector<flatbuffers::Offset<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 Schema *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
case MessageHeader_DictionaryBatch: {
|
||||
auto ptr = reinterpret_cast<const DictionaryBatch *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
case MessageHeader_RecordBatch: {
|
||||
auto ptr = reinterpret_cast<const RecordBatch *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
case MessageHeader_Tensor: {
|
||||
auto ptr = reinterpret_cast<const Tensor *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
case MessageHeader_SparseTensor: {
|
||||
auto ptr = reinterpret_cast<const SparseTensor *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
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_
|
File diff suppressed because it is too large
Load Diff
@ -1,644 +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 SparseMatrixIndexCSR;
|
||||
|
||||
struct SparseTensor;
|
||||
|
||||
enum SparseTensorIndex {
|
||||
SparseTensorIndex_NONE = 0,
|
||||
SparseTensorIndex_SparseTensorIndexCOO = 1,
|
||||
SparseTensorIndex_SparseMatrixIndexCSR = 2,
|
||||
SparseTensorIndex_MIN = SparseTensorIndex_NONE,
|
||||
SparseTensorIndex_MAX = SparseTensorIndex_SparseMatrixIndexCSR
|
||||
};
|
||||
|
||||
inline const SparseTensorIndex (&EnumValuesSparseTensorIndex())[3] {
|
||||
static const SparseTensorIndex values[] = {
|
||||
SparseTensorIndex_NONE,
|
||||
SparseTensorIndex_SparseTensorIndexCOO,
|
||||
SparseTensorIndex_SparseMatrixIndexCSR
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesSparseTensorIndex() {
|
||||
static const char * const names[] = {
|
||||
"NONE",
|
||||
"SparseTensorIndexCOO",
|
||||
"SparseMatrixIndexCSR",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameSparseTensorIndex(SparseTensorIndex e) {
|
||||
if (e < SparseTensorIndex_NONE || e > SparseTensorIndex_SparseMatrixIndexCSR) 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<SparseTensorIndexCOO> {
|
||||
static const SparseTensorIndex enum_value = SparseTensorIndex_SparseTensorIndexCOO;
|
||||
};
|
||||
|
||||
template<> struct SparseTensorIndexTraits<SparseMatrixIndexCSR> {
|
||||
static const SparseTensorIndex enum_value = SparseTensorIndex_SparseMatrixIndexCSR;
|
||||
};
|
||||
|
||||
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
|
||||
/// Coodinate (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 {
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_INDICESTYPE = 4,
|
||||
VT_INDICESSTRIDES = 6,
|
||||
VT_INDICESBUFFER = 8
|
||||
};
|
||||
/// The type of values in indicesBuffer
|
||||
const Int *indicesType() const {
|
||||
return GetPointer<const Int *>(VT_INDICESTYPE);
|
||||
}
|
||||
/// Non-negative byte offsets to advance one value cell along each dimension
|
||||
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 Buffer *indicesBuffer() const {
|
||||
return GetStruct<const Buffer *>(VT_INDICESBUFFER);
|
||||
}
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_INDICESTYPE) &&
|
||||
verifier.VerifyTable(indicesType()) &&
|
||||
VerifyOffset(verifier, VT_INDICESSTRIDES) &&
|
||||
verifier.VerifyVector(indicesStrides()) &&
|
||||
VerifyField<Buffer>(verifier, VT_INDICESBUFFER) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct SparseTensorIndexCOOBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_indicesType(flatbuffers::Offset<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 Buffer *indicesBuffer) {
|
||||
fbb_.AddStruct(SparseTensorIndexCOO::VT_INDICESBUFFER, indicesBuffer);
|
||||
}
|
||||
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);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<SparseTensorIndexCOO> CreateSparseTensorIndexCOO(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<Int> indicesType = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<int64_t>> indicesStrides = 0,
|
||||
const Buffer *indicesBuffer = 0) {
|
||||
SparseTensorIndexCOOBuilder builder_(_fbb);
|
||||
builder_.add_indicesBuffer(indicesBuffer);
|
||||
builder_.add_indicesStrides(indicesStrides);
|
||||
builder_.add_indicesType(indicesType);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<SparseTensorIndexCOO> CreateSparseTensorIndexCOODirect(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<Int> indicesType = 0,
|
||||
const std::vector<int64_t> *indicesStrides = nullptr,
|
||||
const Buffer *indicesBuffer = 0) {
|
||||
auto indicesStrides__ = indicesStrides ? _fbb.CreateVector<int64_t>(*indicesStrides) : 0;
|
||||
return org::apache::arrow::flatbuf::CreateSparseTensorIndexCOO(
|
||||
_fbb,
|
||||
indicesType,
|
||||
indicesStrides__,
|
||||
indicesBuffer);
|
||||
}
|
||||
|
||||
/// Compressed Sparse Row format, that is matrix-specific.
|
||||
struct SparseMatrixIndexCSR FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_INDPTRTYPE = 4,
|
||||
VT_INDPTRBUFFER = 6,
|
||||
VT_INDICESTYPE = 8,
|
||||
VT_INDICESBUFFER = 10
|
||||
};
|
||||
/// The type of values in indptrBuffer
|
||||
const Int *indptrType() const {
|
||||
return GetPointer<const 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 Buffer *indptrBuffer() const {
|
||||
return GetStruct<const Buffer *>(VT_INDPTRBUFFER);
|
||||
}
|
||||
/// The type of values in indicesBuffer
|
||||
const Int *indicesType() const {
|
||||
return GetPointer<const 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 Buffer *indicesBuffer() const {
|
||||
return GetStruct<const Buffer *>(VT_INDICESBUFFER);
|
||||
}
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_INDPTRTYPE) &&
|
||||
verifier.VerifyTable(indptrType()) &&
|
||||
VerifyField<Buffer>(verifier, VT_INDPTRBUFFER) &&
|
||||
VerifyOffset(verifier, VT_INDICESTYPE) &&
|
||||
verifier.VerifyTable(indicesType()) &&
|
||||
VerifyField<Buffer>(verifier, VT_INDICESBUFFER) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct SparseMatrixIndexCSRBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_indptrType(flatbuffers::Offset<Int> indptrType) {
|
||||
fbb_.AddOffset(SparseMatrixIndexCSR::VT_INDPTRTYPE, indptrType);
|
||||
}
|
||||
void add_indptrBuffer(const Buffer *indptrBuffer) {
|
||||
fbb_.AddStruct(SparseMatrixIndexCSR::VT_INDPTRBUFFER, indptrBuffer);
|
||||
}
|
||||
void add_indicesType(flatbuffers::Offset<Int> indicesType) {
|
||||
fbb_.AddOffset(SparseMatrixIndexCSR::VT_INDICESTYPE, indicesType);
|
||||
}
|
||||
void add_indicesBuffer(const Buffer *indicesBuffer) {
|
||||
fbb_.AddStruct(SparseMatrixIndexCSR::VT_INDICESBUFFER, indicesBuffer);
|
||||
}
|
||||
explicit SparseMatrixIndexCSRBuilder(flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
SparseMatrixIndexCSRBuilder &operator=(const SparseMatrixIndexCSRBuilder &);
|
||||
flatbuffers::Offset<SparseMatrixIndexCSR> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = flatbuffers::Offset<SparseMatrixIndexCSR>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<SparseMatrixIndexCSR> CreateSparseMatrixIndexCSR(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<Int> indptrType = 0,
|
||||
const Buffer *indptrBuffer = 0,
|
||||
flatbuffers::Offset<Int> indicesType = 0,
|
||||
const Buffer *indicesBuffer = 0) {
|
||||
SparseMatrixIndexCSRBuilder builder_(_fbb);
|
||||
builder_.add_indicesBuffer(indicesBuffer);
|
||||
builder_.add_indicesType(indicesType);
|
||||
builder_.add_indptrBuffer(indptrBuffer);
|
||||
builder_.add_indptrType(indptrType);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct SparseTensor FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
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
|
||||
};
|
||||
Type type_type() const {
|
||||
return static_cast<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 Null *type_as_Null() const {
|
||||
return type_type() == Type_Null ? static_cast<const Null *>(type()) : nullptr;
|
||||
}
|
||||
const Int *type_as_Int() const {
|
||||
return type_type() == Type_Int ? static_cast<const Int *>(type()) : nullptr;
|
||||
}
|
||||
const FloatingPoint *type_as_FloatingPoint() const {
|
||||
return type_type() == Type_FloatingPoint ? static_cast<const FloatingPoint *>(type()) : nullptr;
|
||||
}
|
||||
const Binary *type_as_Binary() const {
|
||||
return type_type() == Type_Binary ? static_cast<const Binary *>(type()) : nullptr;
|
||||
}
|
||||
const Utf8 *type_as_Utf8() const {
|
||||
return type_type() == Type_Utf8 ? static_cast<const Utf8 *>(type()) : nullptr;
|
||||
}
|
||||
const Bool *type_as_Bool() const {
|
||||
return type_type() == Type_Bool ? static_cast<const Bool *>(type()) : nullptr;
|
||||
}
|
||||
const Decimal *type_as_Decimal() const {
|
||||
return type_type() == Type_Decimal ? static_cast<const Decimal *>(type()) : nullptr;
|
||||
}
|
||||
const Date *type_as_Date() const {
|
||||
return type_type() == Type_Date ? static_cast<const Date *>(type()) : nullptr;
|
||||
}
|
||||
const Time *type_as_Time() const {
|
||||
return type_type() == Type_Time ? static_cast<const Time *>(type()) : nullptr;
|
||||
}
|
||||
const Timestamp *type_as_Timestamp() const {
|
||||
return type_type() == Type_Timestamp ? static_cast<const Timestamp *>(type()) : nullptr;
|
||||
}
|
||||
const Interval *type_as_Interval() const {
|
||||
return type_type() == Type_Interval ? static_cast<const Interval *>(type()) : nullptr;
|
||||
}
|
||||
const List *type_as_List() const {
|
||||
return type_type() == Type_List ? static_cast<const List *>(type()) : nullptr;
|
||||
}
|
||||
const Struct_ *type_as_Struct_() const {
|
||||
return type_type() == Type_Struct_ ? static_cast<const Struct_ *>(type()) : nullptr;
|
||||
}
|
||||
const Union *type_as_Union() const {
|
||||
return type_type() == Type_Union ? static_cast<const Union *>(type()) : nullptr;
|
||||
}
|
||||
const FixedSizeBinary *type_as_FixedSizeBinary() const {
|
||||
return type_type() == Type_FixedSizeBinary ? static_cast<const FixedSizeBinary *>(type()) : nullptr;
|
||||
}
|
||||
const FixedSizeList *type_as_FixedSizeList() const {
|
||||
return type_type() == Type_FixedSizeList ? static_cast<const FixedSizeList *>(type()) : nullptr;
|
||||
}
|
||||
const Map *type_as_Map() const {
|
||||
return type_type() == Type_Map ? static_cast<const Map *>(type()) : nullptr;
|
||||
}
|
||||
const Duration *type_as_Duration() const {
|
||||
return type_type() == Type_Duration ? static_cast<const Duration *>(type()) : nullptr;
|
||||
}
|
||||
const LargeBinary *type_as_LargeBinary() const {
|
||||
return type_type() == Type_LargeBinary ? static_cast<const LargeBinary *>(type()) : nullptr;
|
||||
}
|
||||
const LargeUtf8 *type_as_LargeUtf8() const {
|
||||
return type_type() == Type_LargeUtf8 ? static_cast<const LargeUtf8 *>(type()) : nullptr;
|
||||
}
|
||||
const LargeList *type_as_LargeList() const {
|
||||
return type_type() == Type_LargeList ? static_cast<const LargeList *>(type()) : nullptr;
|
||||
}
|
||||
/// The dimensions of the tensor, optionally named.
|
||||
const flatbuffers::Vector<flatbuffers::Offset<TensorDim>> *shape() const {
|
||||
return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<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);
|
||||
}
|
||||
SparseTensorIndex sparseIndex_type() const {
|
||||
return static_cast<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 SparseTensorIndexCOO *sparseIndex_as_SparseTensorIndexCOO() const {
|
||||
return sparseIndex_type() == SparseTensorIndex_SparseTensorIndexCOO ? static_cast<const SparseTensorIndexCOO *>(sparseIndex()) : nullptr;
|
||||
}
|
||||
const SparseMatrixIndexCSR *sparseIndex_as_SparseMatrixIndexCSR() const {
|
||||
return sparseIndex_type() == SparseTensorIndex_SparseMatrixIndexCSR ? static_cast<const SparseMatrixIndexCSR *>(sparseIndex()) : nullptr;
|
||||
}
|
||||
/// The location and size of the tensor's data
|
||||
const Buffer *data() const {
|
||||
return GetStruct<const Buffer *>(VT_DATA);
|
||||
}
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<uint8_t>(verifier, VT_TYPE_TYPE) &&
|
||||
VerifyOffset(verifier, VT_TYPE) &&
|
||||
VerifyType(verifier, type(), type_type()) &&
|
||||
VerifyOffset(verifier, VT_SHAPE) &&
|
||||
verifier.VerifyVector(shape()) &&
|
||||
verifier.VerifyVectorOfTables(shape()) &&
|
||||
VerifyField<int64_t>(verifier, VT_NON_ZERO_LENGTH) &&
|
||||
VerifyField<uint8_t>(verifier, VT_SPARSEINDEX_TYPE) &&
|
||||
VerifyOffset(verifier, VT_SPARSEINDEX) &&
|
||||
VerifySparseTensorIndex(verifier, sparseIndex(), sparseIndex_type()) &&
|
||||
VerifyField<Buffer>(verifier, VT_DATA) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
template<> inline const Null *SparseTensor::type_as<Null>() const {
|
||||
return type_as_Null();
|
||||
}
|
||||
|
||||
template<> inline const Int *SparseTensor::type_as<Int>() const {
|
||||
return type_as_Int();
|
||||
}
|
||||
|
||||
template<> inline const FloatingPoint *SparseTensor::type_as<FloatingPoint>() const {
|
||||
return type_as_FloatingPoint();
|
||||
}
|
||||
|
||||
template<> inline const Binary *SparseTensor::type_as<Binary>() const {
|
||||
return type_as_Binary();
|
||||
}
|
||||
|
||||
template<> inline const Utf8 *SparseTensor::type_as<Utf8>() const {
|
||||
return type_as_Utf8();
|
||||
}
|
||||
|
||||
template<> inline const Bool *SparseTensor::type_as<Bool>() const {
|
||||
return type_as_Bool();
|
||||
}
|
||||
|
||||
template<> inline const Decimal *SparseTensor::type_as<Decimal>() const {
|
||||
return type_as_Decimal();
|
||||
}
|
||||
|
||||
template<> inline const Date *SparseTensor::type_as<Date>() const {
|
||||
return type_as_Date();
|
||||
}
|
||||
|
||||
template<> inline const Time *SparseTensor::type_as<Time>() const {
|
||||
return type_as_Time();
|
||||
}
|
||||
|
||||
template<> inline const Timestamp *SparseTensor::type_as<Timestamp>() const {
|
||||
return type_as_Timestamp();
|
||||
}
|
||||
|
||||
template<> inline const Interval *SparseTensor::type_as<Interval>() const {
|
||||
return type_as_Interval();
|
||||
}
|
||||
|
||||
template<> inline const List *SparseTensor::type_as<List>() const {
|
||||
return type_as_List();
|
||||
}
|
||||
|
||||
template<> inline const Struct_ *SparseTensor::type_as<Struct_>() const {
|
||||
return type_as_Struct_();
|
||||
}
|
||||
|
||||
template<> inline const Union *SparseTensor::type_as<Union>() const {
|
||||
return type_as_Union();
|
||||
}
|
||||
|
||||
template<> inline const FixedSizeBinary *SparseTensor::type_as<FixedSizeBinary>() const {
|
||||
return type_as_FixedSizeBinary();
|
||||
}
|
||||
|
||||
template<> inline const FixedSizeList *SparseTensor::type_as<FixedSizeList>() const {
|
||||
return type_as_FixedSizeList();
|
||||
}
|
||||
|
||||
template<> inline const Map *SparseTensor::type_as<Map>() const {
|
||||
return type_as_Map();
|
||||
}
|
||||
|
||||
template<> inline const Duration *SparseTensor::type_as<Duration>() const {
|
||||
return type_as_Duration();
|
||||
}
|
||||
|
||||
template<> inline const LargeBinary *SparseTensor::type_as<LargeBinary>() const {
|
||||
return type_as_LargeBinary();
|
||||
}
|
||||
|
||||
template<> inline const LargeUtf8 *SparseTensor::type_as<LargeUtf8>() const {
|
||||
return type_as_LargeUtf8();
|
||||
}
|
||||
|
||||
template<> inline const LargeList *SparseTensor::type_as<LargeList>() const {
|
||||
return type_as_LargeList();
|
||||
}
|
||||
|
||||
template<> inline const SparseTensorIndexCOO *SparseTensor::sparseIndex_as<SparseTensorIndexCOO>() const {
|
||||
return sparseIndex_as_SparseTensorIndexCOO();
|
||||
}
|
||||
|
||||
template<> inline const SparseMatrixIndexCSR *SparseTensor::sparseIndex_as<SparseMatrixIndexCSR>() const {
|
||||
return sparseIndex_as_SparseMatrixIndexCSR();
|
||||
}
|
||||
|
||||
struct SparseTensorBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_type_type(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<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(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 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);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<SparseTensor> CreateSparseTensor(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
Type type_type = Type_NONE,
|
||||
flatbuffers::Offset<void> type = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<TensorDim>>> shape = 0,
|
||||
int64_t non_zero_length = 0,
|
||||
SparseTensorIndex sparseIndex_type = SparseTensorIndex_NONE,
|
||||
flatbuffers::Offset<void> sparseIndex = 0,
|
||||
const 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,
|
||||
Type type_type = Type_NONE,
|
||||
flatbuffers::Offset<void> type = 0,
|
||||
const std::vector<flatbuffers::Offset<TensorDim>> *shape = nullptr,
|
||||
int64_t non_zero_length = 0,
|
||||
SparseTensorIndex sparseIndex_type = SparseTensorIndex_NONE,
|
||||
flatbuffers::Offset<void> sparseIndex = 0,
|
||||
const Buffer *data = 0) {
|
||||
auto shape__ = shape ? _fbb.CreateVector<flatbuffers::Offset<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 SparseTensorIndexCOO *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
case SparseTensorIndex_SparseMatrixIndexCSR: {
|
||||
auto ptr = reinterpret_cast<const SparseMatrixIndexCSR *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
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_
|
@ -1,377 +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 Tensor;
|
||||
|
||||
/// ----------------------------------------------------------------------
|
||||
/// Data structures for dense tensors
|
||||
/// Shape data for a single axis in a tensor
|
||||
struct TensorDim FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
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 {
|
||||
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 {
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_TYPE_TYPE = 4,
|
||||
VT_TYPE = 6,
|
||||
VT_SHAPE = 8,
|
||||
VT_STRIDES = 10,
|
||||
VT_DATA = 12
|
||||
};
|
||||
Type type_type() const {
|
||||
return static_cast<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 Null *type_as_Null() const {
|
||||
return type_type() == Type_Null ? static_cast<const Null *>(type()) : nullptr;
|
||||
}
|
||||
const Int *type_as_Int() const {
|
||||
return type_type() == Type_Int ? static_cast<const Int *>(type()) : nullptr;
|
||||
}
|
||||
const FloatingPoint *type_as_FloatingPoint() const {
|
||||
return type_type() == Type_FloatingPoint ? static_cast<const FloatingPoint *>(type()) : nullptr;
|
||||
}
|
||||
const Binary *type_as_Binary() const {
|
||||
return type_type() == Type_Binary ? static_cast<const Binary *>(type()) : nullptr;
|
||||
}
|
||||
const Utf8 *type_as_Utf8() const {
|
||||
return type_type() == Type_Utf8 ? static_cast<const Utf8 *>(type()) : nullptr;
|
||||
}
|
||||
const Bool *type_as_Bool() const {
|
||||
return type_type() == Type_Bool ? static_cast<const Bool *>(type()) : nullptr;
|
||||
}
|
||||
const Decimal *type_as_Decimal() const {
|
||||
return type_type() == Type_Decimal ? static_cast<const Decimal *>(type()) : nullptr;
|
||||
}
|
||||
const Date *type_as_Date() const {
|
||||
return type_type() == Type_Date ? static_cast<const Date *>(type()) : nullptr;
|
||||
}
|
||||
const Time *type_as_Time() const {
|
||||
return type_type() == Type_Time ? static_cast<const Time *>(type()) : nullptr;
|
||||
}
|
||||
const Timestamp *type_as_Timestamp() const {
|
||||
return type_type() == Type_Timestamp ? static_cast<const Timestamp *>(type()) : nullptr;
|
||||
}
|
||||
const Interval *type_as_Interval() const {
|
||||
return type_type() == Type_Interval ? static_cast<const Interval *>(type()) : nullptr;
|
||||
}
|
||||
const List *type_as_List() const {
|
||||
return type_type() == Type_List ? static_cast<const List *>(type()) : nullptr;
|
||||
}
|
||||
const Struct_ *type_as_Struct_() const {
|
||||
return type_type() == Type_Struct_ ? static_cast<const Struct_ *>(type()) : nullptr;
|
||||
}
|
||||
const Union *type_as_Union() const {
|
||||
return type_type() == Type_Union ? static_cast<const Union *>(type()) : nullptr;
|
||||
}
|
||||
const FixedSizeBinary *type_as_FixedSizeBinary() const {
|
||||
return type_type() == Type_FixedSizeBinary ? static_cast<const FixedSizeBinary *>(type()) : nullptr;
|
||||
}
|
||||
const FixedSizeList *type_as_FixedSizeList() const {
|
||||
return type_type() == Type_FixedSizeList ? static_cast<const FixedSizeList *>(type()) : nullptr;
|
||||
}
|
||||
const Map *type_as_Map() const {
|
||||
return type_type() == Type_Map ? static_cast<const Map *>(type()) : nullptr;
|
||||
}
|
||||
const Duration *type_as_Duration() const {
|
||||
return type_type() == Type_Duration ? static_cast<const Duration *>(type()) : nullptr;
|
||||
}
|
||||
const LargeBinary *type_as_LargeBinary() const {
|
||||
return type_type() == Type_LargeBinary ? static_cast<const LargeBinary *>(type()) : nullptr;
|
||||
}
|
||||
const LargeUtf8 *type_as_LargeUtf8() const {
|
||||
return type_type() == Type_LargeUtf8 ? static_cast<const LargeUtf8 *>(type()) : nullptr;
|
||||
}
|
||||
const LargeList *type_as_LargeList() const {
|
||||
return type_type() == Type_LargeList ? static_cast<const LargeList *>(type()) : nullptr;
|
||||
}
|
||||
/// The dimensions of the tensor, optionally named
|
||||
const flatbuffers::Vector<flatbuffers::Offset<TensorDim>> *shape() const {
|
||||
return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<TensorDim>> *>(VT_SHAPE);
|
||||
}
|
||||
/// Non-negative byte offsets to advance one value cell along each dimension
|
||||
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 Buffer *data() const {
|
||||
return GetStruct<const Buffer *>(VT_DATA);
|
||||
}
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<uint8_t>(verifier, VT_TYPE_TYPE) &&
|
||||
VerifyOffset(verifier, VT_TYPE) &&
|
||||
VerifyType(verifier, type(), type_type()) &&
|
||||
VerifyOffset(verifier, VT_SHAPE) &&
|
||||
verifier.VerifyVector(shape()) &&
|
||||
verifier.VerifyVectorOfTables(shape()) &&
|
||||
VerifyOffset(verifier, VT_STRIDES) &&
|
||||
verifier.VerifyVector(strides()) &&
|
||||
VerifyField<Buffer>(verifier, VT_DATA) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
template<> inline const Null *Tensor::type_as<Null>() const {
|
||||
return type_as_Null();
|
||||
}
|
||||
|
||||
template<> inline const Int *Tensor::type_as<Int>() const {
|
||||
return type_as_Int();
|
||||
}
|
||||
|
||||
template<> inline const FloatingPoint *Tensor::type_as<FloatingPoint>() const {
|
||||
return type_as_FloatingPoint();
|
||||
}
|
||||
|
||||
template<> inline const Binary *Tensor::type_as<Binary>() const {
|
||||
return type_as_Binary();
|
||||
}
|
||||
|
||||
template<> inline const Utf8 *Tensor::type_as<Utf8>() const {
|
||||
return type_as_Utf8();
|
||||
}
|
||||
|
||||
template<> inline const Bool *Tensor::type_as<Bool>() const {
|
||||
return type_as_Bool();
|
||||
}
|
||||
|
||||
template<> inline const Decimal *Tensor::type_as<Decimal>() const {
|
||||
return type_as_Decimal();
|
||||
}
|
||||
|
||||
template<> inline const Date *Tensor::type_as<Date>() const {
|
||||
return type_as_Date();
|
||||
}
|
||||
|
||||
template<> inline const Time *Tensor::type_as<Time>() const {
|
||||
return type_as_Time();
|
||||
}
|
||||
|
||||
template<> inline const Timestamp *Tensor::type_as<Timestamp>() const {
|
||||
return type_as_Timestamp();
|
||||
}
|
||||
|
||||
template<> inline const Interval *Tensor::type_as<Interval>() const {
|
||||
return type_as_Interval();
|
||||
}
|
||||
|
||||
template<> inline const List *Tensor::type_as<List>() const {
|
||||
return type_as_List();
|
||||
}
|
||||
|
||||
template<> inline const Struct_ *Tensor::type_as<Struct_>() const {
|
||||
return type_as_Struct_();
|
||||
}
|
||||
|
||||
template<> inline const Union *Tensor::type_as<Union>() const {
|
||||
return type_as_Union();
|
||||
}
|
||||
|
||||
template<> inline const FixedSizeBinary *Tensor::type_as<FixedSizeBinary>() const {
|
||||
return type_as_FixedSizeBinary();
|
||||
}
|
||||
|
||||
template<> inline const FixedSizeList *Tensor::type_as<FixedSizeList>() const {
|
||||
return type_as_FixedSizeList();
|
||||
}
|
||||
|
||||
template<> inline const Map *Tensor::type_as<Map>() const {
|
||||
return type_as_Map();
|
||||
}
|
||||
|
||||
template<> inline const Duration *Tensor::type_as<Duration>() const {
|
||||
return type_as_Duration();
|
||||
}
|
||||
|
||||
template<> inline const LargeBinary *Tensor::type_as<LargeBinary>() const {
|
||||
return type_as_LargeBinary();
|
||||
}
|
||||
|
||||
template<> inline const LargeUtf8 *Tensor::type_as<LargeUtf8>() const {
|
||||
return type_as_LargeUtf8();
|
||||
}
|
||||
|
||||
template<> inline const LargeList *Tensor::type_as<LargeList>() const {
|
||||
return type_as_LargeList();
|
||||
}
|
||||
|
||||
struct TensorBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_type_type(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<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 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);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Tensor> CreateTensor(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
Type type_type = Type_NONE,
|
||||
flatbuffers::Offset<void> type = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<TensorDim>>> shape = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<int64_t>> strides = 0,
|
||||
const 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,
|
||||
Type type_type = Type_NONE,
|
||||
flatbuffers::Offset<void> type = 0,
|
||||
const std::vector<flatbuffers::Offset<TensorDim>> *shape = nullptr,
|
||||
const std::vector<int64_t> *strides = nullptr,
|
||||
const Buffer *data = 0) {
|
||||
auto shape__ = shape ? _fbb.CreateVector<flatbuffers::Offset<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_
|
@ -1,839 +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 CategoryMetadata;
|
||||
|
||||
struct TimestampMetadata;
|
||||
|
||||
struct DateMetadata;
|
||||
|
||||
struct TimeMetadata;
|
||||
|
||||
struct Column;
|
||||
|
||||
struct CTable;
|
||||
|
||||
/// 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 {
|
||||
Type_BOOL = 0,
|
||||
Type_INT8 = 1,
|
||||
Type_INT16 = 2,
|
||||
Type_INT32 = 3,
|
||||
Type_INT64 = 4,
|
||||
Type_UINT8 = 5,
|
||||
Type_UINT16 = 6,
|
||||
Type_UINT32 = 7,
|
||||
Type_UINT64 = 8,
|
||||
Type_FLOAT = 9,
|
||||
Type_DOUBLE = 10,
|
||||
Type_UTF8 = 11,
|
||||
Type_BINARY = 12,
|
||||
Type_CATEGORY = 13,
|
||||
Type_TIMESTAMP = 14,
|
||||
Type_DATE = 15,
|
||||
Type_TIME = 16,
|
||||
Type_LARGE_UTF8 = 17,
|
||||
Type_LARGE_BINARY = 18,
|
||||
Type_MIN = Type_BOOL,
|
||||
Type_MAX = Type_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[] = {
|
||||
"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 (e < Type_BOOL || e > Type_LARGE_BINARY) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesType()[index];
|
||||
}
|
||||
|
||||
enum Encoding {
|
||||
Encoding_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
|
||||
,
|
||||
Encoding_DICTIONARY = 1,
|
||||
Encoding_MIN = Encoding_PLAIN,
|
||||
Encoding_MAX = Encoding_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[] = {
|
||||
"PLAIN",
|
||||
"DICTIONARY",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameEncoding(Encoding e) {
|
||||
if (e < Encoding_PLAIN || e > Encoding_DICTIONARY) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesEncoding()[index];
|
||||
}
|
||||
|
||||
enum TimeUnit {
|
||||
TimeUnit_SECOND = 0,
|
||||
TimeUnit_MILLISECOND = 1,
|
||||
TimeUnit_MICROSECOND = 2,
|
||||
TimeUnit_NANOSECOND = 3,
|
||||
TimeUnit_MIN = TimeUnit_SECOND,
|
||||
TimeUnit_MAX = TimeUnit_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[] = {
|
||||
"SECOND",
|
||||
"MILLISECOND",
|
||||
"MICROSECOND",
|
||||
"NANOSECOND",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameTimeUnit(TimeUnit e) {
|
||||
if (e < TimeUnit_SECOND || e > TimeUnit_NANOSECOND) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesTimeUnit()[index];
|
||||
}
|
||||
|
||||
enum TypeMetadata {
|
||||
TypeMetadata_NONE = 0,
|
||||
TypeMetadata_CategoryMetadata = 1,
|
||||
TypeMetadata_TimestampMetadata = 2,
|
||||
TypeMetadata_DateMetadata = 3,
|
||||
TypeMetadata_TimeMetadata = 4,
|
||||
TypeMetadata_MIN = TypeMetadata_NONE,
|
||||
TypeMetadata_MAX = TypeMetadata_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[] = {
|
||||
"NONE",
|
||||
"CategoryMetadata",
|
||||
"TimestampMetadata",
|
||||
"DateMetadata",
|
||||
"TimeMetadata",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameTypeMetadata(TypeMetadata e) {
|
||||
if (e < TypeMetadata_NONE || e > 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<CategoryMetadata> {
|
||||
static const TypeMetadata enum_value = TypeMetadata_CategoryMetadata;
|
||||
};
|
||||
|
||||
template<> struct TypeMetadataTraits<TimestampMetadata> {
|
||||
static const TypeMetadata enum_value = TypeMetadata_TimestampMetadata;
|
||||
};
|
||||
|
||||
template<> struct TypeMetadataTraits<DateMetadata> {
|
||||
static const TypeMetadata enum_value = TypeMetadata_DateMetadata;
|
||||
};
|
||||
|
||||
template<> struct TypeMetadataTraits<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 {
|
||||
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
|
||||
};
|
||||
Type type() const {
|
||||
return static_cast<Type>(GetField<int8_t>(VT_TYPE, 0));
|
||||
}
|
||||
Encoding encoding() const {
|
||||
return static_cast<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 {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_type(Type type) {
|
||||
fbb_.AddElement<int8_t>(PrimitiveArray::VT_TYPE, static_cast<int8_t>(type), 0);
|
||||
}
|
||||
void add_encoding(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,
|
||||
Type type = Type_BOOL,
|
||||
Encoding encoding = 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 {
|
||||
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 PrimitiveArray *levels() const {
|
||||
return GetPointer<const 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 {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_levels(flatbuffers::Offset<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<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 {
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_UNIT = 4,
|
||||
VT_TIMEZONE = 6
|
||||
};
|
||||
TimeUnit unit() const {
|
||||
return static_cast<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 {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_unit(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,
|
||||
TimeUnit unit = 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,
|
||||
TimeUnit unit = 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 {
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct DateMetadataBuilder {
|
||||
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 {
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_UNIT = 4
|
||||
};
|
||||
TimeUnit unit() const {
|
||||
return static_cast<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 {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_unit(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,
|
||||
TimeUnit unit = TimeUnit_SECOND) {
|
||||
TimeMetadataBuilder builder_(_fbb);
|
||||
builder_.add_unit(unit);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct Column FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
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 PrimitiveArray *values() const {
|
||||
return GetPointer<const PrimitiveArray *>(VT_VALUES);
|
||||
}
|
||||
TypeMetadata metadata_type() const {
|
||||
return static_cast<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 CategoryMetadata *metadata_as_CategoryMetadata() const {
|
||||
return metadata_type() == TypeMetadata_CategoryMetadata ? static_cast<const CategoryMetadata *>(metadata()) : nullptr;
|
||||
}
|
||||
const TimestampMetadata *metadata_as_TimestampMetadata() const {
|
||||
return metadata_type() == TypeMetadata_TimestampMetadata ? static_cast<const TimestampMetadata *>(metadata()) : nullptr;
|
||||
}
|
||||
const DateMetadata *metadata_as_DateMetadata() const {
|
||||
return metadata_type() == TypeMetadata_DateMetadata ? static_cast<const DateMetadata *>(metadata()) : nullptr;
|
||||
}
|
||||
const TimeMetadata *metadata_as_TimeMetadata() const {
|
||||
return metadata_type() == TypeMetadata_TimeMetadata ? static_cast<const 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 CategoryMetadata *Column::metadata_as<CategoryMetadata>() const {
|
||||
return metadata_as_CategoryMetadata();
|
||||
}
|
||||
|
||||
template<> inline const TimestampMetadata *Column::metadata_as<TimestampMetadata>() const {
|
||||
return metadata_as_TimestampMetadata();
|
||||
}
|
||||
|
||||
template<> inline const DateMetadata *Column::metadata_as<DateMetadata>() const {
|
||||
return metadata_as_DateMetadata();
|
||||
}
|
||||
|
||||
template<> inline const TimeMetadata *Column::metadata_as<TimeMetadata>() const {
|
||||
return metadata_as_TimeMetadata();
|
||||
}
|
||||
|
||||
struct ColumnBuilder {
|
||||
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<PrimitiveArray> values) {
|
||||
fbb_.AddOffset(Column::VT_VALUES, values);
|
||||
}
|
||||
void add_metadata_type(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<PrimitiveArray> values = 0,
|
||||
TypeMetadata metadata_type = 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<PrimitiveArray> values = 0,
|
||||
TypeMetadata metadata_type = 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 {
|
||||
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<Column>> *columns() const {
|
||||
return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<Column>> *>(VT_COLUMNS);
|
||||
}
|
||||
/// Version number of the Feather format
|
||||
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 {
|
||||
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<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<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<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<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 CategoryMetadata *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
case TypeMetadata_TimestampMetadata: {
|
||||
auto ptr = reinterpret_cast<const TimestampMetadata *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
case TypeMetadata_DateMetadata: {
|
||||
auto ptr = reinterpret_cast<const DateMetadata *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
case TypeMetadata_TimeMetadata: {
|
||||
auto ptr = reinterpret_cast<const TimeMetadata *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
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_
|
Loading…
Reference in New Issue
Block a user