com.bigdata.btree.raba
Class EmptyRaba

java.lang.Object
  extended by com.bigdata.btree.raba.EmptyRaba
All Implemented Interfaces:
IRaba, Externalizable, Serializable, Iterable<byte[]>
Direct Known Subclasses:
EmptyRaba.EmptyKeysRaba, EmptyRaba.EmptyValuesRaba

public abstract class EmptyRaba
extends Object
implements IRaba, Externalizable

An immutable, empty IRaba.

Version:
$Id: EmptyRaba.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
See Also:
Serialized Form

Nested Class Summary
static class EmptyRaba.EmptyKeysRaba
          An empty, immutable B+Tree keys IRaba.
static class EmptyRaba.EmptyValuesRaba
          An empty, immutable B+Tree values IRaba.
 
Field Summary
static IRaba KEYS
          An empty, immutable B+Tree keys IRaba instance.
static IRaba VALUES
          An empty, immutable B+Tree values IRaba instance.
 
Constructor Summary
EmptyRaba()
          De-serialization ctor.
 
Method Summary
 int add(byte[] a)
          Append a byte[] value to the end of the logical byte[][] (optional operation).
 int add(byte[] value, 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).
 int capacity()
          The capacity of the logical byte[][].
 int copy(int index, OutputStream os)
          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.
 boolean isReadOnly()
          Return true if this implementation is read-only.
 Iterator<byte[]> iterator()
          Iterator visits the byte[] elements in the view order.
 int length(int index)
          The length of the byte[] at that index.
 void readExternal(ObjectInput in)
           
 int search(byte[] searchKey)
          Search for the given searchKey in the key buffer (optional operation).
 void set(int index, byte[] a)
          Set the byte[] value at the specified index (optional operation).
 int size()
          The #of entries in the logical byte[][].
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.bigdata.btree.raba.IRaba
isKeys
 

Field Detail

KEYS

public static transient IRaba KEYS
An empty, immutable B+Tree keys IRaba instance.


VALUES

public static transient IRaba VALUES
An empty, immutable B+Tree values IRaba instance.

Constructor Detail

EmptyRaba

public EmptyRaba()
De-serialization ctor.

Method Detail

capacity

public final int capacity()
Description copied from interface: IRaba
The capacity of the logical byte[][].

Specified by:
capacity in interface IRaba

isEmpty

public final boolean isEmpty()
Description copied from interface: IRaba
True iff the logical byte[][] is empty.

Specified by:
isEmpty in interface IRaba

isFull

public final boolean isFull()
Description copied from interface: IRaba
True iff the logical byte[][] is full.

Specified by:
isFull in interface IRaba

size

public final int size()
Description copied from interface: IRaba
The #of entries in the logical byte[][].

Specified by:
size in interface IRaba

isReadOnly

public final boolean isReadOnly()
Description copied from interface: IRaba
Return true if this implementation is read-only.

Specified by:
isReadOnly in interface IRaba

isNull

public final boolean isNull(int index)
Description copied from interface: IRaba
Return true 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.

Specified by:
isNull in interface IRaba
Parameters:
index - The index in [0:IRaba.size()-1].

length

public final int length(int index)
Description copied from interface: IRaba
The length of the byte[] at that index.

Specified by:
length in interface IRaba
Parameters:
index - The index in [0:IRaba.size()-1].
Returns:
The length of the byte[] at that index.

get

public final byte[] get(int index)
Description copied from interface: IRaba
Return the byte[] at the specified index. For greater efficiency, implementations MAY return a reference to an internal the byte[].

Specified by:
get in interface IRaba
Parameters:
index - The index in [0:IRaba.size()-1].
Returns:
The byte[] value at that index and null if a null value was stored at that index.

copy

public final int copy(int index,
                      OutputStream os)
Description copied from interface: IRaba
Copy the value at the specified index onto the output stream. This is often used with an ByteArrayBuffer so that the same backing byte[] can be overwritten by each visited key.

Specified by:
copy in interface IRaba
Parameters:
index - The index in [0:IRaba.size()-1].
Returns:
The #of bytes copied.

iterator

public final Iterator<byte[]> iterator()
Description copied from interface: IRaba
Iterator visits the byte[] elements in the view order. If an element is null, then the iterator will report a null for that element.

Specified by:
iterator in interface IRaba
Specified by:
iterator in interface Iterable<byte[]>

search

public final int search(byte[] searchKey)
Description copied from interface: IRaba
Search for the given searchKey in the key buffer (optional operation). Whether or not search is supported depends on whether the logical byte[][] is ordered. However, the efficiency of search, where supported, depends on the implementation. Some implementations support binary search of the coded byte[] values. Others may require a mixture of binary and linear search, etc.

 entryIndex = -entryIndex - 1
 
or just
 entryIndex = -entryIndex
 
if you are looking for the first key after the searchKey.

Specified by:
search in interface IRaba
Parameters:
searchKey - The search key.
Returns:
index of the search key, if it is found; otherwise, (-(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.

set

public final void set(int index,
                      byte[] a)
Description copied from interface: IRaba
Set the byte[] value at the specified index (optional operation).

Specified by:
set in interface IRaba
Parameters:
index - The index in [0:IRaba.size()-1].
a - The byte[] value.

add

public final int add(byte[] a)
Description copied from interface: IRaba
Append a byte[] value to the end of the logical byte[][] (optional operation).

Specified by:
add in interface IRaba
Parameters:
a - A value.
Returns:
The #of values in the logical byte[][] (postcondition).

add

public final int add(byte[] value,
                     int off,
                     int len)
Description copied from interface: IRaba
Append a byte[] value to the end of the logical byte[][] (optional operation).

Specified by:
add in interface IRaba
Parameters:
value - A value
off - The offset of the first byte to be copied.
len - The #of bytes to be copied.
Returns:
The #of values in the logical byte[][] (postcondition).

add

public final int add(DataInput in,
                     int len)
              throws IOException
Description copied from interface: IRaba
Append a byte[] value to the end of the logical byte[][] (optional operation).

Specified by:
add in interface IRaba
Parameters:
in - The input stream from which the byte[] will be read.
len - The #of bytes to be read.
Returns:
The #of values in the logical byte[][] (postcondition).
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.