public class DiskBackedQueue<E> extends Object implements Queue<E>
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E record)
Add the record to the tail of the queue, spilling to disk if necessary
Must check that (canAdd() == true) before calling this method
|
boolean |
addAll(Collection<? extends E> c)
Add all elements from collection c to this DiskBackedQueue
Must check that (canAdd() == true) before calling this method
|
boolean |
canAdd() |
void |
clear() |
boolean |
contains(Object o)
Not supported.
|
boolean |
containsAll(Collection<?> c)
Not supported.
|
E |
element() |
protected void |
finalize()
Clean up disk resources in case clear() has not been explicitly called (as would be preferable)
Closes the input and output streams associated with this DiskBackedQueue and deletes the temporary file
|
int |
getNumRecordsOnDisk() |
boolean |
headRecordIsFromDisk() |
boolean |
isEmpty() |
Iterator<E> |
iterator()
Not supported at this time
|
static <T> DiskBackedQueue<T> |
newInstance(SortingCollection.Codec<T> codec,
int maxRecordsInRam,
List<File> tmpDir)
Syntactic sugar around the ctor, to save some typing of type parameters
|
boolean |
offer(E e) |
E |
peek() |
E |
poll() |
E |
remove() |
boolean |
remove(Object o)
Not supported.
|
boolean |
removeAll(Collection<?> c)
Not supported.
|
boolean |
retainAll(Collection<?> c)
Not supported.
|
int |
size()
Return the total number of elements in the queue, both in memory and on disk
|
Object[] |
toArray()
Not supported at this time
|
<T1> T1[] |
toArray(T1[] a)
Not supported at this time
|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitequals, hashCode, parallelStream, removeIf, spliterator, streampublic static <T> DiskBackedQueue<T> newInstance(SortingCollection.Codec<T> codec, int maxRecordsInRam, List<File> tmpDir)
codec - For writing records to file and reading them back into RAMmaxRecordsInRam - how many records to accumulate in memory before spilling to disktmpDir - Where to write files of records that will not fit in RAMpublic boolean canAdd()
public int getNumRecordsOnDisk()
public boolean headRecordIsFromDisk()
public boolean add(E record) throws IllegalStateException
add in interface Collection<E>add in interface Queue<E>record - The record to be added to the queueIllegalStateException - if the queue cannot be added topublic int size()
size in interface Collection<E>public boolean isEmpty()
isEmpty in interface Collection<E>public boolean addAll(Collection<? extends E> c)
addAll in interface Collection<E>c - the collection of elements to addIllegalStateException - if the queue cannot be added topublic void clear()
clear in interface Collection<E>protected void finalize()
throws Throwable
public boolean remove(Object o)
remove in interface Collection<E>UnsupportedOperationExceptionpublic boolean removeAll(Collection<?> c)
removeAll in interface Collection<E>UnsupportedOperationExceptionpublic boolean retainAll(Collection<?> c)
retainAll in interface Collection<E>UnsupportedOperationExceptionpublic boolean contains(Object o)
contains in interface Collection<E>UnsupportedOperationExceptionpublic boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>UnsupportedOperationExceptionpublic Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>UnsupportedOperationExceptionpublic Object[] toArray()
toArray in interface Collection<E>UnsupportedOperationExceptionpublic <T1> T1[] toArray(T1[] a)
toArray in interface Collection<E>UnsupportedOperationException