|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ID
- The ID type for records that will be indexedREC
- The type of record that will be indexedpublic interface QueryIndexer<ID,REC>
An QueryIndexer
handles creation and retrieval of IdxIndex
es
against an indexable repository. Application code does not normally
operate directly with a QueryIndexer
, but rather utilizes the
corresponding index management methods on a QueryRepository
or
QueryEngine
which delegate index management to their underlying
QueryIndexer
Any IdxIndex
created or retrieved through an instance of this
class are considered 'owned' by that instance and are tied to its
lifecycle.
Method Summary | ||
---|---|---|
void |
clear(boolean dropIndexes)
Removes all indexed entries, optionally preserving the index definitions. |
|
void |
close()
Shut down the QueryIndexer . |
|
void |
commit(long commitSequenceNumber)
Commits all indexeing operations since the last call to commit(long) . |
|
|
createIndex(IdxField<REC,T> field,
boolean unique,
String name)
Adds an index to this QueryIndexer . |
|
void |
delete()
If the index is persistent, deletes the index. |
|
|
dropIndex(IdxField<REC,T> field)
Drops a previously created index. |
|
boolean |
dropIndex(String indexName)
Drops a previously created index for this. |
|
|
getIndex(IdxField<REC,T> field)
Retrieve an existing IdxIndex . |
|
List<IdxIndex<?,ID>> |
getIndexes()
Retrieve all IdxIndex es. |
|
String |
getIndexProperty(String name)
Gets a stored property value. |
|
|
getIndexStats(IdxField<REC,T> field)
Gets Index statistics for an index. |
|
long |
getLiveCommitSequenceNumber()
Retrieved the last (highest) successfully committed sequence number. |
|
|
getNonUniqueIndex(IdxField<REC,T> field)
Retrieve an existing IdxNonUniqueIndex . |
|
int |
getSize()
Return the size of the indexed data set. |
|
|
getUniqueIndex(IdxField<REC,T> field)
Retrieve an existing IdxUniqueIndex . |
|
boolean |
isLiveCommitSequenceNumber(long commitSequence)
Indicates whether this commit sequence number represents a live commit sequence number. |
|
void |
open()
Opens an QueryIndexer . |
|
void |
put(REC record)
Indexes an object. |
|
void |
remove(REC record)
Remove all index entries for this object. |
|
void |
rename(String newName)
Renames the QueryIndexer . |
|
void |
rollback()
Discard any current indexing. |
|
void |
setIndexProperty(String name,
String value)
Stores a name/value pair for the indexer. |
|
void |
update(REC before,
REC after)
Updates indexes by removing indexed values for an old record and adding values for a new record. |
|
|
updateField(REC record,
IdxField<REC,T> field,
T oldVal,
T newVal)
Updates indexes for a single field and it subfields by removing indexed values for the old field value and adding indexes for the new field value. |
Method Detail |
---|
void setIndexProperty(String name, String value)
name
- The property namevalue
- The property valueString getIndexProperty(String name)
name
- The property namelong getLiveCommitSequenceNumber()
QueryRepository
to indicate which records have already been indexed.
Any index owned by this QueryIndexer
's IdxIndex
are considered to
be 'live' if all of the records up to this sequence number have been indexed for
that index. An index that is not live is one that has been added after initial
indexing has been done. Such indexes trigger a re-index operation to catch them
up to the live sequence number.
The live sequence number does not necessarily indicate that the index is up to
date with respect to all of the records in the QueryRepository
being indexed.
It is possible that the repositories indexer has records beyond this sequence number
that still need indexing.
boolean isLiveCommitSequenceNumber(long commitSequence)
commitSequence
- the commitSequenceNumber to test.void open() throws Exception
QueryIndexer
.
Exception
- If there is an error opening the QueryIndexer
.void close() throws Exception
QueryIndexer
. Any indexes returned by the index manager are no
longer valid for use.
Exception
- If there is an error closing the QueryIndexer
.void rename(String newName) throws QueryException
QueryIndexer
. The name of an indexer is used to
to create its persistent files. After calling this method all indexes owned by
this QueryIndexer
are invalid, and must be refetched.
newName
- The new name of the QueryIndexer
QueryException
IdxIndex
owned by this QueryIndexer
void delete() throws QueryException, IllegalStateException
QueryException
- If there is an error deleting the index.
IllegalStateException
- if the indexer is open.void rollback()
void commit(long commitSequenceNumber)
commit(long)
.
commitSequenceNumber
- A monotonically increasing commit sequence number.<T> IdxIndex<T,ID> createIndex(IdxField<REC,T> field, boolean unique, String name) throws QueryException
QueryIndexer
. 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 name
will be the name of the field as returned by IdxField.getName()
If this QueryIndexer
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 QueryIndexer
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 QueryIndexer
isn't open an exception is thrown.
Upon addition of a new index, the caller must reindex existing records prior to
committing any new records. The next call to commit with a sequence number greater
than or equal to the last commit sequence number returned by getLiveCommitSequenceNumber()
will have the effect of marking the newly created index as being indexed up until that
point so it is critical that all existing records be reindexed before such a call is made.
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 index.<T> boolean dropIndex(IdxField<REC,T> field) throws QueryException
IdxIndex
may no longer be used.
field
- the field for which the index should be dropped.
QueryException
- If there is an error dropping the index.boolean dropIndex(String indexName) throws QueryException
IdxIndex
may no longer be used.
indexName
- the name of the index to drop.
QueryException
- If there is an error dropping the index.<T> IdxIndex<T,ID> getIndex(IdxField<REC,T> field)
IdxIndex
.
field
- IdxField
the field for which the index should be retrieved.
<T> IdxUniqueIndex<T,ID> getUniqueIndex(IdxField<REC,T> field)
IdxUniqueIndex
.
field
- IdxField
the field for which the index should be retrieved.
<T> IdxNonUniqueIndex<T,ID> getNonUniqueIndex(IdxField<REC,T> field)
IdxNonUniqueIndex
.
field
- IdxField
the field for which the index should be retrieved.
List<IdxIndex<?,ID>> getIndexes()
IdxIndex
es.
IdxIndex
es.<T> IdxIndex.Stats<T> getIndexStats(IdxField<REC,T> field)
field
- The field for which to retrieve index statistics.
void put(REC record)
record
- The record to be indexed.void update(REC before, REC after)
before
- The record containing the last indexed values. If null
this method behaves just like put(Object)
after
- The record containing the new values to index<T> void updateField(REC record, IdxField<REC,T> field, T oldVal, T newVal)
record
- The record containing the fieldfield
- The fieldoldVal
- The old valuenewVal
- The new valuevoid remove(REC record)
record
- The record for index entries should be removed.void clear(boolean dropIndexes)
dropIndexes
- If false all indexes will be dropped along with their contents
if true, then all the enties in the indexes will be dropped, but the index definitions
will remain.int getSize()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |