From 2c35d48173833a072d039eb6fd4a17adb260d3b2 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Tue, 2 Mar 2021 18:13:44 -0600 Subject: [PATCH 1/3] use estimated size when no result size was returned --- R/TileDBArray.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/R/TileDBArray.R b/R/TileDBArray.R index efac91778b..f4487107e7 100644 --- a/R/TileDBArray.R +++ b/R/TileDBArray.R @@ -526,7 +526,11 @@ setMethod("[", "tiledb_array", libtiledb_query_result_buffer_elements(qryptr, name) } estsz <- mapply(getResultSize, allnames, allvarnum, MoreArgs=list(qryptr=qryptr), SIMPLIFY=TRUE) - resrv <- max(estsz, na.rm=TRUE) + if (any(!is.na(estsz))) { + resrv <- max(estsz, na.rm=TRUE) + } else { + resrv <- resrv/8 # character case where bytesize of offset vector was used + } ## get results getResult <- function(buf, name, varnum, resrv, qryptr) { From ce8c5f3caf45a20665b7a10c0a9cd97595fb577c Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 4 Mar 2021 14:30:10 -0600 Subject: [PATCH 2/3] update NEWS --- inst/NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/NEWS.md b/inst/NEWS.md index b326aae52e..fc43ed8d7b 100644 --- a/inst/NEWS.md +++ b/inst/NEWS.md @@ -8,6 +8,7 @@ * Two tests with datetime comparisons which fail only on one macOS system are now conditional (#216) +* Result sets with all-character column now fall back to estimated result sizes (#217) # 0.9.0 From f8718d39c7963631dfb30e046e194bad5d0f4835 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 4 Mar 2021 14:48:00 -0600 Subject: [PATCH 3/3] add a unit test --- inst/tinytest/test_dataframe.R | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/inst/tinytest/test_dataframe.R b/inst/tinytest/test_dataframe.R index 846bb7d20a..e3321cef0e 100644 --- a/inst/tinytest/test_dataframe.R +++ b/inst/tinytest/test_dataframe.R @@ -70,7 +70,6 @@ expect_equal(df, newdf[,-1]) ## test dense with non-default index columm -#exit_file("not finished") uri <- tempfile() set.seed(42) rows <- 50L @@ -233,3 +232,17 @@ if (getRversion() < '4.0.0') { val$B <- as.character(val$B) } expect_equal(dat, val) + +## array with char only columns in dimension and attribute, used to error before #217 +N <- 20 +D <- data.frame(sample=paste(LETTERS[1:N], as.character(sort(trunc(runif(N, 100, 200)))), sep=""), + header=paste(LETTERS[1:N], as.character(sort(trunc(runif(N, 10000, 20000)))), sep=""), + stringsAsFactors=FALSE) +uri <- tempfile() +fromDataFrame(D, uri, col_index=1, sparse=TRUE) +chk <- tiledb_array(uri, as.data.frame=TRUE) +if (getRversion() < '4.0.0') { + chk$sample <- as.character(chk$sample) + chk$header <- as.character(chk$header) +} +expect_equal(D, chk[])