use of org.apache.geode.cache.query.internal.StructFields in project geode by apache.
the class AbstractIndex method addToStructsWithUnionOrIntersection.
private void addToStructsWithUnionOrIntersection(Collection results, SelectResults intermediateResults, boolean isIntersection, Object[] values) {
for (int i = 0; i < values.length; i++) {
values[i] = verifyAndGetPdxDomainObject(values[i]);
}
if (intermediateResults == null) {
if (results instanceof StructFields) {
((StructFields) results).addFieldValues(values);
} else {
// The results could be LinkedStructSet or SortedResultsBag or StructSet
SelectResults selectResults = (SelectResults) results;
StructImpl structImpl = new StructImpl((StructTypeImpl) selectResults.getCollectionType().getElementType(), values);
selectResults.add(structImpl);
}
} else {
if (isIntersection) {
if (results instanceof StructFields) {
int occurrences = intermediateResults.occurrences(values);
if (occurrences > 0) {
((StructFields) results).addFieldValues(values);
((StructFields) intermediateResults).removeFieldValues(values);
}
} else {
// could be LinkedStructSet or SortedResultsBag
SelectResults selectResults = (SelectResults) results;
StructImpl structImpl = new StructImpl((StructTypeImpl) selectResults.getCollectionType().getElementType(), values);
if (intermediateResults.remove(structImpl)) {
selectResults.add(structImpl);
}
}
} else {
if (results instanceof StructFields) {
((StructFields) results).addFieldValues(values);
} else {
// could be LinkedStructSet or SortedResultsBag
SelectResults selectResults = (SelectResults) results;
StructImpl structImpl = new StructImpl((StructTypeImpl) selectResults.getCollectionType().getElementType(), values);
if (intermediateResults.remove(structImpl)) {
selectResults.add(structImpl);
}
}
}
}
}
use of org.apache.geode.cache.query.internal.StructFields in project geode by apache.
the class AbstractIndex method removeProjection.
private void removeProjection(List projAttrib, ExecutionContext context, Collection result, Object iterValue, SelectResults intermediateResults, boolean isIntersection) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException {
if (projAttrib == null) {
this.removeFromResultsWithUnionOrIntersection(result, intermediateResults, isIntersection, iterValue);
} else {
if (result instanceof StructFields) {
int projCount = projAttrib.size();
Object[] values = new Object[projCount];
Iterator projIter = projAttrib.iterator();
int i = 0;
while (projIter.hasNext()) {
Object[] projDef = (Object[]) projIter.next();
values[i++] = ((CompiledValue) projDef[1]).evaluate(context);
}
this.removeFromStructsWithUnionOrIntersection(result, intermediateResults, isIntersection, values);
} else {
Object[] temp = (Object[]) projAttrib.get(0);
Object val = ((CompiledValue) temp[1]).evaluate(context);
this.removeFromResultsWithUnionOrIntersection(result, intermediateResults, isIntersection, val);
}
}
}
Aggregations