for (int j = 0; j < input.length; j++) {
input[j] = q.getChildAt(j).getResult();
}
} else {
//Leaves
GraphView newView = graphModel.newView();
views.add(newView);
input = new Graph[]{graphModel.getGraph(newView)}; //duplicate root
}
//PROCESS
if (q instanceof OperatorQueryImpl && !((OperatorQueryImpl) q).isSimple()) {
OperatorQueryImpl operatorQuery = (OperatorQueryImpl) q;
Operator op = (Operator) operatorQuery.getFilter();
q.setResult(op.filter(input));
} else if (q instanceof OperatorQueryImpl && ((OperatorQueryImpl) q).isSimple()) {
OperatorQueryImpl operatorQuery = (OperatorQueryImpl) q;
Operator op = (Operator) operatorQuery.getFilter();
Filter[] filters = new Filter[operatorQuery.getChildrenCount()];
for (int k = 0; k < filters.length; k++) {
filters[k] = operatorQuery.getChildAt(k).getFilter();
}
GraphView newView = graphModel.newView();
views.add(newView);
q.setResult(op.filter(graphModel.getGraph(newView), filters));
} else {
FilterQueryImpl filterQuery = (FilterQueryImpl) q;
Filter filter = filterQuery.getFilter();
if (filter instanceof NodeFilter && filter instanceof EdgeFilter) {
processNodeFilter((NodeFilter) filter, input[0]);
processEdgeFilter((EdgeFilter) filter, input[0]);
q.setResult(input[0]);
} else if (filter instanceof NodeFilter) {
processNodeFilter((NodeFilter) filter, input[0]);
q.setResult(input[0]);
} else if (filter instanceof EdgeFilter) {
processEdgeFilter((EdgeFilter) filter, input[0]);
q.setResult(input[0]);
} else if (filter instanceof ComplexFilter) {
ComplexFilter cf = (ComplexFilter) filter;
q.setResult(cf.filter(input[0]));
} else {
q.setResult(input[0]); //Put input as result, the filter don't do anything
}
}
}
Graph finalResult = tree[0].result;
//Destroy intermediate views
GraphView finalView = finalResult.getView();
for (GraphView v : views) {
if (v != finalView) {
graphModel.destroyView(v);
}
}