public class Indexes extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Indexes.Builder
Builder which is used to create a new Indexes object.
|
Modifier and Type | Field and Description |
---|---|
static int |
SKIP_PARTITIONS_COUNT_CHECK
The partitions count check detects a race condition when a
query is executed on the index which is under (re)construction.
|
Modifier and Type | Method and Description |
---|---|
InternalIndex |
addOrGetIndex(String name,
boolean ordered)
Obtains the existing index or creates a new one (if an index doesn't exist
yet) for the given name in this indexes instance.
|
void |
clearAll()
Clears contents of indexes managed by this instance.
|
void |
createIndexesFromRecordedDefinitions()
Creates indexes according to the index definitions stored inside this
indexes.
|
void |
destroyIndexes()
Destroys and then removes all the indexes from this indexes instance.
|
InternalIndex[] |
getCompositeIndexes()
Returns all the composite indexes known to this indexes instance.
|
TypeConverter |
getConverter(String attribute) |
InternalIndex |
getIndex(String name) |
Collection<IndexInfo> |
getIndexDefinitions() |
InternalIndex[] |
getIndexes()
Returns all the indexes known to this indexes instance.
|
IndexesStats |
getIndexesStats()
Returns the indexes stats of this indexes instance.
|
boolean |
haveAtLeastOneIndex()
Returns
true if this indexes instance contains at least one index,
false otherwise. |
boolean |
haveAtLeastOneIndexOrDefinition()
Returns
true if the indexes instance contains either at least one index or its definition,
false otherwise. |
boolean |
isGlobal() |
static void |
markPartitionAsIndexed(int partitionId,
InternalIndex[] indexes)
Marks the given partition as indexed by the given indexes.
|
static void |
markPartitionAsUnindexed(int partitionId,
InternalIndex[] indexes)
Marks the given partition as unindexed by the given indexes.
|
InternalIndex |
matchIndex(String pattern,
Class<? extends Predicate> predicateClass,
QueryContext.IndexMatchHint matchHint,
int ownedPartitionCount)
Matches an index for the given pattern and match hint that can evaluate
the given predicate class.
|
InternalIndex |
matchIndex(String pattern,
QueryContext.IndexMatchHint matchHint,
int ownedPartitionCount)
Matches an index for the given pattern and match hint.
|
static Indexes.Builder |
newBuilder(SerializationService ss,
IndexCopyBehavior indexCopyBehavior) |
void |
putEntry(QueryableEntry queryableEntry,
Object oldValue,
Index.OperationSource operationSource)
Inserts a new queryable entry into this indexes instance or updates the
existing one.
|
Set<QueryableEntry> |
query(Predicate predicate,
int ownedPartitionCount)
Performs a query on this indexes instance using the given predicate.
|
void |
recordIndexDefinition(String name,
boolean ordered)
Records the given index definition in this indexes without creating an
index.
|
void |
removeEntry(Data key,
Object value,
Index.OperationSource operationSource)
Removes the entry from this indexes instance identified by the given key
and value.
|
public static final int SKIP_PARTITIONS_COUNT_CHECK
public static void markPartitionAsIndexed(int partitionId, InternalIndex[] indexes)
partitionId
- the ID of the partition to mark as indexed.indexes
- the indexes by which the given partition is indexed.public static void markPartitionAsUnindexed(int partitionId, InternalIndex[] indexes)
partitionId
- the ID of the partition to mark as unindexed.indexes
- the indexes by which the given partition is unindexed.public static Indexes.Builder newBuilder(SerializationService ss, IndexCopyBehavior indexCopyBehavior)
ss
- the serializationServiceindexCopyBehavior
- the indexCopyBehaviorIndexCopyBehavior
public InternalIndex addOrGetIndex(String name, boolean ordered)
name
- the name of the index; the passed value might not
represent a canonical index name (as specified by
{@link Index#getName()), in this case the method
canonicalizes it.ordered
- true
if the new index should be ordered, false
otherwise.public void recordIndexDefinition(String name, boolean ordered)
name
- the name of the index; the passed value might not
represent a canonical index name (as specified by
{@link Index#getName()), in this case the method
canonicalizes it.ordered
- true
if the new index should be ordered, false
otherwise.public void createIndexesFromRecordedDefinitions()
public Collection<IndexInfo> getIndexDefinitions()
public InternalIndex[] getIndexes()
public InternalIndex[] getCompositeIndexes()
public void destroyIndexes()
public void clearAll()
public boolean haveAtLeastOneIndex()
true
if this indexes instance contains at least one index,
false
otherwise.public boolean haveAtLeastOneIndexOrDefinition()
true
if the indexes instance contains either at least one index or its definition,
false
otherwise.public void putEntry(QueryableEntry queryableEntry, Object oldValue, Index.OperationSource operationSource)
queryableEntry
- the queryable entry to insert or update.oldValue
- the old entry value to update, null
if
inserting the new entry.operationSource
- the operation source.public void removeEntry(Data key, Object value, Index.OperationSource operationSource)
key
- the key if the entry to remove.value
- the value of the entry to remove.operationSource
- the operation source.public boolean isGlobal()
In case of a partitioned-index, each query has to query the index in each partition separately, which all-together may be around 3 times slower than querying a single global index.
public InternalIndex getIndex(String name)
null
if such index does
not exist. It's a caller's responsibility to canonicalize the passed
index name as specified by Index.getName()
.public Set<QueryableEntry> query(Predicate predicate, int ownedPartitionCount)
predicate
- the predicate to evaluate.ownedPartitionCount
- a count of owned partitions a query runs on.
Negative value indicates that the value is not defined.null
if the query can't be
performed using the indexes known to this indexes instance.public InternalIndex matchIndex(String pattern, QueryContext.IndexMatchHint matchHint, int ownedPartitionCount)
pattern
- the pattern to match an index for. May be either an
attribute name or an exact index name.matchHint
- the match hint.ownedPartitionCount
- a count of owned partitions a query runs on.
Negative value indicates that the value is not defined.null
if nothing matched.QueryContext.IndexMatchHint
,
QueryContext.matchIndex(java.lang.String, com.hazelcast.query.impl.QueryContext.IndexMatchHint)
public InternalIndex matchIndex(String pattern, Class<? extends Predicate> predicateClass, QueryContext.IndexMatchHint matchHint, int ownedPartitionCount)
pattern
- the pattern to match an index for. May be either an
attribute name or an exact index name.predicateClass
- the predicate class the matched index must be
able to evaluate.matchHint
- the match hint.ownedPartitionCount
- a count of owned partitions a query runs on.
Negative value indicates that the value is not defined.null
if nothing matched.QueryContext.IndexMatchHint
,
Index.evaluate(com.hazelcast.query.Predicate)
public TypeConverter getConverter(String attribute)
null
if
a converter is not available. The later may happen if the attribute is
unknown to this indexes instance or there are no populated
indexes involving the given attribute.public IndexesStats getIndexesStats()
Copyright © 2020 Hazelcast, Inc.. All Rights Reserved.