|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.rawstore.AbstractRawStore
com.bigdata.btree.IndexSegmentStore
public class IndexSegmentStore
A read-only store backed by a file containing a single IndexSegment.
| Field Summary | |
|---|---|
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 . |
| Fields inherited from class com.bigdata.rawstore.AbstractRawStore |
|---|
serializer |
| Fields inherited from interface com.bigdata.rawstore.IAddressManager |
|---|
NULL |
| Constructor Summary | |
|---|---|
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 Events. |
|
| Method Summary | |
|---|---|
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) and clears any records for the store from the IGlobalLRU. |
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()
Reports 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. |
IResourceMetadata |
getResourceMetadata()
A description of this store in support of the scale-out architecture. |
UUID |
getUUID()
Return the UUID which identifies this IRawStore. |
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. |
void |
packAddr(DataOutput out,
long addr)
Pack the address onto the output stream. |
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 |
unpackAddr(DataInput in)
Unpack the address from the input stream. |
long |
write(ByteBuffer data)
Write the data (unisolated). |
| Methods inherited from class com.bigdata.rawstore.AbstractRawStore |
|---|
deserialize, deserialize, deserialize, serialize |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.log4j.Logger log
protected static final String mode
file .
protected final File file
protected final IBigdataFederation<?> fed
Events are reported out.
protected final ReentrantLock lock
| Constructor Detail |
|---|
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 IndexSegmentStores is mediated by the
StoreManager which imposes a canonicalizing weak value cache to
ensure that we do not double-open an IndexSegmentStore.
file - The file
RuntimeException - 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 Events.
file - fed - | Method Detail |
|---|
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 AbstractRawStorepublic final IndexSegmentCheckpoint getCheckpoint()
public final UUID getUUID()
IRawStoreUUID which identifies this IRawStore. This
supports both IRawStore.getResourceMetadata() and the LRUNexus.
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.
finalize in class ObjectExceptionpublic String toString()
toString in class Objectpublic 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 IndexSegments 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()
IRawStoretrue iff the store is open.
true iff the store is open.public final boolean isReadOnly()
IRawStoretrue 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()
IRawStorenull 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()
IRawStoreIGlobalLRU.
public void destroy()
IGlobalLRU.
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()
IRawStore
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.
IOExceptionpublic final int getByteCount(long addr)
IAddressManager
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 void packAddr(DataOutput out,
long addr)
throws IOException
IAddressManager
out - The output stream.addr - The opaque identifier that is the within store locator for
some datum.
IOException
public 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.
public final long unpackAddr(DataInput in)
throws IOException
IAddressManager
in - The input stream.
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||