Skip to content

Commit 3d42661

Browse files
authored
Bug fix: Data buffer is not resized for byte objects after completing the buffer and offsets conversion (#2150)
1 parent 9638128 commit 3d42661

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tiledb/npbuffer.cc

+2
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ if (PyUnicode_Check(u.ptr())) {
211211
output_p += sz;
212212
idx++;
213213
}
214+
215+
data_buf_->resize(data_nbytes_);
214216
}
215217

216218
void convert_object() {

tiledb/tests/test_fixes.py

+28
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,34 @@ def test_sc56611(self):
354354
tiledb.from_numpy(uri, data, sparse=True)
355355
assert str(exc_info.value) == "from_numpy only supports dense arrays"
356356

357+
@pytest.mark.parametrize(
358+
"array_data",
359+
[
360+
np.array([b"", b"testing", b"", b"with empty", b"bytes"], dtype="S"),
361+
np.array([b"and", b"\0\0", b"again"], dtype="S"),
362+
np.array(
363+
[b"", b"and with", b"the last one", b"", b"emtpy", b""], dtype="S"
364+
),
365+
],
366+
)
367+
def test_sc62594_buffer_resize(self, array_data):
368+
uri = self.path("test_agis")
369+
dom = tiledb.Domain(
370+
tiledb.Dim(name="dim", domain=(0, len(array_data) - 1), dtype=np.int64)
371+
)
372+
373+
schema = tiledb.ArraySchema(
374+
domain=dom, sparse=False, attrs=[tiledb.Attr(name="a", dtype="S", var=True)]
375+
)
376+
377+
tiledb.DenseArray.create(uri, schema)
378+
379+
with tiledb.DenseArray(uri, mode="w") as T:
380+
T[...] = array_data
381+
382+
with tiledb.DenseArray(uri) as T:
383+
assert_array_equal(array_data, T)
384+
357385

358386
class SOMA919Test(DiskTestCase):
359387
"""

0 commit comments

Comments
 (0)