# Class ColumnStorage

java.lang.Object
uk.ac.starlink.ttools.plot2.data.ColumnStorage

public abstract class ColumnStorage extends Object
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
Constructor
Description
`ColumnStorage()`

## Method Summary

Modifier and Type
Method
Description
`abstract 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.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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

public 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. 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

public abstract CachedColumn createDiskColumn(File[] files) throws IOException
Returns a CachedColumn that can be used to read/write data using disk storage. The `files` array should be a value returned from `getFileNames` method.

Parameters:
  `files` - array of filenames into which bytes will be written
Returns:
  CachedColumn instance for compatible data write/read
Throws:
  `IOException`

### createDiskReader

public abstract CachedReader createDiskReader(File[] files) throws IOException
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 the `createDiskColumn` method invoked with the same `files` 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

public abstract long getDiskRowCount(File[] files)
Returns an estimate of the number of rows contained in files previously written by this storage object. The `files` array should be a value returned from `getFileNames` 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

public static ColumnStorage getStorage(StorageType type)
Returns a ColumnStorage object suitable for use with a given StorageType. Return values are thread safe.

Parameters:
  `type` - storage type
Returns:
  column storage object