Skip to content

Commit 6b422f1

Browse files
committed
Fix getting fill for BLOB, WKB, WKT
1 parent bd45fe7 commit 6b422f1

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

tiledb/cc/attribute.cc

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,42 @@ void set_fill_value(Attribute &attr, py::array value) {
1919
}
2020

2121
py::array get_fill_value(Attribute &attr) {
22+
// Get the fill value from the C++ API as a void* value.
2223
const void *value;
2324
uint64_t size;
24-
2525
attr.get_fill_value(&value, &size);
2626

27-
auto value_num = attr.cell_val_num();
28-
auto value_type = tdb_to_np_dtype(attr.type(), value_num);
29-
27+
// If this is a string type, we want to return each value as a single cell.
3028
if (is_tdb_str(attr.type())) {
31-
value_type = py::dtype("|S1");
32-
value_num = size;
29+
auto value_type = py::dtype("|S1");
30+
return py::array(value_type, size, value);
3331
}
3432

35-
// record type
33+
// If this is a record type (void), return a single cell.
34+
// If this is a blob-like type, we want to return each value as a single byte
35+
// cell.
36+
auto tdb_type = attr.type();
37+
if (tdb_type == TILEDB_BLOB
38+
#if TILEDB_VERSION_MAJOR >= 2 && TILEDB_VERSION_MINOR >= 21
39+
|| tdb_type == TILEDB_GEOM_WKB || tdb_type == TILEDB_GEOM_WKT
40+
#endif
41+
) {
42+
auto value_type = py::dtype("S");
43+
return py::array(value_type, size, value);
44+
}
45+
46+
// Get the number of values in a cell and the Python datatype.
47+
auto value_num = attr.cell_val_num();
48+
auto value_type = tdb_to_np_dtype(attr.type(), value_num);
49+
3650
if (py::str(value_type.attr("kind")) == py::str("V")) {
37-
value_num = 1;
51+
return py::array(value_type, 1, value);
3852
}
3953

40-
// complex type - both cell values fit in a single complex element
54+
// If this is a complex type both cell values fit in a single complex element.
4155
if (value_type == py::dtype("complex64") ||
4256
value_type == py::dtype("complex128")) {
43-
value_num = 1;
57+
return py::array(value_type, 1, value);
4458
}
4559

4660
return py::array(value_type, value_num, value);

0 commit comments

Comments
 (0)