|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface QueryRepository<ID,REC>
A QueryRepository
is an indexable store of Object
s that can be queried by a QueryEngine
.
Its 3 main purpose are:
QueryEngine
that map object attributes to their unique keys.
A QueryEngine
uses a QueryRepository
's IdxIndex
es to assist in
execution of queries. Users can proactively add indexes to this QueryRepository
or it can be left to the discretion of the QueryEngine
or the QueryRepository
implementation itself.
A QueryRepository
is responsible for keeping its indexes in sync with the objects it contains.
Any operation performed on an IdxIndex
in the repository must be representative of
all values in the repository at the time the IdxIndex
is accessed.
However, it is possible that from the time an IdxIndex
returns results to the time the index
entries are used to access records in the repository that the corresponding values have
changed. To allow access to multiple indexes and object retrieval while the repository is in a
consistent state the acquireWriteLock()
method may be called.
Method Summary | ||
---|---|---|
void |
acquireWriteLock()
Lock the QueryRepository from being updated. |
|
void |
close()
Close the repository and its associated indexes. |
|
|
createIndex(IdxField<REC,T> field,
boolean unique)
Adds an index to this repository. |
|
|
createIndex(IdxField<REC,T> field,
boolean unique,
String name)
Adds an index to this QueryRepository . |
|
boolean |
dropIndex(IdxField<REC,?> field)
Drops a previously created index for this QueryRepository . |
|
boolean |
dropIndex(String indexName)
Drops a previously created index for this QueryRepository . |
|
void |
flushIndexing()
Waits for indexing to complete. |
|
|
getIndex(IdxField<REC,T> field)
Gets a IdxIndex for the given Class 's field if an index exists, or null
no index exists. |
|
List<IdxIndex<?,ID>> |
getIndexes()
Retrieve a list of the names of all indexes managed by this repository. |
|
String |
getName()
|
|
|
getNonUniqueIndex(IdxField<REC,T> field)
Gets a IdxNonUniqueIndex for the given Class 's field if such an index exists, or null
no index exists. |
|
|
getUniqueIndex(IdxField<REC,T> field)
Gets a IdxUniqueIndex for the given Class 's corresponding field if such an index exists,
or null no index exists. |
|
void |
open()
Opens this repository and its associate index. |
|
void |
releaseWriteLock()
Releases a QueryRepository s write lock. |
|
REC |
retrieve(ID key)
Retrieves a record for the repository. |
|
Iterable<REC> |
retrieve(Iterable<ID> keys)
Returns an Iterable of all values in the QueryRepository for the given
keys. |
|
Iterable<REC> |
retrieveAll()
Returns an iterable set of all values in the QueryRepository . |
Method Detail |
---|
String getName()
void open() throws Exception
Exception
- If there is an error opening the log.void close() throws Exception
Exception
- If there is an error closing the repository.<T> IdxIndex<T,ID> createIndex(IdxField<REC,T> field, boolean unique) throws QueryException
Object
in this repository.
This is equivalent to calling createIndex(IdxField, boolean, String)
with
a name
that is null
field
- The IdxField
to index.unique
- Whether or not the index is guaranteed to be unique.
QueryException
<T> IdxIndex<T,ID> createIndex(IdxField<REC,T> field, boolean unique, String name) throws QueryException
QueryRepository
. An index must be declared as
either unique or non-unique. This decision determines whether the particular
field is unique across all Object
in this repository.
If the name provided is null or empty then the name of the index
will be the name of the field as returned by IdxField.getName()
If this QueryRepository
already has the index then this operation will not have any effect
unless the existing index has a name different from this field's name in which
case it will result in the index being renamed.
If this QueryRepository
already has an index with this name, but corresponding to a different
field then the existing index will be dropped and replaced by this index.
If this QueryRepository
isn't open an exception is thrown.
field
- The IdxField
to index.unique
- Whether or not the index is guaranteed to be unique.name
- A name for the index. If null the name of the field will be used.
QueryException
- If there is an error creating the indexboolean dropIndex(IdxField<REC,?> field) throws QueryException
QueryRepository
. If there
is no such index this method simply does nothing.
If this QueryRepository
isn't open an exception is thrown.
field
- The IdxField
to stop indexing.
QueryException
- If there is an error dropping the indexboolean dropIndex(String indexName) throws QueryException
QueryRepository
. If there
is no such index this method simply does nothing.
If this QueryRepository
isn't open an exception is thrown.
indexName
- The name of the index to drop
QueryException
- If there is an error dropping the indexList<IdxIndex<?,ID>> getIndexes()
If this QueryRepository
isn't open an exception is thrown.
Set
of index names for the QueryRepository
<T> IdxIndex<T,ID> getIndex(IdxField<REC,T> field) throws QueryException
IdxIndex
for the given Class
's field if an index exists, or null
no index exists.
field
- The IdxField
for which to retrieve the index.
QueryException
<T> IdxUniqueIndex<T,ID> getUniqueIndex(IdxField<REC,T> field) throws QueryException
IdxUniqueIndex
for the given Class
's corresponding field if such an index exists,
or null
no index exists.
field
- The IdxField
for which to retrieve the index.
QueryException
<T> IdxNonUniqueIndex<T,ID> getNonUniqueIndex(IdxField<REC,T> field) throws QueryException
IdxNonUniqueIndex
for the given Class
's field if such an index exists, or null
no index exists.
field
- The IdxField
for which to retrieve the index.
QueryException
REC retrieve(ID key) throws QueryException
key
- The unique key that identifies the record.
QueryException
- if there is an error fetching the result.Iterable<REC> retrieveAll() throws QueryException
QueryRepository
.
QueryRepository
.
QueryException
- if there is an error preparing the resultsIterable<REC> retrieve(Iterable<ID> keys) throws QueryException
Iterable
of all values in the QueryRepository
for the given
keys. If a particular key can not be found then the returned Iterable
should omit the value without complaint.
This returned Iterable
does not need to prefetch these values and may instead fetch
them lazily.
keys
- The keys for the values to be retrieved.
QueryException
- if there is an error preparing the resultsvoid acquireWriteLock()
QueryRepository
from being updated. This allows a QueryEngine
to
perform operations against multiple indexes against the QueryRepository
while it
is in a consistent state.
void releaseWriteLock()
QueryRepository
s write lock.
void flushIndexing() throws QueryException
QueryException
- if there is an error waiting for indexing to complete.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |