public final void close() throws TeiidComponentException { if (!this.getProcessingState().closed) { closeDirect(); for(int i=0; i<children.length; i++) { if(children[i] != null) { children[i].close(); } else { break; } } this.getProcessingState().closed = true; } }
/** * @see org.teiid.query.processor.relational.RelationalNode#getBatchSize() * @since 4.2 */ protected int getBatchSize() { if(this.batchSize != 0) { return this.batchSize; } return super.getBatchSize(); }
static void connectExternal(RelationalNode node, CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) { node.initialize(context, bufferMgr, dataMgr); RelationalNode[] children = node.getChildren(); int childCount = node.getChildCount(); for(int i=0; i<childCount; i++) { if(children[i] != null) { connectExternal(children[i], context, dataMgr, bufferMgr); } else { break; } } }
protected void getNodeString(StringBuffer str) { str.append(getClassName()); str.append("("); //$NON-NLS-1$ str.append(getID()); str.append(") output="); //$NON-NLS-1$ str.append(getElements()); str.append(" "); //$NON-NLS-1$ }
CommandContext context = this.getContext(); if (context != null && context.isCancelled()) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30160, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30160, getContext().getRequestId())); this.getProcessingState().nodeStatistics.startBatchTimer(); TupleBatch batch = nextBatchDirect(); if (recordStats) { this.getProcessingState().nodeStatistics.stopBatchTimer(); this.getProcessingState().nodeStatistics.collectCumulativeNodeStats((long)batch.getRowCount(), RelationalNodeStatistics.BATCHCOMPLETE_STOP); if (batch.getTerminationFlag()) { this.getProcessingState().nodeStatistics.collectNodeStats(this.getChildren()); this.recordBatch(batch); recordStats = false; close(); if(recordStats) { this.getProcessingState().nodeStatistics.stopBatchTimer(); this.getProcessingState().nodeStatistics.collectCumulativeNodeStats(null, RelationalNodeStatistics.BLOCKEDEXCEPTION_STOP); recordStats = false; } finally { if(recordStats) { this.getProcessingState().nodeStatistics.stopBatchTimer();
Map<Expression, Integer> elementMap = RelationalNode.createLookupMap(xt.getProjectedSymbols()); List cols = (List) node.getProperty(NodeConstants.Info.OUTPUT_COLS); int[] projectionIndexes = RelationalNode.getProjectionIndexes(elementMap, cols); ArrayList<XMLColumn> filteredColumns = new ArrayList<XMLColumn>(projectionIndexes.length); for (int col : projectionIndexes) { Map<Expression, Integer> elementMap = RelationalNode.createLookupMap(ot.getProjectedSymbols()); List<Expression> cols = (List<Expression>) node.getProperty(NodeConstants.Info.OUTPUT_COLS); int[] projectionIndexes = RelationalNode.getProjectionIndexes(elementMap, cols); ArrayList<ObjectColumn> filteredColumns = new ArrayList<ObjectColumn>(projectionIndexes.length); for (int col : projectionIndexes) { unionAllNode.setElements( (List) node.getProperty(NodeConstants.Info.OUTPUT_COLS) ); processNode.addChild(unionAllNode);
FakeDataManager fdm = new FakeDataManager(); for(int i=0; i<children.length; i++) { union.addChild(children[i]); children[i].initialize(context, mgr, fdm); union.initialize(context, mgr, fdm); union.open(); TupleBatch batch = union.nextBatch(); for(int row = currentRow; row <= batch.getEndRow(); row++) { List tuple = batch.getTuple(row); union.close();
public void open() throws TeiidComponentException, TeiidProcessingException { for(int i=0; i<children.length; i++) { if(children[i] != null) { children[i].open(); } else { break; } } }
/** * @see ProcessorPlan#nextBatch() */ public TupleBatch nextBatch() throws BlockedException, TeiidComponentException, TeiidProcessingException { return this.root.nextBatch(); }
while(nextParent.getChildren()[0] != null) { nextParent = nextParent.getChildren()[0]; && childNode.getProperty(Info.SET_OPERATION) == planNode.getProperty(Info.SET_OPERATION) && childNode.getType() == NodeConstants.Types.SET_OP && childNode.hasBooleanProperty(Info.USE_ALL)) { for (RelationalNode grandChild : child.getChildren()) { if (grandChild != null) { nextParent.addChild(grandChild); nextParent.addChild(child);
public SourceState(RelationalNode source, List expressions) { this.source = source; this.expressions = expressions; List elements = source.getElements(); this.outerVals = Collections.nCopies(elements.size(), null); this.expressionIndexes = getExpressionIndecies(expressions, elements); }
private void optimizeStagingTableAccess(RelationalNode node) throws QueryMetadataException, TeiidComponentException { checkNode(node); for (RelationalNode child : node.getChildren()) { if (child != null) { optimizeStagingTableAccess(child); } } }
@Test public void testLimitWithUnknownChildCardinality() throws Exception { String query = "select e1 from pm1.g1 limit 2"; //$NON-NLS-1$ RelationalPlan plan = (RelationalPlan)TestOptimizer.helpPlan(query, RealMetadataFactory.example1Cached(), new String[] {"SELECT e1 FROM pm1.g1"}); //$NON-NLS-1$ assertEquals(new Float(2), plan.getRootNode().getEstimateNodeCardinality()); }
long indexSize = possibleIndex.hasBuffer()?possibleIndex.getRowCount():-1; long otherSize = other.hasBuffer()?other.getRowCount():-1; int schemaSize = this.joinNode.getBufferManager().getSchemaSize(other.getSource().getOutputElements()); int toReserve = this.joinNode.getBufferManager().getMaxProcessingSize(); int minSize = toReserve/schemaSize*this.joinNode.getBatchSize(); int indexSchemaSize = this.joinNode.getBufferManager().getSchemaSize(possibleIndex.getSource().getOutputElements()); rows/=Math.max(2, possibleIndex.getSource().getBatchSize()); depth+=1;
CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$ child.setElements(childElements); child.initialize(context, mgr, dataMgr); selectNode.setCriteria(criteria); selectNode.setElements(elements);
@Override public void open() throws TeiidComponentException, TeiidProcessingException { if (with != null && tempTableStore.getProcessors() == null) { HashMap<String, TableProcessor> processors = new HashMap<String, TableProcessor>(); tempTableStore.setProcessors(processors); for (WithQueryCommand withCommand : this.with) { if (withCommand.isRecursive()) { SetQuery setQuery = (SetQuery)withCommand.getCommand(); ProcessorPlan initial = setQuery.getLeftQuery().getProcessorPlan(); QueryProcessor withProcessor = new QueryProcessor(initial, getContext().clone(), root.getBufferManager(), root.getDataManager()); processors.put(withCommand.getGroupSymbol().getName(), new RecursiveTableProcessor(withProcessor, withCommand.getColumns(), setQuery.getRightQuery().getProcessorPlan(), setQuery.isAll())); continue; } ProcessorPlan plan = withCommand.getCommand().getProcessorPlan(); QueryProcessor withProcessor = new QueryProcessor(plan, getContext().clone(), root.getBufferManager(), root.getDataManager()); processors.put(withCommand.getGroupSymbol().getName(), new TableProcessor(withProcessor, withCommand.getColumns())); } } this.root.open(); }
static Boolean requiresTransaction(boolean transactionalReads, RelationalNode node) { Boolean requiresTxn = node.requiresTransaction(transactionalReads); if (Boolean.TRUE.equals(requiresTxn)) { return true; } boolean last = true; for (RelationalNode child : node.getChildren()) { if (child == null) { continue; } Boolean childRequires = requiresTransaction(transactionalReads, child); if (Boolean.TRUE.equals(childRequires)) { return true; } if (childRequires == null) { if (requiresTxn == null) { return true; } requiresTxn = null; last = true; } else { last = false; } } if (requiresTxn == null && !last) { return true; } return requiresTxn; }
RelationalNode root = relationalPlan.getRootNode(); if (root.getChildren()[0] != null) { root = root.getChildren()[0]; Number planCardinality = root.getEstimateNodeCardinality();
/** * Because we lack a cost value based upon complexity the * heurstic is to look that the dependent set is fully pushed. * there are situations where it won't be fully pushed, but * for which it will still be a better plan and we'll reject */ private boolean isUsingDependentJoin(String id, RelationalNode rn) { if (rn instanceof DependentAccessNode) { DependentAccessNode dan = (DependentAccessNode)rn; Query qc = (Query) dan.getCommand(); Criteria c = qc.getCriteria(); for (Criteria crit : Criteria.separateCriteriaByAnd(c)) { if (crit instanceof DependentSetCriteria) { DependentSetCriteria dsc = (DependentSetCriteria)crit; if (dsc.getContextSymbol().equals(id)) { return true; } } } } RelationalNode[] children = rn.getChildren(); for (int i=0; i<rn.getChildCount(); i++) { if (isUsingDependentJoin(id, children[i])) { return true; } } return false; }
public void collectNodeStats(RelationalNode[] relationalNodes) { // set nodeEndTime to the time gathered at the end of the last batch this.nodeEndTime = this.batchEndTime; this.nodeCumulativeProcessingTime = this.nodeEndTime - this.nodeStartTime; this.nodeNextBatchProcessingTime = this.nodeCumulativeNextBatchProcessingTime; for (int i = 0; i < relationalNodes.length; i++) { if (relationalNodes[i] == null) { break; } this.nodeNextBatchProcessingTime -= relationalNodes[i].getNodeStatistics().getNodeCumulativeNextBatchProcessingTime(); } }