public CompiledValue getReceiver(ExecutionContext cxt) { // receiver may be cached in execution context if (this.receiver == null && cxt != null) { return (CompiledValue) cxt.cacheGet(this); } return this.receiver; }
/** * _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); }
private int getWildcardPosition(ExecutionContext context) { return (Integer) context.cacheGet(wildcardPositionKey, -1); }
private int getPatternLength(ExecutionContext context) { return (Integer) context.cacheGet(patternLengthKey, 0); }
private boolean getIsIndexEvaluated(ExecutionContext context) { return (Boolean) context.cacheGet(isIndexEvaluatedKey, false); }
private IndexInfo[] privGetIndexInfo(ExecutionContext context) { return (IndexInfo[]) context.cacheGet(this); }
private int getWildcardType(ExecutionContext context) { return (Integer) context.cacheGet(wildcardTypeKey, -1); }
private IndexInfo[] privGetIndexInfo(ExecutionContext context) { return (IndexInfo[]) context.cacheGet(this); }
/** Method called while appropriate lock held on index */ private void lockedQueryPrivate(Object key, int operator, Collection results, CompiledValue iterOps, RuntimeIterator runtimeItr, ExecutionContext context, Set keysToRemove, List projAttrib, SelectResults intermediateResults, boolean isIntersection) throws TypeMismatchException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException { if (keysToRemove == null) { keysToRemove = new HashSet(0); } int limit = -1; Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX); if (applyLimit != null && applyLimit) { limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT); } Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX); boolean applyOrderBy = false; List orderByAttrs = null; if (orderByClause != null && orderByClause) { orderByAttrs = (List) context.cacheGet(CompiledValue.ORDERBY_ATTRIB); CompiledSortCriterion csc = (CompiledSortCriterion) orderByAttrs.get(0); applyOrderBy = true; } evaluate(key, operator, results, iterOps, runtimeItr, context, keysToRemove, projAttrib, intermediateResults, isIntersection, limit, applyOrderBy, orderByAttrs); }
/** Method called while appropriate lock held on index */ private void lockedQueryPrivate(Object key, int operator, Collection results, CompiledValue iterOps, RuntimeIterator runtimeItr, ExecutionContext context, Set keysToRemove, List projAttrib, SelectResults intermediateResults, boolean isIntersection) throws TypeMismatchException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException { if (keysToRemove == null) { keysToRemove = new HashSet(0); } int limit = -1; Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX); if (applyLimit != null && applyLimit) { limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT); } Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX); boolean applyOrderBy = false; List orderByAttrs = null; if (orderByClause != null && orderByClause) { orderByAttrs = (List) context.cacheGet(CompiledValue.ORDERBY_ATTRIB); CompiledSortCriterion csc = (CompiledSortCriterion) orderByAttrs.get(0); applyOrderBy = true; } if (isEmpty()) { return; } key = getPdxStringForIndexedPdxKeys(key); evaluate(key, operator, results, iterOps, runtimeItr, context, keysToRemove, projAttrib, intermediateResults, isIntersection, limit, applyOrderBy, orderByAttrs); }
@Override protected PlanInfo protGetPlanInfo(ExecutionContext context) throws TypeMismatchException, AmbiguousNameException, NameResolutionException { PlanInfo result = new PlanInfo(); IndexInfo[] indexInfo = getIndexInfo(context); if (indexInfo == null) return result; for (int i = 0; i < indexInfo.length; ++i) { result.indexes.add(indexInfo[i]._index); } result.evalAsFilter = true; String preferredCondn = (String) context.cacheGet(PREF_INDEX_COND); if (preferredCondn != null) { // This means that the system is having only one independent iterator so equi join is ruled // out. // thus the first index is guaranteed to be on the condition which may match our preferred // index if (indexInfo[0]._index.getCanonicalizedIndexedExpression().equals(preferredCondn) && indexInfo[0]._index.getType() != IndexType.PRIMARY_KEY) { result.isPreferred = true; } } return result; }
public SelectResults getEmptyResultSet(Object[] parameters, InternalCache cache, Query query) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { ExecutionContext context = new QueryExecutionContext(parameters, cache, query); computeDependencies(context); context.newScope((Integer) context.cacheGet(scopeID)); context.pushExecCache((Integer) context.cacheGet(scopeID)); SelectResults results = null; try { Iterator iter = iterators.iterator(); while (iter.hasNext()) { CompiledIteratorDef iterDef = (CompiledIteratorDef) iter.next(); RuntimeIterator rIter = iterDef.getRuntimeIterator(context); context.bindIterator(rIter); } results = prepareEmptyResultSet(context, false); } finally { context.popScope(); context.popExecCache(); } return results; }
Pattern pattern = (Pattern) context.cacheGet(this.bindArg); if (pattern == null) { String strPattern = this.bindArg.evaluate(context).toString(); // handles both Strings and
/** * Invariant: the receiver is dependent on the current iterator. */ @Override protected PlanInfo protGetPlanInfo(ExecutionContext context) throws TypeMismatchException, AmbiguousNameException, NameResolutionException { PlanInfo result = new PlanInfo(); IndexInfo[] indexInfo = getIndexInfo(context); if (indexInfo == null) return result; for (int i = 0; i < indexInfo.length; ++i) { result.indexes.add(indexInfo[i]._index); } result.evalAsFilter = true; String preferredCondn = (String) context.cacheGet(PREF_INDEX_COND); if (preferredCondn != null) { // This means that the system is having only one independent iterator so equi join is ruled // out. // thus the first index is guaranteed to be on the condition which may match our preferred // index if (indexInfo[0]._index.getCanonicalizedIndexedExpression().equals(preferredCondn) && (indexInfo[0]._index.getType() == IndexType.FUNCTIONAL || indexInfo[0]._index.getType() == IndexType.HASH)) { result.isPreferred = true; } } return result; }
IndexCutDownExpansionHelper(List checkList, ExecutionContext context) { cutDownNeeded = checkList != null && (checkSize = checkList.size()) > 0; if (cutDownNeeded) { Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX); boolean useLinkedDataStructure = false; boolean nullValuesAtStart = true; if (orderByClause != null && orderByClause) { List orderByAttrs = (List) context.cacheGet(CompiledValue.ORDERBY_ATTRIB); useLinkedDataStructure = orderByAttrs.size() == 1; nullValuesAtStart = !((CompiledSortCriterion) orderByAttrs.get(0)).getCriterion();
/** * 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 * where c.status = 'preferred') The sub query would create a set that would not change and store * it into the context if it does not yet exist */ private Object evaluateColln(ExecutionContext context) throws QueryInvocationTargetException, NameResolutionException, TypeMismatchException, FunctionDomainException { Object evalColln = null; if (this.colln.isDependentOnCurrentScope(context)) { evalColln = this.colln.evaluate(context); } else { evalColln = context.cacheGet(this.colln); if (evalColln == null) { evalColln = this.colln.evaluate(context); context.cachePut(this.colln, evalColln); } } return evalColln; }
Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX); if (orderByClause != null && orderByClause) { List orderByAttrs = (List) context.cacheGet(CompiledValue.ORDERBY_ATTRIB); useLinkedDataStructure = orderByAttrs.size() == 1; nullValuesAtStart = !((CompiledSortCriterion) orderByAttrs.get(0)).getCriterion();
Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX); boolean multiColOrderBy = false; List orderByAttrs = null; boolean asc = true; if (orderByClause != null && orderByClause) { orderByAttrs = (List) context.cacheGet(CompiledValue.ORDERBY_ATTRIB); CompiledSortCriterion csc = (CompiledSortCriterion) orderByAttrs.get(0); asc = !csc.getCriterion();
(Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX); context.cachePut(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX, Boolean.FALSE); Boolean originalCanApplyOrderBy = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX); context.cachePut(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX, Boolean.FALSE);