private void createProcessor() throws TeiidComponentException { if (this.userCommand instanceof CreateProcedureCommand && this.processPlan instanceof ProcedurePlan) { ((ProcedurePlan)this.processPlan).setValidateAccess(true); } this.context.setTransactionContext(getTransactionContext(true)); this.processor = new QueryProcessor(processPlan, context, bufferManager, processorDataManager); }
@Override public void close() throws TeiidComponentException { closeProcessing(); }
private void setWarnings(ResultsMessage response) { boolean sanitize = this.options.isSanitizeMessages() && !LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL); // send any warnings with the response object List<Throwable> responseWarnings = new ArrayList<Throwable>(); if (this.processor != null) { List<Exception> currentWarnings = processor.getAndClearWarnings(); if (currentWarnings != null) { if (sanitize) { for (Exception e : currentWarnings) { responseWarnings.add(ExceptionUtil.sanitize(e, false)); } } else { responseWarnings.addAll(currentWarnings); } } } response.setWarnings(responseWarnings); }
void close(boolean removeBuffer) { if (processor == null) { return; } processor.requestCanceled(); processor.closeProcessing(); //check that the collector has it's own buffer if (removeBuffer && collector.getTupleBuffer() != null) { collector.getTupleBuffer().remove(); } processor = null; } }
if (workingQp == null) { recursive.reset(); workingQp = new QueryProcessor(recursive, this.queryProcessor.getContext().clone(), this.queryProcessor.getBufferManager(), this.queryProcessor.getProcessorDataManager()); this.iterator = new BatchProducerTupleSource(workingQp); throw new TeiidProcessingException(QueryPlugin.Event.TEIID31158, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31158, maxIterations, tempTable.getMetadataId().getName())); this.workingQp.closeProcessing(); this.workingQp = null;
@Override public void open() throws TeiidComponentException, TeiidProcessingException { TransactionContext tc = this.getContext().getTransactionContext(); if (tc != null && tc.getTransactionType() == Scope.NONE && queryPlan != null && !Boolean.FALSE.equals(queryPlan.requiresTransaction(false))) { //start a transaction - if not each of the row plans will //be executed in it's own transaction, which is bad for performance //TODO: should probably allow non-atomic row plans //the parser accepts a trigger block without atomic //but the spec mandates it - and we treat it as atomic //either way //TODO: for non-transactional environments this will //trigger an error this.getContext().getTransactionServer().begin(tc); this.planContext = tc; } if (queryPlan != null) { queryProcessor = new QueryProcessor(queryPlan, getContext().clone(), this.bufferMgr, this.dataMgr); batchCollector = queryProcessor.createBatchCollector(); } }
init(); long currentTime = System.currentTimeMillis(); Assertion.assertTrue(!processorClosed); List<Object> terminationTuple = Arrays.asList(new Object[this.getOutputElements().size()]); result.getTuples().add(terminationTuple); this.context.getTupleSourceCache().close(); throw e; } catch (TeiidException e) { closeProcessing(); if (e instanceof TeiidProcessingException) { throw (TeiidProcessingException)e; closeProcessing(); RequestWorkItem workItem = this.getContext().getWorkItem(); if (workItem != null) {
boolean deterministic = true; if (state.processor != null && correlatedRefs != null) { Determinism determinism = state.processor.getContext().getDeterminismLevel(); deterministic = Determinism.COMMAND_DETERMINISTIC.compareTo(determinism) <= 0; Determinism determinism = state.processor.getContext().getDeterminismLevel(); deterministic = Determinism.COMMAND_DETERMINISTIC.compareTo(determinism) <= 0; if (deterministic) { CommandContext subContext = context.clone(); state.plan.reset(); state.processor = new QueryProcessor(state.plan, subContext, manager, this.dataMgr); if (currentContext != null) { state.processor.getContext().pushVariableContext(currentContext); state.collector = state.processor.createBatchCollector();
if (this.currentState != null && this.currentState.processor.getProcessorPlan() != command) { state = new CursorState(); state.usesLocalTemp = usesLocalTemp; state.processor = new QueryProcessor(command, subContext, this.bufferMgr, this); state.ts = new BatchIterator(state.processor); if (mode == Mode.HOLD && procAssignments != null && state.processor.getOutputElements().size() - procAssignments.size() > 0) { state.resultsBuffer = bufferMgr.createTupleBuffer(state.processor.getOutputElements().subList(0, state.processor.getOutputElements().size() - procAssignments.size()), getContext().getConnectionId(), TupleSourceType.PROCESSOR); } else if ((this.blockContext != null || this.programs.peek().isTrappingExceptions()) && (mode == Mode.HOLD || rsName != null)) { state.resultsBuffer = bufferMgr.createTupleBuffer(state.processor.getOutputElements(), getContext().getConnectionId(), TupleSourceType.PROCESSOR); continue; int index = this.currentState.processor.getOutputElements().indexOf(entry.getKey()); getCurrentVariableContext().setValue(entry.getValue(), DataTypeManager.transformValue(this.currentState.currentRow.get(index), entry.getValue().getType()));
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager); processor.setNonBlocking(true); BatchCollector collector = processor.createBatchCollector(); TupleBuffer id = collector.collectTuples();
@Override protected TupleSource createTupleSource() throws TeiidComponentException, TeiidProcessingException { TupleBuffer tb = bc.collectTuples(); CachedResults cr = new CachedResults(); cr.setResults(tb, qp.getProcessorPlan()); Determinism determinismLevel = qp.getContext().getDeterminismLevel(); if (hint != null && hint.getDeterminism() != null) { LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified the query determinism from ",determinismLevel, " to ", hint.getDeterminism() }); //$NON-NLS-1$ //$NON-NLS-2$ determinismLevel = hint.getDeterminism(); } cache.put(cid, determinismLevel, cr, hint != null?hint.getTtl():null); context.setDeterminismLevel(determinismLevel); success = true; return tb.createIndexedTupleSource(); }
this.tupleSource = new BatchIterator(internalProcessor); if (openOnly) { internalProcessor.init(); TupleSource result = this.dataManager.registerRequest(this.internalProcessor.getContext(), insert, TempMetadataAdapter.TEMP_MODEL.getName(), new RegisterRequestParameter()); result.nextTuple(); doneLoading = true; internalProcessor.closeProcessing(); AlterTempTable att = new AlterTempTable(tempTable); this.dataManager.registerRequest(this.internalProcessor.getContext(), att, TempMetadataAdapter.TEMP_MODEL.getName(), new RegisterRequestParameter()); this.tupleSource = this.dataManager.registerRequest(this.internalProcessor.getContext(), this.resultInfo.getTempSelect(), TempMetadataAdapter.TEMP_MODEL.getName(), new RegisterRequestParameter()); this.dataManager.registerRequest(this.internalProcessor.getContext(), att, TempMetadataAdapter.TEMP_MODEL.getName(), new RegisterRequestParameter());
@Test public void testCloseBeforeInitialization() throws TeiidComponentException { BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager(); FakeDataManager dataManager = new FakeDataManager(); CommandContext context = new CommandContext("pid", "group", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$ QueryProcessor processor = new QueryProcessor(null, context, bufferMgr, dataManager); processor.closeProcessing(); }
/** * Close the executor and release all the resources. */ public void close() throws TeiidComponentException { this.internalProcessor.closeProcessing(); if (this.tupleSource != null) { this.tupleSource.closeSource(); } String rsTempTable = this.resultInfo.getTempTable(); if (rsTempTable != null) { LogManager.logDetail(LogConstants.CTX_XML_PLAN, "Unloading result set temp table", rsTempTable); //$NON-NLS-1$ internalProcessor.closeProcessing(); try { this.tupleSource = this.dataManager.registerRequest(this.internalProcessor.getContext(), this.resultInfo.getTempDrop(), TempMetadataAdapter.TEMP_MODEL.getName(), new RegisterRequestParameter()); } catch (TeiidProcessingException e) { LogManager.logDetail(org.teiid.logging.LogConstants.CTX_XML_PLAN, e, "Error dropping result set temp table", rsTempTable); //$NON-NLS-1$ } } LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"closed executor", resultInfo.getResultSetName()}); //$NON-NLS-1$ }
this.cid = cacheId; request.processor.getContext().setDataObjects(new HashSet<Object>(4)); request.processor.getContext().setWorkItem(this); processor = request.processor; planningEnd = System.currentTimeMillis(); this.dqpCore.logMMCommand(this, Event.PLAN, null, null); collector = new BatchCollector(processor, processor.getBufferManager(), this.request.context, isForwardOnly()) { if (this.resultsBuffer == null) { resultsBuffer = this.processor.getBufferManager().createTupleBuffer(this.originalCommand.getProjectedSymbols(), this.request.context.getConnectionId(), TupleSourceType.FINAL); } else if (this.requestMsg.getRequestOptions().isContinuous()) {
/** * Get the schema from the tuple source that * represents the columns in a result set * @param rsName the ResultSet name (not a temp group) * @return List of elements * @throws QueryProcessorException if the list of elements is null */ public List getSchema(String rsName) throws TeiidComponentException { CursorState cursorState = getCursorState(rsName); // get the schema from the tuple source List schema = cursorState.processor.getOutputElements(); return schema; }
private void setAnalysisRecords(ResultsMessage response) { if(analysisRecord != null) { if (requestMsg.getShowPlan() != ShowPlan.OFF) { if (processor != null) { PlanNode node = processor.getProcessorPlan().getDescriptionProperties(); node.addProperty(AnalysisRecord.PROP_DATA_BYTES_SENT, String.valueOf(dataBytes.get())); if (planningEnd != 0) { node.addProperty(AnalysisRecord.PROP_PLANNING_TIME, String.valueOf(planningEnd - planningStart)); } response.setPlanDescription(node); } if (analysisRecord.getAnnotations() != null && !analysisRecord.getAnnotations().isEmpty()) { response.setAnnotations(analysisRecord.getAnnotations()); analysisRecord.getAnnotations().clear(); } } if (requestMsg.getShowPlan() == ShowPlan.DEBUG) { response.setDebugLog(analysisRecord.getDebugLog()); analysisRecord.stopDebugLog(); } } }
void setReferenceValues(Map<ElementSymbol, Object> referencesValues) { if (referencesValues == null || referencesValues.isEmpty()) { return; } for (Map.Entry<ElementSymbol, Object> entry : referencesValues.entrySet()) { this.internalProcessor.getContext().getVariableContext().setValue(entry.getKey(), entry.getValue()); } }
final BatchCollector bc = qp.createBatchCollector();
private void flowControl(TupleBatch batch) throws BlockedException { if (processor.hasBuffer() || batch.getTerminationFlag() || transactionState == TransactionState.ACTIVE) {