/** * Add RuntimeIterator as a dependency of a CompiledValue. ASSUMPTION: unsynchronized, assumed to * be single-threaded. * * @return the dependency set as a shortcut */ Set addDependency(CompiledValue cv, RuntimeIterator itr) { Set ds = getDependencySet(cv, false); ds.add(itr); return ds; }
/** @return the dependency set as a shortcut */ public Set addDependencies(CompiledValue cv, Set set /* <RuntimeIterator> */) { if (set.isEmpty()) return getDependencySet(cv, true); Set ds = getDependencySet(cv, false); ds.addAll(set); return ds; }
/** * Return true if given CompiledValue is dependent on specified RuntimeIterator */ boolean isDependentOn(CompiledValue cv, RuntimeIterator itr) { return getDependencySet(cv, true).contains(itr); }
/** * Return true if given CompiledValue is dependent on any RuntimeIterator in all of the scopes */ boolean isDependentOnAnyIterator(CompiledValue cv) { return !getDependencySet(cv, true).isEmpty(); }
@Override public Set computeDependencies(ExecutionContext context) throws TypeMismatchException, AmbiguousNameException, NameResolutionException { for (Iterator itr = this.args.iterator(); itr.hasNext();) { CompiledValue cv = (CompiledValue) itr.next(); context.addDependencies(this, cv.computeDependencies(context)); } return context.getDependencySet(this, true); } }
/** * Calculates set of Runtime Iterators on which a given CompiledValue ultimately depends. The * independent iterators may belong to other scopes. * <p> * This function will populate the set to its independent RuntimeIterators. However if the * CompiledValue happens to be a CompiledIteratorDef & if it is independent of any other * RuntimeIterators then no addition will be done in the Set. * <p> * TODO: the behavior of this function will change if we modify the computeDependency function of * the CompiledIteratorDef as in that case the Set will be added with the self RuntimeIterator ( * if the CompiledIteratorDef is independent) which is not the case now. * <p> * TODO: If a CompiledIteratorDef has only one dependent RuntimeIterator should it still be stored * in a Set or should it be a single value? */ void computeUltimateDependencies(CompiledValue cv, Set set) { Set dependencySet = this.getDependencySet(cv, true /* readOnly */); if (dependencySet != Collections.emptySet()) { Iterator iter = dependencySet.iterator(); RuntimeIterator rIter; while (iter.hasNext()) { rIter = (RuntimeIterator) iter.next(); Set indRuntimeIterators = (Set) this.itrDefToIndpndtRuntimeItrMap.get(rIter.getCmpIteratorDefn()); if (indRuntimeIterators != null) { set.addAll(indRuntimeIterators); } } } }
@Override public Set computeDependencies(ExecutionContext context) throws TypeMismatchException, AmbiguousNameException, NameResolutionException { int len = this._args.length; for (int i = 0; i < len; i++) { context.addDependencies(this, this._args[i].computeDependencies(context)); } return context.getDependencySet(this, true); }
@Override public Set computeDependencies(ExecutionContext context) throws TypeMismatchException, AmbiguousNameException, NameResolutionException { for (int i = 0; i < _operands.length; i++) { context.addDependencies(this, this._operands[i].computeDependencies(context)); } return context.getDependencySet(this, true); }
/** * Return true if given CompiledValue is dependent on any RuntimeIterator in current scope */ boolean isDependentOnCurrentScope(CompiledValue cv) { // return !getDependencySet(cv, true).isEmpty(); Set setRItr = getDependencySet(cv, true); boolean isDependent = false; if (!setRItr.isEmpty()) { // int currScopeID = this.scopes.size(); int currScopeID = currentScope().getScopeID(); for (Iterator itr = setRItr.iterator(); itr.hasNext();) { RuntimeIterator ritr = (RuntimeIterator) itr.next(); if (currScopeID == ritr.getScopeID()) { isDependent = true; break; } } } return isDependent; }
/** * Checks if the iterator in question is dependent on any other RuntimeIterator of its own or * lesser scope. */ boolean isDependentOnAnyIteratorOfScopeLessThanItsOwn(ExecutionContext context) { // Get the list of all iterators on which the colelction expression // is ultimately dependent on // If dependent on self then also assume it to be dependent boolean isDep = false; // Get the list of all iterators on which the colelction expression // is dependent on Set dependencySet = context.getDependencySet(this, true); Iterator itr = dependencySet.iterator(); int currScope = context.currentScope().getScopeID();// context.getScopeCount(); while (itr.hasNext()) { RuntimeIterator ritr = (RuntimeIterator) itr.next(); if (ritr.getScopeID() <= currScope) { isDep = true; break; } } return isDep; } }
} else { this.doTreeTransformation(context); return context.getDependencySet(this, true);