class FileSystemQueue<E> extends AbstractQueue<E>
Modifier and Type | Class and Description |
---|---|
private class |
FileSystemQueue.Itr |
Modifier and Type | Field and Description |
---|---|
private BufferedFile |
_bufferedFile |
private DataInputStream |
_dataInputStream |
private DataOutputStream |
_dataOutputStream |
private static Debug |
_debug |
private long |
_fileHeadPosition |
private long |
_fileSizeInUse |
private long |
_fileTailPosition |
private int |
_maxBufferSize |
private long |
_maximumFileSize |
private QueueSerializer<E> |
_queueSerializer |
private int |
_size |
Constructor and Description |
---|
FileSystemQueue(long maximumFileSize,
QueueSerializer<E> queueSerializer)
Eine Queue, die zur Speicherung von Daten ausschließlich das Dateisystem verwendet
|
FileSystemQueue(long maximumFileSize,
QueueSerializer<E> queueSerializer,
int maxBufferSize)
Eine Queue, die zur Speicherung von Daten ausschließlich das Dateisystem verwendet
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
long |
getCapacity() |
long |
getDiskUsed() |
Iterator<E> |
iterator()
Returns an iterator over the elements contained in this collection.
|
boolean |
offer(E e)
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.
|
E |
peek()
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
|
E |
poll()
Retrieves and removes the head of this queue, or returns null if this queue is empty.
|
private E |
read() |
int |
size() |
String |
toString() |
private void |
write(E e) |
add, addAll, element, remove
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
private static final Debug _debug
private final int _maxBufferSize
private long _fileHeadPosition
private long _fileSizeInUse
private final long _maximumFileSize
private final QueueSerializer<E> _queueSerializer
private int _size
private long _fileTailPosition
private final BufferedFile _bufferedFile
private final DataOutputStream _dataOutputStream
private final DataInputStream _dataInputStream
public FileSystemQueue(long maximumFileSize, QueueSerializer<E> queueSerializer)
maximumFileSize
- Maximalgröße der Datei in Bytes. Diese kann um maximal eine Elementgröße überschritten werden, sodass immer mindestens ein Eintrag in
die Datei passt.public FileSystemQueue(long maximumFileSize, QueueSerializer<E> queueSerializer, int maxBufferSize)
maximumFileSize
- Maximalgröße der Datei in Bytes. Diese kann um maximal eine Elementgröße überschritten werden, sodass immer mindestens ein Eintrag in
die Datei passt.maxBufferSize
- Maximale Größe für den Schreib- und Lesebuffer für Datei-Ein- und Ausgaben. Kleine Werte verringern den Speicherverbrauch,
senken aber auch die Performance.public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in class AbstractCollection<E>
public int size()
size
in interface Collection<E>
size
in class AbstractCollection<E>
public boolean offer(E e)
AbstractQueue.add(E)
, which can fail to insert an element only by throwing an exception.e
- the element to addClassCastException
- if the class of the specified element prevents it from being added to this queueNullPointerException
- if the specified element is null and this queue does not permit null elementsIllegalArgumentException
- if some property of this element prevents it from being added to this queueprivate E read() throws IOException
IOException
private void write(E e) throws IOException
IOException
public E poll()
public E peek()
public String toString()
toString
in class AbstractCollection<E>
public long getDiskUsed()
public long getCapacity()
public void clear()
clear
in interface Collection<E>
clear
in class AbstractQueue<E>