public void closeDirect() { try { plan.close(); } catch (TeiidComponentException e1){ LogManager.logDetail(org.teiid.logging.LogConstants.CTX_DQP, e1, "Error closing processor"); //$NON-NLS-1$ } }
public CommandContext getContext() { CommandContext context = super.getContext(); if (evaluatedParams) { context.setVariableContext(currentVarContext); } return context; }
public PlanNode getDescriptionProperties() { PlanNode props = super.getDescriptionProperties(); for (int i = 0; i < getPlanCount(); i++) { props.addProperty("Batch Plan " + i, updatePlans[i].getDescriptionProperties()); //$NON-NLS-1$ } return props; }
@Override public Boolean requiresTransaction(boolean transactionalReads) { return plan.requiresTransaction(transactionalReads); }
/** * Returns a deep clone */ public LoopInstruction clone(){ ProcessorPlan clonedPlan = this.plan.clone(); return new LoopInstruction(this.loopProgram.clone(), this.rsName, clonedPlan, label); }
@Override public List getOutputElements() { return this.processPlan.getOutputElements(); }
private void resetPlan() { plan.reset(); isOpen = false; needsProcessing = false; }
@Override public TupleBatch nextBatch() throws BlockedException, TeiidComponentException, TeiidProcessingException { while (planIndex < plans.size()) { try { if (!open) { plans.get(planIndex).open(); } plans.get(planIndex).nextBatch(); plans.get(planIndex).close(); } catch (TeiidProcessingException e) { LogManager.logWarning(LogConstants.CTX_DQP, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31214, names.get(planIndex), table)); } catch (BlockedException e) { throw e; } //allow other exception types to bubble up open = false; planIndex++; } TupleBatch batch = new TupleBatch(1, new List<?>[0]); batch.setTerminationFlag(true); return batch; }
@Test public void testRollup() throws Exception { String sql = "select e1, sum(e2) from pm1.g1 group by rollup(e1)"; //$NON-NLS-1$ List[] expected = new List[] { Arrays.asList("a", Long.valueOf(3)), Arrays.asList("b", Long.valueOf(1)), Arrays.asList(null, Long.valueOf(4)) }; ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached()); HardcodedDataManager hdm = new HardcodedDataManager(); hdm.addData("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1", Arrays.asList("a", 1), Arrays.asList("a", 2), Arrays.asList("b", 1)); helpProcess(plan, hdm, expected); expected = new List[] { Arrays.asList("a", Long.valueOf(4)), Arrays.asList(null, Long.valueOf(4)) }; plan.close(); plan.reset(); hdm = new HardcodedDataManager(); hdm.addData("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1", Arrays.asList("a", 1), Arrays.asList("a", 3)); helpProcess(plan, hdm, expected); }
public static void helpProcess(ProcessorPlan plan, CommandContext context, ProcessorDataManager dataManager, List[] expectedResults) throws Exception { ProcessorPlan clonePlan = plan.clone(); // Process twice to test reset and clone doProcess(plan, dataManager, expectedResults, context); plan.reset(); doProcess(plan, dataManager, expectedResults, context); // Execute cloned of original plan doProcess(clonePlan, dataManager, expectedResults, context); }
process = process.clone(); assertNotNull("Output elements of process plan are null", process.getOutputElements()); //$NON-NLS-1$
@Override public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) { super.initialize(context, dataMgr, bufferMgr); for (ProcessorPlan plan : plans) { plan.initialize(context, dataMgr, bufferMgr); } }
public void open() throws TeiidComponentException, TeiidProcessingException { super.open(); // Initialize plan for execution CommandContext subContext = getContext().clone(); subContext.pushVariableContext(new VariableContext()); plan.initialize(subContext, getDataManager(), this.getBufferManager()); if (openPlanImmediately() && prepareNextCommand()) { needsProcessing = true; plan.open(); isOpen = true; } }
@Override public boolean hasBuffer() { return !continuous && this.processPlan.hasBuffer(); }
@Override public TupleBuffer getBuffer(int maxRows) throws BlockedException, TeiidComponentException, TeiidProcessingException { while (true) { long wait = DEFAULT_WAIT; try { init(); return this.processPlan.getBuffer(maxRows); } catch (BlockedException e) { if (!this.context.isNonBlocking()) { throw e; } if (e == BlockedException.BLOCKED_ON_MEMORY_EXCEPTION) { continue; //TODO: pass the commandcontext into sortutility } } catch (TeiidComponentException e) { closeProcessing(); throw e; } catch (TeiidProcessingException e) { closeProcessing(); throw e; } try { Thread.sleep(wait); } catch (InterruptedException err) { throw new TeiidComponentException(QueryPlugin.Event.TEIID30163, err); } } }
@Override public Boolean requiresTransaction(boolean transactionalReads) { return plan.requiresTransaction(transactionalReads); }
/** * Returns a deep clone */ public CreateCursorResultSetInstruction clone(){ ProcessorPlan clonedPlan = this.plan.clone(); CreateCursorResultSetInstruction clone = new CreateCursorResultSetInstruction(this.rsName, clonedPlan, mode); clone.setProcAssignments(procAssignments); clone.usesLocalTemp = true; return clone; }
@Override public List getOutputElements() { return this.processPlan.getOutputElements(); }
private void resetPlan() { plan.reset(); isOpen = false; needsProcessing = false; }
@Override public TupleBatch nextBatch() throws BlockedException, TeiidComponentException, TeiidProcessingException { while (planIndex < plans.size()) { try { if (!open) { plans.get(planIndex).open(); } plans.get(planIndex).nextBatch(); plans.get(planIndex).close(); } catch (TeiidProcessingException e) { LogManager.logWarning(LogConstants.CTX_DQP, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31214, names.get(planIndex), table)); } catch (BlockedException e) { throw e; } //allow other exception types to bubble up open = false; planIndex++; } TupleBatch batch = new TupleBatch(1, new List<?>[0]); batch.setTerminationFlag(true); return batch; }