Skip to content

Commit 07823d0

Browse files
committed
Add extra offset element to buffer size in order to avoid incomplete retry
[sc-skip]
1 parent 8bf4f2d commit 07823d0

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

HISTORY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Bug Fixes
44
* Fix default validity for write to nullable attribute [#994]((https://github.com/TileDB-Inc/TileDB-Py/pull/994)
5-
5+
* Reduce query time for dense var-length arrays by including extra offset element in initial buffer allocation [#1005](https://github.com/TileDB-Inc/TileDB-Py/pull/1005)
66
## API Changes
77
* Addition of `ArraySchema.version` to get version of array schema [#949](https://github.com/TileDB-Inc/TileDB-Py/pull/949)
88
* Deprecate `coords_filters` from `ArraySchema` [#993](https://github.com/TileDB-Inc/TileDB-Py/pull/993)

tiledb/core.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,11 @@ class PyQuery {
825825
} else { // !nullable && !var
826826
buf_nbytes = query_->est_result_size(name);
827827
}
828+
829+
// Add extra offset to estimate in order to avoid incomplete resubmit
830+
// libtiledb 2.7.* does not include extra element in estimate.
831+
// Remove this section after resolution of SC-16301.
832+
offsets_num += (var && use_arrow_) ? 1 : 0;
828833
}
829834

830835
// - for sparse arrays: don't try to allocate more than alloc_max_bytes_

tiledb/tests/test_fixes.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,39 @@ def slice_array(a: tiledb.Array, indexer, selection, expected):
8787
# Important: must get each result here or else assertion
8888
# failures or exceptions will disappear.
8989
list(map(lambda x: x.result(), futures))
90+
91+
# skip, does not currently work, because we cannot force use
92+
# of the memory estimate
93+
@pytest.mark.skip
94+
def test_sc16301_arrow_extra_estimate_dense(self):
95+
"""
96+
Test that dense query of array with var-length attribute completes
97+
in one try. We are currently adding an extra element to the offset
98+
estimate from libtiledb, in order to avoid an unnecessary pair of
99+
query resubmits when the offsets won't fit in the estimated buffer.
100+
"""
101+
102+
uri = self.path("test_sc16301_arrow_extra_estimate_dense")
103+
104+
dim1 = tiledb.Dim(name="d1", dtype="int64", domain=(1, 3))
105+
att = tiledb.Attr(name="a1", dtype="<U0", var=True)
106+
107+
schema = tiledb.ArraySchema(
108+
domain=tiledb.Domain(dim1),
109+
attrs=(att,),
110+
sparse=False,
111+
allows_duplicates=False,
112+
)
113+
tiledb.Array.create(uri, schema)
114+
115+
with tiledb.open(uri, "w") as A:
116+
A[:] = np.array(["aaa", "bb", "c"])
117+
118+
with tiledb.open(uri) as A:
119+
tiledb.stats_enable()
120+
r = A[:]
121+
assert (
122+
""""Context.StorageManager.Query.Reader.loop_num": 1"""
123+
in tiledb.stats_dump(print_out=False)
124+
)
125+
tiledb.stats_disable()

0 commit comments

Comments
 (0)