public class SvdlibcSparseBinaryMatrixBuilder extends Object implements MatrixBuilder
MatrixBuilder
implementation for creating matrix files in the SVDLIBC sparse
binary matrix format.
The addColumn
method is capable of throwing an IOError
if any
IOException
occurs while operating on the underlying matrix file.
This class is thread-safe.
Constructor and Description |
---|
SvdlibcSparseBinaryMatrixBuilder()
Creates a builder for a matrix in the
SVDLIBC_SPARSE_BINARY format to be
stored in a temporary file. |
SvdlibcSparseBinaryMatrixBuilder(boolean transposeData)
Creates a builder for a matrix in the
SVDLIBC_SPARSE_BINARY format to be
stored in a temporary file. |
SvdlibcSparseBinaryMatrixBuilder(File backingFile)
Creates a builder for a matrix in the
SVDLIBC_SPARSE_BINARY format,
which will be stored in the specified file. |
SvdlibcSparseBinaryMatrixBuilder(File backingFile,
boolean transposeData)
Creates a builder for a matrix in the
SVDLIBC_SPARSE_BINARY format,
which will be stored in the specified file. |
Modifier and Type | Method and Description |
---|---|
int |
addColumn(double[] column)
Adds the column values to the underlying matrix, updating the dimensions
as necessary and returning the index at which the column was added.
|
int |
addColumn(SparseArray<? extends Number> column)
Adds the
double values in the array to the underlying matrix,
updating the dimensions as necessary and returning the index at which the
column was added. |
int |
addColumn(Vector col)
Adds the vector values to the underlying matrix, updating the dimensions
as necessary and returning the index at which the column was added.
|
void |
finish()
Indicates that no further data will be added to the matrix and any
remaining matrix meta-data should be written and flushed to disk.
|
File |
getFile()
Returns the file containing the matrix data after all data has finished
being written.
|
MatrixFile |
getMatrixFile() |
MatrixIO.Format |
getMatrixFormat()
Returns
SVDLIBC_SPARSE_BINARY . |
boolean |
isFinished()
Returns
true if no further data should be added to the matrix and
the file containing the data is available for us. |
public SvdlibcSparseBinaryMatrixBuilder()
SVDLIBC_SPARSE_BINARY
format to be
stored in a temporary file.public SvdlibcSparseBinaryMatrixBuilder(boolean transposeData)
SVDLIBC_SPARSE_BINARY
format to be
stored in a temporary file.transposeData
- true
if the input matrix columns should be
tranposed in the backing matrix filepublic SvdlibcSparseBinaryMatrixBuilder(File backingFile)
SVDLIBC_SPARSE_BINARY
format,
which will be stored in the specified file.backingFile
- the file to which the matrix should be writtenpublic SvdlibcSparseBinaryMatrixBuilder(File backingFile, boolean transposeData)
SVDLIBC_SPARSE_BINARY
format,
which will be stored in the specified file.backingFile
- the file to which the matrix should be writtentransposeData
- true
if the input matrix columns should be
tranposed in the backing matrix filepublic int addColumn(double[] column)
addColumn
in interface MatrixBuilder
column
- the values of the column in the matrix.public int addColumn(SparseArray<? extends Number> column)
double
values in the array to the underlying matrix,
updating the dimensions as necessary and returning the index at which the
column was added.addColumn
in interface MatrixBuilder
column
- the values of the column in the matrix.public int addColumn(Vector col)
addColumn
in interface MatrixBuilder
col
- the values of the column in the matrix.public void finish()
addColumn
will thcolumn a IllegalStateException
if called. Once this method has been called, any subsequent calls will
have no effect and will not throw an exception.finish
in interface MatrixBuilder
public File getFile()
finish
method must be called prior to
accessing the underlying file to ensure that all necessary matrix
meta-data has been written to disk.getFile
in interface MatrixBuilder
public MatrixIO.Format getMatrixFormat()
SVDLIBC_SPARSE_BINARY
.getMatrixFormat
in interface MatrixBuilder
public MatrixFile getMatrixFile()
getMatrixFile
in interface MatrixBuilder
public boolean isFinished()
true
if no further data should be added to the matrix and
the file containing the data is available for us. This will only return
true
if finish
has been called first.isFinished
in interface MatrixBuilder
true
if no further data should be added to the matrixCopyright © 2012. All Rights Reserved.