use of org.teiid.query.processor.relational.SubqueryAwareEvaluator.SubqueryState in project teiid by teiid.
the class AccessNode method openInternal.
private void openInternal() throws TeiidComponentException, TeiidProcessingException {
// TODO: support a partitioning concept with multi-source and full dependent join pushdown
if (subPlans != null) {
if (this.evaluatedPlans == null) {
this.evaluatedPlans = new HashMap<GroupSymbol, SubqueryState>();
for (Map.Entry<GroupSymbol, RelationalPlan> entry : subPlans.entrySet()) {
SubqueryState state = new SubqueryState();
RelationalPlan value = entry.getValue();
value.reset();
state.processor = new QueryProcessor(value, getContext().clone(), getBufferManager(), getDataManager());
state.collector = state.processor.createBatchCollector();
this.evaluatedPlans.put(entry.getKey(), state);
}
}
BlockedException be = null;
for (SubqueryState state : evaluatedPlans.values()) {
try {
state.collector.collectTuples();
} catch (BlockedException e) {
be = e;
}
}
if (be != null) {
throw be;
}
}
/*
* Check to see if we need a multi-source expansion. If the connectorBindingExpression != null, then
* the logic below will handle that case
*/
if (multiSource && connectorBindingExpression == null) {
synchronized (this) {
// the description can be obtained asynchly, so we need to synchronize
VDBMetaData vdb = getContext().getVdb();
ModelMetaData model = vdb.getModel(getModelName());
List<String> sources = model.getSourceNames();
// make sure that we have the right nodes
if (this.getChildCount() != 0 && (this.sourceNames == null || !this.sourceNames.equals(sources))) {
this.childCount--;
this.getChildren()[0] = null;
}
if (this.getChildCount() == 0) {
sourceNames = sources;
RelationalNode node = multiSourceModify(this, connectorBindingExpression, getContext().getMetadata(), sourceNames);
RelationalPlan.connectExternal(node, getContext(), getDataManager(), getBufferManager());
this.addChild(node);
}
}
this.getChildren()[0].open();
return;
}
// Copy command and resolve references if necessary
if (processingCommand == null) {
processingCommand = command;
isUpdate = RelationalNodeUtil.isUpdate(command);
}
boolean needProcessing = true;
if (this.connectorBindingExpression != null && connectorBindingId == null) {
this.connectorBindingId = (String) getEvaluator(Collections.emptyMap()).evaluate(this.connectorBindingExpression, null);
VDBMetaData vdb = getContext().getVdb();
ModelMetaData model = vdb.getModel(getModelName());
List<String> sources = model.getSourceNames();
String replacement = this.connectorBindingId;
if (!sources.contains(this.connectorBindingId)) {
shouldExecute = false;
if (command instanceof StoredProcedure) {
StoredProcedure sp = (StoredProcedure) command;
if (sp.returnParameters() && sp.getProjectedSymbols().size() > sp.getResultSetColumns().size()) {
throw new TeiidProcessingException(QueryPlugin.Event.TEIID30561, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30561, command));
}
}
return;
}
if (!(command instanceof StoredProcedure || command instanceof Insert)) {
processingCommand = (Command) command.clone();
MultiSourceElementReplacementVisitor.visit(replacement, getContext().getMetadata(), processingCommand);
}
}
do {
Command atomicCommand = nextCommand();
if (shouldEvaluate) {
needProcessing = prepareNextCommand(atomicCommand);
nextCommand = null;
} else {
needProcessing = RelationalNodeUtil.shouldExecute(atomicCommand, true);
}
if (needProcessing) {
registerRequest(atomicCommand);
}
// We use an upper limit here to the currency because these commands have potentially large in-memory value sets
} while (!processCommandsIndividually() && hasNextCommand() && this.tupleSources.size() < Math.max(Math.min(MAX_CONCURRENT, this.getContext().getUserRequestSourceConcurrency()), this.getContext().getUserRequestSourceConcurrency() / 2));
}
use of org.teiid.query.processor.relational.SubqueryAwareEvaluator.SubqueryState in project teiid by teiid.
the class AccessNode method closeDirect.
public void closeDirect() {
if (reserved > 0) {
getBufferManager().releaseBuffers(reserved);
reserved = 0;
}
if (this.evaluatedPlans != null) {
for (SubqueryState state : this.evaluatedPlans.values()) {
state.close(true);
}
this.evaluatedPlans = null;
}
super.closeDirect();
closeSources();
}
Aggregations