|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.bsvrz.ars.ars.persistence.index.DataTimeIndex
public final class DataTimeIndex
Diese Klasse stellt einen DatenzeitIndex dar. Sie verhält sich ähnlich dem ATimeMonotoneIndex
. Der Unterschied ist, dass die Folge der Eintraege
(min, max, min, max...) nicht monoton ist, weil es Rueckspruenge geben kann. Stattdessen sind die Eintraege nur nach dem min-Wert sortiert.
Nested Class Summary | |
---|---|
static class |
DataTimeIndex.IndexStartmode
Modi, mit denen ein Index angelegt werden kann (siehe DataTimeIndex(int,String,byte[],IndexStartmode) ) |
Field Summary | |
---|---|
static DataTimeIndex.IndexStartmode |
APPEND_REUSE_LAST
|
private long |
biggestDTMaxInFile
Hilfsvariablen |
private static int |
CONTID_POS
|
private long[] |
currentEntry
Current Entry Array - aktuelle Daten |
private static int |
DI_MAX_POS
|
private static int |
DI_MIN_POS
|
private static int |
DT_MAX_POS
|
private static int |
DT_MIN_POS
Positionen einzelner Daten im Enty-Array |
static DataTimeIndex.IndexStartmode |
ERASE_OLD
|
private static String |
ERROR_ACCESS
|
private static String |
ERROR_CLOSE
|
private static String |
ERROR_OPEN
|
private long |
filePositionReactivatedEntry
|
static String |
IDX_FILENAME
Dateiname, unter dem alle Indices dieser Art gespeichert werden |
static int |
NO_VALUE
Flag, mit dem signalisiert wird, dass ein Eintrag "keinen Wert" hat |
private int |
rbBiggestEntry
|
private byte[] |
rbBuffer
|
private boolean |
rbFileupdateNecessary
|
private int |
rbFirstUnsaved
|
private int |
rbSmallestEntry
|
Constructor Summary | |
---|---|
DataTimeIndex(int bufferSize)
Erzeugt einen neuen DatenZeitIndex. |
|
DataTimeIndex(int bufferSize,
String basePath,
byte[] temp,
DataTimeIndex.IndexStartmode startmode)
Erzeugt einen neuen Datenzeitindex. |
Method Summary | |
---|---|
void |
add(String basePath,
byte[] temp,
long dTMin,
long dTMax,
long dIMin,
long dIMax,
long contId)
Fügt dem Index einen neuen Eintrag hinzu. |
private long |
binaryFileSearch(RandomAccessFile raf,
byte[] temp,
long key)
Ermittelt mit einer binären Suche die Position, an der der Key1 untergebracht werden kann. |
int |
capacity()
Anzahl der Einträge, die dieser Index im RAM halten kann |
void |
checkForAdd(String basePath,
byte[] temp,
long dTMin,
long dTMax,
long dIMin,
long dIMax,
long contId)
Prüft, ob dem Index ein neuer Eintrag hinzugefügt werden könnte. |
void |
closeIndex(String basePath,
byte[] temp)
Schließt den Index und speichert alle geänderten Daten auf Platte. |
private int |
containsKey(byte[] array,
int cnt,
long key)
|
private void |
currentEntryToBuffer(String basePath,
byte[] temp)
|
int |
entries()
Anzahl der Einträge, die dieser Index im RAM hält |
private void |
flush(String basePath)
|
long |
getAbsolutDTMin(String basePath)
Liefert den kleinsten DT Min Wert, der jemals in diesem Index gespeichert wird. |
IndexResult |
getContainerID(String basePath,
byte[] temp,
long dTMin,
long dTMax)
Liefert eine Matrix mit DTMin/Max, DIMin/Max und ContainerIds, deren DTMin/Max-Werte zwischen dTMin und dTMax liegen. |
long |
getCurrentCID()
Liefert die aktuelle Container ID. |
long |
getCurrentDIMax()
Liefert vom aktuellen Eintrag den Max-Wert des DatenIndex |
long |
getCurrentDIMin()
Liefert vom aktuellen Eintrag den Min-Wert des DatenIndex |
long |
getCurrentDTMax()
Liefert vom aktuellen Eintrag den Max-Wert |
long |
getCurrentDTMin()
Liefert vom aktuellen Eintrag den Min-Wert |
private long[][] |
getMaximaFromFile(RandomAccessFile raf,
byte[] temp,
int fileStart,
int fileEnd)
|
private void |
ifClose(RandomAccessFile raf)
|
private RandomAccessFile |
ifOpen(String basePath)
|
private void |
insertIntoFile(String basePath,
byte[] temp)
|
private long[] |
linearFileSearch(RandomAccessFile raf,
byte[] temp,
IndexResult ir,
long min,
long max)
Sucht mit Hilfe eine linearen Suche auf der Indexdatei Container der Datenzeiten sich mit dem übergebenen Bereich schneiden und speicher diese im übergebenen Indexresult. |
private static int |
locateEntry(byte[] buffer,
long[] entry)
|
private boolean |
overlap(long firstMin,
long firstMax,
long secondMin,
long secondMax)
|
private void |
rbAddCurrentEntry()
|
private void |
rbAppendCurrentEntry()
|
private void |
rbAppendToFile(RandomAccessFile raf)
|
private int |
rbBytePos(int pos)
|
private boolean |
rbCacheChanged()
|
private int |
rbCapacity()
|
private int |
rbCapacityInBytes()
|
private int |
rbElementsInbetween(int start,
int stop,
int ringbufferSize)
|
private int |
rbEntries()
|
private int |
rbEntryLength()
|
private void |
rbExtractMaxima()
|
private int |
rbFindDTMin(long key)
|
private long |
rbGetCID(int index)
|
private long |
rbGetDIMax(int index)
|
private long |
rbGetDIMin(int index)
|
private long |
rbGetDTMax(int index)
|
private long |
rbGetDTMin(int index)
|
private long[] |
rbGetEntry(int index)
|
private long[] |
rbGetFileAnchor()
|
private int |
rbGetFirstUnsaved()
|
private boolean |
rbHasUnsavedData()
|
private void |
rbInit(int entries)
|
private void |
rbInsertElement()
|
private void |
rbLoad(RandomAccessFile raf)
|
private void |
rbMoveEntryLeft(int index)
|
private void |
rbMoveEntryRight(int index)
|
private boolean |
rbMustBeSaved()
|
private int |
rbStep(int index)
|
private int |
rbStepBack(int index)
|
private String |
rbToString()
|
void |
resize(int newSize,
String basePath)
Verändert die Größe des RingBuffers. |
String |
toString()
Gibt den Inhalt des ByteBuffers als String aus, inkl Angaben über Kapazität, Anzahl der Einträge und des CurrentEntries. |
private void |
updateCurrentEntryInFile(String basePath)
|
void |
updateMax(long newDTMax,
long newDIMax)
Aktualisiert den Max-Wert des aktuellsten Eintrages. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String IDX_FILENAME
public static final int NO_VALUE
public static final DataTimeIndex.IndexStartmode APPEND_REUSE_LAST
public static final DataTimeIndex.IndexStartmode ERASE_OLD
private static final int DT_MIN_POS
private static final int DT_MAX_POS
private static final int DI_MIN_POS
private static final int DI_MAX_POS
private static final int CONTID_POS
private static final String ERROR_OPEN
private static final String ERROR_CLOSE
private static final String ERROR_ACCESS
private long biggestDTMaxInFile
private long filePositionReactivatedEntry
private long[] currentEntry
private byte[] rbBuffer
private int rbSmallestEntry
private int rbBiggestEntry
private int rbFirstUnsaved
private boolean rbFileupdateNecessary
Constructor Detail |
---|
public DataTimeIndex(int bufferSize, String basePath, byte[] temp, DataTimeIndex.IndexStartmode startmode) throws IndexException
bufferSize
- Anzahl der Einträge, die der die der Index im RAM halten sollbasePath
- Verzeichnis, in dem die Indexdatei liegttemp
- Ein temporäres ByteArray, das zum Suchen des currentEntries verwendet wirdstartmode
- DataTimeIndex.IndexStartmode.ERASE_OLD
: alte Indexdatei loeschen, DataTimeIndex.IndexStartmode.APPEND_REUSE_LAST
: anfuegen, letzten Eintrag
weiterverwenden
IndexException
- Bei Problemem mit dem Dateizugriffpublic DataTimeIndex(int bufferSize)
bufferSize
- Anzahl der Einträge, die der die der Index im RAM halten sollMethod Detail |
---|
public void updateMax(long newDTMax, long newDIMax) throws IndexException
newDTMax
- neuer Wert für DatenZeitIndex-MaxnewDIMax
- neuer Wert für DatenIndexIndex-Max
IndexException
- Wenn der neue Wert kleiner als der dazugehörige Min-Wert ist oder wenn keinen currentEntry gibtpublic long getCurrentCID()
public long getCurrentDTMin()
public long getCurrentDTMax()
public long getCurrentDIMin()
public long getCurrentDIMax()
public int capacity()
public int entries()
public void add(String basePath, byte[] temp, long dTMin, long dTMax, long dIMin, long dIMax, long contId) throws IndexException
basePath
- Verzeichnis, in dem die Index-Datei liegttemp
- Puffer, der beim Einlesen/Schreiben der Index-Datei verwendet wirddTMin
- DatenZeit Min-WertdTMax
- DatenZeit Max-WertdIMin
- DatenIndex Min-WertdIMax
- DatenIndex Max-WertcontId
- Container ID
IndexException
- Bei Problemem mit der Index-Dateipublic void checkForAdd(String basePath, byte[] temp, long dTMin, long dTMax, long dIMin, long dIMax, long contId) throws IndexException
basePath
- Verzeichnis, in dem die Index-Datei liegttemp
- Puffer, der beim Einlesen/Schreiben der Index-Datei verwendet wirddTMin
- DatenZeit Min-WertdTMax
- DatenZeit Max-WertdIMin
- DatenIndex Min-WertdIMax
- DatenIndex Max-WertcontId
- Container ID
IndexException
- Bei Problemem mit der Index-Dateipublic IndexResult getContainerID(String basePath, byte[] temp, long dTMin, long dTMax) throws IndexException
basePath
- Verzeichnis, in dem die Index-Datei liegttemp
- Puffer, der beim Einlesen/Schreiben der Index-Datei verwendet wirddTMin
- Min-Wert der ZeitspannedTMax
- Max-Wert der Zeitspanne
IndexException
- Bei Problemem mit der IndexDateipublic long getAbsolutDTMin(String basePath) throws IndexException
basePath
- Verzeichnis, in dem die Index-Datei liegt
IndexException
- Bei Zugriffsproblemen mit der IndexDateipublic void closeIndex(String basePath, byte[] temp) throws IndexException
basePath
- Verzeichnis, in dem die Index-Datei liegttemp
- Puffer, der beim Schreiben der Index-Datei verwendet wird
IndexException
public String toString()
toString
in class Object
private void currentEntryToBuffer(String basePath, byte[] temp) throws IndexException
IndexException
private void flush(String basePath) throws IndexException
IndexException
private void insertIntoFile(String basePath, byte[] temp) throws IndexException
IndexException
private long binaryFileSearch(RandomAccessFile raf, byte[] temp, long key) throws IndexException, IOException
raf
- Eine Referenz auf die Dateitemp
- Ein Temp Array, zum Einlesen der Datei. Je größer umso besserkey
- der gesuchte Key1
IndexException
IOException
private long[] linearFileSearch(RandomAccessFile raf, byte[] temp, IndexResult ir, long min, long max) throws IndexException
raf
- Eine Referenz auf die Dateitemp
- Ein Temp Array, zum Einlesen der Datei. Je größer umso besserir
- Speichert die gefundenen Containermin
- Minimum des gesuchten Zeitbereichsmax
- Maximum des gesuchten Zeitbereichs
IndexException
private static int locateEntry(byte[] buffer, long[] entry)
private void updateCurrentEntryInFile(String basePath) throws IndexException
IndexException
private long[][] getMaximaFromFile(RandomAccessFile raf, byte[] temp, int fileStart, int fileEnd) throws IOException
raf
- Random Access Filetemp
- Temp. BufferfileStart
- Erstes Byte, ab den gelesen werden sollfileEnd
- Letztes Byte, bis zu dem gelesen werden soll
IOException
private int containsKey(byte[] array, int cnt, long key)
private boolean overlap(long firstMin, long firstMax, long secondMin, long secondMax)
private RandomAccessFile ifOpen(String basePath) throws IndexException
IndexException
private void ifClose(RandomAccessFile raf) throws IndexException
IndexException
private void rbInit(int entries)
private void rbLoad(RandomAccessFile raf) throws IndexException
IndexException
public void resize(int newSize, String basePath) throws IndexException
newSize
- basePath
-
IndexException
private int rbElementsInbetween(int start, int stop, int ringbufferSize)
private int rbEntries()
private int rbBytePos(int pos)
private int rbCapacity()
private int rbCapacityInBytes()
private int rbEntryLength()
private boolean rbMustBeSaved()
private void rbAddCurrentEntry()
private void rbAppendCurrentEntry()
private void rbInsertElement()
private void rbExtractMaxima()
private void rbMoveEntryRight(int index)
private void rbMoveEntryLeft(int index)
private int rbFindDTMin(long key)
private long rbGetDTMin(int index)
private long rbGetDTMax(int index)
private long rbGetDIMin(int index)
private long rbGetDIMax(int index)
private long rbGetCID(int index)
private long[] rbGetEntry(int index)
private int rbStep(int index)
private int rbStepBack(int index)
private void rbAppendToFile(RandomAccessFile raf) throws Exception
Exception
private long[] rbGetFileAnchor()
private boolean rbHasUnsavedData()
private boolean rbCacheChanged()
private int rbGetFirstUnsaved()
private String rbToString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |