|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.knowceans.util.ArrayCache<T>
T
- type of the array elementspublic class ArrayCache<T>
ArrayCache represents a cache for a large multidimensional array, with the minor dimensions being type-dependent. The outmost array, say int[][] is completely exposed to programming code, allowing the developer usage of the ordinary array data structure. If code is about to access other parts of the array, a fetch() message is sent to the array. After it is clear that the element will not be touched for a while, a done() message is sent.
The idea is to lookup a row in the main array and check whether this is loaded. All rows not currently fetched are set to null. The user needs to either fetch the data to work on a given row or put it into the array themselves and call done() on the row.
Constructor Summary | |
---|---|
ArrayCache(java.lang.String backend,
int rowsize,
int typesize,
T[] array)
init the cache with the backend file and array |
|
ArrayCache(java.lang.String backend,
T[] array,
int rowsize,
int typesize,
java.lang.String access)
init the cache with the backend file and array |
Method Summary | |
---|---|
boolean |
done(int row)
done with the single row |
boolean |
done(int rowstart,
int length)
|
boolean |
fetch(int row)
fetch a single row |
boolean |
fetch(int rowstart,
int length)
fetch a range of the array from the backend |
static void |
main(java.lang.String[] args)
|
boolean |
save()
save the complete array to the backend |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ArrayCache(java.lang.String backend, int rowsize, int typesize, T[] array) throws java.io.FileNotFoundException
backend
- array
- the T[length] array with all higher dimensions null or filledrowsize
- length of rowstypesize
- size of one row element in bytes (array length x element size
for multidimensional arrays)
java.io.FileNotFoundException
public ArrayCache(java.lang.String backend, T[] array, int rowsize, int typesize, java.lang.String access) throws java.io.FileNotFoundException
backend
- array
- the T[length] array with all higher dimensions null or filledrowsize
- length of rowstypesize
- size of one row element in bytes (array length x element size
for multidimensional arrays)access
- string to control behaviour of file backend:
r(ead)|w(rite)|s(ynced)
java.io.FileNotFoundException
Method Detail |
---|
public static void main(java.lang.String[] args)
public boolean fetch(int rowstart, int length) throws java.io.IOException
rowstart
- length
-
java.io.IOException
public boolean fetch(int row)
row
-
public boolean done(int rowstart, int length)
rowstart
- length
-
public boolean done(int row)
row
-
public boolean save()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |