Skip to content

More precise return value when the result set is empty.#132

Merged
eddelbuettel merged 6 commits intoTileDB-Inc:feature/select_rangesfrom
LTLA:feature/select_ranges
Jun 19, 2020
Merged

More precise return value when the result set is empty.#132
eddelbuettel merged 6 commits intoTileDB-Inc:feature/select_rangesfrom
LTLA:feature/select_ranges

Conversation

@LTLA
Copy link
Contributor

@LTLA LTLA commented Jun 19, 2020

As suggested in LTLA/TileDBArray#9 (comment).

library(tiledb)
tmp <- tempfile()
dir.create(tmp)

d1  <- tiledb_dim("d1", domain = c(1L, 100L))
d2  <- tiledb_dim("d2", domain = c(1L, 100L))
dom <- tiledb_domain(c(d1, d2))
val <- tiledb_attr("val", type = "FLOAT64")
sch <- tiledb_array_schema(dom, c(val), sparse=TRUE)
tiledb_array_create(tmp, sch)

x <- tiledb_array(uri = tmp)
x[] <- data.frame(d1=1, d2=1, val=1)
x@selected_ranges <- list(cbind(2,2), cbind(2,2))
x[]
## $d1
## integer(0)
## 
## $d2
## integer(0)
## 
## $val
## numeric(0)

R/TileDBArray.R Outdated
if (x@as.data.frame) {
res <- do.call(data.frame, c(res, list(check.names=FALSE, stringsAsFactors=FALSE)))
}
return(invisible(res))
Copy link
Contributor

@eddelbuettel eddelbuettel Jun 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much that is a very good start but not general enough. See eg here for possible types. (And to make it worse there are other routines too...)

How to map types back and forth between R and TileDB isn't fully fleshed out but we need to at least support the datetypes and int64.

@eddelbuettel
Copy link
Contributor

The fact that the checks failed is not good. The implemented method breaks some of the post 2.0.0 API accessors. So this is clearly not ready yet.

@eddelbuettel
Copy link
Contributor

This is now quite slick with the one-liner ensuring at least one-row attempts and automagically shrinking them down later.

It is a little "costly" as we will run queries we know will fail.

@eddelbuettel eddelbuettel merged commit 1c78d07 into TileDB-Inc:feature/select_ranges Jun 19, 2020
eddelbuettel added a commit that referenced this pull request Jun 26, 2020
* More precise return value when the result set is empty.

* Use tiledb_datatype_R_type for more comprehensive type finding.
Take best shot at type determination for dates.

* Minor bugfix for correct nanotime coercion.

* Mimic a non-empty buffer to re-use type translation from C++ code.

* Further streamlining of the intervention.

* ensure one more test receive as.data.frame

Co-authored-by: Dirk Eddelbuettel <edd@debian.org>
eddelbuettel added a commit that referenced this pull request Jun 29, 2020
* generalized range selection also taking optional range matrices

* add unit tests

* updated documentation

* adding setter and getter for selected_ranges

* modified tests

* robustification for part one of @LTLA's note

* do not use require domain() info

* make est_res_size result use more tolerant

* correct subsetting to allow empty result sets

* additional tests

* correct one index variable

* More precise return value when the result set is empty. (#132)

* More precise return value when the result set is empty.

* Use tiledb_datatype_R_type for more comprehensive type finding.
Take best shot at type determination for dates.

* Minor bugfix for correct nanotime coercion.

* Mimic a non-empty buffer to re-use type translation from C++ code.

* Further streamlining of the intervention.

* ensure one more test receive as.data.frame

Co-authored-by: Dirk Eddelbuettel <edd@debian.org>

* add a NEWS entry

* show selected_ranges, add simple validator

* more robust validity check for selected_ranges

* add simple TileDB Cloud example

* correct typo (and change whitespace accordingly)

Co-authored-by: Aaron Lun <LTLA@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants