@Test public void testLoopInstructionTransaction() throws Exception { //create a dummy instruction that may need a transaction to create the loop LoopInstruction loop = new LoopInstruction(new Program(false) { @Override public Boolean requiresTransaction(boolean transactionalReads) { return null; } }, "x", new RelationalPlan(new RelationalNode(1) { @Override protected TupleBatch nextBatchDirect() throws BlockedException, TeiidComponentException, TeiidProcessingException { return null; } @Override public Object clone() { return null; } }), "y"); assertNull(loop.requiresTransaction(true)); }
childPlans.add(new RelationalPlan(projectNode)); if (planContexts != null) { planContexts.add(new VariableContext());
childPlans.add(new RelationalPlan(projectNode)); if (planContexts != null) { planContexts.add(new VariableContext());
childPlans.add(new RelationalPlan(projectNode)); if (planContexts != null) { planContexts.add(new VariableContext());
public RelationalPlan convert(PlanNode planNode) throws QueryPlannerException, TeiidComponentException { try { boolean debug = analysisRecord.recordDebug(); if(debug) { analysisRecord.println("\n============================================================================"); //$NON-NLS-1$ analysisRecord.println("CONVERTING PLAN TREE TO PROCESS TREE"); //$NON-NLS-1$ } // Convert plan tree nodes into process tree nodes RelationalNode processNode; try { processNode = convertPlan(planNode); } catch (TeiidProcessingException e) { if (e instanceof QueryPlannerException) { throw (QueryPlannerException)e; } throw new QueryPlannerException(e); } if(debug) { analysisRecord.println("\nPROCESS PLAN = \n" + processNode); //$NON-NLS-1$ analysisRecord.println("============================================================================"); //$NON-NLS-1$ } RelationalPlan processPlan = new RelationalPlan(processNode); return processPlan; } finally { sharedCommands.clear(); } }
public RelationalPlan convert(PlanNode planNode) throws QueryPlannerException, TeiidComponentException { try { boolean debug = analysisRecord.recordDebug(); if(debug) { analysisRecord.println("\n============================================================================"); //$NON-NLS-1$ analysisRecord.println("CONVERTING PLAN TREE TO PROCESS TREE"); //$NON-NLS-1$ } // Convert plan tree nodes into process tree nodes RelationalNode processNode; try { processNode = convertPlan(planNode); } catch (TeiidProcessingException e) { if (e instanceof QueryPlannerException) { throw (QueryPlannerException)e; } throw new QueryPlannerException(e); } if(debug) { analysisRecord.println("\nPROCESS PLAN = \n" + processNode); //$NON-NLS-1$ analysisRecord.println("============================================================================"); //$NON-NLS-1$ } RelationalPlan processPlan = new RelationalPlan(processNode); return processPlan; } finally { sharedCommands.clear(); } }
public RelationalPlan convert(PlanNode planNode) throws QueryPlannerException, TeiidComponentException { try { boolean debug = analysisRecord.recordDebug(); if(debug) { analysisRecord.println("\n============================================================================"); //$NON-NLS-1$ analysisRecord.println("CONVERTING PLAN TREE TO PROCESS TREE"); //$NON-NLS-1$ } // Convert plan tree nodes into process tree nodes RelationalNode processNode; try { processNode = convertPlan(planNode); } catch (TeiidProcessingException e) { if (e instanceof QueryPlannerException) { throw (QueryPlannerException)e; } throw new QueryPlannerException(e); } if(debug) { analysisRecord.println("\nPROCESS PLAN = \n" + processNode); //$NON-NLS-1$ analysisRecord.println("============================================================================"); //$NON-NLS-1$ } RelationalPlan processPlan = new RelationalPlan(processNode); return processPlan; } finally { sharedCommands.clear(); } }
public void testNoRowsFirstBatch() throws Exception { RelationalNode node = new FakeRelationalNode(0, new List[0]); RelationalPlan plan = new RelationalPlan(node); TupleBatch batch = plan.nextBatch(); assertTrue("Did not get terminator batch", batch.getTerminationFlag()); //$NON-NLS-1$ }
private void helpPutPreparedPlans(SessionAwareCache<PreparedPlan> cache, DQPWorkContext session, int start, int count){ for(int i=0; i<count; i++){ Command dummy; try { dummy = QueryParser.getQueryParser().parseCommand(EXAMPLE_QUERY + (start + i)); } catch (QueryParserException e) { throw new RuntimeException(e); } CacheID id = new CacheID(session, pi, dummy.toString()); PreparedPlan pPlan = new PreparedPlan(); cache.put(id, Determinism.SESSION_DETERMINISTIC, pPlan, null); pPlan.setCommand(dummy); pPlan.setPlan(new RelationalPlan(new ProjectNode(i)), new CommandContext()); AnalysisRecord analysisRecord = new AnalysisRecord(true, false); pPlan.setAnalysisRecord(analysisRecord); ArrayList<Reference> refs = new ArrayList<Reference>(); refs.add(new Reference(1)); pPlan.setReferences(refs); } }
@Test public void testGet(){ SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>("preparedplan", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.PREPAREDPLAN, 0); helpPutPreparedPlans(cache, token, 0, 10); helpPutPreparedPlans(cache, token2, 0, 15); //read an entry for session2 (token2) PreparedPlan pPlan = cache.get(new CacheID(token2, pi, EXAMPLE_QUERY + 12)); assertNotNull("Unable to get prepared plan from cache", pPlan); //$NON-NLS-1$ assertEquals("Error getting plan from cache", new RelationalPlan(new ProjectNode(12)).toString(), pPlan.getPlan().toString()); //$NON-NLS-1$ assertEquals("Error getting command from cache", EXAMPLE_QUERY + 12, pPlan.getCommand().toString()); //$NON-NLS-1$ assertNotNull("Error getting plan description from cache", pPlan.getAnalysisRecord()); //$NON-NLS-1$ assertEquals("Error gettting reference from cache", new Reference(1), pPlan.getReferences().get(0)); //$NON-NLS-1$ }
public RelationalPlan clone(){ RelationalPlan plan = new RelationalPlan((RelationalNode)root.clone()); plan.setOutputElements(outputCols); if (with != null) { List<WithQueryCommand> newWith = LanguageObject.Util.deepClone(this.with, WithQueryCommand.class); for (WithQueryCommand withQueryCommand : newWith) { if (withQueryCommand.isRecursive()) { SetQuery setQuery = (SetQuery)withQueryCommand.getCommand(); setQuery.getLeftQuery().setProcessorPlan(setQuery.getLeftQuery().getProcessorPlan().clone()); setQuery.getRightQuery().setProcessorPlan(setQuery.getRightQuery().getProcessorPlan().clone()); } else { withQueryCommand.getCommand().setProcessorPlan(withQueryCommand.getCommand().getProcessorPlan().clone()); } } plan.setWith(newWith); } return plan; }
public RelationalPlan clone(){ RelationalPlan plan = new RelationalPlan((RelationalNode)root.clone()); plan.setOutputElements(outputCols); if (with != null) { List<WithQueryCommand> newWith = LanguageObject.Util.deepClone(this.with, WithQueryCommand.class); for (WithQueryCommand withQueryCommand : newWith) { if (withQueryCommand.isRecursive()) { SetQuery setQuery = (SetQuery)withQueryCommand.getCommand(); setQuery.getLeftQuery().setProcessorPlan(setQuery.getLeftQuery().getProcessorPlan().clone()); setQuery.getRightQuery().setProcessorPlan(setQuery.getRightQuery().getProcessorPlan().clone()); } else { withQueryCommand.getCommand().setProcessorPlan(withQueryCommand.getCommand().getProcessorPlan().clone()); } } plan.setWith(newWith); } return plan; }
public RelationalPlan clone(){ RelationalPlan plan = new RelationalPlan((RelationalNode)root.clone()); plan.setOutputElements(outputCols); if (with != null) { List<WithQueryCommand> newWith = LanguageObject.Util.deepClone(this.with, WithQueryCommand.class); for (WithQueryCommand withQueryCommand : newWith) { if (withQueryCommand.isRecursive()) { SetQuery setQuery = (SetQuery)withQueryCommand.getCommand(); setQuery.getLeftQuery().setProcessorPlan(setQuery.getLeftQuery().getProcessorPlan().clone()); setQuery.getRightQuery().setProcessorPlan(setQuery.getRightQuery().getProcessorPlan().clone()); } else { withQueryCommand.getCommand().setProcessorPlan(withQueryCommand.getCommand().getProcessorPlan().clone()); } } plan.setWith(newWith); } return plan; }