void setCurrent(RuntimeIterator iterator, Object obj) { iterator.setCurrent(obj); }
private void doNestedIterationsForIndexInit(int level, List runtimeIterators) throws TypeMismatchException, AmbiguousNameException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException, IMQException { if (level == 1) { ++this.initEntriesUpdated; } if (level == this.iteratorSize) { applyProjectionForIndexInit(runtimeIterators); } else { RuntimeIterator rIter = (RuntimeIterator) runtimeIterators.get(level); Collection c = rIter.evaluateCollection(this.initContext); if (c == null) return; Iterator cIter = c.iterator(); while (cIter.hasNext()) { rIter.setCurrent(cIter.next()); doNestedIterationsForIndexInit(level + 1, runtimeIterators); } } }
private void doNestedIterationsForIndexInit(int level, List runtimeIterators) throws TypeMismatchException, AmbiguousNameException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException, IMQException { if (level == 1) { ++this.initEntriesUpdated; } if (level == this.iteratorSize) { applyProjectionForIndexInit(runtimeIterators); } else { RuntimeIterator rIter = (RuntimeIterator) runtimeIterators.get(level); // System.out.println("Level = "+level+" Iter = "+rIter.getDef()); Collection c = rIter.evaluateCollection(this.initContext); if (c == null) return; Iterator cIter = c.iterator(); while (cIter.hasNext()) { rIter.setCurrent(cIter.next()); doNestedIterationsForIndexInit(level + 1, runtimeIterators); } } }
public Object evaluateKey(Object object) { Object value = object; ExecutionContext newContext = null; Object key = null; try { if (object instanceof RegionEntry) { RegionEntry regionEntry = (RegionEntry) object; newContext = createExecutionContext(regionEntry); value = getTargetObjectForUpdate(regionEntry); } // context we use is the update context, from IMQEvaluator List iterators = newContext.getCurrentIterators(); RuntimeIterator itr = (RuntimeIterator) iterators.get(0); itr.setCurrent(value); key = this.indexedExpr.evaluate(newContext); } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("Could not reevaluate key for hash index"); } throw new Error("Could not reevaluate key for hash index", e); } if (key == null) { key = IndexManager.NULL; } return key; }
private void doNestedExpansion(int level, ExecutionContext expansionContext, List expandedResults, Object lowerBoundKey, Object upperBoundKey, int lowerBoundOperator, int upperBoundOperator, Object value) throws TypeMismatchException, AmbiguousNameException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException, IMQException { List iterList = expansionContext.getCurrentIterators(); int iteratorSize = iterList.size(); if (level == iteratorSize) { expand(expansionContext, expandedResults, lowerBoundKey, upperBoundKey, lowerBoundOperator, upperBoundOperator, value); } else { RuntimeIterator rIter = (RuntimeIterator) iterList.get(level); Collection c = rIter.evaluateCollection(expansionContext); if (c == null) return; Iterator cIter = c.iterator(); while (cIter.hasNext()) { rIter.setCurrent(cIter.next()); doNestedExpansion(level + 1, expansionContext, expandedResults, lowerBoundKey, upperBoundKey, lowerBoundOperator, upperBoundOperator, value); } } }
/** * @param add true if adding to index, false if removing */ private void doNestedIterations(int level, boolean add, ExecutionContext context) throws TypeMismatchException, AmbiguousNameException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException, IMQException { List iterList = context.getCurrentIterators(); if (level == this.iteratorSize) { applyProjection(add, context); } else { RuntimeIterator rIter = (RuntimeIterator) iterList.get(level); // System.out.println("Level = "+level+" Iter = "+rIter.getDef()); Collection c = rIter.evaluateCollection(context); if (c == null) return; Iterator cIter = c.iterator(); while (cIter.hasNext()) { rIter.setCurrent(cIter.next()); doNestedIterations(level + 1, add, context); } } }
private void derivedDerivative(Object[] idDerivedAndResults, ExecutionContext context, List expansionList) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { String idDerived = (String) idDerivedAndResults[0]; SelectResults results = (SelectResults) idDerivedAndResults[1]; RuntimeIterator ritr = getMatchingRuntimeIterator(idDerived, expansionList); List remainingOps = this.getRemainingOps(); Iterator iterator = results.iterator(); while (iterator.hasNext()) { Object val = iterator.next(); ritr.setCurrent(val); createDerivedJoinResultsFromOpsList(idDerived, context, remainingOps); } }
/** * @param add true if adding to index, false if removing */ private void doNestedIterations(int level, boolean add, ExecutionContext context) throws TypeMismatchException, AmbiguousNameException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException, IMQException { List iterList = context.getCurrentIterators(); if (level == this.iteratorSize) { applyProjection(add, context); } else { RuntimeIterator rIter = (RuntimeIterator) iterList.get(level); // System.out.println("Level = "+level+" Iter = "+rIter.getDef()); Collection c = rIter.evaluateCollection(context); if (c == null) return; Iterator cIter = c.iterator(); while (cIter.hasNext()) { rIter.setCurrent(cIter.next()); doNestedIterations(level + 1, add, context); } } }
private void doNestedIterationsForIndexInit(int level, List runtimeIterators) throws TypeMismatchException, AmbiguousNameException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException, IMQException { if (level == 1) { ++this.initEntriesUpdated; } if (level == this.iteratorSize) { applyProjectionForIndexInit(runtimeIterators); } else { RuntimeIterator rIter = (RuntimeIterator) runtimeIterators.get(level); Collection collection = rIter.evaluateCollection(this.initContext); if (collection == null) { return; } for (Object aCollection : collection) { rIter.setCurrent(aCollection); doNestedIterationsForIndexInit(level + 1, runtimeIterators); } } }
currItrator.setCurrent(value);
@Override public void expansion(List expandedResults, Object lowerBoundKey, Object upperBoundKey, int lowerBoundOperator, int upperBoundOperator, Object value) throws IMQException { try { ExecutionContext expansionContext = createExecutionContext(value); List iterators = expansionContext.getCurrentIterators(); RuntimeIterator iter = (RuntimeIterator) iterators.get(0); iter.setCurrent(value); // first iter level is region entries, we can ignore as we already broke it down in the // index doNestedExpansion(1, expansionContext, expandedResults, lowerBoundKey, upperBoundKey, lowerBoundOperator, upperBoundOperator, value); } catch (Exception e) { throw new IMQException(e); } }
private void doNestedIterations(int level, ExecutionContext context) throws TypeMismatchException, AmbiguousNameException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException, IMQException { List iterList = context.getCurrentIterators(); if (level == this.iteratorSize) { applyProjection(context); } else { RuntimeIterator rIter = (RuntimeIterator) iterList.get(level); Collection collection = rIter.evaluateCollection(context); if (collection == null) { return; } for (Object aCollection : collection) { rIter.setCurrent(aCollection); doNestedIterations(level + 1, context); } } }
indexFieldToItrsMapping[0].setCurrent(value); } else { Struct struct = (Struct) value; rItr = indexFieldToItrsMapping[i]; if (rItr != null) { rItr.setCurrent(fieldValues[i]); if (icdeh.cutDownNeeded) { checkFields[j++] = fieldValues[i];
private SelectResults doIterationEvaluate(ExecutionContext context, boolean evaluateWhereClause) throws TypeMismatchException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException { SelectResults results = prepareEmptyResultSet(context, false); // TODO: SELF : Work on limit implementation on bulk get // check for bulk get optimization if (evaluateWhereClause) { List tmpResults = optimizeBulkGet(context); if (tmpResults != null) { // (has only one iterator) RuntimeIterator rIter = (RuntimeIterator) context.getCurrentIterators().get(0); for (Iterator itr = tmpResults.iterator(); itr.hasNext();) { Object currObj = itr.next(); rIter.setCurrent(currObj); QueryObserver observer = QueryObserverHolder.getInstance(); observer.beforeIterationEvaluation(rIter, currObj); applyProjectionAndAddToResultSet(context, results, this.orderByAttrs == null); } return results; } } int numElementsInResult = 0; try { doNestedIterations(0, results, context, evaluateWhereClause, numElementsInResult); } catch (CompiledSelect.NullIteratorException ignore) { return null; } return results; }
/** * 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. * * @return true if entry value and index value are consistent. */ private boolean verifyInnerAndOuterEntryValues(RegionEntry entry, ExecutionContext context, IndexInfo indexInfo, Object keyVal) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { // Verify index key in value. CompactRangeIndex index = (CompactRangeIndex) indexInfo._getIndex(); RuntimeIterator runtimeItr = index.getRuntimeIteratorForThisIndex(context, indexInfo); if (runtimeItr != null) { runtimeItr.setCurrent(getTargetObject(entry)); } return evaluateEntry(indexInfo, context, keyVal); }
/** * 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); }
((RuntimeIterator) iterators.get(i)).setCurrent(values[i]); while (((this.orderByAttrs != null && !ignoreOrderBy) || limitValue < 0 || (numElementsAdded < limitValue)) && resultsIter.hasNext()) { rIter.setCurrent(resultsIter.next()); int occurrence = applyProjectionAndAddToResultSet(context, pResultSet, ignoreOrderBy); if (occurrence == 1 || (occurrence > 1 && !this.distinct)) {
Object values[] = ((Struct) tuple).getFieldValues(); for (int i = 0; i < values.length; i++) { rIters[i].setCurrent(values[i]); rIters[0].setCurrent(tuple);
runtimeItr.setCurrent(value); runtimeItr.setCurrent(value);
Iterator cIter = coll.iterator(); Object currObj = cIter.next(); rIter.setCurrent(currObj);