FunctionalIndexCreationHelper(String fromClause, String indexedExpression, String projectionAttributes, String imports, InternalCache cache, ExecutionContext externalContext, IndexManager imgr) throws IndexInvalidException { super(fromClause, projectionAttributes, cache); if (externalContext == null) { this.context = new ExecutionContext(null, cache); } else { this.context = externalContext; } this.context.newScope(1); this.imports = imports; prepareFromClause(imgr); prepareIndexExpression(indexedExpression); prepareProjectionAttributes(projectionAttributes); Object[] data = modifyIterDefToSuiteIMQ((CompiledIteratorDef) this.fromClauseIterators.get(0)); if (data[0] == null || data[1] == null) { throw new IndexInvalidException( String.format("Invalid FROM Clause : ' %s '", fromClause)); } this.fromClauseIterators.remove(0); this.fromClauseIterators.add(0, data[1]); this.region = (QRegion) data[0]; }
public PrimaryKeyIndexCreationHelper(String fromClause, String indexedExpression, String projectionAttributes, InternalCache cache, ExecutionContext externalContext, IndexManager imgr) throws IndexInvalidException { super(fromClause, projectionAttributes, cache); if (externalContext == null) { context = new ExecutionContext(null, cache); } else { this.context = externalContext; } context.newScope(1); this.region = imgr.region; prepareFromClause(imgr); prepareIndexExpression(indexedExpression); prepareProjectionAttributes(projectionAttributes); }
/** Creates a new instance of IMQEvaluator */ IMQEvaluator(IndexCreationHelper helper) { this.cache = helper.getCache(); this.fromIterators = helper.getIterators(); this.indexedExpr = helper.getCompiledIndexedExpression(); this.rgn = helper.getRegion(); // The modified iterators for optimizing Index creation this.isFirstItrOnEntry = ((FunctionalIndexCreationHelper) helper).isFirstIteratorRegionEntry; this.isFirstItrOnKey = ((FunctionalIndexCreationHelper) helper).isFirstIteratorRegionKey; this.additionalProj = ((FunctionalIndexCreationHelper) helper).additionalProj; Object[] params1 = {new QRegion(this.rgn, false)}; this.initContext = new ExecutionContext(params1, this.cache); this.canonicalIterNames = ((FunctionalIndexCreationHelper) helper).canonicalizedIteratorNames; if (this.isFirstItrOnEntry) { this.indexInitIterators = this.fromIterators; } else { this.indexInitIterators = ((FunctionalIndexCreationHelper) helper).indexInitIterators; this.modifiedIndexExpr = ((FunctionalIndexCreationHelper) helper).modifiedIndexExpr; this.addnlProjType = ((FunctionalIndexCreationHelper) helper).addnlProjType; } this.iteratorSize = this.indexInitIterators.size(); }
ExecutionContext context = new ExecutionContext(null, CacheUtils.getCache()); final OrderByComparator obc = new OrderByComparator(orderByAttribs, resultType, context); Comparator baseComparator = obc;
private <E> NWayMergeResults<E> createSingleFieldMergedResult( Collection<? extends Collection<E>> sortedResults, boolean isDistinct, int limit) throws Exception { CompiledSortCriterion csc = new CompiledSortCriterion(false, CompiledSortCriterion.ProjectionField.getProjectionField()); Method method = CompiledSortCriterion.class .getDeclaredMethod("substituteExpressionWithProjectionField", Integer.TYPE); method.setAccessible(true); method.invoke(csc, 0); List<CompiledSortCriterion> orderByAttribs = new ArrayList<CompiledSortCriterion>(); orderByAttribs.add(csc); ExecutionContext context = new ExecutionContext(null, null); ObjectType elementType = new ObjectTypeImpl(Object.class); return new NWayMergeResults<E>(sortedResults, isDistinct, limit, orderByAttribs, context, elementType); }
additionalProj = ((FunctionalIndexCreationHelper) helper).additionalProj; Object params1[] = {new QRegion(rgn, false)}; initContext = new ExecutionContext(params1, cache); if (isFirstItrOnEntry) { this.indexInitIterators = this.fromIterators;
private NWayMergeResults<Struct> createStructFieldMergedResult( Collection<? extends Collection<Struct>> sortedResults, boolean isDistinct, int limit, StructTypeImpl structType) throws Exception { CompiledSortCriterion csc1 = new CompiledSortCriterion(false, CompiledSortCriterion.ProjectionField.getProjectionField()); CompiledSortCriterion csc2 = new CompiledSortCriterion(true, CompiledSortCriterion.ProjectionField.getProjectionField()); Method method = CompiledSortCriterion.class .getDeclaredMethod("substituteExpressionWithProjectionField", Integer.TYPE); method.setAccessible(true); method.invoke(csc1, 0); method.invoke(csc2, 1); List<CompiledSortCriterion> orderByAttribs = new ArrayList<CompiledSortCriterion>(); orderByAttribs.add(csc1); orderByAttribs.add(csc2); ExecutionContext context = new ExecutionContext(null, null); return new NWayMergeResults<Struct>(sortedResults, false, -1, orderByAttribs, context, structType); }
ExecutionContext externalContext = new ExecutionContext(null, cache); externalContext.setBucketRegion(PartitionedRegion.this, (BucketRegion) bucket); IndexManager indMng = IndexUtils.getIndexManager(cache, bucket, true);
@Test public void testMaxMin() throws Exception { CompiledAggregateFunction caf1 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.MAX); ExecutionContext context1 = new ExecutionContext(null, cache); Aggregator agg = (Aggregator) caf1.evaluate(context1); assertThat(agg).isInstanceOf(MaxMin.class); MaxMin maxMin = (MaxMin) agg; Class maxMinClass = MaxMin.class; Field findMax = maxMinClass.getDeclaredField("findMax"); findMax.setAccessible(true); assertThat(findMax.get(maxMin)).isEqualTo(Boolean.TRUE); CompiledAggregateFunction caf2 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.MIN); Aggregator agg1 = (Aggregator) caf2.evaluate(context1); assertThat(agg1).isInstanceOf(MaxMin.class); MaxMin maxMin1 = (MaxMin) agg1; assertThat(findMax.get(maxMin1)).isEqualTo(Boolean.FALSE); } }
additionalProj = ((FunctionalIndexCreationHelper) helper).additionalProj; Object params1[] = {new QRegion(rgn, false)}; initContext = new ExecutionContext(params1, cache); if (isFirstItrOnEntry) { this.indexInitIterators = this.fromIterators;
VMThinRegionEntryHeap.getEntryFactory().createEntry((RegionEntryContext) rgn, 0, value)); Object params[] = {dQRegion}; ExecutionContext context = new ExecutionContext(params, this.cache); context.newScope(IndexCreationHelper.INDEX_QUERY_SCOPE_ID); try {
dQRegion.setEntry(target); Object params[] = {dQRegion}; ExecutionContext context = new ExecutionContext(params, this.cache); context.newScope(IndexCreationHelper.INDEX_QUERY_SCOPE_ID);
private List sortIncomingData(List objects, List<CompiledSortCriterion> orderByAttribs) { ObjectType resultType = cumulativeResults.getCollectionType().getElementType(); ExecutionContext local = new ExecutionContext(null, this.pr.cache); Comparator comparator = new OrderByComparator(orderByAttribs, resultType, local); boolean nullAtStart = !orderByAttribs.get(0).getCriterion(); final SelectResults newResults; // Asif: There is a bug in the versions < 9.0, such that the struct results coming from the // bucket nodes , do not contain approrpiate ObjectTypes. All the projection fields have // have the types as ObjectType. The resultset being created here has the right more selective // type. // so the addition of objects throw exception due to type mismatch. To handle this problem, // instead // of adding the struct objects as is, add fieldValues. if (resultType != null && resultType.isStructType()) { SortedStructBag sortedStructBag = new SortedStructBag(comparator, (StructType) resultType, nullAtStart); for (Object o : objects) { Struct s = (Struct) o; sortedStructBag.addFieldValues(s.getFieldValues()); } newResults = sortedStructBag; } else { newResults = new SortedResultsBag(comparator, resultType, nullAtStart); newResults.addAll(objects); } objects = newResults.asList(); return objects; }
@Test public void testSum() throws Exception { CompiledAggregateFunction caf1 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.SUM); ExecutionContext context1 = new ExecutionContext(null, cache); assertThat(caf1.evaluate(context1)).isInstanceOf(Sum.class); CompiledAggregateFunction caf2 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.SUM, true); ExecutionContext context2 = new ExecutionContext(null, cache); assertThat(caf2.evaluate(context2)).isInstanceOf(SumDistinct.class); CompiledAggregateFunction caf3 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.SUM); ExecutionContext context3 = new ExecutionContext(null, cache); context3.setIsPRQueryNode(true); assertThat(caf3.evaluate(context3)).isInstanceOf(Sum.class); CompiledAggregateFunction caf4 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.SUM); QueryExecutionContext context4 = new QueryExecutionContext(null, cache); context4.setBucketList(bucketList); assertThat(caf4.evaluate(context4)).isInstanceOf(Sum.class); CompiledAggregateFunction caf5 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.SUM, true); ExecutionContext context5 = new ExecutionContext(null, cache); context5.setIsPRQueryNode(true); assertThat(caf5.evaluate(context5)).isInstanceOf(SumDistinctPRQueryNode.class); CompiledAggregateFunction caf6 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.SUM, true); QueryExecutionContext context6 = new QueryExecutionContext(null, cache); context6.setBucketList(bucketList); assertThat(caf6.evaluate(context6)).isInstanceOf(DistinctAggregator.class); }
@Test public void testCount() throws Exception { CompiledAggregateFunction caf1 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.COUNT); ExecutionContext context1 = new ExecutionContext(null, cache); assertThat(caf1.evaluate(context1)).isInstanceOf(Count.class); CompiledAggregateFunction caf2 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.COUNT, true); ExecutionContext context2 = new ExecutionContext(null, cache); assertThat(caf2.evaluate(context2)).isInstanceOf(CountDistinct.class); CompiledAggregateFunction caf3 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.COUNT); ExecutionContext context3 = new ExecutionContext(null, cache); context3.setIsPRQueryNode(true); assertThat(caf3.evaluate(context3)).isInstanceOf(CountPRQueryNode.class); CompiledAggregateFunction caf4 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.COUNT); QueryExecutionContext context4 = new QueryExecutionContext(null, cache); context4.setBucketList(bucketList); assertThat(caf4.evaluate(context4)).isInstanceOf(Count.class); CompiledAggregateFunction caf5 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.COUNT, true); ExecutionContext context5 = new ExecutionContext(null, cache); context5.setIsPRQueryNode(true); assertThat(caf5.evaluate(context5)).isInstanceOf(CountDistinctPRQueryNode.class); CompiledAggregateFunction caf6 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.COUNT, true); QueryExecutionContext context6 = new QueryExecutionContext(null, cache); context6.setBucketList(bucketList); assertThat(caf6.evaluate(context6)).isInstanceOf(DistinctAggregator.class); }
@Test public void testAvg() throws Exception { CompiledAggregateFunction caf1 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.AVG); ExecutionContext context1 = new ExecutionContext(null, cache); assertThat(caf1.evaluate(context1)).isInstanceOf(Avg.class); CompiledAggregateFunction caf2 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.AVG, true); ExecutionContext context2 = new ExecutionContext(null, cache); assertThat(caf2.evaluate(context2)).isInstanceOf(AvgDistinct.class); CompiledAggregateFunction caf3 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.AVG); ExecutionContext context3 = new ExecutionContext(null, cache); context3.setIsPRQueryNode(true); assertThat(caf3.evaluate(context3)).isInstanceOf(AvgPRQueryNode.class); CompiledAggregateFunction caf4 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.AVG); QueryExecutionContext context4 = new QueryExecutionContext(null, cache); context4.setBucketList(this.bucketList); assertThat(caf4.evaluate(context4)).isInstanceOf(AvgBucketNode.class); CompiledAggregateFunction caf5 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.AVG, true); ExecutionContext context5 = new ExecutionContext(null, cache); context5.setIsPRQueryNode(true); assertThat(caf5.evaluate(context5)).isInstanceOf(AvgDistinctPRQueryNode.class); CompiledAggregateFunction caf6 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.AVG, true); QueryExecutionContext context6 = new QueryExecutionContext(null, cache); context6.setBucketList(this.bucketList); assertThat(caf6.evaluate(context6)).isInstanceOf(DistinctAggregator.class); }
dQRegion.setEntry(target); Object[] params = {dQRegion}; ExecutionContext context = new ExecutionContext(params, this.cache); context.newScope(IndexCreationHelper.INDEX_QUERY_SCOPE_ID);
baseResults = this.buildCumulativeResults(isDistinct, limit); ExecutionContext context = new ExecutionContext(null, pr.cache); context.setIsPRQueryNode(true); return cgs.applyAggregateAndGroupBy(baseResults, context);
dQRegion.setEntry(target); Object params[] = {dQRegion}; ExecutionContext context = new ExecutionContext(params, this.cache); context.newScope(IndexCreationHelper.INDEX_QUERY_SCOPE_ID); try {
ExecutionContext externalContext = new ExecutionContext(null, bukRegion.getCache()); externalContext.setBucketRegion(pr, bukRegion);