SPT Object Database API

com.sptci.prevayler
Interface AbstractDatabase<P extends PrevalentObject>

All Superinterfaces:
Serializable
All Known Subinterfaces:
Database<P>, DatabaseSystem
All Known Implementing Classes:
ConstraintSystem, IndexSystem, ObjectGraphSystem, PrevalentManager, PrevalentSystem, SearchSystem, StorageSystem

public interface AbstractDatabase<P extends PrevalentObject>
extends Serializable

A base interface that defines the public interface exposed by the database system. This interface defines the common non-transactional features supported by the system.

© Copyright 2008 Sans Pareil Technologies, Inc.

Version:
$Id: AbstractDatabase.java 22 2008-11-24 19:04:25Z sptrakesh $
Author:
Rakesh 2008-11-23

Method Summary
 int count(Class cls)
          Return the total number of instances of the specified type in the prevalent system.
 Collection<P> fetch(Class cls, long start, long end)
          Fetch the prevalent objects in the specified range of data.
 P fetch(Class cls, Object oid)
          Retrieve the prevalent object of type with object id.
 Collection<P> fetch(Class cls, String field, Object object)
          Fetch the prevalent object(s) of the specified cls type which has the specified object as the value of the specified field.
 Collection<P> fetchIntersection(Class cls, Map<String,?> parameters)
          Fetch the prevalent object(s) of the specified cls type which has the specified indexed field values.
 Collection<P> fetchUnion(Class cls, Map<String,?> parameters)
          Fetch the prevalent object(s) of the specified cls type which has the specified indexed field values.
 Collection<P> search(org.apache.lucene.search.Query query, org.apache.lucene.search.Filter filter, int count, org.apache.lucene.search.Sort sort)
          Execute the specified lucene query and return the collection of matching prevalent objects.
 

Method Detail

count

int count(Class cls)
          throws PrevalentException
Return the total number of instances of the specified type in the prevalent system.

Parameters:
cls - The type of the prevalent object whose count is desired.
Returns:
The total number of prevalent objects of the specified type.
Throws:
PrevalentException - If errors are encountered while interacting with the prevalent system.

fetch

P fetch(Class cls,
        Object oid)
                                throws PrevalentException
Retrieve the prevalent object of type with object id.

Parameters:
cls - The type of the prevalent object.
oid - The object id for the prevalent object to retrieve.
Returns:
The prevalent object instance. Returns null if no such object is stored in the prevalent system.
Throws:
PrevalentException - If errors are encountered while reconstituting the prevalent object.

fetch

Collection<P> fetch(Class cls,
                    long start,
                    long end)
                                            throws PrevalentException
Fetch the prevalent objects in the specified range of data. This method supports display of paginated view of the prevalent objects of the type specified. Note that the objects are returned in insertion order.

Parameters:
cls - The type of prevalent object to retrive.
start - The starting index (inclusive) from which to fetch the prevalent objects.
end - The ending index (exclusive) to which to fetch the prevalent objects.
Returns:
The collection of prevalent objects. Returns an empty collection if there are no objects in the specified range.
Throws:
PrevalentException - If errors are encountered while fetching the objects.
See Also:
PrimaryStorage.get( long, long )

fetch

Collection<P> fetch(Class cls,
                    String field,
                    Object object)
                                            throws PrevalentException
Fetch the prevalent object(s) of the specified cls type which has the specified object as the value of the specified field.

Note: Only indexed fields are searched. If the specified field is not indexed, this method returns an empty collection.

Parameters:
cls - The type of prevalent object to query for.
field - The name of the field in the prevalent object using which the results are to be queried.
object - The value of the field.
Returns:
The collection of prevalent objects who have the specified object in the field specified. Returns an empty collection if no results are found.
Throws:
PrevalentException - If errors are encountered while reconstituting the prevalent objects being returned.

fetchUnion

Collection<P> fetchUnion(Class cls,
                         Map<String,?> parameters)
                                                 throws PrevalentException
Fetch the prevalent object(s) of the specified cls type which has the specified indexed field values. The results contain a union of the matching objects.

Note: Only indexed fields are searched. If the specified field(s) are not indexed, this method ignores those field(s).

Parameters:
cls - The type of prevalent object to query for.
parameters - The map of parameters to use to filter the prevalent instances.
Returns:
The collection of prevalent objects that matches the specified parameters.
Throws:
PrevalentException - If errors are encountered while reconstituting the prevalent objects being returned.
See Also:
fetch( Class, String, Object )

fetchIntersection

Collection<P> fetchIntersection(Class cls,
                                Map<String,?> parameters)
                                                        throws PrevalentException
Fetch the prevalent object(s) of the specified cls type which has the specified indexed field values. The results contain an intersection of the matching objects.

Note: Only indexed fields are searched. If the specified field(s) are not indexed, this method ignores those field(s).

Parameters:
cls - The type of prevalent object to query for.
parameters - The map of parameters to use to filter the prevalent instances.
Returns:
The collection of prevalent objects that matches the specified parameters.
Throws:
PrevalentException - If errors are encountered while reconstituting the prevalent objects being returned.
See Also:
fetch( Class, String, Object )

search

Collection<P> search(org.apache.lucene.search.Query query,
                     org.apache.lucene.search.Filter filter,
                     int count,
                     org.apache.lucene.search.Sort sort)
                                             throws PrevalentException
Execute the specified lucene query and return the collection of matching prevalent objects.

Notes:

Parameters:
query - The lucene query that is to be executed to find matching prevalent object instances.
filter - The filter to apply to restrict the query results.
count - The maximum number to top hits for the search to return.
sort - The sort criteria to use for the results.
Returns:
The collection of matching instances or an empty collection.
Throws:
PrevalentException - If errors are encountered while reconstituting the prevalent objects being returned.

SPT Object Database API