-
Notifications
You must be signed in to change notification settings - Fork 8
/
enums.go
710 lines (641 loc) · 25 KB
/
enums.go
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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
package tiledb
/*
#include <tiledb/tiledb.h>
#include <tiledb/tiledb_enum.h>
#include <tiledb/tiledb_serialization.h>
#include <stdlib.h>
*/
import "C"
import (
"encoding/json"
"fmt"
"reflect"
"strconv"
"time"
"unsafe"
)
// ArrayType enum for tiledb arrays
type ArrayType int8
const (
// TILEDB_DENSE dense array
TILEDB_DENSE ArrayType = C.TILEDB_DENSE
// TILEDB_SPARSE dense array
TILEDB_SPARSE ArrayType = C.TILEDB_SPARSE
)
// Datatype
type Datatype int8
const (
// TILEDB_INT32 32-bit signed integer
TILEDB_INT32 Datatype = C.TILEDB_INT32
// TILEDB_INT64 64-bit signed integer
TILEDB_INT64 Datatype = C.TILEDB_INT64
// TILEDB_FLOAT32 32-bit floating point value
TILEDB_FLOAT32 Datatype = C.TILEDB_FLOAT32
// TILEDB_FLOAT64 64-bit floating point value
TILEDB_FLOAT64 Datatype = C.TILEDB_FLOAT64
// TILEDB_CHAR Character
TILEDB_CHAR Datatype = C.TILEDB_CHAR
// TILEDB_INT8 8-bit signed integer
TILEDB_INT8 Datatype = C.TILEDB_INT8
// TILEDB_UINT8 8-bit unsigned integer
TILEDB_UINT8 Datatype = C.TILEDB_UINT8
// TILEDB_INT16 16-bit signed integer
TILEDB_INT16 Datatype = C.TILEDB_INT16
// TILEDB_UINT16 16-bit unsigned integer
TILEDB_UINT16 Datatype = C.TILEDB_UINT16
// TILEDB_UINT32 32-bit unsigned integer
TILEDB_UINT32 Datatype = C.TILEDB_UINT32
// TILEDB_UINT64 64-bit unsigned integer
TILEDB_UINT64 Datatype = C.TILEDB_UINT64
// TILEDB_STRING_ASCII ASCII string
TILEDB_STRING_ASCII Datatype = C.TILEDB_STRING_ASCII
// TILEDB_STRING_UTF8 UTF-8 string
TILEDB_STRING_UTF8 Datatype = C.TILEDB_STRING_UTF8
// TILEDB_STRING_UTF16 UTF-16 string
TILEDB_STRING_UTF16 Datatype = C.TILEDB_STRING_UTF16
// TILEDB_STRING_UTF32 UTF-32 string
TILEDB_STRING_UTF32 Datatype = C.TILEDB_STRING_UTF32
// TILEDB_STRING_UCS2 UCS2 string
TILEDB_STRING_UCS2 Datatype = C.TILEDB_STRING_UCS2
// TILEDB_STRING_UCS4 UCS4 string
TILEDB_STRING_UCS4 Datatype = C.TILEDB_STRING_UCS4
// TILEDB_ANY This can be any datatype. Must store (type tag, value) pairs.
TILEDB_ANY Datatype = C.TILEDB_ANY
// TILEDB_DATETIME_YEAR 64-bit signed integer representing year
TILEDB_DATETIME_YEAR Datatype = C.TILEDB_DATETIME_YEAR
// TILEDB_DATETIME_MONTH 64-bit signed integer representing month
TILEDB_DATETIME_MONTH Datatype = C.TILEDB_DATETIME_MONTH
// TILEDB_DATETIME_WEEK 64-bit signed integer representing week
TILEDB_DATETIME_WEEK Datatype = C.TILEDB_DATETIME_WEEK
// TILEDB_DATETIME_DAY 64-bit signed integer representing day
TILEDB_DATETIME_DAY Datatype = C.TILEDB_DATETIME_DAY
// TILEDB_DATETIME_HR 64-bit signed integer representing hour
TILEDB_DATETIME_HR Datatype = C.TILEDB_DATETIME_HR
// TILEDB_DATETIME_MIN 64-bit signed integer representing minute
TILEDB_DATETIME_MIN Datatype = C.TILEDB_DATETIME_MIN
// TILEDB_DATETIME_SEC 64-bit signed integer representing second
TILEDB_DATETIME_SEC Datatype = C.TILEDB_DATETIME_SEC
// TILEDB_DATETIME_MS 64-bit signed integer representing ms
TILEDB_DATETIME_MS Datatype = C.TILEDB_DATETIME_MS
// TILEDB_DATETIME_US 64-bit signed integer representing us
TILEDB_DATETIME_US Datatype = C.TILEDB_DATETIME_US
// TILEDB_DATETIME_NS 64-bit signed integer representing ns
TILEDB_DATETIME_NS Datatype = C.TILEDB_DATETIME_NS
// TILEDB_DATETIME_PS 64-bit signed integer representing ps
TILEDB_DATETIME_PS Datatype = C.TILEDB_DATETIME_PS
// TILEDB_DATETIME_FS 64-bit signed integer representing fs
TILEDB_DATETIME_FS Datatype = C.TILEDB_DATETIME_FS
// TILEDB_DATETIME_AS 64-bit signed integer representing as
TILEDB_DATETIME_AS Datatype = C.TILEDB_DATETIME_AS
// TILEDB_TIME_HR 64-bit signed integer representing hour
TILEDB_TIME_HR Datatype = C.TILEDB_TIME_HR
// TILEDB_TIME_MIN 64-bit signed integer representing minute
TILEDB_TIME_MIN Datatype = C.TILEDB_TIME_MIN
// TILEDB_TIME_SEC 64-bit signed integer representing second
TILEDB_TIME_SEC Datatype = C.TILEDB_TIME_SEC
// TILEDB_TIME_MS 64-bit signed integer representing ms
TILEDB_TIME_MS Datatype = C.TILEDB_TIME_MS
// TILEDB_TIME_US 64-bit signed integer representing us
TILEDB_TIME_US Datatype = C.TILEDB_TIME_US
// TILEDB_TIME_NS 64-bit signed integer representing ns
TILEDB_TIME_NS Datatype = C.TILEDB_TIME_NS
// TILEDB_TIME_PS 64-bit signed integer representing ps
TILEDB_TIME_PS Datatype = C.TILEDB_TIME_PS
// TILEDB_TIME_FS 64-bit signed integer representing fs
TILEDB_TIME_FS Datatype = C.TILEDB_TIME_FS
// TILEDB_TIME_AS 64-bit signed integer representing as
TILEDB_TIME_AS Datatype = C.TILEDB_TIME_AS
// TILEDB_BLOB 8-bit unsigned integer (or std::byte)
TILEDB_BLOB Datatype = C.TILEDB_BLOB
// TILEDB_BOOL 8-bit boolean type
TILEDB_BOOL Datatype = C.TILEDB_BOOL
// TILEDB_GEOM_WKB 8-bit unsigned integer (or std::byte)
TILEDB_GEOM_WKB Datatype = C.TILEDB_GEOM_WKB
// TILEDB_GEOM_WKT 8-bit unsigned integer (or std::byte)
TILEDB_GEOM_WKT Datatype = C.TILEDB_GEOM_WKT
)
// String returns a string representation.
func (d Datatype) String() string {
var cname *C.char
C.tiledb_datatype_to_str(C.tiledb_datatype_t(d), &cname)
return C.GoString(cname)
}
// MarshalJSON implements the interface for marshaling to json.
func (d Datatype) MarshalJSON() ([]byte, error) {
return json.Marshal(d.String())
}
// UnmarshalJSON implements the interface for unmarshaling from json.
func (d *Datatype) UnmarshalJSON(bytes []byte) error {
return d.FromString(string(bytes))
}
// FromString converts from a datatype string to enum.
func (d *Datatype) FromString(s string) error {
cname := C.CString(s)
defer C.free(unsafe.Pointer(cname))
var cDatatype C.tiledb_datatype_t
ret := C.tiledb_datatype_from_str(cname, &cDatatype)
if ret != C.TILEDB_OK {
return fmt.Errorf("%s is not a recognized tiledb_datatype_t", s)
}
*d = Datatype(cDatatype)
return nil
}
// DatatypeFromString converts from a datatype string to enum.
func DatatypeFromString(s string) (Datatype, error) {
var d Datatype
err := d.FromString(s)
if err != nil {
return TILEDB_ANY, err
}
return d, nil
}
// ReflectKind returns the reflect kind given a datatype.
func (d Datatype) ReflectKind() reflect.Kind {
switch d {
case TILEDB_INT8:
return reflect.Int8
case TILEDB_INT16:
return reflect.Int16
case TILEDB_INT32:
return reflect.Int32
case TILEDB_INT64:
return reflect.Int64
case TILEDB_UINT8, TILEDB_BLOB, TILEDB_GEOM_WKB, TILEDB_GEOM_WKT:
return reflect.Uint8
case TILEDB_UINT16:
return reflect.Uint16
case TILEDB_UINT32:
return reflect.Uint32
case TILEDB_UINT64:
return reflect.Uint64
case TILEDB_FLOAT32:
return reflect.Float32
case TILEDB_FLOAT64:
return reflect.Float64
case TILEDB_CHAR:
return reflect.Uint8
case TILEDB_STRING_ASCII:
return reflect.Uint8
case TILEDB_STRING_UTF8:
return reflect.Uint8
case TILEDB_STRING_UTF16:
return reflect.Uint16
case TILEDB_STRING_UTF32:
return reflect.Uint32
case TILEDB_STRING_UCS2:
return reflect.Uint16
case TILEDB_STRING_UCS4:
return reflect.Uint32
case TILEDB_ANY:
return reflect.Interface
case TILEDB_DATETIME_YEAR, TILEDB_DATETIME_MONTH, TILEDB_DATETIME_WEEK, TILEDB_DATETIME_DAY, TILEDB_DATETIME_HR, TILEDB_DATETIME_MIN, TILEDB_DATETIME_SEC, TILEDB_DATETIME_MS, TILEDB_DATETIME_US, TILEDB_DATETIME_NS, TILEDB_DATETIME_PS, TILEDB_DATETIME_FS, TILEDB_DATETIME_AS, TILEDB_TIME_HR, TILEDB_TIME_MIN, TILEDB_TIME_SEC, TILEDB_TIME_MS, TILEDB_TIME_US, TILEDB_TIME_NS, TILEDB_TIME_PS, TILEDB_TIME_FS, TILEDB_TIME_AS:
return reflect.Int64
case TILEDB_BOOL:
return reflect.Bool
default:
return reflect.Interface
}
}
// ReflectType returns the reflect type given a datatype.
func (d Datatype) ReflectType() reflect.Type {
switch d {
case TILEDB_INT8:
return reflect.TypeOf(int8(0))
case TILEDB_INT16:
return reflect.TypeOf(int16(0))
case TILEDB_INT32:
return reflect.TypeOf(int32(0))
case TILEDB_INT64:
return reflect.TypeOf(int64(0))
case TILEDB_UINT8, TILEDB_BLOB, TILEDB_GEOM_WKB, TILEDB_GEOM_WKT:
return reflect.TypeOf(uint8(0))
case TILEDB_UINT16:
return reflect.TypeOf(uint16(0))
case TILEDB_UINT32:
return reflect.TypeOf(uint32(0))
case TILEDB_UINT64:
return reflect.TypeOf(uint64(0))
case TILEDB_FLOAT32:
return reflect.TypeOf(float32(0))
case TILEDB_FLOAT64:
return reflect.TypeOf(float64(0))
case TILEDB_CHAR:
return reflect.TypeOf(uint8(0))
case TILEDB_STRING_ASCII:
return reflect.TypeOf(uint8(0))
case TILEDB_STRING_UTF8:
return reflect.TypeOf(uint8(0))
case TILEDB_STRING_UTF16:
return reflect.TypeOf(uint16(0))
case TILEDB_STRING_UTF32:
return reflect.TypeOf(uint32(0))
case TILEDB_STRING_UCS2:
return reflect.TypeOf(uint16(0))
case TILEDB_STRING_UCS4:
return reflect.TypeOf(uint32(0))
case TILEDB_ANY: // deprecated type since 2.7.0, treat as invalid
return reflect.TypeOf(nil)
case TILEDB_DATETIME_YEAR, TILEDB_DATETIME_MONTH, TILEDB_DATETIME_WEEK, TILEDB_DATETIME_DAY, TILEDB_DATETIME_HR, TILEDB_DATETIME_MIN, TILEDB_DATETIME_SEC, TILEDB_DATETIME_MS, TILEDB_DATETIME_US, TILEDB_DATETIME_NS, TILEDB_DATETIME_PS, TILEDB_DATETIME_FS, TILEDB_DATETIME_AS, TILEDB_TIME_HR, TILEDB_TIME_MIN, TILEDB_TIME_SEC, TILEDB_TIME_MS, TILEDB_TIME_US, TILEDB_TIME_NS, TILEDB_TIME_PS, TILEDB_TIME_FS, TILEDB_TIME_AS:
return reflect.TypeOf(int64(0))
case TILEDB_BOOL:
return reflect.TypeOf(true)
default:
return reflect.TypeOf(nil)
}
}
// Size returns the datatype size in bytes.
func (d Datatype) Size() uint64 {
return uint64(C.tiledb_datatype_size(C.tiledb_datatype_t(d)))
}
// MakeSlice makes a slice of the correct type corresponding to the datatype, with a given number of elements.
func (d Datatype) MakeSlice(numElements uint64) (interface{}, unsafe.Pointer, error) {
switch d {
case TILEDB_INT8:
return makeSlice[int8](numElements)
case TILEDB_INT16:
return makeSlice[int16](numElements)
case TILEDB_INT32:
return makeSlice[int32](numElements)
case TILEDB_INT64, TILEDB_DATETIME_YEAR, TILEDB_DATETIME_MONTH, TILEDB_DATETIME_WEEK, TILEDB_DATETIME_DAY, TILEDB_DATETIME_HR, TILEDB_DATETIME_MIN, TILEDB_DATETIME_SEC, TILEDB_DATETIME_MS, TILEDB_DATETIME_US, TILEDB_DATETIME_NS, TILEDB_DATETIME_PS, TILEDB_DATETIME_FS, TILEDB_DATETIME_AS, TILEDB_TIME_HR, TILEDB_TIME_MIN, TILEDB_TIME_SEC, TILEDB_TIME_MS, TILEDB_TIME_US, TILEDB_TIME_NS, TILEDB_TIME_PS, TILEDB_TIME_FS, TILEDB_TIME_AS:
return makeSlice[int64](numElements)
case TILEDB_UINT8, TILEDB_CHAR, TILEDB_STRING_ASCII, TILEDB_STRING_UTF8, TILEDB_BLOB, TILEDB_GEOM_WKB, TILEDB_GEOM_WKT:
return makeSlice[uint8](numElements)
case TILEDB_UINT16, TILEDB_STRING_UTF16, TILEDB_STRING_UCS2:
return makeSlice[uint16](numElements)
case TILEDB_UINT32, TILEDB_STRING_UTF32, TILEDB_STRING_UCS4:
return makeSlice[uint32](numElements)
case TILEDB_UINT64:
return makeSlice[uint64](numElements)
case TILEDB_FLOAT32:
return makeSlice[float32](numElements)
case TILEDB_FLOAT64:
return makeSlice[float64](numElements)
case TILEDB_BOOL:
return makeSlice[bool](numElements)
default:
return nil, nil, fmt.Errorf("error making datatype slice; unrecognized datatype: %d", d)
}
}
// makeSlice makes a slice and returns it as well as a pointer to its start.
// Its return type matches d.MakeSlice for convenience.
func makeSlice[T any](numElements uint64) (any, unsafe.Pointer, error) {
slice := make([]T, numElements)
return slice, slicePtr(slice), nil
}
// GetValue gets value stored in a void pointer for this data type.
func (d Datatype) GetValue(valueNum uint, cvalue unsafe.Pointer) (interface{}, error) {
switch d {
case TILEDB_INT8:
return getValueInternal[int8](valueNum, cvalue)
case TILEDB_INT16:
return getValueInternal[int16](valueNum, cvalue)
case TILEDB_INT32:
return getValueInternal[int32](valueNum, cvalue)
case TILEDB_INT64:
return getValueInternal[int64](valueNum, cvalue)
case TILEDB_UINT8, TILEDB_BLOB, TILEDB_GEOM_WKB, TILEDB_GEOM_WKT:
return getValueInternal[uint8](valueNum, cvalue)
case TILEDB_UINT16:
return getValueInternal[uint16](valueNum, cvalue)
case TILEDB_UINT32:
return getValueInternal[uint32](valueNum, cvalue)
case TILEDB_UINT64:
return getValueInternal[uint64](valueNum, cvalue)
case TILEDB_FLOAT32:
return getValueInternal[float32](valueNum, cvalue)
case TILEDB_FLOAT64:
return getValueInternal[float64](valueNum, cvalue)
case TILEDB_CHAR, TILEDB_STRING_ASCII, TILEDB_STRING_UTF8:
if cvalue == nil || valueNum == 0 {
return "", nil
}
return C.GoStringN((*C.char)(cvalue), C.int(valueNum)), nil
case TILEDB_DATETIME_YEAR, TILEDB_DATETIME_MONTH, TILEDB_DATETIME_WEEK,
TILEDB_DATETIME_DAY, TILEDB_DATETIME_HR, TILEDB_DATETIME_MIN,
TILEDB_DATETIME_SEC, TILEDB_DATETIME_MS, TILEDB_DATETIME_US,
TILEDB_DATETIME_NS, TILEDB_DATETIME_PS, TILEDB_DATETIME_FS,
TILEDB_DATETIME_AS, TILEDB_TIME_HR, TILEDB_TIME_MIN, TILEDB_TIME_SEC, TILEDB_TIME_MS, TILEDB_TIME_US, TILEDB_TIME_NS, TILEDB_TIME_PS, TILEDB_TIME_FS, TILEDB_TIME_AS:
if valueNum > 1 {
return nil, fmt.Errorf("only 1 timestamp may be returned, not %d", d)
}
if cvalue == nil {
return time.Time{}, nil
}
timestamp := *(*int64)(cvalue)
return GetTimeFromTimestamp(d, timestamp), nil
case TILEDB_BOOL:
// We handle this differently to ensure that our bools are always in the
// canonical form (true/1 or false/0).
if cvalue == nil {
return false, nil
}
bytes := unsafeSlice[byte](cvalue, valueNum)
if valueNum == 1 {
return bytes[0] != 0, nil
}
bools := make([]bool, valueNum)
for i, b := range bytes {
bools[i] = b != 0
}
return bools, nil
default:
return nil, fmt.Errorf("Unrecognized value type: %d", d)
}
}
// getValueInternal handles the internals of Datatype.GetValue. It returns
// `valueNum` Ts located at `ptr`. As a special case, if valueNum == 1,
// it returns a T itself rather than a []T.
func getValueInternal[T any](valueNum uint, ptr unsafe.Pointer) (any, error) {
var singleValue T
if ptr == nil {
return singleValue, nil
}
if valueNum == 1 {
singleValue = *(*T)(ptr)
return singleValue, nil
}
out := make([]T, valueNum)
inSlice := unsafeSlice[T](ptr, valueNum)
copy(out, inSlice)
return out, nil
}
var tileDBInt, tileDBUint = intUintTypes() // The Datatypes of Go `int` and `uint`.
func intUintTypes() (Datatype, Datatype) {
switch strconv.IntSize {
case 32:
return TILEDB_INT32, TILEDB_UINT32
case 64:
return TILEDB_INT64, TILEDB_UINT64
}
panic(fmt.Sprintf("can't run on systems with %v-bit integers", strconv.IntSize))
}
// EncryptionType represents different encryption algorithms.
type EncryptionType uint8
const (
// TILEDB_NO_ENCRYPTION No encryption
TILEDB_NO_ENCRYPTION EncryptionType = C.TILEDB_NO_ENCRYPTION
// TILEDB_AES_256_GCM AES-256-GCM encryption
TILEDB_AES_256_GCM EncryptionType = C.TILEDB_AES_256_GCM
)
// String returns a string representation.
func (encryptionType EncryptionType) String() string {
var ctype *C.char
C.tiledb_encryption_type_to_str(C.tiledb_encryption_type_t(encryptionType), &ctype)
return C.GoString(ctype)
}
// FilterType for attribute/coordinates/offsets filters
type FilterType uint8
const (
// TILEDB_FILTER_NONE No-op filter
TILEDB_FILTER_NONE FilterType = C.TILEDB_FILTER_NONE
// TILEDB_FILTER_GZIP Gzip compressor
TILEDB_FILTER_GZIP FilterType = C.TILEDB_FILTER_GZIP
// TILEDB_FILTER_ZSTD Zstandard compressor
TILEDB_FILTER_ZSTD FilterType = C.TILEDB_FILTER_ZSTD
// TILEDB_FILTER_LZ4 LZ4 compressor
TILEDB_FILTER_LZ4 FilterType = C.TILEDB_FILTER_LZ4
// TILEDB_FILTER_RLE Run-length encoding compressor
TILEDB_FILTER_RLE FilterType = C.TILEDB_FILTER_RLE
// TILEDB_FILTER_BZIP2 Bzip2 compressor
TILEDB_FILTER_BZIP2 FilterType = C.TILEDB_FILTER_BZIP2
// TILEDB_FILTER_DOUBLE_DELTA Double-delta compressor
TILEDB_FILTER_DOUBLE_DELTA FilterType = C.TILEDB_FILTER_DOUBLE_DELTA
// TILEDB_FILTER_BIT_WIDTH_REDUCTION Bit width reduction filter.
TILEDB_FILTER_BIT_WIDTH_REDUCTION FilterType = C.TILEDB_FILTER_BIT_WIDTH_REDUCTION
// TILEDB_FILTER_BITSHUFFLE Bitshuffle filter.
TILEDB_FILTER_BITSHUFFLE FilterType = C.TILEDB_FILTER_BITSHUFFLE
// TILEDB_FILTER_BYTESHUFFLE Byteshuffle filter.
TILEDB_FILTER_BYTESHUFFLE FilterType = C.TILEDB_FILTER_BYTESHUFFLE
// TILEDB_FILTER_POSITIVE_DELTA Positive-delta encoding filter.
TILEDB_FILTER_POSITIVE_DELTA FilterType = C.TILEDB_FILTER_POSITIVE_DELTA
// TILEDB_FILTER_SCALE_FLOAT FILTER_SCALE_FLOAT float scaling filter.
TILEDB_FILTER_SCALE_FLOAT FilterType = C.TILEDB_FILTER_SCALE_FLOAT
// TILEDB_FILTER_DELTA Delta encoding filter.
TILEDB_FILTER_DELTA FilterType = C.TILEDB_FILTER_DELTA
)
// FilterOption for a given filter
type FilterOption uint8
const (
// TILEDB_COMPRESSION_LEVEL Compression level. Type: `int32_t`.
TILEDB_COMPRESSION_LEVEL FilterOption = C.TILEDB_COMPRESSION_LEVEL
// TILEDB_BIT_WIDTH_MAX_WINDOW Max window length for bit width reduction. Type: `uint32_t`.
TILEDB_BIT_WIDTH_MAX_WINDOW FilterOption = C.TILEDB_BIT_WIDTH_MAX_WINDOW
// TILEDB_POSITIVE_DELTA_MAX_WINDOW Max window length for positive-delta encoding. Type: `uint32_t`.
TILEDB_POSITIVE_DELTA_MAX_WINDOW FilterOption = C.TILEDB_POSITIVE_DELTA_MAX_WINDOW
)
// FS represents support fs types
type FS int8
const (
// TILEDB_HDFS HDFS filesystem support
TILEDB_HDFS FS = C.TILEDB_HDFS
// TILEDB_S3 S3 filesystem support
TILEDB_S3 FS = C.TILEDB_S3
)
// Layout cell/tile layout
type Layout int8
const (
// TILEDB_ROW_MAJOR Row-major layout
TILEDB_ROW_MAJOR Layout = C.TILEDB_ROW_MAJOR
// TILEDB_COL_MAJOR Column-major layout
TILEDB_COL_MAJOR Layout = C.TILEDB_COL_MAJOR
// TILEDB_GLOBAL_ORDER Global-order layout
TILEDB_GLOBAL_ORDER Layout = C.TILEDB_GLOBAL_ORDER
// TILEDB_UNORDERED Unordered layout
TILEDB_UNORDERED Layout = C.TILEDB_UNORDERED
// TILEDB_HILBERT Hilbert layout
TILEDB_HILBERT Layout = C.TILEDB_HILBERT
)
// QueryStatus status of a query
type QueryStatus int8
const (
// TILEDB_FAILED Query failed
TILEDB_FAILED QueryStatus = C.TILEDB_FAILED
// TILEDB_COMPLETED Query completed (all data has been read)
TILEDB_COMPLETED QueryStatus = C.TILEDB_COMPLETED
// TILEDB_INPROGRESS Query is in progress
TILEDB_INPROGRESS QueryStatus = C.TILEDB_INPROGRESS
// TILEDB_INCOMPLETE Query completed (but not all data has been read)
TILEDB_INCOMPLETE QueryStatus = C.TILEDB_INCOMPLETE
// TILEDB_UNINITIALIZED Query not initialized.
TILEDB_UNINITIALIZED QueryStatus = C.TILEDB_UNINITIALIZED
// TILEDB_INITIALIZED Query initialized.
TILEDB_INITIALIZED QueryStatus = C.TILEDB_INITIALIZED
)
// String returns a string representation.
func (q QueryStatus) String() string {
var cname *C.char
C.tiledb_query_status_to_str(C.tiledb_query_status_t(q), &cname)
return C.GoString(cname)
}
// QueryStatusDetailsReason indicates extended information about a returned query status in order to
// allow improved client-side handling of buffers and potential resubmissions.
type QueryStatusDetailsReason uint8
const (
// TILEDB_REASON_NONE No additional details available
TILEDB_REASON_NONE QueryStatusDetailsReason = C.TILEDB_REASON_NONE
// TILEDB_REASON_USER_BUFFER_SIZE User buffers are too small
TILEDB_REASON_USER_BUFFER_SIZE QueryStatusDetailsReason = C.TILEDB_REASON_USER_BUFFER_SIZE
// TILEDB_REASON_MEMORY_BUDGET Exceeded memory budget: can resubmit without resize
TILEDB_REASON_MEMORY_BUDGET QueryStatusDetailsReason = C.TILEDB_REASON_MEMORY_BUDGET
)
// String returns a string representation.
func (r QueryStatusDetailsReason) String() string {
// TileDB does not provide tiledb_query_status_details_reason_to_str
switch r {
case TILEDB_REASON_NONE:
return "REASON_NONE"
case TILEDB_REASON_USER_BUFFER_SIZE:
return "REASON_USER_BUFFER_SIZE"
case TILEDB_REASON_MEMORY_BUDGET:
return "REASON_MEMORY_BUDGET"
}
return "REASON_UNKNOWN"
}
// QueryType read or write query
type QueryType int8
const (
// TILEDB_READ Read query
TILEDB_READ QueryType = C.TILEDB_READ
// TILEDB_WRITE Write query
TILEDB_WRITE QueryType = C.TILEDB_WRITE
// TILEDB_DELETE Delete query
TILEDB_DELETE QueryType = C.TILEDB_DELETE
// TILEDB_MODIFY_EXCLUSIVE Modify exclusive query
TILEDB_MODIFY_EXCLUSIVE QueryType = C.TILEDB_MODIFY_EXCLUSIVE
)
// QueryTypeFromString returns the internal representation of the query type.
func QueryTypeFromString(s string) (QueryType, error) {
cname := C.CString(s)
defer C.free(unsafe.Pointer(cname))
var cQueryType C.tiledb_query_type_t
ret := C.tiledb_query_type_from_str(cname, &cQueryType)
if ret != C.TILEDB_OK {
return 0, fmt.Errorf("%q is not a recognized tiledb_query_type_t", s)
}
return QueryType(cQueryType), nil
}
// QueryConditionOp operation type for a query condition
type QueryConditionOp uint8
const (
// TILEDB_QUERY_CONDITION_LT defines the query condition for a less than comparison
TILEDB_QUERY_CONDITION_LT QueryConditionOp = C.TILEDB_LT
// TILEDB_QUERY_CONDITION_LE defines the query condition for a less than or equal to comparison
TILEDB_QUERY_CONDITION_LE QueryConditionOp = C.TILEDB_LE
// TILEDB_QUERY_CONDITION_GT defines the query condition for a greater than comparison
TILEDB_QUERY_CONDITION_GT QueryConditionOp = C.TILEDB_GT
// TILEDB_QUERY_CONDITION_GE defines the query condition for a greater than or equal to comparison
TILEDB_QUERY_CONDITION_GE QueryConditionOp = C.TILEDB_GE
// TILEDB_QUERY_CONDITION_EQ defines the query condition for an equal to comparison
TILEDB_QUERY_CONDITION_EQ QueryConditionOp = C.TILEDB_EQ
// TILEDB_QUERY_CONDITION_NE defines the query condition for a not equal to comparison
TILEDB_QUERY_CONDITION_NE QueryConditionOp = C.TILEDB_NE
)
// QueryConditionCombinationOp operation type for a query condition combination
type QueryConditionCombinationOp uint8
const (
// TILEDB_QUERY_CONDITION_AND defines the query condition for an and combination
TILEDB_QUERY_CONDITION_AND QueryConditionCombinationOp = C.TILEDB_AND
// TILEDB_QUERY_CONDITION_AND defines the query condition for an or combination
TILEDB_QUERY_CONDITION_OR QueryConditionCombinationOp = C.TILEDB_OR
// TILEDB_QUERY_CONDITION_AND defines the query condition for a not combination
TILEDB_QUERY_CONDITION_NOT QueryConditionCombinationOp = C.TILEDB_NOT
)
// SerializationType how data is serialized
type SerializationType int8
const (
// TILEDB_JSON Serialization to/from json
TILEDB_JSON SerializationType = C.TILEDB_JSON
// TILEDB_JSON Serialization to/from capnp
TILEDB_CAPNP SerializationType = C.TILEDB_CAPNP
)
// VFSMode is virtual file system file open mode
type VFSMode int8
const (
// TILEDB_VFS_READ open file in read mode
TILEDB_VFS_READ VFSMode = C.TILEDB_VFS_READ
// TILEDB_VFS_WRITE open file in write mode
TILEDB_VFS_WRITE VFSMode = C.TILEDB_VFS_WRITE
// TILEDB_VFS_APPENDopen file in write append mode
TILEDB_VFS_APPEND VFSMode = C.TILEDB_VFS_APPEND
)
// ObjectTypeEnum
type ObjectTypeEnum int8
const (
// Invalid object
TILEDB_INVALID ObjectTypeEnum = C.TILEDB_INVALID
// Group object
TILEDB_GROUP ObjectTypeEnum = C.TILEDB_GROUP
// Array object
TILEDB_ARRAY ObjectTypeEnum = C.TILEDB_ARRAY
)
// String returns string representation
func (o ObjectTypeEnum) String() string {
var cname *C.char
C.tiledb_object_type_to_str(C.tiledb_object_t(o), &cname)
return C.GoString(cname)
}
// ObjectTypeFromString returns the internal representation of the object type
func ObjectTypeFromString(s string) (ObjectTypeEnum, error) {
cname := C.CString(s)
defer C.free(unsafe.Pointer(cname))
var cObjType C.tiledb_object_t
ret := C.tiledb_object_type_from_str(cname, &cObjType)
if ret != C.TILEDB_OK {
return 0, fmt.Errorf("%q is not a recognized tiledb_object_t", s)
}
return ObjectTypeEnum(cObjType), nil
}
// WalkOrder
type WalkOrder int8
const (
// Pre-order traversal
TILEDB_PREORDER WalkOrder = C.TILEDB_PREORDER
// Post-order traversal
TILEDB_POSTORDER WalkOrder = C.TILEDB_POSTORDER
)
// TILEDB_VAR_NUM indicates variable sized attributes for cell values
var TILEDB_VAR_NUM = uint32(C.TILEDB_VAR_NUM)
// TILEDB_COORDS A special name indicating the coordinates attribute.
const TILEDB_COORDS = "__coords"
// FileStoreMimeType is an enum for TileDB filestore mime types
type FileStoreMimeType uint32
// Mime types for TileDB filestore. The store can autodetect mime types
// but these are provided if the user wants to enforce a type
const (
// Filestore autodetect mime type
TILEDB_MIME_AUTODETECT = FileStoreMimeType(C.TILEDB_MIME_AUTODETECT)
// Filestore TIFF mime type
TILEDB_MIME_TIFF = FileStoreMimeType(C.TILEDB_MIME_TIFF)
// Filestore PDF mime type
TILEDB_MIME_PDF = FileStoreMimeType(C.TILEDB_MIME_PDF)
)
// DataOrder
type DataOrder int8
const (
// Unordered dimension label.
TILEDB_UNORDERED_DATA DataOrder = C.TILEDB_UNORDERED_DATA
// Ordered dimension label with increasing values.
TILEDB_INCREASING_DATA DataOrder = C.TILEDB_INCREASING_DATA
// Ordered dimension label with decreasing values.
TILEDB_DECREASING_DATA DataOrder = C.TILEDB_DECREASING_DATA
)
// String returns a string representation of a DataOrder.
func (d DataOrder) String() (string, error) {
var dataOrderStr *C.char
ret := C.tiledb_data_order_to_str(C.tiledb_data_order_t(d), &dataOrderStr)
if ret != C.TILEDB_OK {
return "", fmt.Errorf("Error converting DataOrder to string: %d", d)
}
return C.GoString(dataOrderStr), nil
}
// DataOrderFromString converts from a string to the equivalent DataOrder enum.
func DataOrderFromString(name string) (DataOrder, error) {
cName := C.CString(name)
defer C.free(unsafe.Pointer(cName))
var cDataOrder C.tiledb_data_order_t
ret := C.tiledb_data_order_from_str(cName, &cDataOrder)
if ret != C.TILEDB_OK {
return 0, fmt.Errorf("Error converting '%s' to tiledb_data_order_t", name)
}
return DataOrder(cDataOrder), nil
}