public class MutableKeyBuffer extends AbstractKeyBuffer
| Modifier and Type | Field and Description |
|---|---|
byte[][] |
keys
An array containing the keys.
|
int |
nkeys
The #of defined keys.
|
| Constructor and Description |
|---|
MutableKeyBuffer(int capacity)
Allocate a mutable key buffer capable of storing capacity keys.
|
MutableKeyBuffer(int nkeys,
byte[][] keys)
Constructor wraps an existing byte[][].
|
MutableKeyBuffer(int capacity,
IRaba src)
Builds a mutable key buffer.
|
MutableKeyBuffer(MutableKeyBuffer src)
Creates a new instance using a new array of keys but sharing the key
references with the provided
MutableKeyBuffer. |
| Modifier and Type | Method and Description |
|---|---|
protected int |
_binarySearch(int searchKeyOffset,
byte[] searchKey)
Binary search.
|
protected int |
_linearSearch(int searchKeyOffset,
byte[] searchKey)
Linear search.
|
protected int |
_prefixMatchLength(int prefixLength,
byte[] searchKey)
Test the search key against the leading prefix shared by all bytes in the
key buffer.
|
int |
add(byte[] key)
Append a byte[] value to the end of the logical byte[][] (optional
operation).
|
int |
add(byte[] key,
int off,
int len)
Append a byte[] value to the end of the logical byte[][] (optional
operation).
|
int |
add(DataInput in,
int len)
Append a byte[] value to the end of the logical byte[][] (optional
operation).
|
void |
assertKeysMonotonic()
Verifies that the keys are in sort order and that undefined keys are
[null].
|
int |
capacity()
The maximum #of keys that may be held in the buffer (its capacity).
|
int |
copy(int index,
OutputStream out)
Copy the value at the specified index onto the output stream.
|
byte[] |
get(int index)
Returns a reference to the key at that index.
|
byte[] |
getPrefix()
Computes the #of leading bytes shared by all keys and returns a new
byte[] containing those bytes.
|
int |
getPrefixLength()
Computes the length of the prefix by computed by counting the #of leading
bytes that match for the first and last key in the buffer.
|
int |
insert(int index,
byte[] key)
Insert a key into the buffer at the specified index, incrementing the #of
keys in the buffer by one and moving down all keys from that index on
down by one (towards the end of the array).
|
boolean |
isEmpty()
True iff the logical byte[][] is empty.
|
boolean |
isFull()
True iff the key buffer can not contain another key.
|
boolean |
isKeys()
Instances are searchable and do not allow
nulls. |
boolean |
isNull(int index)
Return
true iff the byte[] at that index is
null. |
boolean |
isReadOnly()
Mutable.
|
int |
length(int index)
The length of the byte[] at that index.
|
int |
remove(int index)
Remove a key in the buffer at the specified index, decrementing the #of
keys in the buffer by one and moving up all keys from that index on down
by one (towards the start of the array).
|
int |
search(byte[] searchKey)
Search for the given searchKey in the key buffer (optional
operation).
|
void |
set(int index,
byte[] key)
Set the key at the specified index.
|
int |
size()
The #of entries in the logical byte[][].
|
String |
toString() |
iteratorpublic int nkeys
public final byte[][] keys
public MutableKeyBuffer(int capacity)
capacity - The capacity of the key buffer.public MutableKeyBuffer(int nkeys,
byte[][] keys)
nkeys - The #of defined keys in the array.keys - The array of keys.public MutableKeyBuffer(MutableKeyBuffer src)
MutableKeyBuffer.src - An existing instance.public MutableKeyBuffer(int capacity,
IRaba src)
capacity - The capacity of the new instance (this is based on the
branching factor for the B+Tree).src - The source data.IllegalArgumentException - if the capacity is LT the IRaba.size() of the
src.IllegalArgumentException - if the source is null.public final byte[] get(int index)
index - The index in [0:IRaba.size()-1].null if a
null value was stored at that index.public final int length(int index)
IRabaindex - The index in [0:IRaba.size()-1].public final int copy(int index,
OutputStream out)
IRabaByteArrayBuffer so that the same backing
byte[] can be overwritten by each visited key.index - The index in [0:IRaba.size()-1].public final boolean isNull(int index)
IRabatrue iff the byte[] at that index is
null. If IRaba.isKeys() would return
true then this method MUST return false since
nulls are not permitted for B+Tree keys.index - The index in [0:IRaba.size()-1].public final boolean isEmpty()
IRabapublic final int size()
IRabapublic final int capacity()
public final boolean isFull()
public final boolean isReadOnly()
public final boolean isKeys()
nulls.true if the IRaba represents B+Tree keys and
false if it represents B+Tree values.public final void set(int index,
byte[] key)
index - The index in [0:nkeys-1].key - The key (non-null).public final int add(byte[] key)
IRabakey - A value.public final int add(byte[] key,
int off,
int len)
IRabakey - A valueoff - The offset of the first byte to be copied.len - The #of bytes to be copied.public int add(DataInput in, int len) throws IOException
IRabain - The input stream from which the byte[] will be read.len - The #of bytes to be read.IOExceptionpublic final int insert(int index,
byte[] key)
index - The index in [0:nkeys] (you are allowed to append using this
method).key - The key.public final int remove(int index)
index - The index in [0:nkeys-1].key - The key.public final int search(byte[] searchKey)
IRaba
entryIndex = -entryIndex - 1or just
entryIndex = -entryIndexif you are looking for the first key after the searchKey.
searchKey - The search key.(-(insertion point) - 1). The insertion point is
defined as the point at which the key would be inserted. Note
that this guarantees that the return value will be >= 0 if and
only if the key is found.protected final int _prefixMatchLength(int prefixLength,
byte[] searchKey)
AbstractKeyBuffer_prefixMatchLength in class AbstractKeyBufferprefixLength - The length of the prefix shared by all keys in the buffer.searchKey - The search key.protected final int _linearSearch(int searchKeyOffset,
byte[] searchKey)
AbstractKeyBuffer_linearSearch in class AbstractKeyBufferprotected final int _binarySearch(int searchKeyOffset,
byte[] searchKey)
AbstractKeyBuffer_binarySearch in class AbstractKeyBufferpublic final void assertKeysMonotonic()
public int getPrefixLength()
getPrefixLength in class AbstractKeyBufferpublic byte[] getPrefix()
getPrefix in class AbstractKeyBufferCopyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.