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