E
- public class IndexSegmentMultiBlockIterator<E> extends Object implements ITupleIterator<E>
IndexSegment
. This
iterator is designed for operations which will fully visit either all leaves
in the IndexSegment
or a key-range corresponding to a substantial
proportion of those leaves. A direct ByteBuffer
is allocated from the
caller's DirectBufferPool
and an IO request is issued against the
IndexSegment
to fill the ByteBuffer
with as many leaves
spanned by the key-range as will fit into the buffer. The leaves laid out
contiguously in total key order in the IndexSegment
. The addresses of
the leaves spanned by a key-range are easily identified by two key probes
into the nodes, and the nodes region is generally fully buffered. The #of
leaves spanned by a key range may be estimated as
(rangeCount/branchingFactor).
During traversal, each leaf is copied into a Java byte[]
in
order to provide fast decode of the data in the leaf. When the buffered
leaves have been exhausted, another chunk of leaves will be read using
another multi-block IO.
You should choose this iterator if: (a) the iterator uses forward traversal
only; (b) the key-range includes the entire IndexSegment
-or- a probe
reveals that more than a few leaves would be read; (c) the largest record in
the IndexSegment
will fit within a buffer acquired from the selected
DirectBufferPool
; and (d) it is reasonable to expect that the
iterator will be fully consumed by the caller.
The #of leaves which would be read can be estimated by dividing the range
count by the branching factor. If there are more than 2 full leaves worth of
data to be read this iterator will be faster than the linked leaf traversal
provided by IndexSegment.IndexSegmentTupleCursor
since this class will do one IO
rather than one per leaf.
Modifier and Type | Field and Description |
---|---|
protected static org.apache.log4j.Logger |
log |
Constructor and Description |
---|
IndexSegmentMultiBlockIterator(IndexSegment seg,
DirectBufferPool pool,
byte[] fromKey,
byte[] toKey,
int flags) |
Modifier and Type | Method and Description |
---|---|
protected void |
finalize() |
protected IndexSegment.ImmutableNodeFactory.ImmutableLeaf |
getLeaf()
Return the current leaf.
|
boolean |
hasNext() |
ITuple<E> |
next()
Advance the iterator and return the
ITuple from which you can
extract the data and metadata for next entry. |
void |
remove() |
String |
toString() |
public IndexSegmentMultiBlockIterator(IndexSegment seg, DirectBufferPool pool, byte[] fromKey, byte[] toKey, int flags)
seg
- The IndexSegment
.pool
- The pool from which a direct ByteBuffer
will be
acquired and into which blocks will be read from the backing
file.fromKey
- The inclusive lower bound -or- null
if there is
no lower bound.toKey
- The exclusive upper bound -or- null
if there is
no upper bound.flags
- protected void finalize() throws Throwable
This is extended to ensure that the buffer is released back to the
DirectBufferPool
.
protected IndexSegment.ImmutableNodeFactory.ImmutableLeaf getLeaf()
null
iff no leaves have been
read from the IndexSegment
.public ITuple<E> next()
ITupleIterator
ITuple
from which you can
extract the data and metadata for next entry.
Note: An ITupleIterator
s will generally return the same
ITuple
reference on on each invocation of this method. The caller
is responsible for copying out any data or metadata of interest before
calling ITupleIterator.next()
again. See TupleFilter
which is aware of
this and can be used to stack filters safely.
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.