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 Classes Modifier and Type Class Description static class
BackgroundMemoryListImpl.BinaryRepresentation
Describes the representation and storage of the values in binary format.
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_CHUNK_SIZE
Default Number of data elements per chunk.-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description BackgroundMemoryListImpl(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, javax.measure.Measure<V,Q> element)
void
close()
Closes the link to the file on background storage.void
flush()
javax.measure.Measure<V,Q>
get(int index)
boolean
isClosed()
Get the status of the link to the attached file.void
open()
Opens the link to the file on background storage.javax.measure.Measure<V,Q>
remove(int index)
javax.measure.Measure<V,Q>
set(int index, javax.measure.Measure<V,Q> element)
int
size()
-
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 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 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.
-
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
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 interfaceBackgroundMemoryList<V,Q extends javax.measure.quantity.Quantity>
- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceBackgroundMemoryList<V,Q extends javax.measure.quantity.Quantity>
- Throws:
IOException
-
-