Skip to content

Commit

Permalink
memory alloc: Accomodate zero buffer size estimate v2 (#777)
Browse files Browse the repository at this point in the history
* memory alloc: Accomodate zero buffer size estimate v2

* code-review feedback

Co-authored-by: Paul Hoffman <mojaveazure@users.noreply.github.com>

---------

Co-authored-by: Paul Hoffman <mojaveazure@users.noreply.github.com>
  • Loading branch information
johnkerl and mojaveazure authored Oct 25, 2024
1 parent c2ba622 commit 849fef8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion R/TileDBArray.R
Original file line number Diff line number Diff line change
Expand Up @@ -853,9 +853,16 @@ setMethod("[", "tiledb_array",
MoreArgs=list(qryptr=qryptr), SIMPLIFY=TRUE)
## ensure > 0 for correct handling of zero-length outputs, ensure respecting memory budget
spdl::debug("['['] result of size estimates is {}", paste(ressizes, collapse=","))
resrv <- max(1, min(memory_budget/8, ressizes[ressizes > 0]))
idx <- ressizes > 0
ressizes <- if (any(idx)) {
ressizes[idx]
} else {
0
}
resrv <- max(1, min(memory_budget/8, ressizes))
spdl::debug("['['] overall estimate {} rows", resrv)


## allocate and set buffers
if (!use_arrow) {
getBuffer <- function(name, type, varnum, nullable, resrv, qryptr, arrptr) {
Expand Down

0 comments on commit 849fef8

Please sign in to comment.