public class IndexSegmentCheckpoint extends Object implements ICheckpoint
IndexSegment
.
The checkpoint record for the index segment file is written at the head of the file. It should have identical timestamps at the start and end of the checkpoint record (e.g., it doubles as a root block). Since the file format is immutable it is ok to have what is essentially only a single root block. If the timestamps do not agree then the build was not successfully completed.
Similar to the BTree
's Checkpoint
record, this record
contains only data that pertains specifically to the IndexSegment
checkpoint or data otherwise required to bootstrap the load of the
IndexSegment
from the file. General purpose metadata is stored in the
IndexMetadata
record.
Modifier and Type | Field and Description |
---|---|
long |
addrBloom
Address of the optional bloom filter and 0L iff no bloom filter
was constructed.
|
long |
addrFirstLeaf
Address of the first leaf in the file.
|
long |
addrLastLeaf
Address of the last leaf in the file.
|
long |
addrMetadata
The address of the
IndexMetadata record. |
long |
addrRoot
Address of the root node or leaf in the file.
|
long |
commitTime
The commit time associated with the view from which the
IndexSegment was generated. |
boolean |
compactingMerge
true iff the caller asserted that the IndexSegment
was a fused view of the source index (partition) as of the specified
commitTime . |
static int |
currentVersion
The current serialization version.
|
long |
extentBlobs
The #of bytes in the optional contiguous region containing the raw
records to be resolved by blob references or
0L iff there
are no raw records in this region. |
long |
extentLeaves
The #of bytes in the contiguous region containing the serialized leaves in
the file.
|
long |
extentNodes
The #of bytes in the contiguous region containing the serialized nodes in
the file or
0L iff there are no nodes in the file. |
int |
height
Height of the index segment (origin zero, so height := 0 means that
there is only a root leaf in the tree).
|
long |
length
Length of the file in bytes.
|
static int |
MAGIC
Magic value written at the start of the
IndexSegmentCheckpoint
record. |
int |
maxNodeOrLeafLength
The maximum #of bytes in any node or leaf stored on the
IndexSegment . |
long |
nentries
The #of index entries serialized in the file (non-negative and MAY be
zero).
|
int |
nleaves
The #of leaves serialized in the file.
|
int |
nnodes
The #of nodes serialized in the file.
|
int |
offsetBits
The #of bits in an 64-bit long integer address that are used to represent
the byte offset into the
IndexSegmentStore . |
long |
offsetBlobs
The offset of the optional contiguous region containing the raw records
to be resolved by blob references or
0L iff there are no
raw records in this region. |
long |
offsetLeaves
The offset of the contiguous region containing the serialized leaves in
the file.
|
long |
offsetNodes
The offset of the contiguous region containing the serialized nodes in
the file or
0L iff there are no nodes in the file. |
UUID |
segmentUUID
UUID for this
IndexSegment (it is a unique identifier for the
index segment resource and is reported as the UUID of the
IndexSegmentStore ). |
boolean |
useChecksums
true iff record level checksums are in use for the
IndexSegment . |
static int |
VERSION0
Version 0 of the serialization format.
|
static int |
VERSION1
Version 1 of the serialization format introduces an option for record
level checksums.
|
static int |
VERSION2
Version 2 of the serialization format replaced the int32 value for
nentries with an int64 value.
|
Constructor and Description |
---|
IndexSegmentCheckpoint(int offsetBits,
int height,
int nleaves,
int nnodes,
long nentries,
int maxNodeOrLeafLength,
long offsetLeaves,
long extentLeaves,
long offsetNodes,
long extentNodes,
long offsetBlobs,
long extentBlobs,
long addrRoot,
long addrMetadata,
long addrBloom,
long addrFirstLeaf,
long addrLastLeaf,
long length,
boolean compactingMerge,
boolean useChecksums,
UUID segmentUUID,
long commitTime)
Create a new checkpoint record in preparation for writing it on a file
containing a newly constructed
IndexSegment . |
IndexSegmentCheckpoint(RandomAccessFile raf)
Reads the
IndexSegmentCheckpoint record for the
IndexSegment . |
Modifier and Type | Method and Description |
---|---|
ByteBuffer |
asReadOnlyBuffer()
Returns a new view of the read-only
ByteBuffer containing the
serialized representation of the IndexSegmentCheckpoint record. |
long |
getBloomFilterAddr()
Address of the
IBloomFilter . |
long |
getCheckpointAddr()
The address used to read this
Checkpoint record from the store. |
long |
getCounter()
Return the value of the B+Tree local counter stored in the
Checkpoint record. |
long |
getEntryCount()
The #of index entries (aka tuple count).
|
int |
getGlobalDepth()
The global depth of the root directory (HTree only).
|
int |
getHeight()
The height of a B+Tree.
|
IndexTypeEnum |
getIndexType()
The type of index for this checkpoint record.
|
long |
getLeafCount()
The #of leaves (B+Tree), hash buckets (HTree), or ZERO (0) for a solution
set stream.
|
long |
getMetadataAddr()
Address that can be used to read the
IndexMetadata record for the
index from the store. |
long |
getNodeCount()
The #of non-leaf nodes (B+Tree) or directories (HTree).
|
long |
getRecordVersion()
Return the value of the next record version number to be assigned that is
stored in the
Checkpoint record. |
long |
getRootAddr()
Address of the root node or leaf of the
BTree . |
boolean |
hasCheckpointAddr()
Return
true iff the checkpoint address is defined. |
String |
toString()
A human readable representation of the
IndexSegmentCheckpoint
record. |
void |
validate()
Test validity of the
IndexSegmentCheckpoint record. |
void |
write(RandomAccessFile raf)
Write the checkpoint record at the start of the file.
|
public static final transient int MAGIC
IndexSegmentCheckpoint
record.public static final transient int VERSION0
public static final transient int VERSION1
useChecksums
true
iff record level checksums are enabled. The default
for earlier versions is false
, which provides backward
compatibility for existing IndexSegment
files.public static final transient int VERSION2
public static final transient int currentVersion
public final UUID segmentUUID
IndexSegment
(it is a unique identifier for the
index segment resource and is reported as the UUID
of the
IndexSegmentStore
).public final int offsetBits
IndexSegmentStore
.public final int height
public final int nleaves
Note: IndexSegmentBuilder
is restricted to MAX_INT leaves in
its build plan.
public final int nnodes
nleaves
MUST
be ONE (1) and the index consists solely of a root leaf.
Note: IndexSegmentBuilder
is restricted to MAX_INT leaves in
its build plan and there are always more leaves than nodes in a BTree
so this is also an int32 value.
public final long nentries
public final int maxNodeOrLeafLength
IndexSegment
.
Note: while this appears to be unused now, it is still of interest and will be retained.
public final long offsetLeaves
Note: The offset must be equal to SIZE
since the leaves are
written immediately after the IndexSegmentCheckpoint
record.
public final long extentLeaves
public final long offsetNodes
0L
iff there are no nodes in the file.public final long extentNodes
0L
iff there are no nodes in the file.public final long offsetBlobs
0L
iff there are no
raw records in this region.public final long extentBlobs
0L
iff there
are no raw records in this region.public final long addrRoot
public final long addrMetadata
IndexMetadata
record.public final long addrBloom
public final long addrFirstLeaf
public final long addrLastLeaf
public final long length
public final boolean compactingMerge
true
iff the caller asserted that the IndexSegment
was a fused view of the source index (partition) as of the specified
commitTime
. false
implies that the
IndexSegment
is the result of an incremental build. This flag is
important when attempting a bottom up reconstruction of a scale-out index
from its components on various journals and IndexSegmentStore
s.public final boolean useChecksums
true
iff record level checksums are in use for the
IndexSegment
.VERSION1
public final long commitTime
IndexSegment
was generated. The IndexSegment
state is
equivalent to the state of the view as of that timestamp. However, the
IndexSegment
provides a view of only a single commit point in
contrast to the many commit points that are typically available on a
Journal
.
Note: This field is written at the head and tail of the
IndexSegmentCheckpoint
record. If the timestamps on that record
do not agree then the build operation probably failed while writing the
checkpoint record.
public IndexSegmentCheckpoint(RandomAccessFile raf) throws IOException
IndexSegmentCheckpoint
record for the
IndexSegment
. The operation seeks to the start of the file and
uses relative reads with the file pointer.raf
- The file.IOException
- If there is a IO problem.RootBlockException
- if the IndexSegmentCheckpoint
record is invalid (it
doubles as a root block), including if the total file length
is not large enough to contain an valid
IndexSegmentCheckpoint
record.public IndexSegmentCheckpoint(int offsetBits, int height, int nleaves, int nnodes, long nentries, int maxNodeOrLeafLength, long offsetLeaves, long extentLeaves, long offsetNodes, long extentNodes, long offsetBlobs, long extentBlobs, long addrRoot, long addrMetadata, long addrBloom, long addrFirstLeaf, long addrLastLeaf, long length, boolean compactingMerge, boolean useChecksums, UUID segmentUUID, long commitTime)
IndexSegment
.public void validate()
IndexSegmentCheckpoint
record.public ByteBuffer asReadOnlyBuffer()
ByteBuffer
containing the
serialized representation of the IndexSegmentCheckpoint
record.public void write(RandomAccessFile raf) throws IOException
raf
- The file.IOException
public String toString()
IndexSegmentCheckpoint
record.public long getCheckpointAddr()
Checkpoint
record from the store.
Note: This is set as a side-effect by #write(IRawStore)
.
Note: The checkpoint is assembled from the root block by the constructor. There is no address from which it can be re-read.
getCheckpointAddr
in interface ICheckpoint
0L
public boolean hasCheckpointAddr()
true
iff the checkpoint address is defined.
Note: The checkpoint is assembled from the root block by the constructor. There is no address from which it can be re-read.
hasCheckpointAddr
in interface ICheckpoint
false
public long getMetadataAddr()
ICheckpoint
IndexMetadata
record for the
index from the store.getMetadataAddr
in interface ICheckpoint
public long getRootAddr()
ICheckpoint
BTree
.getRootAddr
in interface ICheckpoint
0L
iff the index does
not have a root page.public long getBloomFilterAddr()
ICheckpoint
IBloomFilter
.getBloomFilterAddr
in interface ICheckpoint
0L
iff the
index does not have a bloom filter.public int getHeight()
ICheckpoint
getHeight
in interface ICheckpoint
IndexTypeEnum.BTree
public int getGlobalDepth()
ICheckpoint
getGlobalDepth
in interface ICheckpoint
IndexTypeEnum.HTree
public long getNodeCount()
ICheckpoint
getNodeCount
in interface ICheckpoint
public long getLeafCount()
ICheckpoint
getLeafCount
in interface ICheckpoint
public long getEntryCount()
ICheckpoint
getEntryCount
in interface ICheckpoint
public long getCounter()
Checkpoint
record.
Note: There is no counter associated with an IndexSegment
. The
counter is only available for the BTree
.
getCounter
in interface ICheckpoint
0L
public long getRecordVersion()
ICheckpoint
Checkpoint
record. This number is incremented each
time a node or leaf is written onto the backing store. The initial value
is ZERO (0). The first value assigned to a node or leaf will be ZERO (0).getRecordVersion
in interface ICheckpoint
public IndexTypeEnum getIndexType()
ICheckpoint
getIndexType
in interface ICheckpoint
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.