Skip to content

Commit b208fa7

Browse files
authored
Update to TileDB 2.28.0 (#374)
* Update to TileDB 2.28.0. * Implement new APIs. * Update README. * Add documentation and keepalive. * Lint * Remove NewArraySchemaAtTime. * Update README to mention removal of Close on Free.
1 parent dac3ffd commit b208fa7

File tree

9 files changed

+133
-10
lines changed

9 files changed

+133
-10
lines changed

.github/workflows/tiledb-go.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ on:
1010

1111
env:
1212
# The version of TileDB to test against.
13-
CORE_VERSION: "2.27.2"
13+
CORE_VERSION: "2.28.0"
1414
# The abbreviated git commit hash to use.
15-
CORE_HASH: "1757013"
15+
CORE_HASH: "4764907"
1616

1717
jobs:
1818
golangci:

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ as such the below table reference which versions are compatible.
100100
| 0.32.0 | 2.26.X |
101101
| 0.33.0 | 2.26.X |
102102
| 0.34.0 | 2.27.X |
103+
| 0.35.0 | 2.27.X |
104+
| 0.36.0 | 2.28.X |
103105

104106

105107
## Deprecated Functionality
@@ -131,3 +133,16 @@ the following TileDB release.
131133

132134
`SerializeArrayMaxBufferSizes` is removed as the underlying core method `tiledb_serialize_array_max_buffer_sizes` is deprecated in
133135
TileDB 2.27.0.
136+
137+
### 0.36.0
138+
139+
`Array.Create` is deprecated in favor of `CreateArray`.
140+
`Array.Consolidate` is deprecated in favor of `ConsolidateArray`.
141+
`Array.Vacuum` is deprecated in favor of `VacuumArray`.
142+
143+
## Breaking Changes
144+
145+
### 0.36.0
146+
147+
`Free` will no longer call `Close` for `Group` and `Array` objects.
148+
The caller is responsible for closing the `Array` or `Group` after operations such as writing metadata or modifying group members.

array_schema_experimental.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package tiledb
2+
3+
/*
4+
#include <tiledb/tiledb.h>
5+
#include <tiledb/tiledb_experimental.h>
6+
#include <stdlib.h>
7+
*/
8+
import "C"
9+
import (
10+
"fmt"
11+
"runtime"
12+
)
13+
14+
// TimestampRange gets the timestamp range for the array schema.
15+
func (a *ArraySchema) TimestampRange() (uint64, uint64, error) {
16+
var lo C.uint64_t
17+
var hi C.uint64_t
18+
ret := C.tiledb_array_schema_timestamp_range(a.context.tiledbContext.Get(), a.tiledbArraySchema.Get(), &lo, &hi)
19+
runtime.KeepAlive(a)
20+
if ret != C.TILEDB_OK {
21+
return 0, 0, fmt.Errorf("error getting timestamp range: %w", a.context.LastError())
22+
}
23+
return uint64(lo), uint64(hi), nil
24+
}

array_schema_experimental_test.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package tiledb
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
"github.com/stretchr/testify/require"
8+
)
9+
10+
// TestArraySchemaAtTime tests creating an array schema at a provided timestamp.
11+
func TestArraySchemaAtTime(t *testing.T) {
12+
config, err := NewConfig()
13+
require.NoError(t, err)
14+
15+
context, err := NewContext(config)
16+
require.NoError(t, err)
17+
18+
arraySchema, err := NewArraySchema(context, TILEDB_DENSE)
19+
require.NoError(t, err)
20+
assert.NotNil(t, arraySchema)
21+
22+
lo, hi, err := arraySchema.TimestampRange()
23+
require.NoError(t, err)
24+
25+
domain, err := NewDomain(context)
26+
require.NoError(t, err)
27+
assert.NotNil(t, domain)
28+
dimension, err := NewDimension(context, "d1", TILEDB_UINT8, []uint8{1, 10}, uint8(5))
29+
require.NoError(t, err)
30+
assert.NotNil(t, dimension)
31+
require.NoError(t, domain.AddDimensions(dimension))
32+
33+
attr, err := NewAttribute(context, "a1", TILEDB_UINT8)
34+
require.NoError(t, err)
35+
assert.NotNil(t, attr)
36+
37+
require.NoError(t, arraySchema.SetDomain(domain))
38+
require.NoError(t, arraySchema.AddAttributes(attr))
39+
40+
tempDir := t.TempDir()
41+
err = CreateArray(context, tempDir, arraySchema)
42+
require.NoError(t, err)
43+
44+
arr, err := NewArray(context, tempDir)
45+
require.NoError(t, err)
46+
require.NotNil(t, arr)
47+
48+
// Test we can open the array with timestamps given by ArraySchema.TimestampRange
49+
err = arr.OpenWithOptions(TILEDB_READ, WithStartTimestamp(lo), WithEndTimestamp(hi))
50+
require.NoError(t, err)
51+
52+
// Opened Start and End timestamps should be equal to TimestampRange values.
53+
start, err := arr.OpenStartTimestamp()
54+
require.NoError(t, err)
55+
end, err := arr.OpenEndTimestamp()
56+
require.NoError(t, err)
57+
require.EqualValues(t, lo, start)
58+
require.EqualValues(t, hi, end)
59+
}

range.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func ExtractRange[T DimensionType](r Range) ([]T, error) {
4747
}
4848

4949
// Endpoints returns the endpoint of the range. This is useful
50-
// to print the range or serialize it, without infering the type first.
50+
// to print the range or serialize it, without inferring the type first.
5151
func (r Range) Endpoints() (start, end any) {
5252
return r.start, r.end
5353
}

stats.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,13 @@ func StatsRaw() (string, error) {
150150

151151
return s, nil
152152
}
153+
154+
// StatsIsEnabled returns whether stats are enabled or not
155+
func StatsIsEnabled() (bool, error) {
156+
var isEnabled C.uint8_t
157+
ret := C.tiledb_stats_is_enabled(&isEnabled)
158+
if ret != C.TILEDB_OK {
159+
return false, errors.New("error checking if stats is enabled")
160+
}
161+
return isEnabled > 0, nil
162+
}

stats_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,17 @@ func TestStats(t *testing.T) {
6060

6161
// Test statistics
6262
func TestStatsRaw(t *testing.T) {
63+
// Check statistics are not enabled
64+
isEnabled, err := StatsIsEnabled()
65+
require.NoError(t, err)
66+
require.EqualValues(t, false, isEnabled)
67+
6368
// Enable statistics
64-
err := StatsEnable()
69+
err = StatsEnable()
70+
require.NoError(t, err)
71+
isEnabled, err = StatsIsEnabled()
6572
require.NoError(t, err)
73+
require.EqualValues(t, true, isEnabled)
6674

6775
// Reset all internal counters to 0
6876
require.NoError(t, StatsReset())

vfs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ func (v *VFS) Sync(fh *VFSfh) error {
456456
return nil
457457
}
458458

459-
// Touch touches a file, i.e., creates a new empty file.
459+
// Touch touches a file, i.e., creates a new empty file. Existing files will not be overwritten.
460460
func (v *VFS) Touch(uri string) error {
461461
curi := C.CString(uri)
462462
defer C.free(unsafe.Pointer(curi))

vfs_test.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,21 @@ func TestVFS(t *testing.T) {
5555

5656
// Copy file
5757
require.NoError(t, vfs.CopyFile(tmpFilePath, dstTmpFilePath))
58-
_, err = os.Stat(dstTmpFilePath)
58+
srcStat, err := os.Stat(tmpFilePath)
5959
require.NoError(t, err)
60-
if err == nil {
61-
os.Remove(dstTmpFilePath)
62-
}
60+
dstStat, err := os.Stat(dstTmpFilePath)
61+
require.NoError(t, err)
62+
require.EqualValues(t, srcStat.Size(), dstStat.Size())
63+
64+
// Touch should not overwrite existing files.
65+
require.NoError(t, vfs.Touch(dstTmpFilePath))
66+
dstStatTouch, err := os.Stat(dstTmpFilePath)
67+
require.NoError(t, err)
68+
require.EqualValues(t, dstStat.Size(), dstStatTouch.Size())
6369

64-
// Remove File
70+
// Remove Files
6571
require.NoError(t, vfs.RemoveFile(tmpFilePath))
72+
require.NoError(t, vfs.RemoveFile(dstTmpFilePath))
6673

6774
// Remove directory
6875
require.NoError(t, vfs.RemoveDir(tmpPath))

0 commit comments

Comments
 (0)