|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tranche.hash.DiskBackedBigHashSet
public class DiskBackedBigHashSet
Splitting some of functionality from Jayson's SimpleDiskBackedBigHashList to a Set so that both classes behave in their expected manner.
| Field Summary | |
|---|---|
static int |
BUFFER_IN_MEMORY
|
long |
filesBuffered
|
| Constructor Summary | |
|---|---|
DiskBackedBigHashSet()
Build a instance using a temp file. |
|
DiskBackedBigHashSet(java.io.File fileForRecords)
Provide a file used to store records on disk. |
|
| Method Summary | |
|---|---|
void |
add(BigHash hash)
|
void |
clear()
Clears out all the hashes. |
void |
close()
Close off resources. |
boolean |
contains(BigHash hash)
|
void |
delete(BigHash hash)
|
java.util.List |
get(long offset,
long limit)
|
int |
getTestBufferSize()
|
boolean |
isAutoWriteBeforeCriticalOperation()
If true, will write buffers to disk before the following operations: |
void |
setAutoWriteBeforeCriticalOperation(boolean autoWriteBeforeCriticalOperation)
If true, will write buffers to disk before the following operations: |
void |
setTestBufferSize(int testBufferSize)
|
int |
size()
Note: this might return an inaccurate result under two conditions: |
int |
size(boolean isAllowEstimate)
Offers caller more choice than size(). |
BigHash[] |
toArray()
Converts contents to array. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public long filesBuffered
public static final int BUFFER_IN_MEMORY
| Constructor Detail |
|---|
public DiskBackedBigHashSet()
Build a instance using a temp file.
public DiskBackedBigHashSet(java.io.File fileForRecords)
Provide a file used to store records on disk.
Primary use case is when information needs to persist across instances.
| Method Detail |
|---|
public void clear()
throws java.lang.Exception
Clears out all the hashes.
java.lang.Exception - Since must delete and create files.public final void add(BigHash hash)
public final void delete(BigHash hash)
public int size()
Note: this might return an inaccurate result under two conditions:
The result will be accurate is autoWriteBeforeCriticalOperation is set to true.
public int size(boolean isAllowEstimate)
Offers caller more choice than size(). Caller decides whether estimate is good enough, which can really save some time.
isAllowEstimate - If true, skip expensive operations that guarentee exact size. Estimates are not reliable, but can be useful if an estimate is appropriate.
public final boolean contains(BigHash hash)
throws java.lang.Exception
java.lang.Exception
public final java.util.List get(long offset,
long limit)
throws java.lang.Exception
offset - limit -
java.lang.Exceptionpublic final void close()
Close off resources.
If collection uses a temporary file, delete. Else flush contents for next use.
public int getTestBufferSize()
public void setTestBufferSize(int testBufferSize)
testBufferSize -
public BigHash[] toArray()
throws java.lang.Exception
Converts contents to array. Note: the purpose of this collection is to disk back to avoid tremendous memory overhead. Only use if know collection will fit in memory.
java.lang.Exceptionpublic boolean isAutoWriteBeforeCriticalOperation()
If true, will write buffers to disk before the following operations:
public void setAutoWriteBeforeCriticalOperation(boolean autoWriteBeforeCriticalOperation)
If true, will write buffers to disk before the following operations:
autoWriteBeforeCriticalOperation - True if writing buffers to disk before critical operations, false otherwise
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||