public abstract class AbstractRaba extends Object implements IRaba
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
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[][].
|
Modifier and Type | Method and Description |
---|---|
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)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isKeys, isReadOnly
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
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[][].public final int size()
IRaba
public final boolean isEmpty()
IRaba
public final boolean isFull()
IRaba
public final int capacity()
IRaba
protected final boolean rangeCheck(int index) throws IndexOutOfBoundsException
IndexOutOfBoundsException
public final byte[] get(int index)
IRaba
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 boolean isNull(int index)
IRaba
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].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 Iterator<byte[]> iterator()
IRaba
null
, then the iterator will report a null
for
that element.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 null
s to be
stored.public void set(int index, byte[] key)
IRaba
set
in interface IRaba
index
- The index in [0:IRaba.size()
-1].key
- The byte[] value.public int add(byte[] key)
IRaba
public int add(byte[] key, int off, int len)
IRaba
public int add(DataInput in, int len) throws IOException
IRaba
add
in interface IRaba
in
- The input stream from which the byte[] will be read.len
- The #of bytes to be read.IOException
public int search(byte[] searchKey)
IRaba
entryIndex = -entryIndex - 1or just
entryIndex = -entryIndexif you are looking for the first key after the 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.public 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.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.