% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/S3_split.R
\name{split_dataset}
\alias{split_dataset}
\alias{split_dataset.HDF5Matrix}
\title{Split an HDF5Matrix into multiple block datasets}
\usage{
split_dataset(x, n_blocks = NULL, block_size = NULL, bycols = FALSE, ...)

\method{split_dataset}{HDF5Matrix}(
  x,
  n_blocks = NULL,
  block_size = NULL,
  bycols = FALSE,
  out_group = "SPLIT",
  out_dataset = NULL,
  overwrite = FALSE,
  ...
)
}
\arguments{
\item{x}{An \code{HDF5Matrix}.}

\item{n_blocks}{Integer or \code{NULL}. Number of blocks.}

\item{block_size}{Integer or \code{NULL}. Rows or columns per block.}

\item{bycols}{Logical. Split by columns (\code{TRUE}) or rows (default \code{FALSE}).}

\item{\dots}{Ignored.}

\item{out_group}{Character. Output HDF5 group (default \code{"SPLIT"}).}

\item{out_dataset}{Character or NULL. Base dataset name.}

\item{overwrite}{Logical. Overwrite existing blocks (default \code{FALSE}).}
}
\value{
A named list of \code{HDF5Matrix} objects.
}
\description{
Splits an \code{HDF5Matrix} into equal-sized sub-matrices stored as
separate datasets in the same HDF5 file. This is the preferred form when
you want an explicit, unambiguous call: unlike \code{split()}, it does not
carry the \code{f} and \code{drop} parameters inherited from
\code{base::split} that have no meaning for HDF5Matrix objects.

Exactly one of \code{n_blocks} or \code{block_size} must be provided.
Output datasets are named \code{<out_group>/<out_dataset>.0},
\code{<out_group>/<out_dataset>.1}, \ldots (0-based index).
}
\examples{
\donttest{
tmp  <- tempfile(fileext = ".h5")
M    <- hdf5_create_matrix(tmp, "data/M", data = matrix(1:60, 6, 10))
blks <- split_dataset(M, n_blocks = 3L)
length(blks)
lapply(blks, close)
close(M)
unlink(tmp)
}

}
\seealso{
\code{\link{split.HDF5Matrix}} for the \code{base::split()} S3
dispatch equivalent; \code{\link{hdf5_reduce}} to recombine blocks.
}
