public class IndexSegmentStore extends AbstractRawStore
IndexSegment
.Modifier and Type | Field and Description |
---|---|
protected IBigdataFederation<?> |
fed
Optional.
|
protected File |
file
The file containing the index segment.
|
protected ReentrantLock |
lock
A lock used to make open and close operations atomic.
|
protected static org.apache.log4j.Logger |
log
Logger.
|
protected static String |
mode
The mode that will be used to open the
file . |
NULL
Constructor and Description |
---|
IndexSegmentStore(File file)
Open a read-only store containing an
IndexSegment , but does not
load the IndexSegment from the store. |
IndexSegmentStore(File file,
IBigdataFederation<?> fed)
Constructor variant that accepts an
IBigdataFederation reference
and will report out Event s. |
Modifier and Type | Method and Description |
---|---|
protected void |
bufferIndexNodes()
Attempts to read the index nodes into
buf_nodes . |
void |
close()
Closes the file and releases the internal buffers.
|
void |
deleteResources()
Deletes the backing file(s) (if any).
|
void |
destroy()
Atomically closes the store (iff open) and then deletes the backing file.
|
protected void |
finalize()
Closes out the
IndexSegmentStore iff it is still open. |
void |
force(boolean metadata)
Force the data to stable storage.
|
IndexSegmentAddressManager |
getAddressManager()
Used to correct decode region-based addresses.
|
int |
getByteCount(long addr)
The length of the datum in bytes.
|
IndexSegmentCheckpoint |
getCheckpoint()
A read-only view of the checkpoint record for the index segment.
|
CounterSet |
getCounters()
Return performance counters.
|
File |
getFile()
The backing file -or-
null if there is no backing file
for the store. |
IndexMetadata |
getIndexMetadata()
The
IndexMetadata record for the IndexSegment . |
long |
getOffset(long addr)
The offset on the store at which the datum is stored.
|
long |
getPhysicalAddress(long addr)
Determine the unencoded physical address
|
IResourceMetadata |
getResourceMetadata()
A description of this store in support of the scale-out architecture.
|
UUID |
getUUID()
|
boolean |
isFullyBuffered()
Return
false since the leaves are not fully buffered even
if the nodes are fully buffered. |
boolean |
isNodesFullyBuffered()
Return
true if the nodes of the IndexSegment are
fully buffered in memory. |
boolean |
isOpen()
true iff the store is open. |
boolean |
isReadOnly()
true iff the store does not allow writes. |
boolean |
isStable()
True iff backed by stable storage.
|
IndexSegment |
loadIndexSegment()
Load the
IndexSegment . |
ByteBuffer |
read(long addr)
Read a record from the
IndexSegmentStore . |
protected BloomFilter |
readBloomFilter()
Reads the bloom filter directly from the file.
|
void |
reopen()
Re-open a (possibly closed) store.
|
long |
size()
The #of application data bytes written on the store (does not count any
headers or root blocks that may exist for the store).
|
long |
toAddr(int nbytes,
long offset)
Converts a byte count and offset into a long integer.
|
String |
toString() |
String |
toString(long addr)
A human readable representation of the address.
|
long |
write(ByteBuffer data)
Write the data (unisolated).
|
delete, getInputStream, getOutputStream
protected static final org.apache.log4j.Logger log
protected static final String mode
file
.protected final File file
protected final IBigdataFederation<?> fed
Event
s are reported out.protected final ReentrantLock lock
public IndexSegmentStore(File file)
IndexSegment
, but does not
load the IndexSegment
from the store.
Note: If an exception is thrown then the backing file will be closed.
Note: Normally access to IndexSegmentStore
s is mediated by the
StoreManager
which imposes a canonicalizing weak value cache to
ensure that we do not double-open an IndexSegmentStore
.
file
- The fileRuntimeException
- if there is a problem.RootBlockException
- if the root block is invalid.loadIndexSegment()
public IndexSegmentStore(File file, IBigdataFederation<?> fed)
IBigdataFederation
reference
and will report out Event
s.file
- fed
- public final IndexSegmentAddressManager getAddressManager()
IndexSegmentBuilder
encodes region-based addresses using
IndexSegmentRegion
. Those addresses are then transparently
decoded by this class. The IndexSegment
itself knows nothing
about this entire slight of hand.getAddressManager
in class AbstractRawStore
public final IndexSegmentCheckpoint getCheckpoint()
public final IndexMetadata getIndexMetadata()
IndexMetadata
record for the IndexSegment
.
Note: The IndexMetadata.getPartitionMetadata()
always reports
that LocalPartitionMetadata.getResources()
is null
.
This is because the BTree
on the AbstractJournal
defines
the index partition view and each IndexSegment
generally
participates in MANY views - one per commit point on each
AbstractJournal
where the IndexSegment
is part of an
index partition view.
protected void finalize() throws Exception
IndexSegmentStore
iff it is still open.
Note: The IndexSegment
has hard reference to the
IndexSegmentStore
but not the other way around. Therefore an
IndexSegment
will be swept before its store is finalized.
public IResourceMetadata getResourceMetadata()
IRawStore
public void reopen()
Note: If an exception is thrown then the backing file will be closed.
RootBlockException
- if the root block is invalid.RuntimeException
- if there is a problem, including a
FileNotFoundException
.close()
public IndexSegment loadIndexSegment()
IndexSegment
. The IndexSegment
(or derived
class) MUST provide a public constructor with the following signature:
className(IndexSegmentFileStore store)
Note: Normally access to IndexSegment
s is mediated by the
StoreManager
which imposes a canonicalizing weak value cache to
ensure that we do not double-open an IndexSegment
.
store
- The store.IndexSegment
or derived class loaded from that store.public final boolean isOpen()
IRawStore
true
iff the store is open.true
iff the store is open.public final boolean isReadOnly()
IRawStore
true
iff the store does not allow writes.public final boolean isStable()
IRawStore
public final boolean isFullyBuffered()
false
since the leaves are not fully buffered even
if the nodes are fully buffered.public boolean isNodesFullyBuffered()
true
if the nodes of the IndexSegment
are
fully buffered in memory. The result is consistent as of the time that
this method examines the state of the IndexSegmentStore
.public final File getFile()
IRawStore
null
if there is no backing file
for the store.public void close()
IndexSegmentStore
is already closed. This
operation may be reversed by reopen()
as long as the backing
file remains available. A read on a closed IndexSegmentStore
will
transparently reopen()
the store as long as the backing file
remains available. destroy()
provides an atomic "close and
delete" operation.public void deleteResources()
IRawStore
public void destroy()
IRawStore.deleteResources()
public final long write(ByteBuffer data)
IRawStore
data
- The data. The bytes from the current
Buffer.position()
to the
Buffer.limit()
will be written and the
Buffer.position()
will be advanced to the
Buffer.limit()
. The caller may subsequently
modify the contents of the buffer without changing the state
of the store (i.e., the data are copied into the store).IAddressManager
.public final void force(boolean metadata)
IRawStore
metadata
- If true, then force both the file contents and the file
metadata to disk.public final long size()
IRawStore
public CounterSet getCounters()
ICounterSetAccess
public ByteBuffer read(long addr)
IndexSegmentStore
. If the request is in
the node region and the nodes have been buffered then this uses a slice
on the node buffer. Otherwise this reads through to the backing file.
Note: An LRU disk cache is a poor choice for the leaves. Since the btree already maintains a cache of the recently touched leaf objects, a recent read against the disk is the best indication that we have that we will NOT want to read that region again soon.
addr
- A long integer that encodes both the offset from which the
data will be read and the #of bytes to be read. See
IAddressManager.toAddr(int, long)
.protected void bufferIndexNodes() throws IOException
buf_nodes
.
Note: If the nodes could not be buffered then reads against the nodes will read through to the backing file.
IOException
protected BloomFilter readBloomFilter() throws IOException
null
if the bloom filter was
not constructed when the IndexSegment
was built.IOException
public final int getByteCount(long addr)
IAddressManager
IRawStore
.addr
- The opaque identifier that is the within store locator for
some datum.public final long getOffset(long addr)
IAddressManager
addr
- The opaque identifier that is the within store locator for
some datum.public final long getPhysicalAddress(long addr)
IAddressManager
addr
- The encoded addresspublic final long toAddr(int nbytes, long offset)
IAddressManager
nbytes
- The byte count.offset
- The byte offset.public final String toString(long addr)
IAddressManager
addr
- The opaque identifier that is the within store locator for
some datum.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.