From 1992e39be7a54a58b58e1dd2e43134a7936149dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Pag=C3=A8s?= Date: Tue, 17 Jun 2025 22:34:47 -0700 Subject: [PATCH 1/2] Small code simplification nzvals/nzwhich work on any SparseArray derivative (i.e. COO_SparseArray and SVT_SparseArray objects). They even work on dgCMatrix objects and other sparse representations from the Matrix package. Furthermore, nzdata() and nzcoo() are just accessors for the 'nzdata' and 'nzcoo' slots of a COO_SparseArray object, but these slots are not guaranteed to contain the nonzero values and their index in an order that is consistent with the "first dimension is the fastest moving dimension" convention. OTOH nzvals/nzwhich are guaranteed to return the nonzero values and their index in an order that follows this convention. Just a FYI as I don't know if this is relevant in the context of the write_block() method for TileDBRealizationSink objects. --- NAMESPACE | 3 +-- R/TileDBRealizationSink.R | 12 +++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 48b4bdb..6f431cd 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -45,7 +45,6 @@ importFrom(S4Vectors,isSingleString) importFrom(S4Vectors,setValidity2) importFrom(SparseArray,COO_SparseArray) importFrom(SparseArray,extract_sparse_array) -importFrom(SparseArray,nzcoo) -importFrom(SparseArray,nzdata) +importFrom(SparseArray,nzvals) importFrom(SparseArray,nzwhich) importFrom(methods,show) diff --git a/R/TileDBRealizationSink.R b/R/TileDBRealizationSink.R index 3c120cb..f626f49 100644 --- a/R/TileDBRealizationSink.R +++ b/R/TileDBRealizationSink.R @@ -207,7 +207,7 @@ setValidity2("TileDBRealizationSink", function(object) { #' @export #' @importClassesFrom SparseArray COO_SparseArray -#' @importFrom SparseArray nzcoo nzdata nzwhich +#' @importFrom SparseArray nzwhich nzvals #' @importFrom DelayedArray start width setMethod("write_block", "TileDBRealizationSink", function(sink, viewport, block) { starts <- start(viewport) - 1L @@ -215,14 +215,8 @@ setMethod("write_block", "TileDBRealizationSink", function(sink, viewport, block on.exit(tiledb_array_close(obj)) if (sink@sparse) { - # Need this because COO_SparseArray doesn't support [. - if (is(block, "COO_SparseArray")) { - idx <- nzcoo(block) - vals <- nzdata(block) - } else { - idx <- nzwhich(block, arr.ind=TRUE) - vals <- block[idx] - } + idx <- nzwhich(block, arr.ind=TRUE) + vals <- nzvals(block) ndim <- ncol(idx) store <- vector("list", ndim + 1L) From 50be402395590e8df1334b11f22c7bb2d096ae00 Mon Sep 17 00:00:00 2001 From: LTLA Date: Thu, 19 Jun 2025 12:05:25 -0700 Subject: [PATCH 2/2] Bumped version and date. --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ea669d8..d3b530d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: TileDBArray -Version: 1.19.0 -Date: 2024-10-01 +Version: 1.19.1 +Date: 2025-06-19 Title: Using TileDB as a DelayedArray Backend Description: Implements a DelayedArray backend for reading and writing dense or sparse arrays in the TileDB format. The