Support Querying Variable-Sized, Nullable Attributes
@@ -748,13 +748,15 @@ public:
if (retries_ < 1) {
// we must not call after submitting
- if (nullable) {
+ if (nullable && var) {
+ auto sizes = query_->est_result_size_var_nullable(name);
+ buf_nbytes = sizes[0];
+ validity_num = sizes[1] / sizeof(uint8_t);
+ } else if (nullable && !var) {
auto sizes = query_->est_result_size_nullable(name);
buf_nbytes = sizes[0];
validity_num = sizes[1] / sizeof(uint8_t);
- } else if (nullable && var) {
- throw TileDBPyError("<todo> nullable var unimplemented");
- } else if (var) {
+ } else if (!nullable && var) {
auto size_pair = query_->est_result_size_var(name);
#if TILEDB_VERSION_MAJOR == 2 && TILEDB_VERSION_MINOR < 2
buf_nbytes = size_pair.first;
@@ -763,7 +765,7 @@ public:
buf_nbytes = size_pair[0];
offsets_num = size_pair[1];
#endif
- } else {
+ } else { // !nullable && !var
buf_nbytes = query_->est_result_size(name);
}
}
@@ -821,20 +823,36 @@ public:
uint64_t data_nelem =
(b.data.size() - (data_vals_read * b.elem_nbytes)) / b.elem_nbytes;
- if (b.isvar) {
+ if (b.isnullable && b.isvar) {
size_t offsets_size = b.offsets.size() - offsets_read;
uint64_t *offsets_ptr = (uint64_t *)b.offsets.data() + offsets_read;
- query_->set_buffer(b.name, (uint64_t *)(offsets_ptr), offsets_size,
- data_ptr, data_nelem);
- } else if (b.isnullable) {
uint64_t validity_size = b.validity.size() - validity_vals_read;
uint8_t *validity_ptr =
(uint8_t *)b.validity.data() + validity_vals_read;
+
+ query_->set_buffer_nullable(b.name, (uint64_t *)(offsets_ptr),
+ offsets_size, data_ptr, data_nelem,
+ validity_ptr, validity_size);
+ } else if (b.isnullable && !b.isvar) {
+ uint64_t validity_size = b.validity.size() - validity_vals_read;
+ assert(validity_size > 0);
+
+ uint8_t *validity_ptr =
+ (uint8_t *)b.validity.data() + validity_vals_read;
+
query_->set_buffer_nullable(b.name, data_ptr, data_nelem, validity_ptr,
validity_size);
- } else {
+ } else if (!b.isnullable && b.isvar) {
+ size_t offsets_size = b.offsets.size() - offsets_read;
+ assert(offsets_size > 0);
+
+ uint64_t *offsets_ptr = (uint64_t *)b.offsets.data() + offsets_read;
+
+ query_->set_buffer(b.name, (uint64_t *)(offsets_ptr), offsets_size,
+ data_ptr, data_nelem);
+ } else { // !b.isnullable && !b.isvar
query_->set_buffer(b.name, data_ptr, data_nelem);
}
}
