Package uk.ac.starlink.ttools.plot2.data
Class ColumnStorage
java.lang.Object
uk.ac.starlink.ttools.plot2.data.ColumnStorage
Arranges for storage of column data (arrays of typed values)
in byte buffers.
Any
ByteStore
type can be used,
but there are special entry points for use with storage in named files,
which makes it possible to use this class for column storage that
persists beyond the length of a JVM.- Since:
- 6 Jan 2020
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract CachedColumn
createColumn
(Supplier<uk.ac.starlink.table.ByteStore> byteStoreSupplier) Creates a CachedColumn for read/write of a data array given any ByteStore type.abstract CachedColumn
createDiskColumn
(File[] files) Returns a CachedColumn that can be used to read/write data using disk storage.abstract CachedReader
createDiskReader
(File[] files) Returns a CachedReader that can be used to read data previously written by this storage object.abstract long
getDiskRowCount
(File[] files) Returns an estimate of the number of rows contained in files previously written by this storage object.abstract File[]
getFileNames
(File baseFile) Returns an array of filenames that can be used for disk-based I/O of data using this storage type.static ColumnStorage
getStorage
(StorageType type) Returns a ColumnStorage object suitable for use with a given StorageType.
-
Constructor Details
-
ColumnStorage
public ColumnStorage()
-
-
Method Details
-
createColumn
public abstract CachedColumn createColumn(Supplier<uk.ac.starlink.table.ByteStore> byteStoreSupplier) Creates a CachedColumn for read/write of a data array given any ByteStore type.- Parameters:
byteStoreSupplier
- factory for byte storage instances- Returns:
- column storage object for data compatible with this
-
getFileNames
Returns an array of filenames that can be used for disk-based I/O of data using this storage type. A base filename is supplied: for a given instance of this class, the returned array will always have the same content for the same base file. This value should be a suitable name for a regular file. The current implementation adds extensions such as ".dat" before using this name.- Parameters:
baseFile
- context filename- Returns:
- array of one or more filenames that can be used for storage
-
createDiskColumn
Returns a CachedColumn that can be used to read/write data using disk storage. Thefiles
array should be a value returned fromgetFileNames
method.- Parameters:
files
- array of filenames into which bytes will be written- Returns:
- CachedColumn instance for compatible data write/read
- Throws:
IOException
-
createDiskReader
Returns a CachedReader that can be used to read data previously written by this storage object. If data has been written to the result of thecreateDiskColumn
method invoked with the samefiles
argument, the reader returned by this method will be able to retrieve it.- Parameters:
files
- array of filenames from which bytes will be read- Returns:
- CachedReader instance from which compatible data can be read
- Throws:
IOException
-
getDiskRowCount
Returns an estimate of the number of rows contained in files previously written by this storage object. Thefiles
array should be a value returned fromgetFileNames
method. An approximate value is permitted; if no information is available, -1 may be returned.- Parameters:
files
- array of filenames from which bytes will be read- Returns:
- best estimate of row count, or -1 if not known
-
getStorage
Returns a ColumnStorage object suitable for use with a given StorageType. Return values are thread safe.- Parameters:
type
- storage type- Returns:
- column storage object
-