org.opends.server.backends.jeb
Class SortValuesSet

java.lang.Object
  extended by org.opends.server.backends.jeb.SortValuesSet

public class SortValuesSet
extends java.lang.Object

This class representsa partial sorted set of sorted entries in a VLV index.


Constructor Summary
SortValuesSet(byte[] keyBytes, byte[] dataBytes, VLVIndex vlvIndex)
          Construct a sort values set from the database.
SortValuesSet(VLVIndex vlvIndex)
          Construct an empty sort values set with the given information.
 
Method Summary
 boolean add(long entryID, AttributeValue[] values)
          Add the given entryID and values from this VLV idnex.
static long[] getEncodedIDs(byte[] bytes, int offset)
          Get the IDs from the provided encoded set.
static int getEncodedSize(byte[] bytes, int offset)
          Get the size of the provided encoded set.
 long[] getEntryIDs()
          Retrieve the entry IDs in this set.
 byte[] getKeyBytes()
          Returns the key to use for this set of sort values in the database.
 SortValues getKeySortValues()
          Returns the key to use for this set of sort values in the database.
 SortValues getSortValues(int index)
          Returns the sort values at the index in this set.
 byte[] getValue(int index)
          Retrieve an attribute value from this values set.
 boolean remove(long entryID, AttributeValue[] values)
          Remove the given entryID and values from this VLV idnex.
 int size()
          Retrieve the size of this set.
 SortValuesSet split(int splitLength)
          Split portions of this set into another set.
 byte[] toDatabase()
          Encode this set to its database format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortValuesSet

public SortValuesSet(VLVIndex vlvIndex)
Construct an empty sort values set with the given information.

Parameters:
vlvIndex - The VLV index using this set.

SortValuesSet

public SortValuesSet(byte[] keyBytes,
                     byte[] dataBytes,
                     VLVIndex vlvIndex)
Construct a sort values set from the database.

Parameters:
keyBytes - The database key used to locate this set.
dataBytes - The bytes to decode and construct this set.
vlvIndex - The VLV index using this set.
Method Detail

add

public boolean add(long entryID,
                   AttributeValue[] values)
            throws JebException,
                   com.sleepycat.je.DatabaseException,
                   DirectoryException
Add the given entryID and values from this VLV idnex.

Parameters:
entryID - The entry ID to add.
values - The values to add.
Returns:
True if the information was successfully added or False otherwise.
Throws:
DirectoryException - If a Directory Server error occurs.
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.
JebException - If an error occurs in the JE database.

remove

public boolean remove(long entryID,
                      AttributeValue[] values)
               throws JebException,
                      com.sleepycat.je.DatabaseException,
                      DirectoryException
Remove the given entryID and values from this VLV idnex.

Parameters:
entryID - The entry ID to remove.
values - The values to remove.
Returns:
True if the information was successfully removed or False otherwise.
Throws:
DirectoryException - If a Directory Server error occurs.
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.
JebException - If an error occurs in the JE database.

split

public SortValuesSet split(int splitLength)
Split portions of this set into another set. The values of the new set is from the end of this set.

Parameters:
splitLength - The size of the new set.
Returns:
The split set.

toDatabase

public byte[] toDatabase()
Encode this set to its database format.

Returns:
The encoded bytes representing this set or null if this set is empty.

getEncodedSize

public static int getEncodedSize(byte[] bytes,
                                 int offset)
Get the size of the provided encoded set.

Parameters:
bytes - The encoded bytes of a SortValuesSet to decode the size from.
offset - The byte offset to start decoding.
Returns:
The size of the provided encoded set.

getEncodedIDs

public static long[] getEncodedIDs(byte[] bytes,
                                   int offset)
Get the IDs from the provided encoded set.

Parameters:
bytes - The encoded bytes of a SortValuesSet to decode the IDs from.
offset - The byte offset to start decoding.
Returns:
The decoded IDs in the provided encoded set.

size

public int size()
Retrieve the size of this set.

Returns:
The size of this set.

getEntryIDs

public long[] getEntryIDs()
Retrieve the entry IDs in this set.

Returns:
The entry IDs in this set.

getKeyBytes

public byte[] getKeyBytes()
                   throws JebException,
                          com.sleepycat.je.DatabaseException,
                          DirectoryException
Returns the key to use for this set of sort values in the database.

Returns:
The key as an array of bytes that should be used for this set in the database or NULL if this set is empty.
Throws:
DirectoryException - If a Directory Server error occurs.
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.
JebException - If an error occurs in the JE database.

getKeySortValues

public SortValues getKeySortValues()
                            throws JebException,
                                   com.sleepycat.je.DatabaseException,
                                   DirectoryException
Returns the key to use for this set of sort values in the database.

Returns:
The key as a sort values object that should be used for this set in the database or NULL if this set is empty or unbounded.
Throws:
DirectoryException - If a Directory Server error occurs.
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.
JebException - If an error occurs in the JE database.

getSortValues

public SortValues getSortValues(int index)
                         throws JebException,
                                com.sleepycat.je.DatabaseException,
                                DirectoryException
Returns the sort values at the index in this set.

Parameters:
index - The index of the sort values to get.
Returns:
The sort values object at the specified index.
Throws:
DirectoryException - If a Directory Server error occurs.
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.
JebException - If an error occurs in the JE database.

getValue

public byte[] getValue(int index)
                throws JebException,
                       com.sleepycat.je.DatabaseException,
                       DirectoryException
Retrieve an attribute value from this values set. The index is the absolute index. (ie. for a sort on 3 attributes per entry, an vlvIndex of 6 will be the 1st attribute value of the 3rd entry).

Parameters:
index - The vlvIndex of the attribute value to retrieve.
Returns:
The byte array representation of the attribute value.
Throws:
DirectoryException - If a Directory Server error occurs.
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.
JebException - If an error occurs in the JE database.