1// automatically generated by the FlatBuffers compiler, do not modify
2
3
4#ifndef FLATBUFFERS_GENERATED_FEATHER_ARROW_IPC_FEATHER_FBS_H_
5#define FLATBUFFERS_GENERATED_FEATHER_ARROW_IPC_FEATHER_FBS_H_
6
7#include "flatbuffers/flatbuffers.h"
8
9namespace arrow {
10namespace ipc {
11namespace feather {
12namespace fbs {
13
14struct PrimitiveArray;
15
16struct CategoryMetadata;
17
18struct TimestampMetadata;
19
20struct DateMetadata;
21
22struct TimeMetadata;
23
24struct Column;
25
26struct CTable;
27
28/// Feather is an experimental serialization format implemented using
29/// techniques from Apache Arrow. It was created as a proof-of-concept of an
30/// interoperable file format for storing data frames originating in Python or
31/// R. It enabled the developers to sidestep some of the open design questions
32/// in Arrow from early 2016 and instead create something simple and useful for
33/// the intended use cases.
34enum Type {
35 Type_BOOL = 0,
36 Type_INT8 = 1,
37 Type_INT16 = 2,
38 Type_INT32 = 3,
39 Type_INT64 = 4,
40 Type_UINT8 = 5,
41 Type_UINT16 = 6,
42 Type_UINT32 = 7,
43 Type_UINT64 = 8,
44 Type_FLOAT = 9,
45 Type_DOUBLE = 10,
46 Type_UTF8 = 11,
47 Type_BINARY = 12,
48 Type_CATEGORY = 13,
49 Type_TIMESTAMP = 14,
50 Type_DATE = 15,
51 Type_TIME = 16,
52 Type_LARGE_UTF8 = 17,
53 Type_LARGE_BINARY = 18,
54 Type_MIN = Type_BOOL,
55 Type_MAX = Type_LARGE_BINARY
56};
57
58inline const Type (&EnumValuesType())[19] {
59 static const Type values[] = {
60 Type_BOOL,
61 Type_INT8,
62 Type_INT16,
63 Type_INT32,
64 Type_INT64,
65 Type_UINT8,
66 Type_UINT16,
67 Type_UINT32,
68 Type_UINT64,
69 Type_FLOAT,
70 Type_DOUBLE,
71 Type_UTF8,
72 Type_BINARY,
73 Type_CATEGORY,
74 Type_TIMESTAMP,
75 Type_DATE,
76 Type_TIME,
77 Type_LARGE_UTF8,
78 Type_LARGE_BINARY
79 };
80 return values;
81}
82
83inline const char * const *EnumNamesType() {
84 static const char * const names[] = {
85 "BOOL",
86 "INT8",
87 "INT16",
88 "INT32",
89 "INT64",
90 "UINT8",
91 "UINT16",
92 "UINT32",
93 "UINT64",
94 "FLOAT",
95 "DOUBLE",
96 "UTF8",
97 "BINARY",
98 "CATEGORY",
99 "TIMESTAMP",
100 "DATE",
101 "TIME",
102 "LARGE_UTF8",
103 "LARGE_BINARY",
104 nullptr
105 };
106 return names;
107}
108
109inline const char *EnumNameType(Type e) {
110 if (e < Type_BOOL || e > Type_LARGE_BINARY) return "";
111 const size_t index = static_cast<size_t>(e);
112 return EnumNamesType()[index];
113}
114
115enum Encoding {
116 Encoding_PLAIN = 0 /// Data is stored dictionary-encoded
117 /// dictionary size: <INT32 Dictionary size>
118 /// dictionary data: <TYPE primitive array>
119 /// dictionary index: <INT32 primitive array>
120 ///
121 /// TODO: do we care about storing the index values in a smaller typeclass
122,
123 Encoding_DICTIONARY = 1,
124 Encoding_MIN = Encoding_PLAIN,
125 Encoding_MAX = Encoding_DICTIONARY
126};
127
128inline const Encoding (&EnumValuesEncoding())[2] {
129 static const Encoding values[] = {
130 Encoding_PLAIN,
131 Encoding_DICTIONARY
132 };
133 return values;
134}
135
136inline const char * const *EnumNamesEncoding() {
137 static const char * const names[] = {
138 "PLAIN",
139 "DICTIONARY",
140 nullptr
141 };
142 return names;
143}
144
145inline const char *EnumNameEncoding(Encoding e) {
146 if (e < Encoding_PLAIN || e > Encoding_DICTIONARY) return "";
147 const size_t index = static_cast<size_t>(e);
148 return EnumNamesEncoding()[index];
149}
150
151enum TimeUnit {
152 TimeUnit_SECOND = 0,
153 TimeUnit_MILLISECOND = 1,
154 TimeUnit_MICROSECOND = 2,
155 TimeUnit_NANOSECOND = 3,
156 TimeUnit_MIN = TimeUnit_SECOND,
157 TimeUnit_MAX = TimeUnit_NANOSECOND
158};
159
160inline const TimeUnit (&EnumValuesTimeUnit())[4] {
161 static const TimeUnit values[] = {
162 TimeUnit_SECOND,
163 TimeUnit_MILLISECOND,
164 TimeUnit_MICROSECOND,
165 TimeUnit_NANOSECOND
166 };
167 return values;
168}
169
170inline const char * const *EnumNamesTimeUnit() {
171 static const char * const names[] = {
172 "SECOND",
173 "MILLISECOND",
174 "MICROSECOND",
175 "NANOSECOND",
176 nullptr
177 };
178 return names;
179}
180
181inline const char *EnumNameTimeUnit(TimeUnit e) {
182 if (e < TimeUnit_SECOND || e > TimeUnit_NANOSECOND) return "";
183 const size_t index = static_cast<size_t>(e);
184 return EnumNamesTimeUnit()[index];
185}
186
187enum TypeMetadata {
188 TypeMetadata_NONE = 0,
189 TypeMetadata_CategoryMetadata = 1,
190 TypeMetadata_TimestampMetadata = 2,
191 TypeMetadata_DateMetadata = 3,
192 TypeMetadata_TimeMetadata = 4,
193 TypeMetadata_MIN = TypeMetadata_NONE,
194 TypeMetadata_MAX = TypeMetadata_TimeMetadata
195};
196
197inline const TypeMetadata (&EnumValuesTypeMetadata())[5] {
198 static const TypeMetadata values[] = {
199 TypeMetadata_NONE,
200 TypeMetadata_CategoryMetadata,
201 TypeMetadata_TimestampMetadata,
202 TypeMetadata_DateMetadata,
203 TypeMetadata_TimeMetadata
204 };
205 return values;
206}
207
208inline const char * const *EnumNamesTypeMetadata() {
209 static const char * const names[] = {
210 "NONE",
211 "CategoryMetadata",
212 "TimestampMetadata",
213 "DateMetadata",
214 "TimeMetadata",
215 nullptr
216 };
217 return names;
218}
219
220inline const char *EnumNameTypeMetadata(TypeMetadata e) {
221 if (e < TypeMetadata_NONE || e > TypeMetadata_TimeMetadata) return "";
222 const size_t index = static_cast<size_t>(e);
223 return EnumNamesTypeMetadata()[index];
224}
225
226template<typename T> struct TypeMetadataTraits {
227 static const TypeMetadata enum_value = TypeMetadata_NONE;
228};
229
230template<> struct TypeMetadataTraits<CategoryMetadata> {
231 static const TypeMetadata enum_value = TypeMetadata_CategoryMetadata;
232};
233
234template<> struct TypeMetadataTraits<TimestampMetadata> {
235 static const TypeMetadata enum_value = TypeMetadata_TimestampMetadata;
236};
237
238template<> struct TypeMetadataTraits<DateMetadata> {
239 static const TypeMetadata enum_value = TypeMetadata_DateMetadata;
240};
241
242template<> struct TypeMetadataTraits<TimeMetadata> {
243 static const TypeMetadata enum_value = TypeMetadata_TimeMetadata;
244};
245
246bool VerifyTypeMetadata(flatbuffers::Verifier &verifier, const void *obj, TypeMetadata type);
247bool VerifyTypeMetadataVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
248
249struct PrimitiveArray FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
250 enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
251 VT_TYPE = 4,
252 VT_ENCODING = 6,
253 VT_OFFSET = 8,
254 VT_LENGTH = 10,
255 VT_NULL_COUNT = 12,
256 VT_TOTAL_BYTES = 14
257 };
258 Type type() const {
259 return static_cast<Type>(GetField<int8_t>(VT_TYPE, 0));
260 }
261 Encoding encoding() const {
262 return static_cast<Encoding>(GetField<int8_t>(VT_ENCODING, 0));
263 }
264 /// Relative memory offset of the start of the array data excluding the size
265 /// of the metadata
266 int64_t offset() const {
267 return GetField<int64_t>(VT_OFFSET, 0);
268 }
269 /// The number of logical values in the array
270 int64_t length() const {
271 return GetField<int64_t>(VT_LENGTH, 0);
272 }
273 /// The number of observed nulls
274 int64_t null_count() const {
275 return GetField<int64_t>(VT_NULL_COUNT, 0);
276 }
277 /// The total size of the actual data in the file
278 int64_t total_bytes() const {
279 return GetField<int64_t>(VT_TOTAL_BYTES, 0);
280 }
281 bool Verify(flatbuffers::Verifier &verifier) const {
282 return VerifyTableStart(verifier) &&
283 VerifyField<int8_t>(verifier, VT_TYPE) &&
284 VerifyField<int8_t>(verifier, VT_ENCODING) &&
285 VerifyField<int64_t>(verifier, VT_OFFSET) &&
286 VerifyField<int64_t>(verifier, VT_LENGTH) &&
287 VerifyField<int64_t>(verifier, VT_NULL_COUNT) &&
288 VerifyField<int64_t>(verifier, VT_TOTAL_BYTES) &&
289 verifier.EndTable();
290 }
291};
292
293struct PrimitiveArrayBuilder {
294 flatbuffers::FlatBufferBuilder &fbb_;
295 flatbuffers::uoffset_t start_;
296 void add_type(Type type) {
297 fbb_.AddElement<int8_t>(PrimitiveArray::VT_TYPE, static_cast<int8_t>(type), 0);
298 }
299 void add_encoding(Encoding encoding) {
300 fbb_.AddElement<int8_t>(PrimitiveArray::VT_ENCODING, static_cast<int8_t>(encoding), 0);
301 }
302 void add_offset(int64_t offset) {
303 fbb_.AddElement<int64_t>(PrimitiveArray::VT_OFFSET, offset, 0);
304 }
305 void add_length(int64_t length) {
306 fbb_.AddElement<int64_t>(PrimitiveArray::VT_LENGTH, length, 0);
307 }
308 void add_null_count(int64_t null_count) {
309 fbb_.AddElement<int64_t>(PrimitiveArray::VT_NULL_COUNT, null_count, 0);
310 }
311 void add_total_bytes(int64_t total_bytes) {
312 fbb_.AddElement<int64_t>(PrimitiveArray::VT_TOTAL_BYTES, total_bytes, 0);
313 }
314 explicit PrimitiveArrayBuilder(flatbuffers::FlatBufferBuilder &_fbb)
315 : fbb_(_fbb) {
316 start_ = fbb_.StartTable();
317 }
318 PrimitiveArrayBuilder &operator=(const PrimitiveArrayBuilder &);
319 flatbuffers::Offset<PrimitiveArray> Finish() {
320 const auto end = fbb_.EndTable(start_);
321 auto o = flatbuffers::Offset<PrimitiveArray>(end);
322 return o;
323 }
324};
325
326inline flatbuffers::Offset<PrimitiveArray> CreatePrimitiveArray(
327 flatbuffers::FlatBufferBuilder &_fbb,
328 Type type = Type_BOOL,
329 Encoding encoding = Encoding_PLAIN,
330 int64_t offset = 0,
331 int64_t length = 0,
332 int64_t null_count = 0,
333 int64_t total_bytes = 0) {
334 PrimitiveArrayBuilder builder_(_fbb);
335 builder_.add_total_bytes(total_bytes);
336 builder_.add_null_count(null_count);
337 builder_.add_length(length);
338 builder_.add_offset(offset);
339 builder_.add_encoding(encoding);
340 builder_.add_type(type);
341 return builder_.Finish();
342}
343
344struct CategoryMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
345 enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
346 VT_LEVELS = 4,
347 VT_ORDERED = 6
348 };
349 /// The category codes are presumed to be integers that are valid indexes into
350 /// the levels array
351 const PrimitiveArray *levels() const {
352 return GetPointer<const PrimitiveArray *>(VT_LEVELS);
353 }
354 bool ordered() const {
355 return GetField<uint8_t>(VT_ORDERED, 0) != 0;
356 }
357 bool Verify(flatbuffers::Verifier &verifier) const {
358 return VerifyTableStart(verifier) &&
359 VerifyOffset(verifier, VT_LEVELS) &&
360 verifier.VerifyTable(levels()) &&
361 VerifyField<uint8_t>(verifier, VT_ORDERED) &&
362 verifier.EndTable();
363 }
364};
365
366struct CategoryMetadataBuilder {
367 flatbuffers::FlatBufferBuilder &fbb_;
368 flatbuffers::uoffset_t start_;
369 void add_levels(flatbuffers::Offset<PrimitiveArray> levels) {
370 fbb_.AddOffset(CategoryMetadata::VT_LEVELS, levels);
371 }
372 void add_ordered(bool ordered) {
373 fbb_.AddElement<uint8_t>(CategoryMetadata::VT_ORDERED, static_cast<uint8_t>(ordered), 0);
374 }
375 explicit CategoryMetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb)
376 : fbb_(_fbb) {
377 start_ = fbb_.StartTable();
378 }
379 CategoryMetadataBuilder &operator=(const CategoryMetadataBuilder &);
380 flatbuffers::Offset<CategoryMetadata> Finish() {
381 const auto end = fbb_.EndTable(start_);
382 auto o = flatbuffers::Offset<CategoryMetadata>(end);
383 return o;
384 }
385};
386
387inline flatbuffers::Offset<CategoryMetadata> CreateCategoryMetadata(
388 flatbuffers::FlatBufferBuilder &_fbb,
389 flatbuffers::Offset<PrimitiveArray> levels = 0,
390 bool ordered = false) {
391 CategoryMetadataBuilder builder_(_fbb);
392 builder_.add_levels(levels);
393 builder_.add_ordered(ordered);
394 return builder_.Finish();
395}
396
397struct TimestampMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
398 enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
399 VT_UNIT = 4,
400 VT_TIMEZONE = 6
401 };
402 TimeUnit unit() const {
403 return static_cast<TimeUnit>(GetField<int8_t>(VT_UNIT, 0));
404 }
405 /// Timestamp data is assumed to be UTC, but the time zone is stored here for
406 /// presentation as localized
407 const flatbuffers::String *timezone() const {
408 return GetPointer<const flatbuffers::String *>(VT_TIMEZONE);
409 }
410 bool Verify(flatbuffers::Verifier &verifier) const {
411 return VerifyTableStart(verifier) &&
412 VerifyField<int8_t>(verifier, VT_UNIT) &&
413 VerifyOffset(verifier, VT_TIMEZONE) &&
414 verifier.VerifyString(timezone()) &&
415 verifier.EndTable();
416 }
417};
418
419struct TimestampMetadataBuilder {
420 flatbuffers::FlatBufferBuilder &fbb_;
421 flatbuffers::uoffset_t start_;
422 void add_unit(TimeUnit unit) {
423 fbb_.AddElement<int8_t>(TimestampMetadata::VT_UNIT, static_cast<int8_t>(unit), 0);
424 }
425 void add_timezone(flatbuffers::Offset<flatbuffers::String> timezone) {
426 fbb_.AddOffset(TimestampMetadata::VT_TIMEZONE, timezone);
427 }
428 explicit TimestampMetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb)
429 : fbb_(_fbb) {
430 start_ = fbb_.StartTable();
431 }
432 TimestampMetadataBuilder &operator=(const TimestampMetadataBuilder &);
433 flatbuffers::Offset<TimestampMetadata> Finish() {
434 const auto end = fbb_.EndTable(start_);
435 auto o = flatbuffers::Offset<TimestampMetadata>(end);
436 return o;
437 }
438};
439
440inline flatbuffers::Offset<TimestampMetadata> CreateTimestampMetadata(
441 flatbuffers::FlatBufferBuilder &_fbb,
442 TimeUnit unit = TimeUnit_SECOND,
443 flatbuffers::Offset<flatbuffers::String> timezone = 0) {
444 TimestampMetadataBuilder builder_(_fbb);
445 builder_.add_timezone(timezone);
446 builder_.add_unit(unit);
447 return builder_.Finish();
448}
449
450inline flatbuffers::Offset<TimestampMetadata> CreateTimestampMetadataDirect(
451 flatbuffers::FlatBufferBuilder &_fbb,
452 TimeUnit unit = TimeUnit_SECOND,
453 const char *timezone = nullptr) {
454 auto timezone__ = timezone ? _fbb.CreateString(timezone) : 0;
455 return arrow::ipc::feather::fbs::CreateTimestampMetadata(
456 _fbb,
457 unit,
458 timezone__);
459}
460
461struct DateMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
462 bool Verify(flatbuffers::Verifier &verifier) const {
463 return VerifyTableStart(verifier) &&
464 verifier.EndTable();
465 }
466};
467
468struct DateMetadataBuilder {
469 flatbuffers::FlatBufferBuilder &fbb_;
470 flatbuffers::uoffset_t start_;
471 explicit DateMetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb)
472 : fbb_(_fbb) {
473 start_ = fbb_.StartTable();
474 }
475 DateMetadataBuilder &operator=(const DateMetadataBuilder &);
476 flatbuffers::Offset<DateMetadata> Finish() {
477 const auto end = fbb_.EndTable(start_);
478 auto o = flatbuffers::Offset<DateMetadata>(end);
479 return o;
480 }
481};
482
483inline flatbuffers::Offset<DateMetadata> CreateDateMetadata(
484 flatbuffers::FlatBufferBuilder &_fbb) {
485 DateMetadataBuilder builder_(_fbb);
486 return builder_.Finish();
487}
488
489struct TimeMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
490 enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
491 VT_UNIT = 4
492 };
493 TimeUnit unit() const {
494 return static_cast<TimeUnit>(GetField<int8_t>(VT_UNIT, 0));
495 }
496 bool Verify(flatbuffers::Verifier &verifier) const {
497 return VerifyTableStart(verifier) &&
498 VerifyField<int8_t>(verifier, VT_UNIT) &&
499 verifier.EndTable();
500 }
501};
502
503struct TimeMetadataBuilder {
504 flatbuffers::FlatBufferBuilder &fbb_;
505 flatbuffers::uoffset_t start_;
506 void add_unit(TimeUnit unit) {
507 fbb_.AddElement<int8_t>(TimeMetadata::VT_UNIT, static_cast<int8_t>(unit), 0);
508 }
509 explicit TimeMetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb)
510 : fbb_(_fbb) {
511 start_ = fbb_.StartTable();
512 }
513 TimeMetadataBuilder &operator=(const TimeMetadataBuilder &);
514 flatbuffers::Offset<TimeMetadata> Finish() {
515 const auto end = fbb_.EndTable(start_);
516 auto o = flatbuffers::Offset<TimeMetadata>(end);
517 return o;
518 }
519};
520
521inline flatbuffers::Offset<TimeMetadata> CreateTimeMetadata(
522 flatbuffers::FlatBufferBuilder &_fbb,
523 TimeUnit unit = TimeUnit_SECOND) {
524 TimeMetadataBuilder builder_(_fbb);
525 builder_.add_unit(unit);
526 return builder_.Finish();
527}
528
529struct Column FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
530 enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
531 VT_NAME = 4,
532 VT_VALUES = 6,
533 VT_METADATA_TYPE = 8,
534 VT_METADATA = 10,
535 VT_USER_METADATA = 12
536 };
537 const flatbuffers::String *name() const {
538 return GetPointer<const flatbuffers::String *>(VT_NAME);
539 }
540 const PrimitiveArray *values() const {
541 return GetPointer<const PrimitiveArray *>(VT_VALUES);
542 }
543 TypeMetadata metadata_type() const {
544 return static_cast<TypeMetadata>(GetField<uint8_t>(VT_METADATA_TYPE, 0));
545 }
546 const void *metadata() const {
547 return GetPointer<const void *>(VT_METADATA);
548 }
549 template<typename T> const T *metadata_as() const;
550 const CategoryMetadata *metadata_as_CategoryMetadata() const {
551 return metadata_type() == TypeMetadata_CategoryMetadata ? static_cast<const CategoryMetadata *>(metadata()) : nullptr;
552 }
553 const TimestampMetadata *metadata_as_TimestampMetadata() const {
554 return metadata_type() == TypeMetadata_TimestampMetadata ? static_cast<const TimestampMetadata *>(metadata()) : nullptr;
555 }
556 const DateMetadata *metadata_as_DateMetadata() const {
557 return metadata_type() == TypeMetadata_DateMetadata ? static_cast<const DateMetadata *>(metadata()) : nullptr;
558 }
559 const TimeMetadata *metadata_as_TimeMetadata() const {
560 return metadata_type() == TypeMetadata_TimeMetadata ? static_cast<const TimeMetadata *>(metadata()) : nullptr;
561 }
562 /// This should (probably) be JSON
563 const flatbuffers::String *user_metadata() const {
564 return GetPointer<const flatbuffers::String *>(VT_USER_METADATA);
565 }
566 bool Verify(flatbuffers::Verifier &verifier) const {
567 return VerifyTableStart(verifier) &&
568 VerifyOffset(verifier, VT_NAME) &&
569 verifier.VerifyString(name()) &&
570 VerifyOffset(verifier, VT_VALUES) &&
571 verifier.VerifyTable(values()) &&
572 VerifyField<uint8_t>(verifier, VT_METADATA_TYPE) &&
573 VerifyOffset(verifier, VT_METADATA) &&
574 VerifyTypeMetadata(verifier, metadata(), metadata_type()) &&
575 VerifyOffset(verifier, VT_USER_METADATA) &&
576 verifier.VerifyString(user_metadata()) &&
577 verifier.EndTable();
578 }
579};
580
581template<> inline const CategoryMetadata *Column::metadata_as<CategoryMetadata>() const {
582 return metadata_as_CategoryMetadata();
583}
584
585template<> inline const TimestampMetadata *Column::metadata_as<TimestampMetadata>() const {
586 return metadata_as_TimestampMetadata();
587}
588
589template<> inline const DateMetadata *Column::metadata_as<DateMetadata>() const {
590 return metadata_as_DateMetadata();
591}
592
593template<> inline const TimeMetadata *Column::metadata_as<TimeMetadata>() const {
594 return metadata_as_TimeMetadata();
595}
596
597struct ColumnBuilder {
598 flatbuffers::FlatBufferBuilder &fbb_;
599 flatbuffers::uoffset_t start_;
600 void add_name(flatbuffers::Offset<flatbuffers::String> name) {
601 fbb_.AddOffset(Column::VT_NAME, name);
602 }
603 void add_values(flatbuffers::Offset<PrimitiveArray> values) {
604 fbb_.AddOffset(Column::VT_VALUES, values);
605 }
606 void add_metadata_type(TypeMetadata metadata_type) {
607 fbb_.AddElement<uint8_t>(Column::VT_METADATA_TYPE, static_cast<uint8_t>(metadata_type), 0);
608 }
609 void add_metadata(flatbuffers::Offset<void> metadata) {
610 fbb_.AddOffset(Column::VT_METADATA, metadata);
611 }
612 void add_user_metadata(flatbuffers::Offset<flatbuffers::String> user_metadata) {
613 fbb_.AddOffset(Column::VT_USER_METADATA, user_metadata);
614 }
615 explicit ColumnBuilder(flatbuffers::FlatBufferBuilder &_fbb)
616 : fbb_(_fbb) {
617 start_ = fbb_.StartTable();
618 }
619 ColumnBuilder &operator=(const ColumnBuilder &);
620 flatbuffers::Offset<Column> Finish() {
621 const auto end = fbb_.EndTable(start_);
622 auto o = flatbuffers::Offset<Column>(end);
623 return o;
624 }
625};
626
627inline flatbuffers::Offset<Column> CreateColumn(
628 flatbuffers::FlatBufferBuilder &_fbb,
629 flatbuffers::Offset<flatbuffers::String> name = 0,
630 flatbuffers::Offset<PrimitiveArray> values = 0,
631 TypeMetadata metadata_type = TypeMetadata_NONE,
632 flatbuffers::Offset<void> metadata = 0,
633 flatbuffers::Offset<flatbuffers::String> user_metadata = 0) {
634 ColumnBuilder builder_(_fbb);
635 builder_.add_user_metadata(user_metadata);
636 builder_.add_metadata(metadata);
637 builder_.add_values(values);
638 builder_.add_name(name);
639 builder_.add_metadata_type(metadata_type);
640 return builder_.Finish();
641}
642
643inline flatbuffers::Offset<Column> CreateColumnDirect(
644 flatbuffers::FlatBufferBuilder &_fbb,
645 const char *name = nullptr,
646 flatbuffers::Offset<PrimitiveArray> values = 0,
647 TypeMetadata metadata_type = TypeMetadata_NONE,
648 flatbuffers::Offset<void> metadata = 0,
649 const char *user_metadata = nullptr) {
650 auto name__ = name ? _fbb.CreateString(name) : 0;
651 auto user_metadata__ = user_metadata ? _fbb.CreateString(user_metadata) : 0;
652 return arrow::ipc::feather::fbs::CreateColumn(
653 _fbb,
654 name__,
655 values,
656 metadata_type,
657 metadata,
658 user_metadata__);
659}
660
661struct CTable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
662 enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
663 VT_DESCRIPTION = 4,
664 VT_NUM_ROWS = 6,
665 VT_COLUMNS = 8,
666 VT_VERSION = 10,
667 VT_METADATA = 12
668 };
669 /// Some text (or a name) metadata about what the file is, optional
670 const flatbuffers::String *description() const {
671 return GetPointer<const flatbuffers::String *>(VT_DESCRIPTION);
672 }
673 int64_t num_rows() const {
674 return GetField<int64_t>(VT_NUM_ROWS, 0);
675 }
676 const flatbuffers::Vector<flatbuffers::Offset<Column>> *columns() const {
677 return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<Column>> *>(VT_COLUMNS);
678 }
679 /// Version number of the Feather format
680 int32_t version() const {
681 return GetField<int32_t>(VT_VERSION, 0);
682 }
683 /// Table metadata (likely JSON), not yet used
684 const flatbuffers::String *metadata() const {
685 return GetPointer<const flatbuffers::String *>(VT_METADATA);
686 }
687 bool Verify(flatbuffers::Verifier &verifier) const {
688 return VerifyTableStart(verifier) &&
689 VerifyOffset(verifier, VT_DESCRIPTION) &&
690 verifier.VerifyString(description()) &&
691 VerifyField<int64_t>(verifier, VT_NUM_ROWS) &&
692 VerifyOffset(verifier, VT_COLUMNS) &&
693 verifier.VerifyVector(columns()) &&
694 verifier.VerifyVectorOfTables(columns()) &&
695 VerifyField<int32_t>(verifier, VT_VERSION) &&
696 VerifyOffset(verifier, VT_METADATA) &&
697 verifier.VerifyString(metadata()) &&
698 verifier.EndTable();
699 }
700};
701
702struct CTableBuilder {
703 flatbuffers::FlatBufferBuilder &fbb_;
704 flatbuffers::uoffset_t start_;
705 void add_description(flatbuffers::Offset<flatbuffers::String> description) {
706 fbb_.AddOffset(CTable::VT_DESCRIPTION, description);
707 }
708 void add_num_rows(int64_t num_rows) {
709 fbb_.AddElement<int64_t>(CTable::VT_NUM_ROWS, num_rows, 0);
710 }
711 void add_columns(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Column>>> columns) {
712 fbb_.AddOffset(CTable::VT_COLUMNS, columns);
713 }
714 void add_version(int32_t version) {
715 fbb_.AddElement<int32_t>(CTable::VT_VERSION, version, 0);
716 }
717 void add_metadata(flatbuffers::Offset<flatbuffers::String> metadata) {
718 fbb_.AddOffset(CTable::VT_METADATA, metadata);
719 }
720 explicit CTableBuilder(flatbuffers::FlatBufferBuilder &_fbb)
721 : fbb_(_fbb) {
722 start_ = fbb_.StartTable();
723 }
724 CTableBuilder &operator=(const CTableBuilder &);
725 flatbuffers::Offset<CTable> Finish() {
726 const auto end = fbb_.EndTable(start_);
727 auto o = flatbuffers::Offset<CTable>(end);
728 return o;
729 }
730};
731
732inline flatbuffers::Offset<CTable> CreateCTable(
733 flatbuffers::FlatBufferBuilder &_fbb,
734 flatbuffers::Offset<flatbuffers::String> description = 0,
735 int64_t num_rows = 0,
736 flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Column>>> columns = 0,
737 int32_t version = 0,
738 flatbuffers::Offset<flatbuffers::String> metadata = 0) {
739 CTableBuilder builder_(_fbb);
740 builder_.add_num_rows(num_rows);
741 builder_.add_metadata(metadata);
742 builder_.add_version(version);
743 builder_.add_columns(columns);
744 builder_.add_description(description);
745 return builder_.Finish();
746}
747
748inline flatbuffers::Offset<CTable> CreateCTableDirect(
749 flatbuffers::FlatBufferBuilder &_fbb,
750 const char *description = nullptr,
751 int64_t num_rows = 0,
752 const std::vector<flatbuffers::Offset<Column>> *columns = nullptr,
753 int32_t version = 0,
754 const char *metadata = nullptr) {
755 auto description__ = description ? _fbb.CreateString(description) : 0;
756 auto columns__ = columns ? _fbb.CreateVector<flatbuffers::Offset<Column>>(*columns) : 0;
757 auto metadata__ = metadata ? _fbb.CreateString(metadata) : 0;
758 return arrow::ipc::feather::fbs::CreateCTable(
759 _fbb,
760 description__,
761 num_rows,
762 columns__,
763 version,
764 metadata__);
765}
766
767inline bool VerifyTypeMetadata(flatbuffers::Verifier &verifier, const void *obj, TypeMetadata type) {
768 switch (type) {
769 case TypeMetadata_NONE: {
770 return true;
771 }
772 case TypeMetadata_CategoryMetadata: {
773 auto ptr = reinterpret_cast<const CategoryMetadata *>(obj);
774 return verifier.VerifyTable(ptr);
775 }
776 case TypeMetadata_TimestampMetadata: {
777 auto ptr = reinterpret_cast<const TimestampMetadata *>(obj);
778 return verifier.VerifyTable(ptr);
779 }
780 case TypeMetadata_DateMetadata: {
781 auto ptr = reinterpret_cast<const DateMetadata *>(obj);
782 return verifier.VerifyTable(ptr);
783 }
784 case TypeMetadata_TimeMetadata: {
785 auto ptr = reinterpret_cast<const TimeMetadata *>(obj);
786 return verifier.VerifyTable(ptr);
787 }
788 default: return false;
789 }
790}
791
792inline bool VerifyTypeMetadataVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
793 if (!values || !types) return !values && !types;
794 if (values->size() != types->size()) return false;
795 for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
796 if (!VerifyTypeMetadata(
797 verifier, values->Get(i), types->GetEnum<TypeMetadata>(i))) {
798 return false;
799 }
800 }
801 return true;
802}
803
804inline const arrow::ipc::feather::fbs::CTable *GetCTable(const void *buf) {
805 return flatbuffers::GetRoot<arrow::ipc::feather::fbs::CTable>(buf);
806}
807
808inline const arrow::ipc::feather::fbs::CTable *GetSizePrefixedCTable(const void *buf) {
809 return flatbuffers::GetSizePrefixedRoot<arrow::ipc::feather::fbs::CTable>(buf);
810}
811
812inline bool VerifyCTableBuffer(
813 flatbuffers::Verifier &verifier) {
814 return verifier.VerifyBuffer<arrow::ipc::feather::fbs::CTable>(nullptr);
815}
816
817inline bool VerifySizePrefixedCTableBuffer(
818 flatbuffers::Verifier &verifier) {
819 return verifier.VerifySizePrefixedBuffer<arrow::ipc::feather::fbs::CTable>(nullptr);
820}
821
822inline void FinishCTableBuffer(
823 flatbuffers::FlatBufferBuilder &fbb,
824 flatbuffers::Offset<arrow::ipc::feather::fbs::CTable> root) {
825 fbb.Finish(root);
826}
827
828inline void FinishSizePrefixedCTableBuffer(
829 flatbuffers::FlatBufferBuilder &fbb,
830 flatbuffers::Offset<arrow::ipc::feather::fbs::CTable> root) {
831 fbb.FinishSizePrefixed(root);
832}
833
834} // namespace fbs
835} // namespace feather
836} // namespace ipc
837} // namespace arrow
838
839#endif // FLATBUFFERS_GENERATED_FEATHER_ARROW_IPC_FEATHER_FBS_H_
840