Class ColumnStorage


  • public abstract class ColumnStorage
    extends java.lang.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

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract CachedColumn createColumn​(java.util.function.Supplier<uk.ac.starlink.table.ByteStore> byteStoreSupplier)
      Creates a CachedColumn for read/write of a data array given any ByteStore type.
      abstract CachedColumn createDiskColumn​(java.io.File[] files)
      Returns a CachedColumn that can be used to read/write data using disk storage.
      abstract CachedReader createDiskReader​(java.io.File[] files)
      Returns a CachedReader that can be used to read data previously written by this storage object.
      abstract long getDiskRowCount​(java.io.File[] files)
      Returns an estimate of the number of rows contained in files previously written by this storage object.
      abstract java.io.File[] getFileNames​(java.io.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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ColumnStorage

        public ColumnStorage()
    • Method Detail

      • createColumn

        public abstract CachedColumn createColumn​(java.util.function.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 java.io.File[] getFileNames​(java.io.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​(java.io.File[] files)
                                               throws java.io.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:
        java.io.IOException
      • createDiskReader

        public abstract CachedReader createDiskReader​(java.io.File[] files)
                                               throws java.io.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:
        java.io.IOException
      • getDiskRowCount

        public abstract long getDiskRowCount​(java.io.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