public String toString() { StringBuilder sb = new StringBuilder(); if (this.with != null) { sb.append(SQLConstants.Reserved.WITH); for (WithQueryCommand withCommand : this.with) { sb.append("\n"); //$NON-NLS-1$ sb.append(withCommand.getGroupSymbol()); if (withCommand.isRecursive()) { sb.append(" anchor\n").append(((SetQuery)withCommand.getCommand()).getLeftQuery().getProcessorPlan()); //$NON-NLS-1$ sb.append("recursive\n").append(((SetQuery)withCommand.getCommand()).getRightQuery().getProcessorPlan()); //$NON-NLS-1$ } else { sb.append("\n"); //$NON-NLS-1$ sb.append(withCommand.getCommand().getProcessorPlan()); } } sb.append("body\n"); //$NON-NLS-1$ } sb.append(this.root.toString()); return sb.toString(); }
public String toString() { StringBuilder sb = new StringBuilder(); if (this.with != null) { sb.append(SQLConstants.Reserved.WITH); for (WithQueryCommand withCommand : this.with) { sb.append("\n"); //$NON-NLS-1$ sb.append(withCommand.getGroupSymbol()); if (withCommand.isRecursive()) { sb.append(" anchor\n").append(((SetQuery)withCommand.getCommand()).getLeftQuery().getProcessorPlan()); //$NON-NLS-1$ sb.append("recursive\n").append(((SetQuery)withCommand.getCommand()).getRightQuery().getProcessorPlan()); //$NON-NLS-1$ } else { sb.append("\n"); //$NON-NLS-1$ sb.append(withCommand.getCommand().getProcessorPlan()); } } sb.append("body\n"); //$NON-NLS-1$ } sb.append(this.root.toString()); return sb.toString(); }
public String toString() { StringBuilder sb = new StringBuilder(); if (this.with != null) { sb.append(SQLConstants.Reserved.WITH); for (WithQueryCommand withCommand : this.with) { sb.append("\n"); //$NON-NLS-1$ sb.append(withCommand.getGroupSymbol()); if (withCommand.isRecursive()) { sb.append(" anchor\n").append(((SetQuery)withCommand.getCommand()).getLeftQuery().getProcessorPlan()); //$NON-NLS-1$ sb.append("recursive\n").append(((SetQuery)withCommand.getCommand()).getRightQuery().getProcessorPlan()); //$NON-NLS-1$ } else { sb.append("\n"); //$NON-NLS-1$ sb.append(withCommand.getCommand().getProcessorPlan()); } } sb.append("body\n"); //$NON-NLS-1$ } sb.append(this.root.toString()); return sb.toString(); }
private QueryCommand minimizeWithProjection(WithQueryCommand with, QueryCommand subCommand, TempMetadataID tid, Collection<TempMetadataID> accessed) throws QueryMetadataException, QueryResolverException, TeiidComponentException { List<TempMetadataID> elements = tid.getElements(); List<Integer> toRemove = new ArrayList<Integer>(); for (int i = elements.size()-1; i >= 0; i--) { TempMetadataID elem = elements.get(i); if (!accessed.contains(elem)) { toRemove.add(i); } } //the strategy here is to replace the actual projections with null. this keeps //the definition of the with clause consistent if (!toRemove.isEmpty()) { if (with.isRecursive()) { SetQuery setQuery = (SetQuery) subCommand; setQuery.setLeftQuery(removeUnusedProjection(with, setQuery.getLeftQuery(), elements, toRemove)); setQuery.setRightQuery(removeUnusedProjection(with, setQuery.getRightQuery(), elements, toRemove)); } else { subCommand = removeUnusedProjection(with, subCommand, elements, toRemove); with.setCommand(subCommand); } } return subCommand; }
private QueryCommand minimizeWithProjection(WithQueryCommand with, QueryCommand subCommand, TempMetadataID tid, Collection<TempMetadataID> accessed) throws QueryMetadataException, QueryResolverException, TeiidComponentException { List<TempMetadataID> elements = tid.getElements(); List<Integer> toRemove = new ArrayList<Integer>(); for (int i = elements.size()-1; i >= 0; i--) { TempMetadataID elem = elements.get(i); if (!accessed.contains(elem)) { toRemove.add(i); } } //the strategy here is to replace the actual projections with null. this keeps //the definition of the with clause consistent if (!toRemove.isEmpty()) { if (with.isRecursive()) { SetQuery setQuery = (SetQuery) subCommand; setQuery.setLeftQuery(removeUnusedProjection(with, setQuery.getLeftQuery(), elements, toRemove)); setQuery.setRightQuery(removeUnusedProjection(with, setQuery.getRightQuery(), elements, toRemove)); } else { subCommand = removeUnusedProjection(with, subCommand, elements, toRemove); with.setCommand(subCommand); } } return subCommand; }
@Override public Boolean requiresTransaction(boolean transactionalReads) { if (this.with != null) { for (WithQueryCommand withCommand : this.with) { if (withCommand.isRecursive()) { SetQuery setQuery = (SetQuery)withCommand.getCommand(); Boolean leftRequires = setQuery.getLeftQuery().getProcessorPlan().requiresTransaction(transactionalReads); Boolean rightRequires = setQuery.getLeftQuery().getProcessorPlan().requiresTransaction(transactionalReads); if (!Boolean.FALSE.equals(leftRequires) || !Boolean.FALSE.equals(rightRequires)) { return true; } } else { Boolean requires = withCommand.getCommand().getProcessorPlan().requiresTransaction(transactionalReads); if (!Boolean.FALSE.equals(requires)) { return true; } } } } return requiresTransaction(transactionalReads, root); }
@Override public Boolean requiresTransaction(boolean transactionalReads) { if (this.with != null) { for (WithQueryCommand withCommand : this.with) { if (withCommand.isRecursive()) { SetQuery setQuery = (SetQuery)withCommand.getCommand(); Boolean leftRequires = setQuery.getLeftQuery().getProcessorPlan().requiresTransaction(transactionalReads); Boolean rightRequires = setQuery.getLeftQuery().getProcessorPlan().requiresTransaction(transactionalReads); if (!Boolean.FALSE.equals(leftRequires) || !Boolean.FALSE.equals(rightRequires)) { return true; } } else { Boolean requires = withCommand.getCommand().getProcessorPlan().requiresTransaction(transactionalReads); if (!Boolean.FALSE.equals(requires)) { return true; } } } } return requiresTransaction(transactionalReads, root); }
@Override public Boolean requiresTransaction(boolean transactionalReads) { if (this.with != null) { for (WithQueryCommand withCommand : this.with) { if (withCommand.isRecursive()) { SetQuery setQuery = (SetQuery)withCommand.getCommand(); Boolean leftRequires = setQuery.getLeftQuery().getProcessorPlan().requiresTransaction(transactionalReads); Boolean rightRequires = setQuery.getLeftQuery().getProcessorPlan().requiresTransaction(transactionalReads); if (!Boolean.FALSE.equals(leftRequires) || !Boolean.FALSE.equals(rightRequires)) { return true; } } else { Boolean requires = withCommand.getCommand().getProcessorPlan().requiresTransaction(transactionalReads); if (!Boolean.FALSE.equals(requires)) { return true; } } } } return requiresTransaction(transactionalReads, root); }
item.setDependentValues(new TupleBufferList(withQueryCommand.getTupleBuffer())); item.setRecusive(withQueryCommand.isRecursive()); items.add(item);
item.setDependentValues(new TupleBufferList(withQueryCommand.getTupleBuffer())); item.setRecusive(withQueryCommand.isRecursive()); items.add(item);
item.setDependentValues(new TupleBufferList(withQueryCommand.getTupleBuffer())); item.setRecusive(withQueryCommand.isRecursive()); items.add(item);
/** * @see org.teiid.query.processor.ProcessorPlan#reset() */ public void reset() { super.reset(); this.root.reset(); if (this.with != null) { for (WithQueryCommand withCommand : this.with) { if (withCommand.isRecursive()) { SetQuery setQuery = (SetQuery)withCommand.getCommand(); setQuery.getLeftQuery().getProcessorPlan().reset(); setQuery.getLeftQuery().getProcessorPlan().reset(); } else { withCommand.getCommand().getProcessorPlan().reset(); } } } }
/** * @see org.teiid.query.processor.ProcessorPlan#reset() */ public void reset() { super.reset(); this.root.reset(); if (this.with != null) { for (WithQueryCommand withCommand : this.with) { if (withCommand.isRecursive()) { SetQuery setQuery = (SetQuery)withCommand.getCommand(); setQuery.getLeftQuery().getProcessorPlan().reset(); setQuery.getLeftQuery().getProcessorPlan().reset(); } else { withCommand.getCommand().getProcessorPlan().reset(); } } } }
/** * @see org.teiid.query.processor.ProcessorPlan#reset() */ public void reset() { super.reset(); this.root.reset(); if (this.with != null) { for (WithQueryCommand withCommand : this.with) { if (withCommand.isRecursive()) { SetQuery setQuery = (SetQuery)withCommand.getCommand(); setQuery.getLeftQuery().getProcessorPlan().reset(); setQuery.getLeftQuery().getProcessorPlan().reset(); } else { withCommand.getCommand().getProcessorPlan().reset(); } } } }
@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(); }
@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(); }
@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(); }
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; }