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
|
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
|
public 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 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.Object
java.lang.Throwable
public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<E>
java.lang.UnsupportedOperationException
public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<E>
java.lang.UnsupportedOperationException
public boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<E>
java.lang.UnsupportedOperationException
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<E>
java.lang.UnsupportedOperationException
public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<E>
java.lang.UnsupportedOperationException
public java.util.Iterator<E> iterator()
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<E>
java.lang.UnsupportedOperationException
public <T1> T1[] toArray(T1[] a)
toArray
in interface java.util.Collection<E>
java.lang.UnsupportedOperationException