http://git-wip-us.apache.org/repos/asf/geode/blob/640b9f03/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIn.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIn.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIn.java index 0aa1efb..db2c65b 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIn.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIn.java @@ -12,7 +12,6 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ - package org.apache.geode.cache.query.internal; import java.lang.reflect.Array; @@ -50,13 +49,6 @@ import org.apache.geode.internal.i18n.LocalizedStrings; import org.apache.geode.internal.logging.LogService; import org.apache.geode.pdx.internal.PdxString; -/** - * Class Description - * - * @version $Revision: 1.1 $ - */ - - public class CompiledIn extends AbstractCompiledValue implements Indexable { private static final Logger logger = LogService.getLogger(); @@ -80,7 +72,7 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { return LITERAL_in; } - /* + /** * We retrieve the collection from the context cache if it exists This allows us to not have to * reevaluate the sub query on every iteration. This improves performance for queries such as * "select * from /receipts r where r.type = 'large' and r.id in (select c.id from /customers c @@ -118,7 +110,7 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { } if (evalColln instanceof Collection) { - Iterator iterator = ((Collection) evalColln).iterator(); + Iterator iterator = ((Iterable) evalColln).iterator(); while (iterator.hasNext()) { Object evalObj = evalElm; Object collnObj = iterator.next(); @@ -158,15 +150,16 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { return Boolean.FALSE; } - // Asif: If the size of aray is two this implies that it is - // a relation ship index & so the key field will be null in both the indexes - // as key is not a meaningful entity. The 0th element will refer to LHS - // operand - // and 1th element will refer to RHS operannd + /** + * If the size of aray is two this implies that it is a relation ship index & so the key field + * will be null in both the indexes as key is not a meaningful entity. The 0th element will refer + * to LHS operand and 1th element will refer to RHS operannd + */ public IndexInfo[] getIndexInfo(ExecutionContext context) throws TypeMismatchException, AmbiguousNameException, NameResolutionException { IndexInfo[] indexInfo = privGetIndexInfo(context); if (indexInfo != null) { + // TODO: == check is identity only if (indexInfo == NO_INDEXES_IDENTIFIER) { return null; } else { @@ -189,7 +182,7 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { if (index != null && index.isValid()) { newIndexInfo = new IndexInfo[1]; newIndexInfo[0] = new IndexInfo(indexKey, path, index, indexData.getMatchLevel(), - indexData.getMapping(), this.TOK_EQ); + indexData.getMapping(), TOK_EQ); } } if (newIndexInfo != null) { @@ -200,9 +193,9 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { return newIndexInfo; } - - // _indexInfo is a transient field - // if this is just faulted in then can be null + /** + * _indexInfo is a transient field if this is just faulted in then can be null + */ private IndexInfo[] privGetIndexInfo(ExecutionContext context) { return (IndexInfo[]) context.cacheGet(this); } @@ -211,7 +204,9 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { context.cachePut(this, indexInfo); } - // Invariant: the receiver is dependent on the current iterator. + /** + * Invariant: the receiver is dependent on the current iterator. + */ protected PlanInfo protGetPlanInfo(ExecutionContext context) throws TypeMismatchException, AmbiguousNameException, NameResolutionException { PlanInfo result = new PlanInfo(); @@ -342,8 +337,7 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { */ private PathAndKey getPathAndKey(ExecutionContext context) throws TypeMismatchException, AmbiguousNameException { - // RuntimeIterator lIter = context.findRuntimeIterator(_left); - // RuntimeIterator rIter = context.findRuntimeIterator(_right); + boolean isLeftDependent = context.isDependentOnCurrentScope(this.elm); boolean isRightDependent = context.isDependentOnCurrentScope(this.colln); if (!isLeftDependent || isRightDependent) @@ -352,15 +346,14 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { CompiledValue path; path = this.elm; indexKey = this.colln; - // Asif Do not worry about the nature of the collection. As long as it + // Do not worry about the nature of the collection. As long as it // is not dependent on the current scope we should be fine return new PathAndKey(path, indexKey); } - /** - * Asif : Evaluates as a filter taking advantage of indexes if appropriate. This function has a + * Evaluates as a filter taking advantage of indexes if appropriate. This function has a * meaningful implementation only in CompiledComparison & CompiledUndefined . It is unsupported in * other classes. The additional parameters which it takes are a boolean which is used to indicate * whether the index result set needs to be expanded to the top level or not. The second is a @@ -378,10 +371,9 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { QueryInvocationTargetException { // see if we're dependent on the current iterator // if not let super handle it - // RuntimeIterator itr = context.getCurrentIterator(); - // Support.Assert(itr != null); - if (!isDependentOnCurrentScope(context)) + if (!isDependentOnCurrentScope(context)) { return super.filterEvaluate(context, intermediateResults); + } IndexInfo[] idxInfo = getIndexInfo(context); Support.Assert(idxInfo != null, "a comparison that is dependent, not indexed, and filter evaluated is not possible"); @@ -396,15 +388,6 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { return TOK_EQ; } - /** - * **************** PRIVATE METHODS ************************** - * - * @throws QueryInvocationTargetException - * @throws NameResolutionException - * @throws FunctionDomainException - * @throws TypeMismatchException - */ - private void queryIndex(Object key, IndexInfo indexInfo, SelectResults results, CompiledValue iterOperands, RuntimeIterator[] indpndntItrs, ExecutionContext context, List projAttrib, boolean conditioningNeeded) throws TypeMismatchException, @@ -419,17 +402,14 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { indexInfo._getIndex(), 0, null, indexInfo._operator()); context.cachePut(CompiledValue.INDEX_INFO, contextIndexInfo); indexInfo._index.query(key, TOK_EQ, results, !conditioningNeeded ? iterOperands : null, - indpndntItrs == null ? null : indpndntItrs[0], context, projAttrib, null, false); // is - // Intersection - - - + indpndntItrs == null ? null : indpndntItrs[0], context, projAttrib, null, false); } /** * evaluate as a filter, involving a single iterator. Use an index if possible. + * + * Invariant: the receiver is dependent on the current iterator. */ - // Invariant: the receiver is dependent on the current iterator. private SelectResults singleBaseCollectionFilterEvaluate(ExecutionContext context, SelectResults intermediateResults, boolean completeExpansionNeeded, CompiledValue iterOperands, IndexInfo indexInfo, RuntimeIterator[] indpndntItr, @@ -447,14 +427,14 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { boolean useLinkedDataStructure = false; boolean nullValuesAtStart = true; Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX); - if (orderByClause != null && orderByClause.booleanValue()) { + if (orderByClause != null && orderByClause) { List orderByAttrs = (List) context.cacheGet(CompiledValue.ORDERBY_ATTRIB); useLinkedDataStructure = orderByAttrs.size() == 1; nullValuesAtStart = !((CompiledSortCriterion) orderByAttrs.get(0)).getCriterion(); } List projAttrib = null; - // //////////////////////////////////////////////////////////////// + ObjectType projResultType = null; if (!conditioningNeeded) { projResultType = evalProj ? (ObjectType) context.cacheGet(RESULT_TYPE) : null; @@ -537,7 +517,6 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { } } - QueryObserver observer = QueryObserverHolder.getInstance(); try { Object evalColln = evaluateColln(context); @@ -568,7 +547,7 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { // key in the [1] // and the evalColln in the [0] position if (key instanceof Object[]) { - Iterator iterator = ((ResultsSet) ((Object[]) key)[0]).iterator(); + Iterator iterator = ((Iterable) ((Object[]) key)[0]).iterator(); while (iterator.hasNext()) { this.queryIndex(new Object[] {iterator.next(), ((Object[]) key)[1]}, indexInfo, results, iterOperands, indpndntItr, context, projAttrib, conditioningNeeded); @@ -597,48 +576,48 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { } else if (evalColln instanceof long[]) { long[] a = (long[]) evalColln; for (int i = 0; i < a.length; i++) { - this.queryIndex(Long.valueOf(a[i]), indexInfo, results, iterOperands, indpndntItr, - context, projAttrib, conditioningNeeded); + this.queryIndex(a[i], indexInfo, results, iterOperands, indpndntItr, context, + projAttrib, conditioningNeeded); } } else if (evalColln instanceof double[]) { double[] a = (double[]) evalColln; for (int i = 0; i < a.length; i++) { - this.queryIndex(Double.valueOf(a[i]), indexInfo, results, iterOperands, indpndntItr, - context, projAttrib, conditioningNeeded); + this.queryIndex(a[i], indexInfo, results, iterOperands, indpndntItr, context, + projAttrib, conditioningNeeded); } } else if (evalColln instanceof float[]) { float[] a = (float[]) evalColln; for (int i = 0; i < a.length; i++) { - this.queryIndex(new Float(a[i]), indexInfo, results, iterOperands, indpndntItr, context, + this.queryIndex(a[i], indexInfo, results, iterOperands, indpndntItr, context, projAttrib, conditioningNeeded); } } else if (evalColln instanceof int[]) { int[] a = (int[]) evalColln; for (int i = 0; i < a.length; i++) { - this.queryIndex(Integer.valueOf(a[i]), indexInfo, results, iterOperands, indpndntItr, - context, projAttrib, conditioningNeeded); + this.queryIndex(a[i], indexInfo, results, iterOperands, indpndntItr, context, + projAttrib, conditioningNeeded); } } else if (evalColln instanceof short[]) { short[] a = (short[]) evalColln; for (int i = 0; i < a.length; i++) { - this.queryIndex(new Short(a[i]), indexInfo, results, iterOperands, indpndntItr, context, + this.queryIndex(a[i], indexInfo, results, iterOperands, indpndntItr, context, projAttrib, conditioningNeeded); } } else if (evalColln instanceof char[]) { char[] a = (char[]) evalColln; for (int i = 0; i < a.length; i++) { - this.queryIndex(new Character(a[i]), indexInfo, results, iterOperands, indpndntItr, - context, projAttrib, conditioningNeeded); + this.queryIndex(a[i], indexInfo, results, iterOperands, indpndntItr, context, + projAttrib, conditioningNeeded); } } else if (evalColln instanceof byte[]) { byte[] a = (byte[]) evalColln; for (int i = 0; i < a.length; i++) { - this.queryIndex(new Byte(a[i]), indexInfo, results, iterOperands, indpndntItr, context, + this.queryIndex(a[i], indexInfo, results, iterOperands, indpndntItr, context, projAttrib, conditioningNeeded); } @@ -646,12 +625,11 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { throw new TypeMismatchException( "Operand of IN cannot be interpreted as a Comparable Object. Operand is of type =" + evalColln.getClass()); - } } if (conditioningNeeded) { - results = QueryUtils.getconditionedIndexResults(results, indexInfo, context, + results = QueryUtils.getConditionedIndexResults(results, indexInfo, context, indexFieldsSize, completeExpansionNeeded, iterOperands, indpndntItr); } else { if (isIntersection && intermediateResults != null) { @@ -662,7 +640,6 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { } finally { observer.afterIndexLookup(results); } - } public boolean isProjectionEvaluationAPossibility(ExecutionContext context) { @@ -702,15 +679,13 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { } conditioningNeeded = ich == null || ich.shufflingNeeded; return conditioningNeeded; - } - /** * evaluate as a filter, producing an intermediate result set. This may require iteration if there - * is no index available. Asif :The booelan true implies that CompiledComparsion when existing on - * its own always requires a Completeexpansion to top level iterators. This flag can get toggled - * to false only from inside a GroupJunction + * is no index available. The boolean true implies that CompiledComparison when existing on its + * own always requires a CompleteExpansion to top level iterators. This flag can get toggled to + * false only from inside a GroupJunction * * @param intermediateResults if this parameter is provided, and we have to iterate, then iterate * over this result set instead of the entire base collection. @@ -718,7 +693,7 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { public SelectResults filterEvaluate(ExecutionContext context, SelectResults intermediateResults) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { - // Asif : This function can be invoked only if the where clause contains + // This function can be invoked only if the where clause contains // a single condition which is CompiledComparison. // If a CompiledComparison exists inside a GroupJunction, then it will // always @@ -738,25 +713,22 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { indpndntItr = (RuntimeIterator) rntmItrs.iterator().next(); } - return filterEvaluate(context, intermediateResults, true/* - * Complete Expansion needed - */, null, - indpndntItr != null ? new RuntimeIterator[] {indpndntItr} - : null/* - * Asif :It is safe to pass null as the independent iterator to which the - * condition belongs is required only if boolean complete expansion turns out to - * be false, which can happen only in case of CompiledComparison/CompiledUndefined - * called from roupJunction or CompositeGroupJunction - */, - true /* is intersection */, this.isConditioningNeededForIndex(indpndntItr, context, true), - true); + /* + * It is safe to pass null as the independent iterator to which the condition belongs is + * required only if boolean complete expansion turns out to be false, which can happen only in + * case of CompiledComparison/CompiledUndefined called from GroupJunction or + * CompositeGroupJunction + */ + return filterEvaluate(context, intermediateResults, true, null, + indpndntItr != null ? new RuntimeIterator[] {indpndntItr} : null, true, + this.isConditioningNeededForIndex(indpndntItr, context, true), true); } - /* - * Asif : This function should never get invoked as now if a CompiledJunction or GroupJunction - * contains a single filterable CompiledComparison it should directly call filterEvaluate rather - * than auxFilterEvalutae. Overriding this function just for ensuring that auxFilterEvaluate is - * not being called by mistake. + /** + * This function should never get invoked as now if a CompiledJunction or GroupJunction contains a + * single filterable CompiledComparison it should directly call filterEvaluate rather than + * auxFilterEvalutae. Overriding this function just for ensuring that auxFilterEvaluate is not + * being called by mistake. */ public SelectResults auxFilterEvaluate(ExecutionContext context, SelectResults intermediateResults) throws FunctionDomainException, TypeMismatchException, @@ -787,7 +759,7 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { isThisBetter = thisSize < thatSize; break; case LITERAL_and: - // Asif: Give preference to IN . Is this right? It does not appear . Ideally we need to get + // Give preference to IN . Is this right? It does not appear . Ideally we need to get // some estimate on Range. This case is possible only in case of RangeJunction break; case TOK_LE: @@ -807,15 +779,15 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { TypeMismatchException, NameResolutionException, QueryInvocationTargetException { IndexInfo[] idxInfo = getIndexInfo(context); if (idxInfo == null) { - // Asif: This implies it is an independent condition. So evaluate it first - // in filter operand + // This implies it is an independent condition. So evaluate it first in filter operand return 0; } assert idxInfo.length == 1; Object key = idxInfo[0].evaluateIndexKey(context); - if (key != null && key.equals(QueryService.UNDEFINED)) + if (key != null && key.equals(QueryService.UNDEFINED)) { return 0; + } if (context instanceof QueryExecutionContext) { QueryExecutionContext qcontext = (QueryExecutionContext) context; @@ -862,67 +834,58 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { } else if (evalColln instanceof long[]) { long[] a = (long[]) evalColln; for (int i = 0; i < a.length; i++) { - size += - idxInfo[0]._index.getSizeEstimate(Long.valueOf(a[i]), TOK_EQ, idxInfo[0]._matchLevel); + size += idxInfo[0]._index.getSizeEstimate(a[i], TOK_EQ, idxInfo[0]._matchLevel); } } else if (evalColln instanceof double[]) { double[] a = (double[]) evalColln; for (int i = 0; i < a.length; i++) { - size += idxInfo[0]._index.getSizeEstimate(Double.valueOf(a[i]), TOK_EQ, - idxInfo[0]._matchLevel); + size += idxInfo[0]._index.getSizeEstimate(a[i], TOK_EQ, idxInfo[0]._matchLevel); } } else if (evalColln instanceof float[]) { float[] a = (float[]) evalColln; for (int i = 0; i < a.length; i++) { - size += - idxInfo[0]._index.getSizeEstimate(new Float(a[i]), TOK_EQ, idxInfo[0]._matchLevel); - + size += idxInfo[0]._index.getSizeEstimate(a[i], TOK_EQ, idxInfo[0]._matchLevel); } } else if (evalColln instanceof int[]) { int[] a = (int[]) evalColln; for (int i = 0; i < a.length; i++) { - size += idxInfo[0]._index.getSizeEstimate(Integer.valueOf(a[i]), TOK_EQ, - idxInfo[0]._matchLevel); + size += idxInfo[0]._index.getSizeEstimate(a[i], TOK_EQ, idxInfo[0]._matchLevel); } } else if (evalColln instanceof short[]) { short[] a = (short[]) evalColln; for (int i = 0; i < a.length; i++) { - size += - idxInfo[0]._index.getSizeEstimate(new Short(a[i]), TOK_EQ, idxInfo[0]._matchLevel); - + size += idxInfo[0]._index.getSizeEstimate(a[i], TOK_EQ, idxInfo[0]._matchLevel); } } else if (evalColln instanceof char[]) { char[] a = (char[]) evalColln; for (int i = 0; i < a.length; i++) { - size += idxInfo[0]._index.getSizeEstimate(new Character(a[i]), TOK_EQ, - idxInfo[0]._matchLevel); + size += idxInfo[0]._index.getSizeEstimate(a[i], TOK_EQ, idxInfo[0]._matchLevel); } } else if (evalColln instanceof byte[]) { byte[] a = (byte[]) evalColln; for (int i = 0; i < a.length; i++) { - size += idxInfo[0]._index.getSizeEstimate(new Byte(a[i]), TOK_EQ, idxInfo[0]._matchLevel); - + size += idxInfo[0]._index.getSizeEstimate(a[i], TOK_EQ, idxInfo[0]._matchLevel); } } else { throw new TypeMismatchException( "Operand of IN cannot be interpreted as a Comparable Object. Operand is of type =" + evalColln.getClass()); - } } return size; - } + public boolean isRangeEvaluatable() { + return false; + } - /* Inner classes for passing stuff around */ - class PathAndKey { + static class PathAndKey { CompiledValue _path; CompiledValue _key; @@ -932,10 +895,4 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { _key = indexKey; } } - - - public boolean isRangeEvaluatable() { - return false; - } - }
http://git-wip-us.apache.org/repos/asf/geode/blob/640b9f03/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIndexOperation.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIndexOperation.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIndexOperation.java index e06937a..f480ebf 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIndexOperation.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIndexOperation.java @@ -142,7 +142,7 @@ public class CompiledIndexOperation extends AbstractCompiledValue implements Map // Asif :Function for generating canonicalized expression @Override - public void generateCanonicalizedExpression(StringBuffer clauseBuffer, ExecutionContext context) + public void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { // Asif: The canonicalization of Index operator will be of // the form IterX.getPositions[IterY.a.b.c] http://git-wip-us.apache.org/repos/asf/geode/blob/640b9f03/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIteratorDef.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIteratorDef.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIteratorDef.java index c19bab3..872614d 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIteratorDef.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIteratorDef.java @@ -14,20 +14,34 @@ */ package org.apache.geode.cache.query.internal; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.apache.logging.log4j.Logger; -import org.apache.geode.cache.*; -import org.apache.geode.cache.query.*; -import org.apache.geode.cache.query.internal.parse.*; -import org.apache.geode.cache.query.types.*; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.query.AmbiguousNameException; +import org.apache.geode.cache.query.FunctionDomainException; +import org.apache.geode.cache.query.NameResolutionException; +import org.apache.geode.cache.query.QueryExecutionTimeoutException; +import org.apache.geode.cache.query.QueryInvocationTargetException; +import org.apache.geode.cache.query.QueryService; +import org.apache.geode.cache.query.RegionNotFoundException; +import org.apache.geode.cache.query.SelectResults; +import org.apache.geode.cache.query.TypeMismatchException; +import org.apache.geode.cache.query.internal.parse.OQLLexerTokenTypes; import org.apache.geode.cache.query.internal.types.TypeUtils; +import org.apache.geode.cache.query.types.CollectionType; +import org.apache.geode.cache.query.types.MapType; +import org.apache.geode.cache.query.types.ObjectType; import org.apache.geode.internal.i18n.LocalizedStrings; import org.apache.geode.internal.logging.LogService; -/** - */ public class CompiledIteratorDef extends AbstractCompiledValue { private static final Logger logger = LogService.getLogger(); @@ -83,17 +97,16 @@ public class CompiledIteratorDef extends AbstractCompiledValue { } } rIter = new RuntimeIterator(this, type); - // Rahul : generate from clause should take care of bucket region substitution if + // generate from clause should take care of bucket region substitution if // necessary and then set the definition. String fromClause = genFromClause(context); rIter.setDefinition(fromClause); - /** - * Asif : If the type of RunTimeIterator is still ObjectType & if the RuneTimeIterator is - * independent of any iterator of the scopes less than or equal to its own scope, we can - * evaluate the collection via RuntimeIterator. This will initialize the Collection of - * RuntimeIterator , which is OK. The code in RuntimeIterator will be rectified such that the - * ElementType of that RuntimeIterator is taken from the collection - * + /* + * If the type of RunTimeIterator is still ObjectType & if the RuneTimeIterator is independent + * of any iterator of the scopes less than or equal to its own scope, we can evaluate the + * collection via RuntimeIterator. This will initialize the Collection of RuntimeIterator , + * which is OK. The code in RuntimeIterator will be rectified such that the ElementType of that + * RuntimeIterator is taken from the collection */ if (type.equals(TypeUtils.OBJECT_TYPE) && !this.isDependentOnAnyIteratorOfScopeLessThanItsOwn(context)) { @@ -174,8 +187,7 @@ public class CompiledIteratorDef extends AbstractCompiledValue { // PR bucketRegion substitution should have already happened // at the expression evaluation level - SelectResults sr = prepareIteratorDef(coll, this.elementType, context); - return sr; + return prepareIteratorDef(coll, this.elementType, context); } public int getType() { @@ -200,22 +212,11 @@ public class CompiledIteratorDef extends AbstractCompiledValue { } /** - * TODO:Asif : We need to implement the belwo method of computeDependencies Once we come to - * implement changes for partitioned region querying, as in that case if first iterator itself is - * a Select Query , then ideally we cannot call that CompiledIteratorDef independent ( which will - * be the case at present). When we use this commented function we will also need to take care of + * TODO: We need to implement the belwo method of computeDependencies Once we come to implement + * changes for partitioned region querying, as in that case if first iterator itself is a Select + * Query , then ideally we cannot call that CompiledIteratorDef independent ( which will be the + * case at present). When we use this commented function we will also need to take care of * correctly implementing the function isDependentOnCurrentScope etc functions. - * - * public Set computeDependencies(ExecutionContext context) throws TypeMismatchException, - * AmbiguousNameException { //Asif : If a CompiledIteratorDef has a collection expression which - * boils down to //a CompiledRegion or CompiledBindArgumnet , then its dependency is empty . In - * such cases // we will assume that the current CompiledIteratorDef has a dependency on itself. - * // This will be required once we start the changes for partitionedRegion Querying //But when we - * are doing check of whether the CompiledIteratorDef is dependent on its // own RuntimeIterator - * we will still return false. Set set = this.collectionExpr.computeDependencies(context); Set - * retSet = null; if(set.isEmpty()){ retSet = - * context.addDependency(this,this.getRuntimeIterator(context)); }else { retSet = - * context.addDependencies(this, set); } return retSet; } */ @Override public Set computeDependencies(ExecutionContext context) @@ -223,7 +224,7 @@ public class CompiledIteratorDef extends AbstractCompiledValue { return context.addDependencies(this, this.collectionExpr.computeDependencies(context)); } - // @todo ericz this method is overly complex, duplicating logic already + // TODO: this method is overly complex, duplicating logic already // in query evaluation itself. It is overly complex ==> It will not be // necessary once we have full typing support. // There is a limitation here that it assumes that the collectionExpr is some @@ -296,7 +297,7 @@ public class CompiledIteratorDef extends AbstractCompiledValue { res.setModifiable(false); return res; } - // @todo primitive arrays? + // TODO: primitive arrays? if (obj instanceof Map) { if (elementType.equals(TypeUtils.OBJECT_TYPE)) { // if we don't have more // specific type info, @@ -325,29 +326,22 @@ public class CompiledIteratorDef extends AbstractCompiledValue { String genFromClause(ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { - StringBuffer sbuff = new StringBuffer(); + StringBuilder sbuff = new StringBuilder(); collectionExpr.generateCanonicalizedExpression(sbuff, context); return sbuff.toString(); } - boolean isDependentOnAnyIterator(ExecutionContext context) { - return context.isDependentOnAnyIterator(this); - } - /** * Checks if the iterator in question is dependent on any other RuntimeIterator of its own or * lesser scope. - * - * @param context */ boolean isDependentOnAnyIteratorOfScopeLessThanItsOwn(ExecutionContext context) { - // Asif : Get the list of all iterators on which the colelction expression + // Get the list of all iterators on which the colelction expression // is ultimately dependent on - // Set indpRitrs = new HashSet(); - // context.computeUtlimateDependencies(this, indpRitrs); - // Asif:If dependent on self then also assume it to be dependent + + // If dependent on self then also assume it to be dependent boolean isDep = false; - // Asif : Get the list of all iterators on which the colelction expression + // Get the list of all iterators on which the colelction expression // is dependent on Set dependencySet = context.getDependencySet(this, true); Iterator itr = dependencySet.iterator(); @@ -360,6 +354,5 @@ public class CompiledIteratorDef extends AbstractCompiledValue { } } return isDep; - } } http://git-wip-us.apache.org/repos/asf/geode/blob/640b9f03/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledLike.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledLike.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledLike.java index fc4a843..4930aed 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledLike.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledLike.java @@ -16,6 +16,8 @@ package org.apache.geode.cache.query.internal; import java.util.regex.Pattern; +import org.apache.logging.log4j.Logger; + import org.apache.geode.cache.query.AmbiguousNameException; import org.apache.geode.cache.query.FunctionDomainException; import org.apache.geode.cache.query.NameResolutionException; @@ -27,43 +29,40 @@ import org.apache.geode.cache.query.internal.index.IndexManager; import org.apache.geode.cache.query.internal.index.IndexProtocol; import org.apache.geode.cache.query.internal.index.PrimaryKeyIndex; import org.apache.geode.cache.query.internal.parse.OQLLexerTokenTypes; -import org.apache.geode.internal.cache.GemFireCacheImpl; +import org.apache.geode.internal.logging.LogService; import org.apache.geode.pdx.internal.PdxString; -/** - * - * - */ public class CompiledLike extends CompiledComparison { - final static int WILDCARD_PERCENT = 0; + private static final Logger logger = LogService.getLogger(); - final static int WILDCARD_UNDERSCORE = 1; + private static final int WILDCARD_PERCENT = 0; - private Object wildcardTypeKey = new Object(); + private static final int WILDCARD_UNDERSCORE = 1; - private Object wildcardPositionKey = new Object(); + private final Object wildcardTypeKey = new Object(); - private Object patternLengthKey = new Object(); + private final Object wildcardPositionKey = new Object(); - final static String LOWEST_STRING = ""; + private final Object patternLengthKey = new Object(); - final static char BOUNDARY_CHAR = (char) 255; + static final String LOWEST_STRING = ""; - final static char UNDERSCORE = '_'; + private static final char BOUNDARY_CHAR = (char) 255; - final static char PERCENT = '%'; + private static final char UNDERSCORE = '_'; - final static char BACKSLASH = '\\'; + private static final char PERCENT = '%'; + + private static final char BACKSLASH = '\\'; private final CompiledValue var; - private Object isIndexEvaluatedKey = new Object(); + private final Object isIndexEvaluatedKey = new Object(); - // private final CompiledBindArgument bindArg; private final CompiledValue bindArg; - public CompiledLike(CompiledValue var, CompiledValue pattern) { + CompiledLike(CompiledValue var, CompiledValue pattern) { super(var, pattern, OQLLexerTokenTypes.TOK_EQ); this.var = var; this.bindArg = pattern; @@ -122,13 +121,7 @@ public class CompiledLike extends CompiledComparison { /** * Expands the CompiledLike operands based on sargability into multiple CompiledComparisons * - * @param context * @return The generated CompiledComparisons - * @throws AmbiguousNameException - * @throws TypeMismatchException - * @throws NameResolutionException - * @throws FunctionDomainException - * @throws QueryInvocationTargetException */ CompiledComparison[] getExpandedOperandsWithIndexInfoSetIfAny(ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException, @@ -159,9 +152,8 @@ public class CompiledLike extends CompiledComparison { } } if (IndexManager.testHook != null) { - if (GemFireCacheImpl.getInstance().getLogger().fineEnabled()) { - GemFireCacheImpl.getInstance().getLogger() - .fine("IndexManager TestHook is set in getExpandedOperandsWithIndexInfoSetIfAny."); + if (logger.isDebugEnabled()) { + logger.debug("IndexManager TestHook is set in getExpandedOperandsWithIndexInfoSetIfAny."); } IndexManager.testHook.hook(12); } @@ -199,13 +191,10 @@ public class CompiledLike extends CompiledComparison { return result; } - /** * Breaks down the like predicate (if sargable) into 2 or 3 CompiledComparisons based on the * presence of wildcard * - * @param var - * @param pattern * @return The generated CompiledComparisons */ CompiledComparison[] getRangeIfSargable(ExecutionContext context, CompiledValue var, @@ -285,7 +274,7 @@ public class CompiledLike extends CompiledComparison { } private String getRegexPattern(String pattern) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); boolean prevMetaChar = false; int len = pattern.length(); @@ -376,7 +365,6 @@ public class CompiledLike extends CompiledComparison { * Checks if index can be used for Strings with wildcards. Two wild cards are supported % and _. * The wildcard could be at any index position of the string. * - * @param buffer * @return position of wildcard if sargable otherwise -1 */ int checkIfSargableAndRemoveEscapeChars(ExecutionContext context, StringBuffer buffer) { @@ -405,22 +393,6 @@ public class CompiledLike extends CompiledComparison { return wildcardPosition; } - /* - * @Override public Object evaluate(ExecutionContext context) throws FunctionDomainException, - * TypeMismatchException, NameResolutionException, QueryInvocationTargetException { CompiledValue - * iterEvaluator = (CompiledValue)context.cacheGet(this.bindArg); if(iterEvaluator == null) { - * String pattern = (String)this.bindArg.evaluate(context); CompiledComparison[] cvs = - * getRangeIfSargable(this.var, pattern); - * - * for (CompiledComparison cp : cvs) { cp.computeDependencies(context); - * - * } if(cvs.length ==2 ) { iterEvaluator = new CompiledJunction(cvs, - * OQLLexerTokenTypes.LITERAL_and); }else { iterEvaluator = cvs[0]; } - * context.cachePut(this.bindArg, iterEvaluator); - * - * } return iterEvaluator.evaluate(context); } - */ - @Override public Object evaluate(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { @@ -436,8 +408,6 @@ public class CompiledLike extends CompiledComparison { "Null values are not supported with LIKE predicate."); } pattern = Pattern.compile(getRegexPattern(strPattern), Pattern.MULTILINE | Pattern.DOTALL); - // GemFireCacheImpl.getInstance().getLogger().fine("### DEBUG : string :" + strPattern + " - // pattern :" + pattern.toString()); context.cachePut(this.bindArg, pattern); } Object value = this.var.evaluate(context); http://git-wip-us.apache.org/repos/asf/geode/blob/640b9f03/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledLiteral.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledLiteral.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledLiteral.java index 673660c..32c5c4d 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledLiteral.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledLiteral.java @@ -57,7 +57,7 @@ public class CompiledLiteral extends AbstractCompiledValue { } @Override - public void generateCanonicalizedExpression(StringBuffer clauseBuffer, ExecutionContext context) + public void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException { if (_obj == null) { clauseBuffer.insert(0, "null"); http://git-wip-us.apache.org/repos/asf/geode/blob/640b9f03/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledNegation.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledNegation.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledNegation.java index 3673b9f..0bb8673 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledNegation.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledNegation.java @@ -65,7 +65,7 @@ public class CompiledNegation extends AbstractCompiledValue { } @Override - public void generateCanonicalizedExpression(StringBuffer clauseBuffer, ExecutionContext context) + public void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { clauseBuffer.insert(0, ')'); _value.generateCanonicalizedExpression(clauseBuffer, context); http://git-wip-us.apache.org/repos/asf/geode/blob/640b9f03/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledOperation.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledOperation.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledOperation.java index f556f2f..e544d8c 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledOperation.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledOperation.java @@ -289,7 +289,7 @@ public class CompiledOperation extends AbstractCompiledValue { // Asif :Function for generating from clause @Override - public void generateCanonicalizedExpression(StringBuffer clauseBuffer, ExecutionContext context) + public void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { // Asif: if the method name starts with getABC & argument list is empty // then canonicalize it to aBC http://git-wip-us.apache.org/repos/asf/geode/blob/640b9f03/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledPath.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledPath.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledPath.java index 2c2bc4a..ec7a84a 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledPath.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledPath.java @@ -156,7 +156,7 @@ public class CompiledPath extends AbstractCompiledValue { } @Override - public void generateCanonicalizedExpression(StringBuffer clauseBuffer, ExecutionContext context) + public void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { // Asif: Canonicalize the tail ID. If the tail ID contains // something like getX ,convert it into x. http://git-wip-us.apache.org/repos/asf/geode/blob/640b9f03/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledRegion.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledRegion.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledRegion.java index d463d28..83228f3 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledRegion.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledRegion.java @@ -19,7 +19,6 @@ import org.apache.geode.cache.*; import org.apache.geode.cache.query.*; import org.apache.geode.cache.Region; import org.apache.geode.internal.cache.BucketRegion; -import org.apache.geode.internal.cache.LocalDataSet; import org.apache.geode.internal.cache.PartitionedRegion; import org.apache.geode.internal.i18n.LocalizedStrings; @@ -94,7 +93,7 @@ public class CompiledRegion extends AbstractCompiledValue { } @Override - public void generateCanonicalizedExpression(StringBuffer clauseBuffer, ExecutionContext context) + public void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws NameResolutionException { clauseBuffer.insert(0, regionPath); // rahul : changed for running queries on partitioned region. http://git-wip-us.apache.org/repos/asf/geode/blob/640b9f03/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledSelect.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledSelect.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledSelect.java index 9b77557..b6d6842 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledSelect.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledSelect.java @@ -45,15 +45,11 @@ import org.apache.geode.cache.query.internal.types.TypeUtils; import org.apache.geode.cache.query.types.CollectionType; import org.apache.geode.cache.query.types.ObjectType; import org.apache.geode.cache.query.types.StructType; +import org.apache.geode.internal.cache.InternalCache; import org.apache.geode.internal.i18n.LocalizedStrings; import org.apache.geode.pdx.PdxInstance; import org.apache.geode.pdx.internal.PdxString; -/** - * Class Description - * - * @version $Revision: 1.2 $ - */ public class CompiledSelect extends AbstractCompiledValue { protected List<CompiledSortCriterion> orderByAttrs; // order by attributes: list of CompiledValue @@ -63,9 +59,9 @@ public class CompiledSelect extends AbstractCompiledValue { // 0 is projection name, 1 is the CompiledValue for the expression private boolean distinct; private boolean count; - // Asif: limits the SelectResults by the number specified. + // limits the SelectResults by the number specified. private CompiledValue limit; - // Shobhit: counts the no of results satisfying where condition for + // counts the no of results satisfying where condition for // count(*) non-distinct queries where no indexes are used. private int countStartQueryResult = 0; @@ -177,7 +173,7 @@ public class CompiledSelect extends AbstractCompiledValue { public Set computeDependencies(ExecutionContext context) throws TypeMismatchException, AmbiguousNameException, NameResolutionException { // bind iterators in new scope in order to determine dependencies - context.cachePut(scopeID, context.assosciateScopeID()); + context.cachePut(scopeID, context.associateScopeID()); context.newScope((Integer) context.cacheGet(scopeID)); context.pushExecCache((Integer) context.cacheGet(scopeID)); try { @@ -240,11 +236,6 @@ public class CompiledSelect extends AbstractCompiledValue { /** * Transforms the group by clause into distinct order by clause, if possible - * - * @param context - * @throws AmbiguousNameException - * @throws TypeMismatchException - * @throws NameResolutionException */ private void transformGroupByIfPossible(ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { @@ -268,8 +259,8 @@ public class CompiledSelect extends AbstractCompiledValue { } boolean shouldTransform = true; - StringBuffer lhsBuffer = new StringBuffer(); - StringBuffer rhsBuffer = new StringBuffer(); + StringBuilder lhsBuffer = new StringBuilder(); + StringBuilder rhsBuffer = new StringBuilder(); outer: for (int i = 0; i < projAttribs.size(); ++i) { Object[] prj = (Object[]) TypeUtils.checkCast(projAttribs.get(i), Object[].class); @@ -336,7 +327,7 @@ public class CompiledSelect extends AbstractCompiledValue { while (iter.hasNext()) { CompiledSortCriterion csc = iter.next(); - // Asif: Ideally for replicated regions, the requirement that + // Ideally for replicated regions, the requirement that // projected columns should // contain order by fields ( directly or derivable on it), // is not needed. But for PR , the query gathers only projected @@ -354,9 +345,8 @@ public class CompiledSelect extends AbstractCompiledValue { } } - private void evalCanonicalizedExpressionForCSC(CompiledSortCriterion csc, - ExecutionContext context, StringBuffer buffer) + ExecutionContext context, StringBuilder buffer) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { csc.getExpr().generateCanonicalizedExpression(buffer, context); } @@ -370,7 +360,7 @@ public class CompiledSelect extends AbstractCompiledValue { * * @return the empty result set of the appropriate type */ - public SelectResults getEmptyResultSet(Object[] parameters, Cache cache, Query query) + public SelectResults getEmptyResultSet(Object[] parameters, InternalCache cache, Query query) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { ExecutionContext context = new QueryExecutionContext(parameters, cache, query); @@ -420,7 +410,7 @@ public class CompiledSelect extends AbstractCompiledValue { CompiledIteratorDef iterDef = (CompiledIteratorDef) iter.next(); RuntimeIterator rIter = iterDef.getRuntimeIterator(context); context.bindIterator(rIter); - // Asif . Ideally the function below should always be called after binding has occured + // Ideally the function below should always be called after binding has occured // So that the interal ID gets set during binding to the scope. If not so then chances // are that internal_id is still null causing index_interanl_id to be null. // Though in our case it may not be an issue as the compute depedency phase must have @@ -453,7 +443,7 @@ public class CompiledSelect extends AbstractCompiledValue { throw new TypeMismatchException( LocalizedStrings.CompiledSelect_THE_WHERE_CLAUSE_WAS_TYPE_0_INSTEAD_OF_BOOLEAN .toLocalizedString(b.getClass().getName())); - } else if (((Boolean) b).booleanValue()) { + } else if ((Boolean) b) { result = doIterationEvaluate(context, false); } else { result = prepareEmptyResultSet(context, false); @@ -466,7 +456,7 @@ public class CompiledSelect extends AbstractCompiledValue { // If order by clause is defined, then the first column should be the preferred index if (this.orderByAttrs != null && numInd == 1) { CompiledSortCriterion csc = (CompiledSortCriterion) orderByAttrs.get(0); - StringBuffer preferredIndexCondn = new StringBuffer(); + StringBuilder preferredIndexCondn = new StringBuilder(); this.evalCanonicalizedExpressionForCSC(csc, context, preferredIndexCondn); context.cachePut(PREF_INDEX_COND, preferredIndexCondn.toString()); } @@ -497,9 +487,9 @@ public class CompiledSelect extends AbstractCompiledValue { && ((Filter) this.whereClause).isLimitApplicableAtIndexLevel(context)) { context.cachePut(CAN_APPLY_LIMIT_AT_INDEX, Boolean.TRUE); } - StringBuffer temp = null; + StringBuilder temp = null; if (this.orderByAttrs != null) { - temp = new StringBuffer(); + temp = new StringBuilder(); CompiledSortCriterion csc = (CompiledSortCriterion) this.orderByAttrs.get(0); this.evalCanonicalizedExpressionForCSC(csc, context, temp); } @@ -562,7 +552,7 @@ public class CompiledSelect extends AbstractCompiledValue { } } } - // TODO:Asif: It does not appear that results would be null ever. + // TODO: It does not appear that results would be null ever. // if (result == null) { return QueryService.UNDEFINED; } assert result != null; // drop duplicates if this is DISTINCT @@ -617,7 +607,7 @@ public class CompiledSelect extends AbstractCompiledValue { result = countResult; } else { - ((ResultsBag) res).addAndGetOccurence(countStartQueryResult); + ((Bag) res).addAndGetOccurence(countStartQueryResult); } } } @@ -632,9 +622,6 @@ public class CompiledSelect extends AbstractCompiledValue { * The index is locked during query to prevent it from being removed by another thread. So we have * to release the lock only after whole query is finished as one query can use an index multiple * times. - * - * - * @param planInfo */ private void releaseReadLockOnUsedIndex(PlanInfo planInfo) { List inds = planInfo.indexes; @@ -649,12 +636,9 @@ public class CompiledSelect extends AbstractCompiledValue { } } - /** - * Retruns the size of region iterator for count(*) on a region without whereclause. + * Returns the size of region iterator for count(*) on a region without whereclause. * - * @param collExpr - * @throws RegionNotFoundException * @since GemFire 6.6.2 */ private int getRegionIteratorSize(ExecutionContext context, CompiledValue collExpr) @@ -693,7 +677,7 @@ public class CompiledSelect extends AbstractCompiledValue { SelectResults results = prepareEmptyResultSet(context, false); - // TODO:Asif: SELF : Work on limit implementation on bulk get + // TODO: SELF : Work on limit implementation on bulk get // check for bulk get optimization if (evaluateWhereClause) { List tmpResults = optimizeBulkGet(context); @@ -713,13 +697,13 @@ public class CompiledSelect extends AbstractCompiledValue { int numElementsInResult = 0; try { doNestedIterations(0, results, context, evaluateWhereClause, numElementsInResult); - } catch (CompiledSelect.NullIteratorException cnie) { + } catch (CompiledSelect.NullIteratorException ignore) { return null; } return results; } - // @todo make this more general to work for any kind of map, not just regions + // TODO: make this more general to work for any kind of map, not just regions /** * Check for the bulk-get pattern and if it applies do an optimized execution. The pattern is: * SELECT ?? FROM <Region>.entrySet e WHERE e.key IN <Collection>. @@ -790,11 +774,11 @@ public class CompiledSelect extends AbstractCompiledValue { if (result == null) { addToResults = false; } else if (result instanceof Boolean) { - addToResults = ((Boolean) result).booleanValue(); + addToResults = (Boolean) result; } else if (result == QueryService.UNDEFINED) { // add UNDEFINED to results only for NOT EQUALS queries if (this.whereClause.getType() == COMPARISON) { - int operator = ((CompiledComparison) this.whereClause).getOperator(); + int operator = ((Filter) this.whereClause).getOperator(); if ((operator != TOK_NE && operator != TOK_NE_ALT)) { addToResults = false; } @@ -810,12 +794,12 @@ public class CompiledSelect extends AbstractCompiledValue { if (addToResults) { int occurence = applyProjectionAndAddToResultSet(context, results, this.orderByAttrs == null); - // Asif: If the occurence is greater than 1, then only in case of + // If the occurence is greater than 1, then only in case of // non distinct query should it be treated as contributing to size // else duplication will be eliminated when making it distinct using // ResultsCollectionWrapper and we will fall short of limit if (occurence == 1 || (occurence > 1 && !this.distinct)) { - // Asif: (Unique i.e first time occurence) or subsequent occurence + // (Unique i.e first time occurence) or subsequent occurence // for non distinct query ++numElementsInResult; } @@ -871,7 +855,7 @@ public class CompiledSelect extends AbstractCompiledValue { NameResolutionException, QueryInvocationTargetException { List iterators = context.getCurrentIterators(); if (projAttrs == null && (this.orderByAttrs == null || ignoreOrderBy)) { - // Asif : If the projection attribute is null( ie.e specified as *) & + // If the projection attribute is null( ie.e specified as *) & // there is only one // Runtime Iteratir we can return the set as it is.But if the proejction // attribute is null & multiple Iterators are defined we need to rectify @@ -909,7 +893,7 @@ public class CompiledSelect extends AbstractCompiledValue { } int occurence = applyProjectionAndAddToResultSet(context, pResultSet, ignoreOrderBy); if (occurence == 1 || (occurence > 1 && !this.distinct)) { - // Asif: (Unique i.e first time occurence) or subsequent occurence + // (Unique i.e first time occurence) or subsequent occurence // for non distinct query ++numElementsAdded; } @@ -925,7 +909,7 @@ public class CompiledSelect extends AbstractCompiledValue { rIter.setCurrent(resultsIter.next()); int occurence = applyProjectionAndAddToResultSet(context, pResultSet, ignoreOrderBy); if (occurence == 1 || (occurence > 1 && !this.distinct)) { - // Asif: (Unique i.e first time occurence) or subsequent occurence + // (Unique i.e first time occurence) or subsequent occurence // for non distinct query ++numElementsAdded; } @@ -941,7 +925,7 @@ public class CompiledSelect extends AbstractCompiledValue { private SelectResults prepareEmptyResultSet(ExecutionContext context, boolean ignoreOrderBy) throws TypeMismatchException, AmbiguousNameException { - // Asif:if no projection attributes or '*'as projection attribute + // if no projection attributes or '*'as projection attribute // & more than one/RunTimeIterator then create a StrcutSet. // If attribute is null or '*' & only one RuntimeIterator then create a // ResultSet. @@ -969,7 +953,7 @@ public class CompiledSelect extends AbstractCompiledValue { context) : new OrderByComparator(this.orderByAttrs, (StructTypeImpl) elementType, context); results = this.distinct ? new SortedStructSet(comparator, (StructTypeImpl) elementType) - : new SortedStructBag(comparator, (StructTypeImpl) elementType, nullValuesAtStart); + : new SortedStructBag(comparator, (StructType) elementType, nullValuesAtStart); } } else { @@ -1018,7 +1002,7 @@ public class CompiledSelect extends AbstractCompiledValue { protected ObjectType prepareResultType(ExecutionContext context) throws TypeMismatchException, AmbiguousNameException { - // Asif:if no projection attributes or '*'as projection attribute + // if no projection attributes or '*'as projection attribute // & more than one/RunTimeIterator then create a StrcutSet. // If attribute is null or '*' & only one RuntimeIterator then create a // ResultSet. @@ -1069,22 +1053,9 @@ public class CompiledSelect extends AbstractCompiledValue { return elementType; } - /* - * private SelectResults prepareEmptySelectResults(ObjectType elementType, boolean isSorted, - * ExecutionContext context) { if (elementType.isStructType()) { if (isSorted) { // sorted struct - * return prepareEmptySortedStructSet((StructTypeImpl)elementType); } else { // unsorted struct - * return new StructBag((StructType)elementType, context.getCachePerfStats()); } } else { // - * non-struct if (isSorted) { // sorted non-struct return - * prepareEmptySortedResultSet(elementType); } else { // unsorted non-struct return new - * ResultsBag(elementType, context.getCachePerfStats()); } } } - */ - - - /** - * Asif: This function should be used to create a StructType for those queries which have * as + * This function should be used to create a StructType for those queries which have * as * projection attribute (implying null projection attribute) & multiple from clauses - * */ private StructTypeImpl createStructTypeForNullProjection(List currentIterators, ExecutionContext context) { @@ -1112,23 +1083,22 @@ public class CompiledSelect extends AbstractCompiledValue { RuntimeIterator rit = context.findRuntimeIterator(cv); List pathOnItr = cv.getPathOnIterator(rit, context); if (pathOnItr != null) { - String path[] = (String[]) pathOnItr.toArray(new String[0]); + String path[] = (String[]) pathOnItr.toArray(new String[pathOnItr.size()]); ObjectType ot[] = PathUtils.calculateTypesAlongPath(rit.getElementType(), path); retType = ot[ot.length - 1]; } - } catch (NameNotFoundException e) { + } catch (NameNotFoundException ignore) { // Unable to determine the type Of attribute.It will default to // ObjectType } return retType; } - // resultSet could be a set or a bag (we have set constructor, or there // could be a distinct subquery) // in future, it would be good to simplify this to always work with a bag // (converting all sets to bags) until the end when we enforce distinct - // Asif: The number returned indicates the occurence of the data in the SelectResults + // The number returned indicates the occurence of the data in the SelectResults // Thus if the SelectResults is of type ResultsSet or StructSet // then 1 will indicate that data was added to the results & that was the // first occurence. For this 0 will indicate that the data was not added @@ -1138,8 +1108,6 @@ public class CompiledSelect extends AbstractCompiledValue { // Currently orderBy is present only for StructSet & ResultSet which are // unique object holders. So the occurence for them can be either 0 or 1 only - - private int applyProjectionAndAddToResultSet(ExecutionContext context, SelectResults resultSet, boolean ignoreOrderBy) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { @@ -1149,7 +1117,7 @@ public class CompiledSelect extends AbstractCompiledValue { ObjectType elementType = resultSet.getCollectionType().getElementType(); boolean isStruct = elementType != null && elementType.isStructType(); - // TODO : Asif : Optimize this condition in some clean way + // TODO: Optimize this condition in some clean way boolean isLinkedStructure = resultSet instanceof Ordered && ((Ordered) resultSet).dataPreordered(); @@ -1209,7 +1177,7 @@ public class CompiledSelect extends AbstractCompiledValue { comparator.addEvaluatedSortCriteria(values, context); occurence = ((StructFields) resultSet).addFieldValues(values) ? 1 : 0; } - // Asif: TODO:Instead of a normal Map containing which holds + // TODO:Instead of a normal Map containing which holds // StructImpl object // use a THashObject with Object[] array hashing stragtegy as we // are unnnecessarily @@ -1274,11 +1242,9 @@ public class CompiledSelect extends AbstractCompiledValue { if (!e.isDestroyed()) { try { values[0] = new CqEntry(e.getKey(), e.getValue()); - } catch (EntryDestroyedException ede) { - // Even though isDestory() check is made, the entry - // could - // throw EntryDestroyedException if the value becomes - // null. + } catch (EntryDestroyedException ignore) { + // Even though isDestory() check is made, the entry could throw + // EntryDestroyedException if the value becomes null. add = false; } } else { @@ -1321,7 +1287,7 @@ public class CompiledSelect extends AbstractCompiledValue { if (distinct) { if (isStruct) { comparator.addEvaluatedSortCriteria(values, context); - // Asif: Occurence field is used to identify the corrcet number of + // Occurence field is used to identify the corrcet number of // iterations // required to implement the limit based on the presence or absence // of distinct clause @@ -1401,23 +1367,15 @@ public class CompiledSelect extends AbstractCompiledValue { } else if (type == METHOD_INV) { name = ((CompiledOperation) projExpr).getMethodName(); } else { - name = new StringBuffer("field$").append(context.nextFieldNum()).toString(); + name = new StringBuilder("field$").append(context.nextFieldNum()).toString(); // name = projExpr.toString(); } } return name; } - /** * Optimized evaluate for CQ execution. - * - * @param context - * @return boolean - * @throws FunctionDomainException - * @throws TypeMismatchException - * @throws NameResolutionException - * @throws QueryInvocationTargetException */ public boolean evaluateCq(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { @@ -1456,7 +1414,7 @@ public class CompiledSelect extends AbstractCompiledValue { } else if (b == QueryService.UNDEFINED) { // add UNDEFINED to results only for NOT EQUALS queries if (this.whereClause.getType() == COMPARISON) { - int operator = ((CompiledComparison) this.whereClause).getOperator(); + int operator = ((Filter) this.whereClause).getOperator(); if ((operator != TOK_NE && operator != TOK_NE_ALT)) { return false; } else { @@ -1466,7 +1424,7 @@ public class CompiledSelect extends AbstractCompiledValue { return false; } } else { - return (((Boolean) b).booleanValue()); + return (Boolean) b; } } finally { context.popExecCache(); http://git-wip-us.apache.org/repos/asf/geode/blob/640b9f03/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledSortCriterion.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledSortCriterion.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledSortCriterion.java index 5268b1c..d49b4a5 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledSortCriterion.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledSortCriterion.java @@ -12,10 +12,13 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ - package org.apache.geode.cache.query.internal; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; import org.apache.geode.cache.CacheException; import org.apache.geode.cache.query.AmbiguousNameException; @@ -28,14 +31,16 @@ import org.apache.geode.cache.query.internal.types.TypeUtils; /** * This class represents a compiled form of sort criterian present in order by clause - * */ public class CompiledSortCriterion extends AbstractCompiledValue { - // Asif: criterion true indicates descending order + + // criterion true indicates descending order private boolean criterion = false; + private CompiledValue expr = null; + int columnIndex = -1; - // private String correctedCanonicalizedExpression = null; + private CompiledValue originalCorrectedExpression = null; @Override @@ -43,20 +48,13 @@ public class CompiledSortCriterion extends AbstractCompiledValue { return Collections.singletonList(this.originalCorrectedExpression); } - /** - * @return int - */ public int getType() { return SORT_CRITERION; } /** * evaluates sort criteria in order by clause - * - * @param context - * @return Object */ - public Object evaluate(Object data, ExecutionContext context) { Object value = null; if (this.columnIndex > 0) { @@ -74,17 +72,11 @@ public class CompiledSortCriterion extends AbstractCompiledValue { try { return this.expr.evaluate(context); } catch (Exception e) { + // TODO: never throw an anonymous inner class throw new CacheException(e) {}; } - } - /** - * concstructor - * - * @param criterion - * @param cv - */ CompiledSortCriterion(boolean criterion, CompiledValue cv) { this.expr = cv; this.criterion = criterion; @@ -103,11 +95,6 @@ public class CompiledSortCriterion extends AbstractCompiledValue { return this.columnIndex; } - /* - * public String getCorrectedCanonicalizedExpression() { return - * this.correctedCanonicalizedExpression; } - */ - @Override public Object evaluate(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { @@ -128,7 +115,7 @@ public class CompiledSortCriterion extends AbstractCompiledValue { private CompiledValue getReconstructedExpression(String projAttribStr, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { List<CompiledValue> expressions = PathUtils.collectCompiledValuesInThePath(expr, context); - StringBuffer tempBuff = new StringBuffer(); + StringBuilder tempBuff = new StringBuilder(); ListIterator<CompiledValue> listIter = expressions.listIterator(expressions.size()); while (listIter.hasPrevious()) { listIter.previous().generateCanonicalizedExpression(tempBuff, context); @@ -152,20 +139,20 @@ public class CompiledSortCriterion extends AbstractCompiledValue { prevCV = cv; switch (cv.getType()) { - case CompiledOperation.METHOD_INV: + case OQLLexerTokenTypes.METHOD_INV: reconstruct.add(0, ((CompiledOperation) cv).getArguments()); reconstruct.add(0, ((CompiledOperation) cv).getMethodName()); break; - case CompiledPath.PATH: + case CompiledValue.PATH: reconstruct.add(0, ((CompiledPath) cv).getTailID()); break; - case CompiledIndexOperation.TOK_LBRACK: + case OQLLexerTokenTypes.TOK_LBRACK: reconstruct.add(0, ((CompiledIndexOperation) cv).getExpression()); break; default: throw new IllegalStateException("Unexpected CompiledValue in order by clause"); } - reconstruct.add(0, Integer.valueOf(prevCV.getType())); + reconstruct.add(0, prevCV.getType()); cv = expressions.get(++index); } while (prevCV != cvToRetainTill); @@ -173,7 +160,7 @@ public class CompiledSortCriterion extends AbstractCompiledValue { Iterator<Object> iter = reconstruct.iterator(); CompiledValue currentValue = ProjectionField.getProjectionField(); while (iter.hasNext()) { - int type = ((Integer) iter.next()).intValue(); + int type = (Integer) iter.next(); switch (type) { case CompiledValue.PATH: currentValue = new CompiledPath(currentValue, (String) iter.next()); @@ -214,7 +201,8 @@ public class CompiledSortCriterion extends AbstractCompiledValue { } if (!mappedColumn) { // the order by expr is not an alias check for path - StringBuffer orderByExprBuffer = new StringBuffer(), projAttribBuffer = new StringBuffer(); + StringBuilder orderByExprBuffer = new StringBuilder(), + projAttribBuffer = new StringBuilder(); expr.generateCanonicalizedExpression(orderByExprBuffer, context); final String orderByExprStr = orderByExprBuffer.toString(); for (int i = 0; i < projAttrs.size(); ++i) { @@ -243,12 +231,12 @@ public class CompiledSortCriterion extends AbstractCompiledValue { RuntimeIterator runtimeIter = (RuntimeIterator) currentIters.get(i); if (runtimeIter == rIter) { /* this.substituteExpressionWithProjectionField( i); */ - StringBuffer temp = new StringBuffer(); + StringBuilder temp = new StringBuilder(); rIter.generateCanonicalizedExpression(temp, context); // this.correctedCanonicalizedExpression = temp.toString(); /* mappedColumn = true; */ String projAttribStr = temp.toString(); - temp = new StringBuffer(); + temp = new StringBuilder(); expr.generateCanonicalizedExpression(temp, context); String orderbyStr = temp.toString(); if (projAttribStr.equals(orderbyStr)) { @@ -277,7 +265,6 @@ public class CompiledSortCriterion extends AbstractCompiledValue { public Object evaluate(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { return context.getCurrentProjectionField(); - } @Override @@ -288,7 +275,5 @@ public class CompiledSortCriterion extends AbstractCompiledValue { public static ProjectionField getProjectionField() { return singleton; } - } - } http://git-wip-us.apache.org/repos/asf/geode/blob/640b9f03/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledUndefined.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledUndefined.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledUndefined.java index 9cce2f2..0a8b129 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledUndefined.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledUndefined.java @@ -17,7 +17,6 @@ package org.apache.geode.cache.query.internal; import java.util.*; import org.apache.geode.cache.query.*; -import org.apache.geode.cache.query.internal.IndexInfo; import org.apache.geode.cache.query.internal.index.IndexData; import org.apache.geode.cache.query.internal.index.IndexProtocol; import org.apache.geode.cache.query.internal.index.IndexUtils; @@ -100,7 +99,7 @@ public class CompiledUndefined extends AbstractCompiledValue implements Negatabl } finally { observer.afterIndexLookup(set); } - return QueryUtils.getconditionedIndexResults(set, idxInfo[0], context, indexFieldsSize, + return QueryUtils.getConditionedIndexResults(set, idxInfo[0], context, indexFieldsSize, completeExpansionNeeded, iterOperands, indpndntItrs); } @@ -224,7 +223,7 @@ public class CompiledUndefined extends AbstractCompiledValue implements Negatabl } @Override - public void generateCanonicalizedExpression(StringBuffer clauseBuffer, ExecutionContext context) + public void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { clauseBuffer.insert(0, ')'); _value.generateCanonicalizedExpression(clauseBuffer, context); http://git-wip-us.apache.org/repos/asf/geode/blob/640b9f03/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledValue.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledValue.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledValue.java index 9da575d..4747980 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledValue.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledValue.java @@ -27,56 +27,51 @@ import org.apache.geode.distributed.internal.DistributionConfig; import java.util.List; import java.util.Set; -/** - * Class Description - * - * @version $Revision: 1.1 $ - */ public interface CompiledValue { - // extra node types: use negative numbers so they don't collide with token - // types - public final static int COMPARISON = -1; - public final static int FUNCTION = -2; - public final static int JUNCTION = -3; - public final static int LITERAL = -4; - public final static int PATH = -5; - public final static int CONSTRUCTION = -6; - public final static int GROUPJUNCTION = -7; - public final static int ALLGROUPJUNCTION = -8; - public final static int COMPOSITEGROUPJUNCTION = -10; - public final static int RANGEJUNCTION = -11; - public final static int NOTEQUALCONDITIONEVALUATOR = -12; - public final static int SINGLECONDNEVALUATOR = -13; - public final static int DOUBLECONDNRANGEJUNCTIONEVALUATOR = -14; - public final static int LIKE = -15; - public final static int FIELD = -16; - public final static int GROUP_BY_SELECT = -17; - public static final int INDEX_RESULT_THRESHOLD_DEFAULT = 100; - public static final String INDX_THRESHOLD_PROP_STR = - DistributionConfig.GEMFIRE_PREFIX + "Query.INDEX_THRESHOLD_SIZE"; - public static final String INDEX_INFO = "index_info"; - public static final int indexThresholdSize = - Integer.getInteger(INDX_THRESHOLD_PROP_STR, INDEX_RESULT_THRESHOLD_DEFAULT).intValue(); - public static final String RESULT_TYPE = "result_type"; - public static final String PROJ_ATTRIB = "projection"; - public static final String ORDERBY_ATTRIB = "orderby"; - public static final IndexInfo[] NO_INDEXES_IDENTIFIER = new IndexInfo[0]; - public static final String RESULT_LIMIT = "limit"; - public static final String CAN_APPLY_LIMIT_AT_INDEX = "can_apply_limit_at_index"; - public static final String CAN_APPLY_ORDER_BY_AT_INDEX = "can_apply_orderby_at_index"; - public static final String PREF_INDEX_COND = "preferred_index_condition"; - public static final String QUERY_INDEX_HINTS = "query_index_hints"; - public static final CompiledValue MAP_INDEX_ALL_KEYS = new AbstractCompiledValue() { - + // extra node types: use negative numbers so they don't collide with token types + int COMPARISON = -1; + int FUNCTION = -2; + int JUNCTION = -3; + int LITERAL = -4; + int PATH = -5; + int CONSTRUCTION = -6; + int GROUPJUNCTION = -7; + int ALLGROUPJUNCTION = -8; + int COMPOSITEGROUPJUNCTION = -10; + int RANGEJUNCTION = -11; + int NOTEQUALCONDITIONEVALUATOR = -12; + int SINGLECONDNEVALUATOR = -13; + int DOUBLECONDNRANGEJUNCTIONEVALUATOR = -14; + int LIKE = -15; + int FIELD = -16; + int GROUP_BY_SELECT = -17; + int INDEX_RESULT_THRESHOLD_DEFAULT = 100; + String INDX_THRESHOLD_PROP_STR = DistributionConfig.GEMFIRE_PREFIX + "Query.INDEX_THRESHOLD_SIZE"; + String INDEX_INFO = "index_info"; + int indexThresholdSize = + Integer.getInteger(INDX_THRESHOLD_PROP_STR, INDEX_RESULT_THRESHOLD_DEFAULT); + String RESULT_TYPE = "result_type"; + String PROJ_ATTRIB = "projection"; + String ORDERBY_ATTRIB = "orderby"; + IndexInfo[] NO_INDEXES_IDENTIFIER = new IndexInfo[0]; + String RESULT_LIMIT = "limit"; + String CAN_APPLY_LIMIT_AT_INDEX = "can_apply_limit_at_index"; + String CAN_APPLY_ORDER_BY_AT_INDEX = "can_apply_orderby_at_index"; + String PREF_INDEX_COND = "preferred_index_condition"; + String QUERY_INDEX_HINTS = "query_index_hints"; + + CompiledValue MAP_INDEX_ALL_KEYS = new AbstractCompiledValue() { @Override - public void generateCanonicalizedExpression(StringBuffer clauseBuffer, ExecutionContext context) + public void generateCanonicalizedExpression(StringBuilder clauseBuffer, + ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { throw new QueryInvalidException( "* cannot be used with index operator. To use as key for map lookup, " + "it should be enclosed in ' '"); } + @Override public Object evaluate(ExecutionContext context) { throw new QueryInvalidException( "* cannot be used with index operator. To use as key for map lookup, " @@ -88,39 +83,39 @@ public interface CompiledValue { return super.getReceiver(); } + @Override public int getType() { return OQLLexerTokenTypes.TOK_STAR; } - }; - public int getType(); + int getType(); - public ObjectType getTypecast(); + ObjectType getTypecast(); - public Object evaluate(ExecutionContext context) throws FunctionDomainException, - TypeMismatchException, NameResolutionException, QueryInvocationTargetException; + Object evaluate(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, + NameResolutionException, QueryInvocationTargetException; - // returns null if N/A - public List getPathOnIterator(RuntimeIterator itr, ExecutionContext context) + /** + * returns null if N/A + */ + List getPathOnIterator(RuntimeIterator itr, ExecutionContext context) throws TypeMismatchException, AmbiguousNameException; - public PlanInfo getPlanInfo(ExecutionContext context) throws FunctionDomainException, + PlanInfo getPlanInfo(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException; - public Set computeDependencies(ExecutionContext context) + Set computeDependencies(ExecutionContext context) throws TypeMismatchException, AmbiguousNameException, NameResolutionException; - public boolean isDependentOnIterator(RuntimeIterator itr, ExecutionContext context); + boolean isDependentOnIterator(RuntimeIterator itr, ExecutionContext context); - public boolean isDependentOnCurrentScope(ExecutionContext context); + boolean isDependentOnCurrentScope(ExecutionContext context); /** * general-purpose visitor (will be used for extracting region path) */ - // public boolean visit(QVisitor visitor); - // Asif :Function for generating from clause - public void generateCanonicalizedExpression(StringBuffer clauseBuffer, ExecutionContext context) + void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException; /** @@ -128,18 +123,17 @@ public interface CompiledValue { * object (CompiledRegion). The default implementation is provided in the AbstractCompiledValue & * overridden in the CompiledSelect as it can contain multiple iterators */ - public void getRegionsInQuery(Set regionNames, Object[] parameters); + void getRegionsInQuery(Set regionNames, Object[] parameters); /** Get the CompiledValues that this owns */ - public List getChildren(); + List getChildren(); - public void visitNodes(NodeVisitor visitor); + void visitNodes(NodeVisitor visitor); - public static interface NodeVisitor { + interface NodeVisitor { /** @return true to continue or false to stop */ - public boolean visit(CompiledValue node); + boolean visit(CompiledValue node); } - public CompiledValue getReceiver(); - + CompiledValue getReceiver(); }