-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy patharrow_defs.h
436 lines (394 loc) · 7.33 KB
/
arrow_defs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
/*
* arrow_enums.h
*
* definitions for apache arrow format
*/
#ifndef _ARROW_ENUMS_H_
#define _ARROW_ENUMS_H_
/*
* MetadataVersion : short
*/
typedef enum
{
ArrowMetadataVersion__V1 = 0, /* not supported */
ArrowMetadataVersion__V2 = 1, /* not supported */
ArrowMetadataVersion__V3 = 2, /* not supported */
ArrowMetadataVersion__V4 = 3,
} ArrowMetadataVersion;
/*
* MessageHeader : byte
*/
typedef enum
{
ArrowMessageHeader__Schema = 1,
ArrowMessageHeader__DictionaryBatch = 2,
ArrowMessageHeader__RecordBatch = 3,
ArrowMessageHeader__Tensor = 4,
ArrowMessageHeader__SparseTensor = 5,
} ArrowMessageHeader;
/*
* Endianness : short
*/
typedef enum
{
ArrowEndianness__Little = 0,
ArrowEndianness__Big = 1,
} ArrowEndianness;
/*
* Type : byte
*/
typedef enum
{
ArrowType__Null = 1,
ArrowType__Int = 2,
ArrowType__FloatingPoint = 3,
ArrowType__Binary = 4,
ArrowType__Utf8 = 5,
ArrowType__Bool = 6,
ArrowType__Decimal = 7,
ArrowType__Date = 8,
ArrowType__Time = 9,
ArrowType__Timestamp = 10,
ArrowType__Interval = 11,
ArrowType__List = 12,
ArrowType__Struct = 13,
ArrowType__Union = 14,
ArrowType__FixedSizeBinary = 15,
ArrowType__FixedSizeList = 16,
ArrowType__Map = 17,
} ArrowTypeTag;
/*
* DateUnit : short
*/
typedef enum
{
ArrowDateUnit__Day = 0,
ArrowDateUnit__MilliSecond = 1,
} ArrowDateUnit;
/*
* TimeUnit : short
*/
typedef enum
{
ArrowTimeUnit__Second = 0,
ArrowTimeUnit__MilliSecond = 1,
ArrowTimeUnit__MicroSecond = 2,
ArrowTimeUnit__NanoSecond = 3,
} ArrowTimeUnit;
/*
* IntervalUnit : short
*/
typedef enum
{
ArrowIntervalUnit__Year_Month = 0,
ArrowIntervalUnit__Day_Time = 1,
} ArrowIntervalUnit;
/*
* Precision : short
*/
typedef enum
{
ArrowPrecision__Half = 0,
ArrowPrecision__Single = 1,
ArrowPrecision__Double = 2,
} ArrowPrecision;
/*
* UnionMode : short
*/
typedef enum
{
ArrowUnionMode__Sparse = 0,
ArrowUnionMode__Dense = 1,
} ArrowUnionMode;
/*
* ArrowNodeTag
*/
typedef enum
{
/* types */
ArrowNodeTag__Null,
ArrowNodeTag__Int,
ArrowNodeTag__FloatingPoint,
ArrowNodeTag__Utf8,
ArrowNodeTag__Binary,
ArrowNodeTag__Bool,
ArrowNodeTag__Decimal,
ArrowNodeTag__Date,
ArrowNodeTag__Time,
ArrowNodeTag__Timestamp,
ArrowNodeTag__Interval,
ArrowNodeTag__List,
ArrowNodeTag__Struct,
ArrowNodeTag__Union,
ArrowNodeTag__FixedSizeBinary,
ArrowNodeTag__FixedSizeList,
ArrowNodeTag__Map,
/* others */
ArrowNodeTag__KeyValue,
ArrowNodeTag__DictionaryEncoding,
ArrowNodeTag__Field,
ArrowNodeTag__FieldNode,
ArrowNodeTag__Buffer,
ArrowNodeTag__Schema,
ArrowNodeTag__RecordBatch,
ArrowNodeTag__DictionaryBatch,
ArrowNodeTag__Message,
ArrowNodeTag__Block,
ArrowNodeTag__Footer,
} ArrowNodeTag;
/*
* ArrowNode
*/
typedef struct
{
ArrowNodeTag tag;
} ArrowNode;
/* Null */
typedef ArrowNode ArrowTypeNull;
/* Int */
typedef struct ArrowTypeInt
{
ArrowNodeTag tag;
int32 bitWidth;
bool is_signed;
} ArrowTypeInt;
/* FloatingPoint */
typedef struct ArrowTypeFloatingPoint
{
ArrowNodeTag tag;
ArrowPrecision precision;
} ArrowTypeFloatingPoint;
/* Utf8 */
typedef ArrowNode ArrowTypeUtf8;
/* Binary */
typedef ArrowNode ArrowTypeBinary;
/* Bool */
typedef ArrowNode ArrowTypeBool;
/* Decimal */
typedef struct ArrowTypeDecimal
{
ArrowNodeTag tag;
int32 precision;
int32 scale;
} ArrowTypeDecimal;
/* Date */
typedef struct ArrowTypeDate
{
ArrowNodeTag tag;
ArrowDateUnit unit;
} ArrowTypeDate;
/* Time */
typedef struct ArrowTypeTime
{
ArrowNodeTag tag;
ArrowTimeUnit unit;
int32 bitWidth;
} ArrowTypeTime;
/* Timestamp */
typedef struct ArrowTypeTimestamp
{
ArrowNodeTag tag;
ArrowTimeUnit unit;
const char *timezone;
int32 _timezone_len;
} ArrowTypeTimestamp;
/* Interval */
typedef struct ArrowTypeInterval
{
ArrowNodeTag tag;
ArrowIntervalUnit unit;
} ArrowTypeInterval;
/* List */
typedef ArrowNode ArrowTypeList;
/* Struct */
typedef ArrowNode ArrowTypeStruct;
/* Union */
typedef struct ArrowTypeUnion
{
ArrowNodeTag tag;
ArrowUnionMode mode;
int32 *typeIds;
int32 _num_typeIds;
} ArrowTypeUnion;
/* FixedSizeBinary */
typedef struct ArrowTypeFixedSizeBinary
{
ArrowNodeTag tag;
int32 byteWidth;
} ArrowTypeFixedSizeBinary;
/* FixedSizeList */
typedef struct ArrowTypeFixedSizeList
{
ArrowNodeTag tag;
int32 listSize;
} ArrowTypeFixedSizeList;
/* Map */
typedef struct ArrowTypeMap
{
ArrowNodeTag tag;
bool keysSorted;
} ArrowTypeMap;
/*
* ArrowType
*/
typedef union ArrowType
{
ArrowNodeTag tag;
ArrowTypeNull Null;
ArrowTypeInt Int;
ArrowTypeFloatingPoint FloatingPoint;
ArrowTypeUtf8 Utf8;
ArrowTypeBinary Binary;
ArrowTypeBool Bool;
ArrowTypeDecimal Decimal;
ArrowTypeDate Date;
ArrowTypeTime Time;
ArrowTypeTimestamp Timestamp;
ArrowTypeInterval Interval;
ArrowTypeList List;
ArrowTypeStruct Struct;
ArrowTypeUnion Union;
ArrowTypeFixedSizeBinary FixedSizeBinary;
ArrowTypeFixedSizeList FixedSizeList;
ArrowTypeMap Map;
} ArrowType;
/*
* Buffer
*/
typedef struct ArrowBuffer
{
ArrowNodeTag tag;
int64 offset;
int64 length;
} ArrowBuffer;
/*
* KeyValue
*/
typedef struct ArrowKeyValue
{
ArrowNodeTag tag;
const char *key;
const char *value;
int _key_len;
int _value_len;
} ArrowKeyValue;
/*
* DictionaryEncoding
*/
typedef struct ArrowDictionaryEncoding
{
ArrowNodeTag tag;
int64 id;
ArrowTypeInt indexType;
bool isOrdered;
} ArrowDictionaryEncoding;
/*
* Field
*/
typedef struct ArrowField
{
ArrowNodeTag tag;
const char *name;
int _name_len;
bool nullable;
ArrowType type;
ArrowDictionaryEncoding dictionary;
/* vector of nested data types */
struct ArrowField *children;
int _num_children;
/* vector of user defined metadata */
ArrowKeyValue *custom_metadata;
int _num_custom_metadata;
} ArrowField;
/*
* FieldNode
*/
typedef struct ArrowFieldNode
{
ArrowNodeTag tag;
uint64 length;
uint64 null_count;
} ArrowFieldNode;
/*
* Schema
*/
typedef struct ArrowSchema
{
ArrowNodeTag tag;
ArrowEndianness endianness;
/* vector of Field */
ArrowField *fields;
int _num_fields;
/* List of KeyValue */
ArrowKeyValue *custom_metadata;
int _num_custom_metadata;
} ArrowSchema;
/*
* RecordBatch
*/
typedef struct ArrowRecordBatch
{
ArrowNodeTag tag;
int64 length;
/* vector of FieldNode */
ArrowFieldNode *nodes;
int _num_nodes;
/* vector of Buffer */
ArrowBuffer *buffers;
int _num_buffers;
} ArrowRecordBatch;
/*
* DictionaryBatch
*/
typedef struct ArrowDictionaryBatch
{
ArrowNodeTag tag;
int64 id;
ArrowRecordBatch data;
bool isDelta;
} ArrowDictionaryBatch;
/*
* ArrowMessageHeader
*/
typedef union ArrowMessageHeader
{
ArrowNodeTag tag;
ArrowNode node;
ArrowSchema schema;
ArrowDictionaryBatch dictionaryBatch;
ArrowRecordBatch recordBatch;
} ArrowMessageBody;
/*
* Message
*/
typedef struct ArrowMessage
{
ArrowNodeTag tag;
ArrowMetadataVersion version;
ArrowMessageBody body;
uint64 bodyLength;
} ArrowMessage;
/*
* Block
*/
typedef struct ArrowBlock
{
ArrowNodeTag tag;
int64 offset;
int32 metaDataLength;
int64 bodyLength;
} ArrowBlock;
/*
* Footer
*/
typedef struct ArrowFooter
{
ArrowNodeTag tag;
ArrowMetadataVersion version;
ArrowSchema schema;
ArrowBlock *dictionaries;
int _num_dictionaries;
ArrowBlock *recordBatches;
int _num_recordBatches;
} ArrowFooter;
#endif /* _ARROW_DEFS_H_ */