Class BackgroundMemoryListImpl<V,Q extends javax.measure.quantity.Quantity>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<javax.measure.Measure<V,Q>>
org.palladiosimulator.edp2.repository.local.dao.internal.backgroundlist.BackgroundMemoryListImpl<V,Q>
- Type Parameters:
V
- Value type of the measurements to be stored. Most often used values are Double or LongQ
- Quantity to be stored, seeQuantity
- 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Describes the representation and storage of the values in binary format. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Default Number of data elements per chunk.Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorsConstructorDescriptionBackgroundMemoryListImpl
(String absoluteFilename, Serializer<V> serialiser, int chunkSize, BackgroundMemoryListImpl.BinaryRepresentation binaryRepresentation, javax.measure.unit.Unit<Q> unit) Constructor for background memory lists.BackgroundMemoryListImpl
(String absoluteFilename, Serializer<V> serialiser, BackgroundMemoryListImpl.BinaryRepresentation binaryRepresentation, javax.measure.unit.Unit<Q> unit) Constructor for background memory lists. -
Method Summary
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, replaceAll, retainAll, sort, spliterator, subList, toArray, toArray
-
Field Details
-
DEFAULT_CHUNK_SIZE
public static final int DEFAULT_CHUNK_SIZEDefault Number of data elements per chunk.- See Also:
-
-
Constructor Details
-
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 Details
-
open
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 interfaceBackgroundMemoryList<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 interfaceBackgroundMemoryList<V,
Q extends javax.measure.quantity.Quantity> - Returns:
true
if the link to the attached file is closed.
-
add
-
get
-
set
-
remove
-
size
public int size()- Specified by:
size
in interfaceCollection<V>
- Specified by:
size
in interfaceList<V>
- Specified by:
size
in classAbstractCollection<javax.measure.Measure<V,
Q extends javax.measure.quantity.Quantity>>
-
close
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 interfaceBackgroundMemoryList<V,
Q extends javax.measure.quantity.Quantity> - Throws:
IOException
-
flush
- Specified by:
flush
in interfaceBackgroundMemoryList<V,
Q extends javax.measure.quantity.Quantity> - Throws:
IOException
-