Hi,
I'm the developer of the DelayedTensor package, which performs tensor arithmetic on DelayedArray objects. I'm exploring using TileDBArray as a backend (instead of HDF5Array) to take advantage of TileDB's native sparse storage.
I found that writeTileDBArray() works correctly for 2D arrays and sparse 3D arrays, but fails for dense 3D arrays with the error:
Error: Subarray should have num_dims * 2 values: (low, high) for each dimension.
Minimal reproducible example
library(TileDBArray)
# 2D dense: OK
mat <- matrix(runif(100), nrow=10, ncol=10)
writeTileDBArray(mat)
#> 10 x 10 TileDBMatrix
# 3D sparse: OK
sparse3d <- SparseArray::randomSparseArray(c(10, 10, 10), density=0.01)
writeTileDBArray(sparse3d)
#> 10 x 10 x 10 TileDBArray
# 3D dense: FAIL
arr3d <- array(runif(1000), dim=c(10, 10, 10))
writeTileDBArray(arr3d)
#> Error: Subarray should have num_dims * 2 values: (low, high) for each
dimension.
# TileDBRealizationSink creation succeeds for 3D
sink <- TileDBRealizationSink(dim=c(10L, 10L, 10L))
#> OK
# But write_block to that sink fails
grid <- RegularArrayGrid(refdim=c(10L, 10L, 10L), spacings=c(10L, 10L, 10L))
block <- array(runif(1000), dim=c(10, 10, 10))
write_block(sink, grid[[1L, 1L, 1L]], block)
#> Error: Subarray should have num_dims * 2 values: (low, high) for each
dimension.
The error seems to come from the dense path of write_block() in TileDBRealizationSink.R (around line 240), where do.call("[<-", args) calls into the tiledb package's subarray write functionality. The sparse path uses a data.frame-based write and works fine.
It's possible this is actually a tiledb R package issue rather than TileDBArray, but I'm reporting here since the sparse path works. Could the dense path perhaps use selected_ranges() as recommended in TileDB-Inc/TileDB-R#259?
Use case
DelayedTensor needs 3D+ array support for tensor decomposition and arithmetic operations. Being able to use TileDBArray as a backend would be very beneficial for sparse tensor workloads, since HDF5 stores everything as dense internally.
Session info
R version 4.5.3 (2026-03-11)
Platform: x86_64-conda-linux-gnu
TileDBArray 1.20.0
tiledb 0.34.0
DelayedArray 0.36.0
SparseArray 1.10.8
S4Arrays 1.10.1
Hi,
I'm the developer of the
DelayedTensorpackage, which performs tensor arithmetic onDelayedArrayobjects. I'm exploring usingTileDBArrayas a backend (instead ofHDF5Array) to take advantage of TileDB's native sparse storage.I found that
writeTileDBArray()works correctly for 2D arrays and sparse 3D arrays, but fails for dense 3D arrays with the error:Error: Subarray should have num_dims * 2 values: (low, high) for each dimension.
Minimal reproducible example
The error seems to come from the dense path of write_block() in
TileDBRealizationSink.R(around line 240), wheredo.call("[<-", args)calls into thetiledbpackage's subarray write functionality. The sparse path uses a data.frame-based write and works fine.It's possible this is actually a
tiledbR package issue rather thanTileDBArray, but I'm reporting here since the sparse path works. Could the dense path perhaps useselected_ranges()as recommended in TileDB-Inc/TileDB-R#259?Use case
DelayedTensorneeds 3D+ array support for tensor decomposition and arithmetic operations. Being able to useTileDBArrayas a backend would be very beneficial for sparse tensor workloads, since HDF5 stores everything as dense internally.Session info