@@ -19,28 +19,42 @@ void set_fill_value(Attribute &attr, py::array value) {
19
19
}
20
20
21
21
py::array get_fill_value (Attribute &attr) {
22
+ // Get the fill value from the C++ API as a void* value.
22
23
const void *value;
23
24
uint64_t size;
24
-
25
25
attr.get_fill_value (&value, &size);
26
26
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.
30
28
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) ;
33
31
}
34
32
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
+
36
50
if (py::str (value_type.attr (" kind" )) == py::str (" V" )) {
37
- value_num = 1 ;
51
+ return py::array (value_type, 1 , value) ;
38
52
}
39
53
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.
41
55
if (value_type == py::dtype (" complex64" ) ||
42
56
value_type == py::dtype (" complex128" )) {
43
- value_num = 1 ;
57
+ return py::array (value_type, 1 , value) ;
44
58
}
45
59
46
60
return py::array (value_type, value_num, value);
0 commit comments