|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.btree.raba.AbstractRaba
public abstract class AbstractRaba
Abstract base class implements mutation operators and search. A concrete subclass need only indicate if it is mutable, searchable, or allows nulls by overriding the appropriate methods.
| Field Summary | |
|---|---|
protected byte[][] |
a
The backing array. |
protected int |
capacity
The maximum #of elements in the view of the backing array. |
protected int |
fromIndex
The inclusive lower bound of the view. |
protected int |
toIndex
The exclusive upper bound of the view. |
| Constructor Summary | |
|---|---|
AbstractRaba(byte[][] a)
Create a view of a byte[][]. |
|
AbstractRaba(int fromIndex,
int toIndex,
int capacity,
byte[][] a)
Create a view from a slice of a byte[][]. |
|
| 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()
|
protected void |
assertNotReadOnly()
|
protected void |
assertNullAllowed(byte[] a)
|
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 |
isNull(int index)
Return true iff the byte[] at that index is
null. |
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)
|
AbstractRaba |
resize(int n)
Resize the buffer, copying up to n references to the existing data into a new view backed by a new byte[][]. |
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()
|
static String |
toString(IRaba raba)
If IRaba.isKeys() is true then represents the
elements as unsigned byte[]s. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.bigdata.btree.raba.IRaba |
|---|
isKeys, isReadOnly |
| Field Detail |
|---|
protected final int fromIndex
protected int toIndex
Note: This field is NOT final since it is modified by a subclass which permits mutation.
protected final int capacity
protected final byte[][] a
| Constructor Detail |
|---|
public AbstractRaba(byte[][] a)
a - The backing byte[][].
public AbstractRaba(int fromIndex,
int toIndex,
int capacity,
byte[][] a)
fromIndex - The index of the first element in the byte[][] which is
visible in the view (inclusive lower bound).toIndex - The index of the first element in the byte[][] beyond the view
(exclusive upper bound).capacity - The #of elements which may be used in the view.a - The backing byte[][].| Method Detail |
|---|
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 assertNotReadOnly()
UnsupportedOperationException - if the view is read-only.protected void assertNotFull()
IllegalStateException - unless there is room to store another value.protected void assertNullAllowed(byte[] a)
a - A byte[] to be inserted or set on the IRaba.
IllegalArgumentException - if the byte[] is null and the
implementation does not permit nulls to be
stored.
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 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 Objectpublic static String toString(IRaba raba)
IRaba.isKeys() is true then represents the
elements as unsigned byte[]s. Otherwise represents the
elements as signed byte[]s.
public AbstractRaba resize(int n)
fromIndex will be
zero in the new view.
This method requires a public constructor with the following signature:
ctor(byte[][])
n - The size of the new buffer.
IllegalArgumentException - if n is negative.
RuntimeException - if the AbstractRaba instance does not declare an
appropriate ctor.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||