Search in sources :

Example 6 with IndexData

use of org.apache.geode.cache.query.internal.index.IndexData in project geode by apache.

the class QueryUtils method getAvailableIndexIfAny.

private static IndexData getAvailableIndexIfAny(CompiledValue cv, ExecutionContext context, boolean usePrimaryIndex) throws AmbiguousNameException, TypeMismatchException, NameResolutionException {
    Set set = new HashSet();
    context.computeUltimateDependencies(cv, set);
    if (set.size() != 1)
        return null;
    RuntimeIterator rIter = (RuntimeIterator) set.iterator().next();
    String regionPath = null;
    // collection is not a Region
    if (rIter.getScopeID() != context.currentScope().getScopeID() || /* context.getScopeCount() */
    (regionPath = context.getRegionPathForIndependentRuntimeIterator(rIter)) == null) {
        return null;
    }
    // The independent iterator is added as the first element
    List groupRuntimeItrs = context.getCurrScopeDpndntItrsBasedOnSingleIndpndntItr(rIter);
    String[] definitions = new String[groupRuntimeItrs.size()];
    Iterator iterator = groupRuntimeItrs.iterator();
    int i = 0;
    while (iterator.hasNext()) {
        RuntimeIterator rIterator = (RuntimeIterator) iterator.next();
        definitions[i++] = rIterator.getDefinition();
    }
    IndexData indexData = IndexUtils.findIndex(regionPath, definitions, cv, "*", context.getCache(), usePrimaryIndex, context);
    if (indexData != null) {
        if (logger.isDebugEnabled()) {
            logger.debug("Indexed expression for indexed data : {}  for region : {}", indexData.getIndex().getCanonicalizedIndexedExpression(), regionPath);
        }
    }
    return indexData;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) IndexData(org.apache.geode.cache.query.internal.index.IndexData) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Aggregations

IndexData (org.apache.geode.cache.query.internal.index.IndexData)6 IndexProtocol (org.apache.geode.cache.query.internal.index.IndexProtocol)4 Iterator (java.util.Iterator)2 List (java.util.List)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ListIterator (java.util.ListIterator)1 Set (java.util.Set)1 Index (org.apache.geode.cache.query.Index)1 QueryService (org.apache.geode.cache.query.QueryService)1 AbstractIndex (org.apache.geode.cache.query.internal.index.AbstractIndex)1 PartitionedIndex (org.apache.geode.cache.query.internal.index.PartitionedIndex)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 Test (org.junit.Test)1