|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.timeindexing.io.AbstractIndexIO
com.timeindexing.io.AbstractFileIO
Has code for indexes that are file-based.
| Constructor Summary | |
AbstractFileIO()
|
|
| Method Summary | |
long |
addItem(ManagedIndexItem itemM)
Add an item. |
protected abstract long |
alignForData()
Align the index for an append of the Data This is done differently for each type of index. |
protected long |
alignForIndexItem()
Align the index for an append of an IndexItem. |
boolean |
awaitWork()
|
protected abstract long |
bufferedDataWrite(java.nio.ByteBuffer buffer)
Write a buffer of data. |
protected abstract long |
bufferedIndexWrite(java.nio.ByteBuffer buffer)
Write a buffer of index items. |
protected long |
bufferedWrite(java.nio.ByteBuffer buffer,
java.nio.channels.FileChannel channel,
ByteBufferRing ring)
Write a buffer of data. |
abstract long |
calculateAppendPosition()
Calculate the append position from the last item of the index. |
DataHolderObject |
convertDataReference(DataReference dataReference)
Read some data, given a DataReference and return it as a DataHolderObject. |
void |
drainWriteQueue()
This drains the write request queue by processing all the WriteRequests. |
protected long |
flushBuffer(java.nio.channels.FileChannel channel,
java.nio.ByteBuffer flushBuffer,
ByteBufferRing ring)
Actually flush the buffer out. |
long |
getAppendPosition()
Get the append position |
abstract ManagedIndexItem |
getItem(long position,
boolean doLoadData)
Get the item at index position Position. |
ManagedIndexItem |
getItem(Position position,
boolean doLoadData)
Get the item at index position Position. |
java.nio.channels.FileLock |
getWriteLock()
Get a write-lock on this index. |
boolean |
gotoAppendPosition()
Goto the append position |
boolean |
gotoFirstPosition()
Goto the first position |
boolean |
isWriteLocked()
Has the Index been write-locked. |
long |
loadIndex(LoadStyle loadStyle)
Load the index |
protected abstract java.nio.ByteBuffer |
memoryMapData(long offset,
long size)
Memory map some data from a channel. |
protected abstract long |
processData(java.nio.ByteBuffer buffer)
Processing of the data. |
protected abstract long |
processIndexItem(java.nio.ByteBuffer buffer)
Processing of the idnex item. |
java.nio.ByteBuffer |
readData(DataReference ref)
Read some data, given a DataReference. |
java.nio.ByteBuffer |
readData(long offset,
long size)
Read some data, given an offset and a size. |
java.nio.ByteBuffer |
readData(Offset offset,
long size)
Read some data, given an offset and a size. |
protected abstract long |
readDataIntoBuffer(java.nio.ByteBuffer buffer,
long size)
Actually read in the data. |
long |
readHeader(byte headerType)
Read an index header from the header stream. |
java.nio.ByteBuffer |
readIndexItem(long offset)
Read an IndexItem given an offset. |
java.nio.ByteBuffer |
readIndexItem(Offset offset,
long size)
Read an IndexItem given an offset. |
ManagedIndexItem |
readItem(long startOffset,
boolean withData)
Read the contents of the item It assumes the index file is alreayd open for writing. |
ManagedIndexItem |
readItem(Offset offset,
boolean withData)
Read the contents of the item It assumes the index file is alreayd open for writing. |
protected DataAbstraction |
readNormalData(long offset,
long size,
boolean withData)
Read some data, from a specified offset for a number of bytes. |
protected IndexReferenceDataHolder |
readReferenceData(long offset,
long size)
Read a reference, from a specified offset for a number of bytes. |
boolean |
releaseWriteLock()
Release a FileLock. |
void |
requestReadWork(Position position,
boolean doLoadData)
Add some work to the read queue. |
void |
requestWriteWork(java.nio.channels.FileChannel channel,
java.nio.ByteBuffer flushBuffer,
ByteBufferRing ring)
Add some work to the write queue. |
void |
run()
The Thread run method. |
protected abstract boolean |
seekToData(long position)
Seek to a certain position in the data file. |
protected boolean |
seekToData(Offset offset)
Seek to a certain position. |
protected abstract boolean |
seekToIndex(long position)
Seek to a certain position. |
protected boolean |
seekToIndex(Offset offset)
Seek to a certain position. |
boolean |
setAppendPosition()
Set the append position from the indexChannelPosition. |
protected IndexFileInteractor |
setItemSize(int itemSize)
Set the index item size. |
boolean |
skipData(long offset,
long size)
Skip over some data, given an offset and a size. |
boolean |
timeOut(long timeout)
Wait for the timeout to go off. |
long |
writeFromWorkQueue()
Write the contents of the ffirst ByteBuffer in the work queue to a FileChannel. |
long |
writeHeader(byte headerType)
Write the contents of the header out It assumes the index file is alreayd open for writing. |
long |
writeItem(ManagedIndexItem itemM)
Write the contents of the item It assumes the index file is alreayd open for writing. |
long |
writeNormal(ManagedIndexItem itemM)
Write the contents of the item with normal data It assumes the index file is alreayd open for writing. |
long |
writeReference(ManagedIndexItem itemM)
Write the contents of the item with a reference. |
| Methods inherited from class com.timeindexing.io.AbstractIndexIO |
getIndex, getThread, initThread, startThread, stopThread |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.timeindexing.io.IndexInteractor |
getIndex |
| Methods inherited from interface com.timeindexing.io.IndexFileReader |
close, open, readMetaData |
| Methods inherited from interface com.timeindexing.io.IndexFileWriter |
close, create, flush, open |
| Constructor Detail |
public AbstractFileIO()
| Method Detail |
public long readHeader(byte headerType)
throws java.io.IOException,
IndexOpenException
readHeader in interface IndexFileReaderheaderType - the type of header, e.g FileType.INLINE_INDEX or FileType.EXTERNAL_INDEX
java.io.IOException
IndexOpenException
public long writeHeader(byte headerType)
throws java.io.IOException
writeHeader in interface IndexFileWriterheaderType - the type of header, e.g FileType.INLINE_INDEX or FileType.EXTERNAL_INDEX
java.io.IOException
public long addItem(ManagedIndexItem itemM)
throws java.io.IOException
addItem in interface IndexInteractorjava.io.IOException
public long writeItem(ManagedIndexItem itemM)
throws java.io.IOException
writeItem in interface IndexFileWriterjava.io.IOException
public long writeNormal(ManagedIndexItem itemM)
throws java.io.IOException
java.io.IOException
public long writeReference(ManagedIndexItem itemM)
throws java.io.IOException
java.io.IOException
protected long alignForIndexItem()
throws java.io.IOException
java.io.IOException
protected abstract long alignForData()
throws java.io.IOException
java.io.IOException
protected abstract long processIndexItem(java.nio.ByteBuffer buffer)
throws java.io.IOException
java.io.IOException
protected abstract long processData(java.nio.ByteBuffer buffer)
throws java.io.IOException
java.io.IOException
protected abstract long bufferedIndexWrite(java.nio.ByteBuffer buffer)
throws java.io.IOException
java.io.IOException
protected abstract long bufferedDataWrite(java.nio.ByteBuffer buffer)
throws java.io.IOException
java.io.IOException
protected long bufferedWrite(java.nio.ByteBuffer buffer,
java.nio.channels.FileChannel channel,
ByteBufferRing ring)
throws java.io.IOException
java.io.IOException
protected long flushBuffer(java.nio.channels.FileChannel channel,
java.nio.ByteBuffer flushBuffer,
ByteBufferRing ring)
throws java.io.IOException
java.io.IOException
public ManagedIndexItem getItem(Position position,
boolean doLoadData)
throws java.io.IOException
getItem in interface IndexInteractorposition - the position of the index item to getdoLoadData - read the data for this IndexItem if withData is true,
the data needs to be read at a later time, otherwise
java.io.IOException
public abstract ManagedIndexItem getItem(long position,
boolean doLoadData)
throws java.io.IOException
getItem in interface IndexFileReaderposition - the position of the index item to getdoLoadData - read the data for this IndexItem if withData is true,
the data needs to be read at a later time, otherwise
java.io.IOException
public ManagedIndexItem readItem(Offset offset,
boolean withData)
throws java.io.IOException
readItem in interface IndexFileReaderoffset - the byte offset in the file to start reading an item fromwithData - read the data for this IndexItem if withData is true,
the data needs to be read at a later time, otherwise
java.io.IOException
public ManagedIndexItem readItem(long startOffset,
boolean withData)
throws java.io.IOException
readItem in interface IndexFileReaderwithData - read the data for this IndexItem if withData is true,
the data needs to be read at a later time, otherwisestartOffset - the byte offset in the file to start reading an item from
java.io.IOException
protected DataAbstraction readNormalData(long offset,
long size,
boolean withData)
throws java.io.IOException
java.io.IOException
protected IndexReferenceDataHolder readReferenceData(long offset,
long size)
throws java.io.IOException
java.io.IOException
public java.nio.ByteBuffer readIndexItem(Offset offset,
long size)
throws java.io.IOException
offset - the byte offset in the file to start reading an item from
java.io.IOException
public java.nio.ByteBuffer readIndexItem(long offset)
throws java.io.IOException
offset - the byte offset in the file to start reading an item from
java.io.IOException
public java.nio.ByteBuffer readData(Offset offset,
long size)
throws java.io.IOException
readData in interface IndexFileReaderoffset - the byte offset in the file to start reading an item fromsize - the number of bytes to read
java.io.IOException
public java.nio.ByteBuffer readData(long offset,
long size)
throws java.io.IOException
readData in interface IndexFileReaderoffset - the byte offset in the file to start reading an item fromsize - the number of bytes to read
java.io.IOException
protected abstract long readDataIntoBuffer(java.nio.ByteBuffer buffer,
long size)
throws java.io.IOException
java.io.IOException
public java.nio.ByteBuffer readData(DataReference ref)
throws java.io.IOException
readData in interface IndexFileReaderjava.io.IOException
protected abstract java.nio.ByteBuffer memoryMapData(long offset,
long size)
throws java.io.IOException
java.io.IOException
protected boolean seekToIndex(Offset offset)
throws java.io.IOException
java.io.IOException
protected abstract boolean seekToIndex(long position)
throws java.io.IOException
java.io.IOException
protected boolean seekToData(Offset offset)
throws java.io.IOException
java.io.IOException
protected abstract boolean seekToData(long position)
throws java.io.IOException
java.io.IOException
public boolean skipData(long offset,
long size)
throws java.io.IOException
offset - the byte offset in the file to start reading an item fromsize - the number of bytes to read
java.io.IOExceptionpublic DataHolderObject convertDataReference(DataReference dataReference)
convertDataReference in interface IndexFileReader
public long loadIndex(LoadStyle loadStyle)
throws java.io.IOException
loadIndex in interface IndexFileReaderjava.io.IOExceptionpublic long getAppendPosition()
getAppendPosition in interface IndexFileWriter
public boolean gotoAppendPosition()
throws java.io.IOException
gotoAppendPosition in interface IndexFileReaderjava.io.IOException
public boolean gotoFirstPosition()
throws java.io.IOException
gotoFirstPosition in interface IndexFileReaderjava.io.IOException
public boolean setAppendPosition()
throws java.io.IOException
setAppendPosition in interface IndexFileReaderjava.io.IOException
public abstract long calculateAppendPosition()
throws java.io.IOException
java.io.IOExceptionprotected IndexFileInteractor setItemSize(int itemSize)
public java.nio.channels.FileLock getWriteLock()
getWriteLock in interface IndexFileWriterpublic boolean releaseWriteLock()
releaseWriteLock in interface IndexFileWriterpublic boolean isWriteLocked()
isWriteLocked in interface IndexFileWriter
public void requestWriteWork(java.nio.channels.FileChannel channel,
java.nio.ByteBuffer flushBuffer,
ByteBufferRing ring)
public void requestReadWork(Position position,
boolean doLoadData)
public long writeFromWorkQueue()
throws java.io.IOException
java.io.IOException
public void drainWriteQueue()
throws java.io.IOException
java.io.IOExceptionpublic boolean timeOut(long timeout)
public boolean awaitWork()
public void run()
run in interface java.lang.Runnable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||