use of org.apache.geode.cache.query.internal.RuntimeIterator in project geode by apache.
the class CompactRangeIndex method verifyInnerAndOuterEntryValues.
/**
* This evaluates the left and right side of a EQUI-JOIN where condition for which this Index was
* used. Like, if condition is "p.ID = e.ID", {@link IndexInfo} will contain Left as p.ID, Right
* as e.ID and operator as TOK_EQ. This method will evaluate p.ID OR e.ID based on if it is inner
* or outer RegionEntry, and verify the p.ID = e.ID.
*
* This method is called only for Memory indexstore
*
* @return true if entry value and index value are consistent.
*/
protected boolean verifyInnerAndOuterEntryValues(IndexStoreEntry entry, ExecutionContext context, IndexInfo indexInfo, Object keyVal) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException {
// Verify index key in value only for memory index store
CompactRangeIndex index = (CompactRangeIndex) indexInfo._getIndex();
RuntimeIterator runtimeItr = index.getRuntimeIteratorForThisIndex(context, indexInfo);
if (runtimeItr != null) {
runtimeItr.setCurrent(((MemoryIndexStoreEntry) entry).getDeserializedValue());
}
return evaluateEntry(indexInfo, context, keyVal);
}
use of org.apache.geode.cache.query.internal.RuntimeIterator in project geode by apache.
the class AbstractIndex method getAllDependentRuntimeIterators.
/**
* Take all independent iterators from context and remove the one which matches for this Index's
* independent iterator. Then get all Dependent iterators from given context for this Index's
* independent iterator.
*
* @param context from executing query.
* @return List of all iterators pertaining to this Index.
*/
private List getAllDependentRuntimeIterators(ExecutionContext context) {
List<RuntimeIterator> indItrs = context.getCurrScopeDpndntItrsBasedOnSingleIndpndntItr(getRuntimeIteratorForThisIndex(context));
List<String> definitions = Arrays.asList(this.getCanonicalizedIteratorDefinitions());
// These are the common iterators between query from clause and index from clause.
List itrs = new ArrayList();
for (RuntimeIterator itr : indItrs) {
if (definitions.contains(itr.getDefinition())) {
itrs.add(itr);
}
}
return itrs;
}
use of org.apache.geode.cache.query.internal.RuntimeIterator in project geode by apache.
the class AbstractIndex method getRuntimeIteratorForThisIndex.
/**
* Similar to {@link #getRuntimeIteratorForThisIndex(ExecutionContext)} except that this one also
* matches the iterator name if present with alias used in the {@link IndexInfo}
*
* @return {@link RuntimeIterator}
*/
RuntimeIterator getRuntimeIteratorForThisIndex(ExecutionContext context, IndexInfo info) {
List<RuntimeIterator> indItrs = context.getCurrentIterators();
Region rgn = this.getRegion();
if (rgn instanceof BucketRegion) {
rgn = ((Bucket) rgn).getPartitionedRegion();
}
String regionPath = rgn.getFullPath();
String definition = this.getCanonicalizedIteratorDefinitions()[0];
for (RuntimeIterator itr : indItrs) {
if (itr.getDefinition().equals(regionPath) || itr.getDefinition().equals(definition)) {
// if iterator has name alias must be used in the query
if (itr.getName() != null) {
CompiledValue path = info._path();
// match the iterator name with alias
String pathName = getReceiverNameFromPath(path);
if (path.getType() == OQLLexerTokenTypes.Identifier || itr.getName().equals(pathName)) {
return itr;
}
} else {
return itr;
}
}
}
return null;
}
use of org.apache.geode.cache.query.internal.RuntimeIterator in project geode by apache.
the class AbstractIndex method evaluateLastColl.
private List evaluateLastColl(Object value, ExecutionContext context, List itrs, int level) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException {
// A tuple is a value generated from RegionEntry value which could be a StructType (Multiple
// Dependent Iterators) or ObjectType (Single Iterator) value.
List tuples = new ArrayList(1);
RuntimeIterator currItrator = (RuntimeIterator) itrs.get(level);
currItrator.setCurrent(value);
// If its last iterator then just evaluate final struct.
if (itrs.size() - 1 == level) {
if (itrs.size() > 1) {
Object[] tuple = new Object[itrs.size()];
for (int i = 0; i < itrs.size(); i++) {
RuntimeIterator iter = (RuntimeIterator) itrs.get(i);
tuple[i] = iter.evaluate(context);
}
// Its ok to pass type as null as we are only interested in values.
tuples.add(new StructImpl(new StructTypeImpl(), tuple));
} else {
tuples.add(currItrator.evaluate(context));
}
} else {
// Not the last iterator.
RuntimeIterator nextItr = (RuntimeIterator) itrs.get(level + 1);
Collection nextLevelValues = nextItr.evaluateCollection(context);
// If value is null or INVALID then the evaluated collection would be Null.
if (nextLevelValues != null) {
for (Object nextLevelValue : nextLevelValues) {
tuples.addAll(evaluateLastColl(nextLevelValue, context, itrs, level + 1));
}
}
}
return tuples;
}
use of org.apache.geode.cache.query.internal.RuntimeIterator in project geode by apache.
the class AbstractIndex method getRuntimeIteratorForThisIndex.
/**
* Matches the Collection reference in given context for this index's from-clause in all current
* independent collection references associated to the context. For example, if a join Query has
* "/region1 p, region2 e" from clause context contains two region references for p and e and
* Index could be used for any of those of both of those regions.
*
* Note: This Index contains its own from clause definition which corresponds to a region
* collection reference in given context and must be contained at 0th index in
* {@link AbstractIndex#canonicalizedDefinitions}.
*
* @return {@link RuntimeIterator} this should not be null ever.
*/
RuntimeIterator getRuntimeIteratorForThisIndex(ExecutionContext context) {
List<RuntimeIterator> indItrs = context.getCurrentIterators();
Region rgn = this.getRegion();
if (rgn instanceof BucketRegion) {
rgn = ((Bucket) rgn).getPartitionedRegion();
}
String regionPath = rgn.getFullPath();
String definition = this.getCanonicalizedIteratorDefinitions()[0];
for (RuntimeIterator itr : indItrs) {
if (itr.getDefinition().equals(regionPath) || itr.getDefinition().equals(definition)) {
return itr;
}
}
return null;
}
Aggregations