public class DiskBackedQueue<E>
extends java.lang.Object
implements java.util.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(java.util.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(java.lang.Object o)
Not supported.
|
boolean |
containsAll(java.util.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() |
java.util.Iterator<E> |
iterator()
Not supported at this time
|
static <T> DiskBackedQueue<T> |
newInstance(SortingCollection.Codec<T> codec,
int maxRecordsInRam,
java.util.List<java.io.File> tmpDir)
Syntactic sugar around the ctor, to save some typing of type parameters
|
static <T> DiskBackedQueue<T> |
newInstanceFromPaths(SortingCollection.Codec<T> codec,
int maxRecordsInRam,
java.util.List<java.nio.file.Path> 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(java.lang.Object o)
Not supported.
|
boolean |
removeAll(java.util.Collection<?> c)
Not supported.
|
boolean |
retainAll(java.util.Collection<?> c)
Not supported.
|
int |
size()
Return the total number of elements in the queue, both in memory and on disk
|
java.lang.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, waitpublic static <T> DiskBackedQueue<T> newInstance(SortingCollection.Codec<T> codec, int maxRecordsInRam, java.util.List<java.io.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 static <T> DiskBackedQueue<T> newInstanceFromPaths(SortingCollection.Codec<T> codec, int maxRecordsInRam, java.util.List<java.nio.file.Path> 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 java.lang.IllegalStateException
public int size()
size in interface java.util.Collection<E>public boolean isEmpty()
isEmpty in interface java.util.Collection<E>public boolean addAll(java.util.Collection<? extends E> c)
addAll in interface java.util.Collection<E>c - the collection of elements to addjava.lang.IllegalStateException - if the queue cannot be added topublic void clear()
clear in interface java.util.Collection<E>protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic boolean remove(java.lang.Object o)
remove in interface java.util.Collection<E>java.lang.UnsupportedOperationExceptionpublic boolean removeAll(java.util.Collection<?> c)
removeAll in interface java.util.Collection<E>java.lang.UnsupportedOperationExceptionpublic boolean retainAll(java.util.Collection<?> c)
retainAll in interface java.util.Collection<E>java.lang.UnsupportedOperationExceptionpublic boolean contains(java.lang.Object o)
contains in interface java.util.Collection<E>java.lang.UnsupportedOperationExceptionpublic boolean containsAll(java.util.Collection<?> c)
containsAll in interface java.util.Collection<E>java.lang.UnsupportedOperationExceptionpublic java.util.Iterator<E> iterator()
public java.lang.Object[] toArray()
toArray in interface java.util.Collection<E>java.lang.UnsupportedOperationExceptionpublic <T1> T1[] toArray(T1[] a)
toArray in interface java.util.Collection<E>java.lang.UnsupportedOperationException