public class MutableValueBuffer extends Object implements IRaba
HTree
bucket page using a
backing byte[][]
. Unlike the values in a B+Tree, the
HTree
values need not be dense. Further, each bucket page is
logically divided into a set of buddy hash buckets. All operations therefore
take place within a buddy bucket. The buddy bucket is identified by its
offset and its extent is identified by the global depth of the bucket page.
Note: Because the slots are divided logically among the buddy buckets any
slot may have a non-null
value and the IRaba
methods as
implemented by this class DO NOT range check the index against
size()
.
MutableKeyBuffer
in this package.Modifier and Type | Field and Description |
---|---|
int |
nvalues
The #of defined values across the entire bucket page.
|
byte[][] |
values
An array containing the values.
|
Constructor and Description |
---|
MutableValueBuffer(int capacity)
Allocate a mutable value buffer capable of storing capacity
values.
|
MutableValueBuffer(int nvalues,
byte[][] values)
Constructor wraps an existing byte[][].
|
MutableValueBuffer(int capacity,
IRaba src)
Builds a mutable value buffer.
|
MutableValueBuffer(MutableValueBuffer src)
Creates a new instance using a new array of values but sharing the value
references with the provided
MutableValueBuffer . |
Modifier and Type | Method and Description |
---|---|
int |
add(byte[] value)
This method is not supported.
|
int |
add(byte[] value,
int off,
int len)
This method is not supported.
|
int |
add(DataInput in,
int len)
This method is not supported.
|
int |
capacity()
The capacity of the logical byte[][].
|
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 value at that index.
|
void |
insert(int index,
byte[] value) |
boolean |
isEmpty()
True iff the logical byte[][] is empty.
|
boolean |
isFull()
True iff the logical byte[][] is full.
|
boolean |
isKeys()
Instances are NOT searchable.
|
boolean |
isNull(int index)
Return
true iff the byte[] at that index is
null . |
boolean |
isReadOnly()
Mutable.
|
Iterator<byte[]> |
iterator()
Iterator visits the byte[] elements in the view order.
|
int |
length(int index)
The length of the byte[] at that index.
|
int |
remove(int index)
Remove a value in the buffer at the specified index, decrementing the #of
value in the buffer by one.
|
int |
search(byte[] searchKey)
This method is not supported.
|
void |
set(int index,
byte[] value)
Set the byte[] value at the specified index (optional operation).
|
int |
size()
The #of entries in the logical byte[][].
|
String |
toString() |
public int nvalues
public final byte[][] values
2^addressBits
.public MutableValueBuffer(int capacity)
capacity
- The capacity of the value buffer.public MutableValueBuffer(int nvalues, byte[][] values)
nvalues
- The #of defined values in the array.values
- The array of values.public MutableValueBuffer(MutableValueBuffer src)
MutableValueBuffer
.src
- An existing instance.public MutableValueBuffer(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)
get
in interface IRaba
index
- The index in [0:IRaba.size()
-1].null
if a
null
value was stored at that index.public final int length(int index)
IRaba
length
in interface IRaba
index
- The index in [0:IRaba.size()
-1].public final int copy(int index, OutputStream out)
IRaba
ByteArrayBuffer
so that the same backing
byte[] can be overwritten by each visited key.copy
in interface IRaba
index
- The index in [0:IRaba.size()
-1].public final boolean isNull(int index)
true
iff the byte[] at that index is
null
. If IRaba.isKeys()
would return
true
then this method MUST return false
since
null
s are not permitted for B+Tree keys.isNull
in interface IRaba
index
- The index in [0:IRaba.size()
-1].true
iff the value at that index is null
.public final boolean isEmpty()
IRaba
public final int size()
Note: This is the #of values in the bucket page (across all buddy buckets on that page). Unless there is only one buddy bucket on the page, you MUST explicitly scan a buddy bucket to determine the #of values in a buddy bucket on the page.
public final int capacity()
IRaba
public final boolean isFull()
IRaba
public final boolean isReadOnly()
isReadOnly
in interface IRaba
public final boolean isKeys()
null
s ARE
permitted.public Iterator<byte[]> iterator()
null
, then the iterator will report a null
for
that element.
This iterator visits all values on the bucket page, including
null
s.
public final void set(int index, byte[] value)
IRaba
set
in interface IRaba
index
- The index in [0:IRaba.size()
-1].value
- The byte[] value.public final void insert(int index, byte[] value)
public final int remove(int index)
index
- The index in [0:capacity()
-1].public final int add(byte[] value)
set(int, byte[])
.add
in interface IRaba
value
- A value.UnsupportedOperationException
public final int add(byte[] value, int off, int len)
set(int, byte[])
.add
in interface IRaba
value
- A valueoff
- The offset of the first byte to be copied.len
- The #of bytes to be copied.UnsupportedOperationException
public int add(DataInput in, int len) throws IOException
set(int, byte[])
.add
in interface IRaba
in
- The input stream from which the byte[] will be read.len
- The #of bytes to be read.UnsupportedOperationException
IOException
public int search(byte[] searchKey)
search
in interface IRaba
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.UnsupportedOperationException
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.