|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.btree.raba.MutableValueBuffer
public class MutableValueBuffer
A flyweight mutable implementation exposing the backing byte[][], permitting
nulls and not supporting search. It is assumed that caller
maintains a dense byte[][] in the sense that all entries in [0:nvalues] are
defined, even if some of entries are null. The implementation is NOT
thread-safe for mutation.
| Field Summary | |
|---|---|
int |
nvalues
The #of entries with valid data. |
byte[][] |
values
The backing array. |
| Constructor Summary | |
|---|---|
MutableValueBuffer(int nvalues)
Create a new, empty byte[][] of the specified capacity. |
|
MutableValueBuffer(int nvalues,
byte[][] values)
Create a view of a byte[][]. |
|
MutableValueBuffer(int capacity,
IRaba src)
Builds a mutable value buffer. |
|
| Method Summary | |
|---|---|
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). |
protected void |
assertNotFull()
|
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)
Return the byte[] at the specified index. |
boolean |
isEmpty()
True iff the logical byte[][] is empty. |
boolean |
isFull()
True iff the logical byte[][] is full. |
boolean |
isKeys()
For B+Tree values. |
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. |
protected boolean |
rangeCheck(int index)
|
int |
search(byte[] searchKey)
Search for the given searchKey in the key buffer (optional operation). |
void |
set(int index,
byte[] key)
Set the byte[] value at the specified index (optional operation). |
int |
size()
The #of entries in the logical byte[][]. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public int nvalues
public final byte[][] values
| Constructor Detail |
|---|
public MutableValueBuffer(int nvalues)
nvalues - The capacity of the byte[][].
public MutableValueBuffer(int nvalues,
byte[][] values)
nvalues - The #of entries in the array with valid data.values - The backing byte[][].
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.| Method Detail |
|---|
public final boolean isReadOnly()
isReadOnly in interface IRabapublic final boolean isKeys()
isKeys in interface IRabatrue if the IRaba represents B+Tree keys and
false if it represents B+Tree values.public final int size()
IRaba
size in interface IRabapublic final boolean isEmpty()
IRaba
isEmpty in interface IRabapublic final boolean isFull()
IRaba
isFull in interface IRabapublic final int capacity()
IRaba
capacity in interface IRaba
protected final boolean rangeCheck(int index)
throws IndexOutOfBoundsException
IndexOutOfBoundsExceptionpublic final byte[] get(int index)
IRaba
get in interface IRabaindex - 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 IRabaindex - 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.
isNull in interface 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.
copy in interface IRabaindex - The index in [0:IRaba.size()-1].
public final Iterator<byte[]> iterator()
IRabanull, then the iterator will report a null for
that element.
iterator in interface IRabaiterator in interface Iterable<byte[]>protected void assertNotFull()
IllegalStateException - unless there is room to store another value.
public void set(int index,
byte[] key)
IRaba
set in interface IRabaindex - The index in [0:IRaba.size()-1].key - The byte[] value.public int add(byte[] key)
IRaba
add in interface IRabakey - A value.
public int add(byte[] key,
int off,
int len)
IRaba
add in interface 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
IRaba
add in interface IRabain - The input stream from which the byte[] will be read.len - The #of bytes to be read.
IOExceptionpublic final int search(byte[] searchKey)
IRaba
entryIndex = -entryIndex - 1or just
entryIndex = -entryIndexif you are looking for the first key after the searchKey.
search in interface IRabasearchKey - 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.public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||