Skip to content

Commit

Permalink
Avoid integer overflow for indptr when incrementally saving a sparse …
Browse files Browse the repository at this point in the history
…matrix.
  • Loading branch information
LTLA committed Jun 7, 2024
1 parent cc91cee commit d5c82b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: alabaster.matrix
Title: Load and Save Artifacts from File
Version: 1.5.2
Date: 2024-05-28
Version: 1.5.3
Date: 2024-06-07
Authors@R: person("Aaron", "Lun", role=c("aut", "cre"), email="[email protected]")
License: MIT + file LICENSE
Description:
Expand Down
6 changes: 3 additions & 3 deletions R/saveSparseMatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ setMethod("h5_write_sparse_matrix", "SVT_SparseMatrix", function(x, handle, deta
column.counts <- integer(ncol(x))

} else {
start <- 1L
cached <- 0
start <- 1 # don't use integers to avoid overflow
cached <- 0 # don't use integers to avoid overflow
last.cleared <- 0L

tstr <- type(x)
Expand Down Expand Up @@ -241,7 +241,7 @@ setMethod("h5_write_sparse_matrix", "ANY", function(x, handle, details, ...) {
mhandle <- H5Screate_simple(1)
on.exit(H5Sclose(mhandle), add=TRUE, after=FALSE)

start <- 1L
start <- 1 # don't use integers to avoid overflow
pointers <- list(0)
for (i in seq_along(grid)) {
block <- read_sparse_block(x, grid[[i]])
Expand Down
2 changes: 2 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
However, note that this was not implemented for the soft-deprecated \code{writeSparseMatrix}, which now errors if such objects are passed in.

\item Added a \code{extract_sparse_array()} method for the \code{WrapperArraySeed} class, for some future-proofing when the seeds eventually make the switch.

\item Bugfix for integer overflow when saving large sparse matrices in \code{saveObject()}.
}}

0 comments on commit d5c82b2

Please sign in to comment.