Skip to content

Commit 9b360de

Browse files
authoredApr 1, 2019
Merge pull request #65 from TileDB-Inc/an/64-cint-to-cint32
converts C.int and C.uint to C.int32_t and C.uint32_t respectively. Closes #64
2 parents caf2023 + e41f478 commit 9b360de

12 files changed

+44
-31
lines changed
 

‎array.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ func (a *Array) NonEmptyDomain() ([]NonEmptyDomain, bool, error) {
259259
return nil, false, err
260260
}
261261

262-
var ret C.int
263-
var isEmpty C.int
262+
var ret C.int32_t
263+
var isEmpty C.int32_t
264264
switch domainType {
265265

266266
case TILEDB_INT8:
@@ -492,7 +492,7 @@ func (a *Array) MaxBufferSize(attributeName string, subarray interface{}) (uint6
492492
defer C.free(unsafe.Pointer(cAttributeName))
493493

494494
var bufferSize C.uint64_t
495-
var ret C.int
495+
var ret C.int32_t
496496
// Switch on domain type to cast subarray to proper type
497497
switch domainType {
498498
case TILEDB_INT8:
@@ -559,7 +559,7 @@ func (a *Array) MaxBufferSizeVar(attributeName string, subarray interface{}) (ui
559559

560560
var bufferValSize C.uint64_t
561561
var bufferOffSize C.uint64_t
562-
var ret C.int
562+
var ret C.int32_t
563563
// Switch on domain type to cast subarray to proper type
564564
switch domainType {
565565
case TILEDB_INT8:

‎array_schema.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (a *ArraySchema) AddAttributes(attributes ...*Attribute) error {
6666

6767
// AttributeNum returns the number of attributes
6868
func (a *ArraySchema) AttributeNum() (uint, error) {
69-
var attrNum C.uint
69+
var attrNum C.uint32_t
7070
ret := C.tiledb_array_schema_get_attribute_num(a.context.tiledbContext, a.tiledbArraySchema, &attrNum)
7171
if ret != C.TILEDB_OK {
7272
return 0, fmt.Errorf("Error getting attribute number for tiledb arraySchema: %s", a.context.LastError())
@@ -77,7 +77,11 @@ func (a *ArraySchema) AttributeNum() (uint, error) {
7777
// AttributeFromIndex get a copy of an Attribute in the schema by name.
7878
func (a *ArraySchema) AttributeFromIndex(index uint) (*Attribute, error) {
7979
attr := Attribute{context: a.context}
80-
ret := C.tiledb_array_schema_get_attribute_from_index(a.context.tiledbContext, a.tiledbArraySchema, C.uint(index), &attr.tiledbAttribute)
80+
ret := C.tiledb_array_schema_get_attribute_from_index(
81+
a.context.tiledbContext,
82+
a.tiledbArraySchema,
83+
C.uint32_t(index),
84+
&attr.tiledbAttribute)
8185
if ret != C.TILEDB_OK {
8286
return nil, fmt.Errorf("Error getting attribute %d for tiledb arraySchema: %s", index, a.context.LastError())
8387
}

‎attribute.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ func (a *Attribute) FilterList() (*FilterList, error) {
7979
// This is inferred from the type parameter of the NewAttribute
8080
// function, but can also be set manually.
8181
func (a *Attribute) SetCellValNum(val uint) error {
82-
ret := C.tiledb_attribute_set_cell_val_num(a.context.tiledbContext, a.tiledbAttribute, C.uint(val))
82+
ret := C.tiledb_attribute_set_cell_val_num(a.context.tiledbContext,
83+
a.tiledbAttribute, C.uint32_t(val))
8384
if ret != C.TILEDB_OK {
8485
return fmt.Errorf("Error setting tiledb attribute cell val num: %s", a.context.LastError())
8586
}
@@ -89,7 +90,7 @@ func (a *Attribute) SetCellValNum(val uint) error {
8990
// CellValNum returns number of values of one cell on this attribute.
9091
// For variable-sized attributes returns TILEDB_VAR_NUM.
9192
func (a *Attribute) CellValNum() (uint, error) {
92-
var cellValNum C.uint
93+
var cellValNum C.uint32_t
9394
ret := C.tiledb_attribute_get_cell_val_num(a.context.tiledbContext, a.tiledbAttribute, &cellValNum)
9495
if ret != C.TILEDB_OK {
9596
return 0, fmt.Errorf("Error getting tiledb attribute cell val num: %s", a.context.LastError())

‎context.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (c *Context) LastError() error {
8686

8787
// IsSupportedFS Return true if the given filesystem backend is supported.
8888
func (c *Context) IsSupportedFS(fs FS) (bool, error) {
89-
var isSupported C.int
89+
var isSupported C.int32_t
9090
ret := C.tiledb_ctx_is_supported_fs(c.tiledbContext, C.tiledb_filesystem_t(fs), &isSupported)
9191

9292
if ret != C.TILEDB_OK {

‎dimension.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func NewDimension(context *Context, name string, domain interface{}, extent inte
4747
}
4848

4949
var datatype Datatype
50-
var ret C.int
50+
var ret C.int32_t
5151
// Convert domain to type then to void*
5252
var cdomain unsafe.Pointer
5353
// Convert extent to type then to void*
@@ -216,7 +216,7 @@ func (d *Dimension) Domain() (interface{}, error) {
216216
return nil, err
217217
}
218218

219-
var ret C.int
219+
var ret C.int32_t
220220
var domain interface{}
221221
switch datatype {
222222
case TILEDB_INT8:
@@ -336,7 +336,7 @@ func (d *Dimension) Extent() (interface{}, error) {
336336
return nil, err
337337
}
338338

339-
var ret C.int
339+
var ret C.int32_t
340340
var extent interface{}
341341
switch datatype {
342342
case TILEDB_INT8:

‎domain.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (d *Domain) Type() (Datatype, error) {
5959

6060
// NDim returns the number of dimensions
6161
func (d *Domain) NDim() (uint, error) {
62-
var ndim C.uint
62+
var ndim C.uint32_t
6363
ret := C.tiledb_domain_get_ndim(d.context.tiledbContext, d.tiledbDomain, &ndim)
6464
if ret != C.TILEDB_OK {
6565
return 0, fmt.Errorf("Error getting tiledb domain number of dimensions: %s", d.context.LastError())
@@ -70,7 +70,8 @@ func (d *Domain) NDim() (uint, error) {
7070
// DimensionFromIndex retrieves a dimension object from a domain by index.
7171
func (d *Domain) DimensionFromIndex(index uint) (*Dimension, error) {
7272
var dim *C.tiledb_dimension_t
73-
ret := C.tiledb_domain_get_dimension_from_index(d.context.tiledbContext, d.tiledbDomain, C.uint(index), &dim)
73+
ret := C.tiledb_domain_get_dimension_from_index(d.context.tiledbContext,
74+
d.tiledbDomain, C.uint32_t(index), &dim)
7475
if ret != C.TILEDB_OK {
7576
return nil, fmt.Errorf("Error getting tiledb dimension by index for domain: %s", d.context.LastError())
7677
}

‎kv.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ setting, where machines need to operate on the same view of the k.
101101
func (k *KV) OpenAtWithKey(queryType QueryType, encryptionType EncryptionType, key string, timestamp uint64) error {
102102
ckey := unsafe.Pointer(C.CString(key))
103103
defer C.free(ckey)
104-
ret := C.tiledb_kv_open_at_with_key(k.context.tiledbContext, k.tiledbKV, C.tiledb_query_type_t(queryType), C.tiledb_encryption_type_t(encryptionType), ckey, C.uint32_t(len(key)), C.uint64_t(timestamp))
104+
ret := C.tiledb_kv_open_at_with_key(k.context.tiledbContext, k.tiledbKV,
105+
C.tiledb_query_type_t(queryType),
106+
C.tiledb_encryption_type_t(encryptionType),
107+
ckey, C.uint32_t(len(key)),
108+
C.uint64_t(timestamp))
105109
if ret != C.TILEDB_OK {
106110
return fmt.Errorf("Error opening tiledb kv with key at %d for querying: %s", timestamp, k.context.LastError())
107111
}

‎kv_item.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ func (k *KVItem) Key() (interface{}, error) {
307307
}
308308
case TILEDB_CHAR:
309309
elements := int(keySize) / C.sizeof_char
310-
return C.GoStringN((*C.char)(cKey), C.int(elements)), nil
310+
return C.GoStringN((*C.char)(cKey), C.int32_t(elements)), nil
311311

312312
default:
313313
return nil, fmt.Errorf("Unsupported tiledb key type: %v", keyType)
@@ -573,7 +573,7 @@ func (k *KVItem) Value(attribute string) (interface{}, error) {
573573
return float64(*(*C.double)(cValue)), nil
574574
case TILEDB_CHAR:
575575
elements := int(valueSize) / C.sizeof_char
576-
return C.GoStringN((*C.char)(cValue), C.int(elements)), nil
576+
return C.GoStringN((*C.char)(cValue), C.int32_t(elements)), nil
577577
default:
578578
return nil, fmt.Errorf("Unsupported tiledb value type: %v", valueType)
579579
}

‎kv_schema.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (k *KVSchema) AddAttributes(attributes ...*Attribute) error {
6666

6767
// AttributeNum returns the number of attributes
6868
func (k *KVSchema) AttributeNum() (uint, error) {
69-
var attrNum C.uint
69+
var attrNum C.uint32_t
7070
ret := C.tiledb_kv_schema_get_attribute_num(k.context.tiledbContext, k.tiledbKVSchema, &attrNum)
7171
if ret != C.TILEDB_OK {
7272
return 0, fmt.Errorf("Error getting attribute number for tiledb KVSchema: %s", k.context.LastError())
@@ -77,7 +77,10 @@ func (k *KVSchema) AttributeNum() (uint, error) {
7777
// AttributeFromIndex get a copy of an Attribute in the schema by name.
7878
func (k *KVSchema) AttributeFromIndex(index uint) (*Attribute, error) {
7979
attr := Attribute{context: k.context}
80-
ret := C.tiledb_kv_schema_get_attribute_from_index(k.context.tiledbContext, k.tiledbKVSchema, C.uint(index), &attr.tiledbAttribute)
80+
ret := C.tiledb_kv_schema_get_attribute_from_index(k.context.tiledbContext,
81+
k.tiledbKVSchema,
82+
C.uint32_t(index),
83+
&attr.tiledbAttribute)
8184
if ret != C.TILEDB_OK {
8285
return nil, fmt.Errorf("Error getting attribute %d for tiledb KVSchema: %s", index, k.context.LastError())
8386
}

‎query.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ func (q *Query) Buffer(attributeName string) (interface{}, error) {
393393
cattributeName := C.CString(attributeName)
394394
defer C.free(unsafe.Pointer(cattributeName))
395395

396-
var ret C.int
396+
var ret C.int32_t
397397
var cbufferSize *C.uint64_t
398398
var cbuffer unsafe.Pointer
399399
var buffer interface{}
@@ -794,7 +794,7 @@ func (q *Query) BufferVar(attributeName string) ([]uint64, interface{}, error) {
794794
cattributeName := C.CString(attributeName)
795795
defer C.free(unsafe.Pointer(cattributeName))
796796

797-
var ret C.int
797+
var ret C.int32_t
798798
var cbufferSize *C.uint64_t
799799
var cbuffer unsafe.Pointer
800800
var buffer interface{}
@@ -1037,7 +1037,7 @@ func (q *Query) Type() (QueryType, error) {
10371037
// HasResults Returns true if the query has results
10381038
// Applicable only to read queries (it returns false for write queries)
10391039
func (q *Query) HasResults() (bool, error) {
1040-
var hasResults C.int
1040+
var hasResults C.int32_t
10411041
ret := C.tiledb_query_has_results(q.context.tiledbContext, q.tiledbQuery, &hasResults)
10421042
if ret != C.TILEDB_OK {
10431043
return false, fmt.Errorf("Error checking if query has results: %s", q.context.LastError())

‎version.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import "C"
1010
// Version returns the TileDB shared library version these bindings are linked
1111
// against at runtime
1212
func Version() (major int, minor int, rev int) {
13-
var cmajor C.int = -1
14-
var cminor C.int = -1
15-
var crev C.int = -1
13+
var cmajor C.int32_t = -1
14+
var cminor C.int32_t = -1
15+
var crev C.int32_t = -1
1616
C.tiledb_version(&cmajor, &cminor, &crev)
1717

1818
return int(cmajor), int(cminor), int(crev)

‎vfs.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (v *VFSfh) Free() {
3030
// IsClosed checks a vfs file handler to see if it is closed. Return true if
3131
// file handler is closed, false if its not closed and error is non-nil on error
3232
func (v *VFSfh) IsClosed() (bool, error) {
33-
var isClosed C.int
33+
var isClosed C.int32_t
3434

3535
ret := C.tiledb_vfs_fh_is_closed(v.context.tiledbContext, v.tiledbVFSfh, &isClosed)
3636

@@ -141,7 +141,7 @@ func (v *VFS) EmptyBucket(uri string) error {
141141
func (v *VFS) IsEmptyBucket(uri string) (bool, error) {
142142
curi := C.CString(uri)
143143
defer C.free(unsafe.Pointer(curi))
144-
var isEmpty C.int
144+
var isEmpty C.int32_t
145145
ret := C.tiledb_vfs_is_empty_bucket(v.context.tiledbContext, v.tiledbVFS, curi, &isEmpty)
146146

147147
if ret != C.TILEDB_OK {
@@ -159,7 +159,7 @@ func (v *VFS) IsEmptyBucket(uri string) (bool, error) {
159159
func (v *VFS) IsBucket(uri string) (bool, error) {
160160
curi := C.CString(uri)
161161
defer C.free(unsafe.Pointer(curi))
162-
var isBucket C.int
162+
var isBucket C.int32_t
163163
ret := C.tiledb_vfs_is_bucket(v.context.tiledbContext, v.tiledbVFS, curi, &isBucket)
164164

165165
if ret != C.TILEDB_OK {
@@ -190,7 +190,7 @@ func (v *VFS) CreateDir(uri string) error {
190190
func (v *VFS) IsDir(uri string) (bool, error) {
191191
curi := C.CString(uri)
192192
defer C.free(unsafe.Pointer(curi))
193-
var isDir C.int
193+
var isDir C.int32_t
194194
ret := C.tiledb_vfs_is_dir(v.context.tiledbContext, v.tiledbVFS, curi, &isDir)
195195

196196
if ret != C.TILEDB_OK {
@@ -221,7 +221,7 @@ func (v *VFS) RemoveDir(uri string) error {
221221
func (v *VFS) IsFile(uri string) (bool, error) {
222222
curi := C.CString(uri)
223223
defer C.free(unsafe.Pointer(curi))
224-
var isFile C.int
224+
var isFile C.int32_t
225225
ret := C.tiledb_vfs_is_file(v.context.tiledbContext, v.tiledbVFS, curi, &isFile)
226226

227227
if ret != C.TILEDB_OK {
@@ -340,7 +340,7 @@ func (v *VFS) Read(fh *VFSfh, offset uint64, nbytes uint64) ([]byte, error) {
340340
return []byte{}, fmt.Errorf("Unknown error in VFS.Read: %s", v.context.LastError())
341341
}
342342

343-
bytes = C.GoBytes(cbuffer, C.int(nbytes))
343+
bytes = C.GoBytes(cbuffer, C.int32_t(nbytes))
344344

345345
return bytes, nil
346346
}

0 commit comments

Comments
 (0)