public void addDerivedResults(IndexInfo indexInfo, SelectResults[] srs) { addDerivedResults(indexInfo, srs[0]); // Nested / range index is not supported at this time due to the way we cross the results // This solution would have duplicates. The problem is the way we doNestedIteration. The map // would // have all values be associated with the current nested level object which is not what the // values would represent // IndexProtocol index = indexInfo._index; // String[] definitions = index.getCanonicalizedIteratorDefinitions(); // for (int i = 0 ; i < definitions.length; i++) { // String key = QueryUtils.getCompiledIdFromPath(indexInfo._path).getId() + ":" + // definitions[i]; // if (derivedResults.containsKey(key)) { // derivedResults.get(key).addAll(srs[i]); // } // else { // derivedResults.put(key, srs[i]); // } // } // // int indexToIterateOn = QueryUtils.figureOutWhichStructIndexToExtract(index); // newDerivatives.add(new Object[]{getCompiledIdFromPath(indexInfo._path).getId(), // srs[indexToIterateOn]}); // successfulOps.add(currentOp); }
private void createDerivedJoinResultsFromOpsList(String theCallingIndexId, ExecutionContext context, List opsList) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { Iterator iter = opsList.iterator(); while (iter.hasNext()) { CompiledValue cv = (CompiledValue) iter.next(); this.currentOp = cv; if (cv.getType() == CompiledValue.COMPARISON) { createDerivedJoinResultsFromCC(theCallingIndexId, (CompiledComparison) cv, context); } } // Now let's derive from our derivatives (for multiple join clauses that can be chained, such as // a.id = 1 and a.id = b.id and b.id = c.id List<Object[]> newDerivatives = new ArrayList<Object[]>(this.newDerivatives); this.newDerivatives.clear(); if (newDerivatives.size() > 0) { Iterator<Object[]> iterator = newDerivatives.iterator(); while (iterator.hasNext()) { Object[] idDerivedAndResults = iterator.next(); derivedDerivative(idDerivedAndResults, context, this.getExpansionList()); } } }
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); } }
private void createDerivedJoinResultsFromCC(String theCallingIndexReceiverId, CompiledComparison cc, ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { if (isCompiledPath(cc._right) && matchingPathIds(theCallingIndexReceiverId, cc._left)) { evaluateDerivedJoin(context, cc._right, new CompiledLiteral(cc._left.evaluate(context)), cc.getOperator()); } else if (isCompiledPath(cc._left) && matchingPathIds(theCallingIndexReceiverId, cc._right)) { evaluateDerivedJoin(context, cc._left, new CompiledLiteral(cc._right.evaluate(context)), cc.getOperator()); } }
DerivedInfo derivedInfo = null; if (IndexManager.JOIN_OPTIMIZATION) { derivedInfo = new DerivedInfo(); derivedInfo.setExpansionList(expansionList); derivedInfo.computeDerivedJoinResults(theFilteringIndex, context, iterOps);
public void computeDerivedJoinResults(IndexInfo theCallingIndex, ExecutionContext context, CompiledValue iterOps) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { // Call this computeDerivedResults() // We are looking for join conditions so we can filter eval instead of iterate eval // Then we can apply the rest of the ops on the results if (theCallingIndex != null && iterOps != null) { if (iterOps instanceof CompiledJunction) { List opsList = ((CompiledJunction) iterOps).getOperands(); this.setOriginalOps(opsList); createDerivedJoinResultsFromOpsList( (QueryUtils.getCompiledIdFromPath(theCallingIndex._path)).getId(), context, opsList); } else if (iterOps.getType() == CompiledValue.COMPARISON) { createDerivedJoinResultsFromCC( (QueryUtils.getCompiledIdFromPath(theCallingIndex._path)).getId(), (CompiledComparison) iterOps, context); } } }
private void evaluateDerivedJoin(ExecutionContext context, CompiledValue newLeftSide, CompiledValue newRightSide, int operator) throws TypeMismatchException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException { CompiledComparison dcc = createDerivedJoin(context, newLeftSide, newRightSide, operator); IndexInfo[] indexInfos = (IndexInfo[]) dcc.getIndexInfo(context); try { if (indexInfos != null && isValidIndexTypeToDerive(indexInfos[0]._getIndex())) { populateDerivedResultsFromDerivedJoin(context, dcc, indexInfos[0]); } } finally { if (indexInfos != null) { Index index = (Index) indexInfos[0]._index; Index prIndex = ((AbstractIndex) index).getPRIndex(); if (prIndex != null) { ((PartitionedIndex) prIndex).releaseIndexReadLockForRemove(); } else { ((AbstractIndex) index).releaseIndexReadLockForRemove(); } } } }
this.addDerivedResults(dcc.getIndexInfo(context)[0], sr);