Skip to content

Commit f867249

Browse files
authored
tiledb_attr raises std::bad_alloc with variable length (#830)
* `tiledb_attr` raises `std::bad_alloc` with variable length * DESCRIPTION NEWS.md * neaten * code-review feedback
1 parent 2e7e171 commit f867249

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: tiledb
22
Type: Package
3-
Version: 0.32.0.3
3+
Version: 0.32.0.4
44
Title: Modern Database Engine for Complex Data Based on Multi-Dimensional Arrays
55
Authors@R: c(
66
person("TileDB, Inc.", role = c("aut", "cph")),

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Schema-dump output is no longer truncated in the case that there are any null fill values in the schema (@johnkerl in [#825](https://github.com/TileDB-Inc/TileDB-R/pull/825))
66
* `tiledb_attr()` now prints the attribute object as expected and documentation has been corrected (@cgiachalis in [#823](https://github.com/TileDB-Inc/TileDB-R/pull/823))
7+
* `tiledb_attr` now works when setting `ncells=NA` to signal variable length (@johnkerl in [#830](https://github.com/TileDB-Inc/TileDB-R/pull/830))
78

89
## Documentation
910

src/libtiledb.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,6 +1517,10 @@ XPtr<tiledb::Attribute> libtiledb_attribute(XPtr<tiledb::Context> ctx,
15171517
if (ncells < 1 && ncells != R_NaInt) {
15181518
Rcpp::stop("ncells must be >= 1 (or NA for variable cells)");
15191519
}
1520+
// R's NA is different from TileDB's NA so test for NA_integer_, else cast
1521+
uint64_t cell_val_num =
1522+
(ncells == R_NaInt) ? TILEDB_VAR_NUM : static_cast<uint64_t>(ncells);
1523+
15201524
// placeholder, overwritten in all branches below
15211525
XPtr<tiledb::Attribute> attr =
15221526
XPtr<tiledb::Attribute>(static_cast<tiledb::Attribute *>(nullptr));
@@ -1536,7 +1540,6 @@ XPtr<tiledb::Attribute> libtiledb_attribute(XPtr<tiledb::Context> ctx,
15361540
attr_dtype == TILEDB_DATETIME_AS) {
15371541
attr = make_xptr<tiledb::Attribute>(
15381542
new tiledb::Attribute(*ctx.get(), name, attr_dtype));
1539-
attr->set_cell_val_num(static_cast<uint64_t>(ncells));
15401543
} else if (attr_dtype == TILEDB_CHAR || attr_dtype == TILEDB_STRING_ASCII ||
15411544
attr_dtype == TILEDB_STRING_UTF8) {
15421545
attr = make_xptr<tiledb::Attribute>(
@@ -1558,10 +1561,7 @@ XPtr<tiledb::Attribute> libtiledb_attribute(XPtr<tiledb::Context> ctx,
15581561
"-- seeing %s which is not",
15591562
type.c_str());
15601563
}
1561-
// R's NA is different from TileDB's NA so test for NA_integer_, else cast
1562-
uint64_t num =
1563-
(ncells == R_NaInt) ? TILEDB_VAR_NUM : static_cast<uint64_t>(ncells);
1564-
attr->set_cell_val_num(num);
1564+
attr->set_cell_val_num(cell_val_num);
15651565
attr->set_filter_list(*fltrlst);
15661566
attr->set_nullable(nullable);
15671567
return attr;

0 commit comments

Comments
 (0)