net.obsearch.index.bucket.impl
Class AbstractBucketContainerShort<O extends OBShort,B extends BucketObjectShort>

java.lang.Object
  extended by net.obsearch.index.bucket.impl.AbstractBucketContainerShort<O,B>
All Implemented Interfaces:
BucketContainer<O,B,OBQueryShort<O>>
Direct Known Subclasses:
BucketContainerShort

public abstract class AbstractBucketContainerShort<O extends OBShort,B extends BucketObjectShort>
extends Object
implements BucketContainer<O,B,OBQueryShort<O>>

AbstractBucketContainerShort Holds the functionality of a bucket that sorts its smap-vectors lexicographically. Binary searches are employed inside the vector.

Author:
Arnoldo Jose Muller Molina

Field Summary
protected  byte[] key
          Iterate only through this key.
 
Constructor Summary
AbstractBucketContainerShort(Index<O> index, int pivots, OBStore<TupleBytes> storage, byte[] key)
          Build a new container for shorts over the given index, with the given pivot number and a certain storage device where all the smap vectors are stored.
AbstractBucketContainerShort(Index<O> index, int pivots, OBStore<TupleBytes> storage, byte[] key, int secondaryIndexPivot)
          Build a new container for shorts over the given index, with the given pivot number and a certain storage device where all the smap vectors are stored.
 
Method Summary
 OperationStatus delete(B bucket, O object)
          Deletes the given object from this BucketContainer.
 OperationStatus exists(B bucket, O object)
          Returns true if the object and its bucket definition exist in this container
 List<B> getObjects()
          Return the object list!
 int getPivots()
          # of pivots for this container.
 OperationStatus insert(B bucket, O object)
          Insert the given bucket into the container.
 OperationStatus insertBulk(B bucket, O object)
          Insert the given bucket into the container.
protected abstract  B instantiateBucketObject()
          Instantiate a new Bucket ready to process each record.
 boolean isModified()
          Return true if the bucket has been modified since it was instantiated.
 void search(AbstractOBQuery<O> q, B bucket, Filter<O> filter, Statistics stats)
          Same as BucketContainer.search(AbstractOBQuery, BucketObject, Filter, Statistics) but it forces the query AbstractOBQuery into the correct type.
 void search(OBQueryShort<O> query, B b, ByteBuffer data, Filter<O> filter, Statistics stats)
          Match the given query and bucket but only for one record found in b.
 void search(OBQueryShort<O> query, B b, Filter<O> filter, byte[] key1, byte[] key2, Statistics stats)
          Convenience method that forces the search to be performed on a certain key set.
 void search(OBQueryShort<O> query, B b, Filter<O> filter, Statistics stats)
          Searches the data by using a binary search to reduce SMAP vector computations.
 byte[] serialize()
          Serialize the bucket
 void setKey(byte[] key)
          Sets the key (bucket id) of a bucket container
 void setPivots(int pivots)
          Sets the # of pivots for this container.
 int size()
          Return the # of S-Map vectors in the bucket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

key

protected byte[] key
Iterate only through this key.

Constructor Detail

AbstractBucketContainerShort

public AbstractBucketContainerShort(Index<O> index,
                                    int pivots,
                                    OBStore<TupleBytes> storage,
                                    byte[] key)
Build a new container for shorts over the given index, with the given pivot number and a certain storage device where all the smap vectors are stored. Key is used as the base key for this bucket.

Parameters:
index - Underlying index.
pivots - Number of pivots employed
storage - Storage device where the smap vectors are stored.
key - Base key of this container

AbstractBucketContainerShort

public AbstractBucketContainerShort(Index<O> index,
                                    int pivots,
                                    OBStore<TupleBytes> storage,
                                    byte[] key,
                                    int secondaryIndexPivot)
Build a new container for shorts over the given index, with the given pivot number and a certain storage device where all the smap vectors are stored. Key is used as the base key for this bucket. The parameter secondaryIndexPivot chooses a dimension of the s-map vector to sort the vectors by this value. This helps in prunning a bit the buckets.

Parameters:
index - Underlying index.
pivots - Number of pivots employed
storage - Storage device where the smap vectors are stored.
key - Base key of this container
secondaryIndexPivot - Sort records by this dimension.
Method Detail

getObjects

public List<B> getObjects()
Return the object list!

Specified by:
getObjects in interface BucketContainer<O extends OBShort,B extends BucketObjectShort,OBQueryShort<O extends OBShort>>
Returns:

instantiateBucketObject

protected abstract B instantiateBucketObject()
Instantiate a new Bucket ready to process each record.


setPivots

public void setPivots(int pivots)
Description copied from interface: BucketContainer
Sets the # of pivots for this container.

Specified by:
setPivots in interface BucketContainer<O extends OBShort,B extends BucketObjectShort,OBQueryShort<O extends OBShort>>

delete

public OperationStatus delete(B bucket,
                              O object)
                       throws OBException,
                              IllegalIdException,
                              IllegalAccessException,
                              InstantiationException
Description copied from interface: BucketContainer
Deletes the given object from this BucketContainer.

Specified by:
delete in interface BucketContainer<O extends OBShort,B extends BucketObjectShort,OBQueryShort<O extends OBShort>>
Parameters:
bucket - This will should match this bucket's id. Used to pass additional information such as the SMAP vector
object - The object that will be deleted.
Returns:
Status.OK and the deleted object's id if the object was found and successfully deleted. Status.NOT_EXISTS if the object is not in the database.
Throws:
OBException
IllegalIdException
IllegalAccessException
InstantiationException

insert

public OperationStatus insert(B bucket,
                              O object)
                       throws OBException,
                              IllegalIdException,
                              IllegalAccessException,
                              InstantiationException
Insert the given bucket into the container.

Specified by:
insert in interface BucketContainer<O extends OBShort,B extends BucketObjectShort,OBQueryShort<O extends OBShort>>
Parameters:
bucket - Bucket to insert.
object - the bucket has an object.
Returns:
The result of the operation.
Throws:
OBException
IllegalIdException
IllegalAccessException
InstantiationException

insertBulk

public OperationStatus insertBulk(B bucket,
                                  O object)
                           throws OBException,
                                  IllegalIdException,
                                  IllegalAccessException,
                                  InstantiationException
Insert the given bucket into the container.

Specified by:
insertBulk in interface BucketContainer<O extends OBShort,B extends BucketObjectShort,OBQueryShort<O extends OBShort>>
Parameters:
bucket - Bucket to insert.
object - the bucket has an object.
Returns:
The result of the operation.
Throws:
OBException
IllegalIdException
IllegalAccessException
InstantiationException

exists

public OperationStatus exists(B bucket,
                              O object)
                       throws OBException,
                              IllegalIdException,
                              IllegalAccessException,
                              InstantiationException
Description copied from interface: BucketContainer
Returns true if the object and its bucket definition exist in this container

Specified by:
exists in interface BucketContainer<O extends OBShort,B extends BucketObjectShort,OBQueryShort<O extends OBShort>>
Parameters:
bucket - The bucket associated to object
object - The object that will be inserted
Returns:
true if object exists in this container.
Throws:
OBException
IllegalIdException
IllegalAccessException
InstantiationException

search

public void search(OBQueryShort<O> query,
                   B b,
                   ByteBuffer data,
                   Filter<O> filter,
                   Statistics stats)
            throws IllegalAccessException,
                   OBException,
                   InstantiationException,
                   IllegalIdException
Description copied from interface: BucketContainer
Match the given query and bucket but only for one record found in b.

Specified by:
search in interface BucketContainer<O extends OBShort,B extends BucketObjectShort,OBQueryShort<O extends OBShort>>
Parameters:
query - The search parameters (range, priority queue with the closest elements)
b - The bucket of the given object.
filter - Filter to be employed.
Throws:
IllegalAccessException
OBException
InstantiationException
IllegalIdException

search

public void search(AbstractOBQuery<O> q,
                   B bucket,
                   Filter<O> filter,
                   Statistics stats)
            throws IllegalAccessException,
                   OBException,
                   InstantiationException,
                   IllegalIdException
Description copied from interface: BucketContainer
Same as BucketContainer.search(AbstractOBQuery, BucketObject, Filter, Statistics) but it forces the query AbstractOBQuery into the correct type.

Specified by:
search in interface BucketContainer<O extends OBShort,B extends BucketObjectShort,OBQueryShort<O extends OBShort>>
Throws:
IllegalAccessException
OBException
IllegalIdException
InstantiationException

search

public void search(OBQueryShort<O> query,
                   B b,
                   Filter<O> filter,
                   Statistics stats)
            throws IllegalAccessException,
                   OBException,
                   InstantiationException,
                   IllegalIdException
Searches the data by using a binary search to reduce SMAP vector computations. Does not cache objects and creates less objects during the search than searchSorted(...).

Specified by:
search in interface BucketContainer<O extends OBShort,B extends BucketObjectShort,OBQueryShort<O extends OBShort>>
Parameters:
query -
b -
filter - Filter to be employed.
Throws:
IllegalAccessException
DatabaseException
OBException
InstantiationException
IllegalIdException

search

public void search(OBQueryShort<O> query,
                   B b,
                   Filter<O> filter,
                   byte[] key1,
                   byte[] key2,
                   Statistics stats)
            throws IllegalAccessException,
                   OBException,
                   InstantiationException,
                   IllegalIdException
Convenience method that forces the search to be performed on a certain key set.

Throws:
IllegalAccessException
OBException
InstantiationException
IllegalIdException

getPivots

public int getPivots()
Description copied from interface: BucketContainer
# of pivots for this container.

Specified by:
getPivots in interface BucketContainer<O extends OBShort,B extends BucketObjectShort,OBQueryShort<O extends OBShort>>
Returns:

size

public int size()
         throws OBException
Return the # of S-Map vectors in the bucket.

Specified by:
size in interface BucketContainer<O extends OBShort,B extends BucketObjectShort,OBQueryShort<O extends OBShort>>
Returns:
The # of objects in this container.
Throws:
OBException

setKey

public void setKey(byte[] key)
Description copied from interface: BucketContainer
Sets the key (bucket id) of a bucket container

Specified by:
setKey in interface BucketContainer<O extends OBShort,B extends BucketObjectShort,OBQueryShort<O extends OBShort>>

serialize

public byte[] serialize()
Description copied from interface: BucketContainer
Serialize the bucket

Specified by:
serialize in interface BucketContainer<O extends OBShort,B extends BucketObjectShort,OBQueryShort<O extends OBShort>>

isModified

public boolean isModified()
Description copied from interface: BucketContainer
Return true if the bucket has been modified since it was instantiated.

Specified by:
isModified in interface BucketContainer<O extends OBShort,B extends BucketObjectShort,OBQueryShort<O extends OBShort>>
Returns:
true if the bucket has been modified since it was instantiated.


Copyright © 2007-2011 Arnoldo Jose Muller Molina. All Rights Reserved.