Class BackgroundMemoryListImpl<V,​Q extends javax.measure.quantity.Quantity>

  • Type Parameters:
    V - Value type of the measurements to be stored. Most often used values are Double or Long
    Q - Quantity to be stored, see Quantity
    All Implemented Interfaces:
    Iterable<javax.measure.Measure<V,​Q>>, Collection<javax.measure.Measure<V,​Q>>, List<javax.measure.Measure<V,​Q>>, BackgroundMemoryList<V,​Q>, BinaryMeasurementsList<V,​Q>

    public class BackgroundMemoryListImpl<V,​Q extends javax.measure.quantity.Quantity>
    extends AbstractList<javax.measure.Measure<V,​Q>>
    implements BackgroundMemoryList<V,​Q>
    A generic list implementation that consumes a constant amount of main memory regardless of the number of elements in the list. It relies on HDD memory as background storage. It uses views on the data stored in form of chunks. A chunk contains a limited number of data elements. Chunks are (de-)serialized to disk depending on the requested data elements. The list has some restrictions: First, all elements have to be serializable with constant memory footprint. Second, deletion of elements in the list is not implemented. Third, insertion is only possible at the end of the list. Fourth, all list elements are persisted with the same unit, so unit conversion and conversion losses may apply.
    • Field Detail

      • DEFAULT_CHUNK_SIZE

        public static final int DEFAULT_CHUNK_SIZE
        Default Number of data elements per chunk.
        See Also:
        Constant Field Values
    • Constructor Detail

      • BackgroundMemoryListImpl

        public BackgroundMemoryListImpl​(String absoluteFilename,
                                        Serializer<V> serialiser,
                                        BackgroundMemoryListImpl.BinaryRepresentation binaryRepresentation,
                                        javax.measure.unit.Unit<Q> unit)
                                 throws IOException
        Constructor for background memory lists.
        Parameters:
        absoluteFilename - Path to the file used as background storage.
        serialiser - The (de-)serializer to use upon serialization of data to the background storage.
        Throws:
        IOException - Thrown if file IO fails.
      • BackgroundMemoryListImpl

        public BackgroundMemoryListImpl​(String absoluteFilename,
                                        Serializer<V> serialiser,
                                        int chunkSize,
                                        BackgroundMemoryListImpl.BinaryRepresentation binaryRepresentation,
                                        javax.measure.unit.Unit<Q> unit)
                                 throws IOException
        Constructor for background memory lists.
        Parameters:
        absoluteFilename - Path to the file used as background storage.
        serialiser - The (de-)serializer to use upon serialization of data to the background storage.
        chunkSize - The size of the chunk in elements which should be used.
        Throws:
        IOException - Thrown if file IO fails.
    • Method Detail

      • open

        public void open()
                  throws IOException
        Description copied from interface: BackgroundMemoryList
        Opens the link to the file on background storage. Only allowed if there is no open link.
        Specified by:
        open in interface BackgroundMemoryList<V,​Q extends javax.measure.quantity.Quantity>
        Throws:
        IOException - Thrown if file IO fails.
      • isClosed

        public boolean isClosed()
        Description copied from interface: BackgroundMemoryList
        Get the status of the link to the attached file. Any read or write operation is only allowed in open state.
        Specified by:
        isClosed in interface BackgroundMemoryList<V,​Q extends javax.measure.quantity.Quantity>
        Returns:
        true if the link to the attached file is closed.
      • add

        public void add​(int index,
                        javax.measure.Measure<V,​Q> element)
        Specified by:
        add in interface List<V>
        Overrides:
        add in class AbstractList<javax.measure.Measure<V,​Q extends javax.measure.quantity.Quantity>>
      • get

        public javax.measure.Measure<V,​Q> get​(int index)
        Specified by:
        get in interface List<V>
        Specified by:
        get in class AbstractList<javax.measure.Measure<V,​Q extends javax.measure.quantity.Quantity>>
      • set

        public javax.measure.Measure<V,​Q> set​(int index,
                                                    javax.measure.Measure<V,​Q> element)
        Specified by:
        set in interface List<V>
        Overrides:
        set in class AbstractList<javax.measure.Measure<V,​Q extends javax.measure.quantity.Quantity>>
      • remove

        public javax.measure.Measure<V,​Q> remove​(int index)
        Specified by:
        remove in interface List<V>
        Overrides:
        remove in class AbstractList<javax.measure.Measure<V,​Q extends javax.measure.quantity.Quantity>>
      • close

        public void close()
                   throws IOException
        Description copied from interface: BackgroundMemoryList
        Closes the link to the file on background storage. There are no further add or get operations allowed after closing.
        Specified by:
        close in interface BackgroundMemoryList<V,​Q extends javax.measure.quantity.Quantity>
        Throws:
        IOException