|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.faunos.skwish.sys.IndexMetrics
public final class IndexMetrics
Encapsulates the immutable properties of an index and its data model.
The Index
class maintains an IndexMetrics
instance in order to store the data read in the
HEADER part of the
index file (sans the entry count part, which is mutable).
Index
also delegates the actual reading and writing
of offset values to this class.
deletedOffset = -offset - 1Either way, user code doesn't actually have to know what this exact representation is: the
isDeleted(long)
, toAbsolute(long)
,
and toDeleted(long)
methods shield the user from this
knowledge.
Constructor Summary | |
---|---|
IndexMetrics(long zeroPosition,
Word wordType,
long baseId,
long baseOffset)
Creates a new instance. |
|
IndexMetrics(Word wordType)
Creates a new instance with default base offset, zero position and base ID of zero. |
|
IndexMetrics(Word wordType,
long baseOffset)
Creates a new instance with default zero position and base ID of zero. |
Method Summary | |
---|---|
long |
getBaseId()
Returns the base ID. |
long |
getBaseOffset()
Returns the base offset. |
long |
getMaxOffset()
Returns the magnitude of the largest offset that is representable in this metric. |
Word |
getOffsetWordType()
Returns the byte width of entry offsets (as a Word ). |
long |
getPositionForId(long id)
Returns the file position (in the index file) of the entry with the given ID. |
long |
getZeroPosition()
Returns the file position (in the index file) of the first entry offset. |
static boolean |
isDeleted(long offset)
Determines whether the given offset represents a deleted offset. |
IndexMetrics |
newBaseId(long baseId)
|
long |
readOffset(ByteBuffer in)
Reads and returns the offset contained in the given buffer. |
static long |
readOffset(ByteBuffer in,
Word wordType,
long baseOffset)
Reads and returns the offset contained in the given buffer using the specified base offset and word type. |
static long |
toAbsolute(long offset)
Returns the given signed offset as an absolute offset. |
static long |
toDeleted(long offset)
Returns the given offset as a deleted offset. |
IndexMetrics |
writeOffset(long offset,
ByteBuffer out)
Writes the specified offset to the given buffer. |
static void |
writeOffset(long offset,
ByteBuffer out,
Word targetWordType,
long targetBaseOffset)
Writes the specified offset to the given buffer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IndexMetrics(Word wordType)
public IndexMetrics(Word wordType, long baseOffset)
public IndexMetrics(long zeroPosition, Word wordType, long baseId, long baseOffset)
Method Detail |
---|
public long getZeroPosition()
getPositionForId(long)
public Word getOffsetWordType()
Word
).
public long getBaseId()
public long getBaseOffset()
public long getMaxOffset()
public long getPositionForId(long id)
id
should not be less than the base ID.
getZeroPosition()
public long readOffset(ByteBuffer in)
public static long readOffset(ByteBuffer in, Word wordType, long baseOffset)
public IndexMetrics writeOffset(long offset, ByteBuffer out)
getMaxOffset()
public static void writeOffset(long offset, ByteBuffer out, Word targetWordType, long targetBaseOffset)
targetBaseOffset
and targetWordType
, then an exception is raised.
public static long toAbsolute(long offset)
toDeleted(long)
public static long toDeleted(long offset)
toAbsolute(long)
,
isDeleted(long)
public static boolean isDeleted(long offset)
toDeleted(long)
public IndexMetrics newBaseId(long baseId)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |