Modifier and Type | Class and Description |
---|---|
private class |
ArrayStack.blobItem |
private class |
ArrayStack.BlobLengths |
private class |
ArrayStack.BlobValues |
BLOB.Reducer, BLOB.Rewriter
Modifier and Type | Field and Description |
---|---|
private java.util.List<ArrayStack.blobItem> |
blobs |
private int |
buffersize |
private static java.util.concurrent.ExecutorService |
DELETE_EXECUTOR |
private java.util.concurrent.ExecutorService |
executor |
private long |
fileAgeLimit |
private long |
fileSizeLimit |
private java.io.File |
heapLocation |
private int |
keylength |
private static long |
maxFileSize |
private static GenericFormatter |
my_SHORT_MILSEC_FORMATTER |
static long |
oneMonth |
private ByteOrder |
ordering |
private java.lang.String |
prefix |
private long |
repositoryAgeMax |
private long |
repositorySizeMax |
private boolean |
trimall |
Constructor and Description |
---|
ArrayStack(java.io.File heapLocation,
java.lang.String prefix,
ByteOrder ordering,
int keylength,
int buffersize,
boolean trimall,
boolean deleteonfail) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
clears the content of the database
|
void |
close(boolean writeIDX)
close the BLOB
|
boolean |
containsKey(byte[] key)
check if a specific key is in the database
|
void |
delete(byte[] key)
delete a BLOB
|
int |
entries()
return the number of BLOB files in this array
|
private void |
executeLimits() |
byte[] |
get(byte[] key)
retrieve the whole BLOB from the table
|
byte[] |
get(java.lang.Object key) |
java.lang.Iterable<byte[]> |
getAll(byte[] key)
get all BLOBs in the array.
|
void |
insert(byte[] key,
byte[] b)
write a whole byte array as BLOB to the table
|
boolean |
isEmpty()
ask if the BLOB is empty
|
private ArrayStack.blobItem |
keeperOf(byte[] key)
find the blobItem that holds the key
if no blobItem is found, then return null
|
int |
keylength()
ask for the length of the primary key
|
CloneableIterator<byte[]> |
keys(boolean up,
boolean rotating)
iterator over all keys
|
CloneableIterator<byte[]> |
keys(boolean up,
byte[] firstKey)
iterate over all keys
|
long |
length()
retrieve the size of the database
|
long |
length(byte[] key)
retrieve the size of the BLOB
|
long |
lengthAdd(byte[] key)
retrieve the sizes of all BLOB
|
java.lang.Iterable<java.lang.Long> |
lengthAll(byte[] key)
get all BLOBs in the array.
|
static void |
main(java.lang.String[] args) |
long |
mem()
calculate the memory in RAM that the BLOB occupies
|
private static <ReferenceType extends Reference> |
merge(CloneableIterator<ReferenceContainer<ReferenceType>> i1,
CloneableIterator<ReferenceContainer<ReferenceType>> i2,
ByteOrder ordering,
HeapWriter writer) |
java.io.File |
mergeMount(java.io.File f1,
java.io.File f2,
ReferenceFactory<? extends Reference> factory,
java.io.File newFile,
int writeBuffer)
merge two blob files into one.
|
private static <ReferenceType extends Reference> |
mergeWorker(ReferenceFactory<ReferenceType> factory,
int keylength,
ByteOrder order,
java.io.File f1,
java.io.File f2,
java.io.File newFile,
int writeBuffer) |
void |
mountBLOB(java.io.File location,
boolean full)
add a blob file to the array.
|
java.lang.String |
name()
return a name of the BLOB; can be the file name
|
java.io.File |
newBLOB(java.util.Date creation)
generate a new BLOB file name with a given date.
|
void |
optimize()
trim the index of the database: this releases memory not currently used
|
ByteOrder |
ordering()
return the underlying odering
|
int |
reduce(byte[] key,
BLOB.Reducer reduce)
replace a BLOB entry with another which must be smaller or same size
|
int |
replace(byte[] key,
BLOB.Rewriter rewriter)
replace a BLOB entry with another
|
private static <ReferenceType extends Reference> |
rewrite(CloneableIterator<ReferenceContainer<ReferenceType>> i,
ByteOrder ordering,
HeapWriter writer) |
private static <ReferenceType extends Reference> |
rewriteWorker(ReferenceFactory<ReferenceType> factory,
int keylength,
ByteOrder order,
java.io.File f,
java.io.File newFile,
int writeBuffer) |
void |
setMaxAge(long maxAge) |
void |
setMaxSize(long maxSize) |
int |
size()
ask for the number of blob entries
|
int[] |
sizes()
ask for the number of blob entries in each blob of the blob array
|
private java.io.File |
smallestBLOB(java.io.File excluding,
long maxsize) |
private java.io.File |
unmount(int idx) |
java.io.File[] |
unmountBestMatch(float maxq,
long maxResultSize) |
private void |
unmountBLOB(java.io.File location,
boolean writeIDX) |
java.io.File |
unmountOldest() |
java.io.File |
unmountOldestBLOB(boolean smallestFromFirst2) |
java.io.File[] |
unmountSmallest(long maxResultSize) |
private static final long maxFileSize
public static final long oneMonth
private int keylength
private ByteOrder ordering
private final java.io.File heapLocation
private long fileAgeLimit
private long fileSizeLimit
private long repositoryAgeMax
private long repositorySizeMax
private java.util.List<ArrayStack.blobItem> blobs
private final java.lang.String prefix
private final int buffersize
private final boolean trimall
private final java.util.concurrent.ExecutorService executor
private static final GenericFormatter my_SHORT_MILSEC_FORMATTER
private static final java.util.concurrent.ExecutorService DELETE_EXECUTOR
public ArrayStack(java.io.File heapLocation, java.lang.String prefix, ByteOrder ordering, int keylength, int buffersize, boolean trimall, boolean deleteonfail) throws java.io.IOException
java.io.IOException
public long mem()
BLOB
public void optimize()
BLOB
public void mountBLOB(java.io.File location, boolean full) throws java.io.IOException
location
- java.io.IOException
private void unmountBLOB(java.io.File location, boolean writeIDX)
private java.io.File unmount(int idx)
public java.io.File[] unmountBestMatch(float maxq, long maxResultSize)
public java.io.File unmountOldest()
public java.io.File[] unmountSmallest(long maxResultSize)
private java.io.File smallestBLOB(java.io.File excluding, long maxsize)
public java.io.File unmountOldestBLOB(boolean smallestFromFirst2)
public int entries()
public java.io.File newBLOB(java.util.Date creation)
creation
- public java.lang.String name()
BLOB
public void setMaxAge(long maxAge)
public void setMaxSize(long maxSize)
private void executeLimits()
public long length()
BLOB
public ByteOrder ordering()
BLOB
public int keylength()
public void clear() throws java.io.IOException
public int size()
public boolean isEmpty()
BLOB
public int[] sizes()
public CloneableIterator<byte[]> keys(boolean up, boolean rotating) throws java.io.IOException
public CloneableIterator<byte[]> keys(boolean up, byte[] firstKey) throws java.io.IOException
public boolean containsKey(byte[] key)
containsKey
in interface BLOB
key
- the primary keyjava.io.IOException
private ArrayStack.blobItem keeperOf(byte[] key)
key
- public byte[] get(byte[] key) throws java.io.IOException, SpaceExceededException
get
in interface BLOB
key
- the primary keyjava.io.IOException
SpaceExceededException
public java.lang.Iterable<byte[]> getAll(byte[] key) throws java.io.IOException
key
- java.io.IOException
public long length(byte[] key) throws java.io.IOException
public java.lang.Iterable<java.lang.Long> lengthAll(byte[] key) throws java.io.IOException
key
- java.io.IOException
public long lengthAdd(byte[] key) throws java.io.IOException
key
- java.io.IOException
public void insert(byte[] key, byte[] b) throws java.io.IOException
insert
in interface BLOB
key
- the primary keyb
- java.io.IOException
SpaceExceededException
public int replace(byte[] key, BLOB.Rewriter rewriter) throws java.io.IOException, SpaceExceededException
replace
in interface BLOB
key
- the primary keyjava.io.IOException
SpaceExceededException
public int reduce(byte[] key, BLOB.Reducer reduce) throws java.io.IOException, SpaceExceededException
reduce
in interface BLOB
key
- the primary keyjava.io.IOException
SpaceExceededException
public void delete(byte[] key) throws java.io.IOException
public java.io.File mergeMount(java.io.File f1, java.io.File f2, ReferenceFactory<? extends Reference> factory, java.io.File newFile, int writeBuffer)
f1
- f2
- (may also be null)factory
- payloadrow
- newFile
- writeBuffer
- private static <ReferenceType extends Reference> java.io.File mergeWorker(ReferenceFactory<ReferenceType> factory, int keylength, ByteOrder order, java.io.File f1, java.io.File f2, java.io.File newFile, int writeBuffer)
private static <ReferenceType extends Reference> java.io.File rewriteWorker(ReferenceFactory<ReferenceType> factory, int keylength, ByteOrder order, java.io.File f, java.io.File newFile, int writeBuffer)
private static <ReferenceType extends Reference> void merge(CloneableIterator<ReferenceContainer<ReferenceType>> i1, CloneableIterator<ReferenceContainer<ReferenceType>> i2, ByteOrder ordering, HeapWriter writer) throws java.io.IOException, SpaceExceededException
java.io.IOException
SpaceExceededException
private static <ReferenceType extends Reference> void rewrite(CloneableIterator<ReferenceContainer<ReferenceType>> i, ByteOrder ordering, HeapWriter writer) throws java.io.IOException, SpaceExceededException
java.io.IOException
SpaceExceededException
public static void main(java.lang.String[] args)