public class IndexedChronicle extends Object implements Chronicle
Chronicle
that
you can put huge numbers of objects in, having different sizes.
For each record, IndexedChronicle holds the memory-offset in another index cache for random access. This means IndexedChronicle "knows" where the Nth object resides at in memory, thus the name "Indexed". But this index is just sequential index, first object has index 0, second object has index 1, and so on. If you want to access objects with other logical keys you have to manage your own mapping from logical key to index.
Indexing and data storage are achieved using two backing (memory-mapped) files:
Modifier and Type | Class and Description |
---|---|
protected class |
IndexedChronicle.AbstractIndexedExcerpt |
Modifier and Type | Method and Description |
---|---|
ChronicleQueueBuilder.IndexedChronicleQueueBuilder |
builder()
Returns the
ChronicleQueueBuilder that has been used to create
the current instance of IndexedChronicle |
void |
checkNotClosed()
Checks if this instance of IndexedChronicle is closed or not.
|
void |
clear() |
void |
close()
Closes this instance of IndexedChronicle, including the backing files.
|
ExcerptAppender |
createAppender()
Returns a new instance of
ExcerptAppender which can be used for
sequential writes into this Chronicle. |
Excerpt |
createExcerpt()
Returns a new instance of
Excerpt which can be used for random
access to the data stored in this Chronicle. |
ExcerptTailer |
createTailer()
Returns a new instance of
ExcerptTailer which can be used for
sequential reads from this Chronicle. |
long |
findTheLastIndex()
|
boolean |
isClosed() |
long |
lastIndex() |
long |
lastWrittenIndex()
|
String |
name()
Returns the base file name backing this instance of IndexChronicle.
|
long |
size()
|
public void checkNotClosed()
IllegalStateException
will be thrown.IllegalStateException
- if this IndexChronicle is closepublic ChronicleQueueBuilder.IndexedChronicleQueueBuilder builder()
ChronicleQueueBuilder
that has been used to create
the current instance of IndexedChroniclepublic long findTheLastIndex()
Excerpt
s previously
written into this Chronicle
. Basically the same value as
returned by lastWrittenIndex()
, but does it by looking at the
content of the backing files and figuring it out from there.
A side effect of the method is that it also stores the obtained value and it can and will
be used by subsequent calls of lastWrittenIndex()
.
The constructors of IndexedChronicle automatically call this method so they properly handle the backing file being both empty or non-empty at the start.
public long size()
public String name()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
- if an I/O error occurs@NotNull public Excerpt createExcerpt() throws IOException
Excerpt
which can be used for random
access to the data stored in this Chronicle.createExcerpt
in interface Chronicle
Excerpt
for this ChronicleIOException
- if an I/O error occurs@NotNull public ExcerptTailer createTailer() throws IOException
ExcerptTailer
which can be used for
sequential reads from this Chronicle.createTailer
in interface Chronicle
ExcerptTailer
for this ChronicleIOException
- if an I/O error occurs@NotNull public ExcerptAppender createAppender() throws IOException
ExcerptAppender
which can be used for
sequential writes into this Chronicle.createAppender
in interface Chronicle
ExcerptAppender
for this ChronicleIOException
- if an I/O error occurspublic long lastWrittenIndex()
Excerpt
s previously
written into this Chronicle
. Basically size() - 1.lastWrittenIndex
in interface Chronicle
Copyright © 2017. All rights reserved.