public Object clone(){ ProjectNode clonedNode = new ProjectNode(); this.copyTo(clonedNode); return clonedNode; }
void init() { List<? extends Expression> childElements = getChildren()[0].getElements(); this.elementMap = createLookupMap(childElements);
private void updateTuple(Expression symbol, int projectionIndex, List<?> values, List<Object> tuple) throws BlockedException, TeiidComponentException, ExpressionEvaluationException { int index = this.projectionIndexes[projectionIndex]; if(index != -1) { tuple.add(values.get(index)); } else { tuple.add(getEvaluator(this.elementMap).evaluate(symbol, values)); } }
public ProjectNode helpSetupProject(List elements, List[] data, List childElements, ProcessorDataManager dataMgr) { BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager(); CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$ FakeRelationalNode dataNode = new FakeRelationalNode(2, data); dataNode.setElements(childElements); dataNode.initialize(context, mgr, null); ProjectNode projectNode = new ProjectNode(1); projectNode.setSelectSymbols(elements); projectNode.setElements(elements); projectNode.addChild(dataNode); projectNode.initialize(context, mgr, dataMgr); return projectNode; }
private RelationalNode correctProjectionInternalTables(PlanNode node, AccessNode aNode) throws QueryMetadataException, TeiidComponentException { if (node.getGroups().size() != 1) { return aNode; } GroupSymbol group = node.getGroups().iterator().next(); if (!CoreConstants.SYSTEM_MODEL.equals(metadata.getFullName(metadata.getModelID(group.getMetadataID()))) && !CoreConstants.SYSTEM_ADMIN_MODEL.equals(metadata.getFullName(metadata.getModelID(group.getMetadataID())))) { return aNode; } List projectSymbols = (List) node.getProperty(NodeConstants.Info.OUTPUT_COLS); List<ElementSymbol> acutalColumns = ResolverUtil.resolveElementsInGroup(group, metadata); if (projectSymbols.equals(acutalColumns)) { return aNode; } node.setProperty(NodeConstants.Info.OUTPUT_COLS, acutalColumns); if (node.getParent() != null && node.getParent().getType() == NodeConstants.Types.PROJECT) { //if the parent is already a project, just correcting the output cols is enough return aNode; } ProjectNode pnode = new ProjectNode(getID()); pnode.setSelectSymbols(projectSymbols); aNode = (AccessNode)prepareToAdd(node, aNode); node.setProperty(NodeConstants.Info.OUTPUT_COLS, projectSymbols); pnode.addChild(aNode); return pnode; }
if(this.getChildren()[0] == null){ currentBatch = new TupleBatch(1, EMPTY_TUPLE); currentBatch.setTerminationFlag(true); }else{ currentBatch = this.getChildren()[0].nextBatch(); while (currentRow <= currentBatch.getEndRow() && !isBatchFull()) { List<?> tuple = currentBatch.getTuple(currentRow); updateTuple(symbol, i, tuple, projectedTuple); addBatchRow(projectedTuple); currentRow++; terminateBatches(); return pullBatch();
@Override public TupleBuffer getBufferDirect(int maxRows) throws BlockedException, TeiidComponentException, TeiidProcessingException { return this.getChildren()[0].getBuffer(maxRows); }
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); } }
@Override public void addChild(RelationalNode child) { super.addChild(child); init(); }
ProjectNode projectNode = new ProjectNode(idGenerator.nextInt()); modelName); List symbols = batchedUpdateCommand.getProjectedSymbols(); projectNode.setSelectSymbols(symbols); projectNode.setElements(symbols); projectNode.addChild(batchNode);
private RelationalNode correctProjectionInternalTables(PlanNode node, AccessNode aNode) throws QueryMetadataException, TeiidComponentException { if (node.getGroups().size() != 1) { return aNode; } GroupSymbol group = node.getGroups().iterator().next(); if (!CoreConstants.SYSTEM_MODEL.equals(metadata.getFullName(metadata.getModelID(group.getMetadataID()))) && !CoreConstants.SYSTEM_ADMIN_MODEL.equals(metadata.getFullName(metadata.getModelID(group.getMetadataID())))) { return aNode; } List projectSymbols = (List) node.getProperty(NodeConstants.Info.OUTPUT_COLS); List<ElementSymbol> acutalColumns = ResolverUtil.resolveElementsInGroup(group, metadata); if (projectSymbols.equals(acutalColumns)) { return aNode; } node.setProperty(NodeConstants.Info.OUTPUT_COLS, acutalColumns); if (node.getParent() != null && node.getParent().getType() == NodeConstants.Types.PROJECT) { //if the parent is already a project, just correcting the output cols is enough return aNode; } ProjectNode pnode = new ProjectNode(getID()); pnode.setSelectSymbols(projectSymbols); aNode = (AccessNode)prepareToAdd(node, aNode); node.setProperty(NodeConstants.Info.OUTPUT_COLS, projectSymbols); pnode.addChild(aNode); return pnode; }
if(this.getChildren()[0] == null){ currentBatch = new TupleBatch(1, EMPTY_TUPLE); currentBatch.setTerminationFlag(true); }else{ currentBatch = this.getChildren()[0].nextBatch(); while (currentRow <= currentBatch.getEndRow() && !isBatchFull()) { List<?> tuple = currentBatch.getTuple(currentRow); updateTuple(symbol, i, tuple, projectedTuple); addBatchRow(projectedTuple); currentRow++; terminateBatches(); return pullBatch();
@Override public TupleBuffer getBufferDirect(int maxRows) throws BlockedException, TeiidComponentException, TeiidProcessingException { return this.getChildren()[0].getBuffer(maxRows); }
@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$ }
@Override public void addChild(RelationalNode child) { super.addChild(child); init(); }
ProjectNode projectNode = new ProjectNode(idGenerator.nextInt()); modelName); List symbols = batchedUpdateCommand.getProjectedSymbols(); projectNode.setSelectSymbols(symbols); projectNode.setElements(symbols); projectNode.addChild(batchNode);
private RelationalNode correctProjectionInternalTables(PlanNode node, AccessNode aNode) throws QueryMetadataException, TeiidComponentException { if (node.getGroups().size() != 1) { return aNode; } GroupSymbol group = node.getGroups().iterator().next(); if (!CoreConstants.SYSTEM_MODEL.equals(metadata.getFullName(metadata.getModelID(group.getMetadataID()))) && !CoreConstants.SYSTEM_ADMIN_MODEL.equals(metadata.getFullName(metadata.getModelID(group.getMetadataID())))) { return aNode; } List projectSymbols = (List) node.getProperty(NodeConstants.Info.OUTPUT_COLS); List<ElementSymbol> acutalColumns = ResolverUtil.resolveElementsInGroup(group, metadata); if (projectSymbols.equals(acutalColumns)) { return aNode; } node.setProperty(NodeConstants.Info.OUTPUT_COLS, acutalColumns); if (node.getParent() != null && node.getParent().getType() == NodeConstants.Types.PROJECT) { //if the parent is already a project, just correcting the output cols is enough return aNode; } ProjectNode pnode = new ProjectNode(getID()); pnode.setSelectSymbols(projectSymbols); aNode = (AccessNode)prepareToAdd(node, aNode); node.setProperty(NodeConstants.Info.OUTPUT_COLS, projectSymbols); pnode.addChild(aNode); return pnode; }
if(this.getChildren()[0] == null){ currentBatch = new TupleBatch(1, EMPTY_TUPLE); currentBatch.setTerminationFlag(true); }else{ currentBatch = this.getChildren()[0].nextBatch(); while (currentRow <= currentBatch.getEndRow() && !isBatchFull()) { List<?> tuple = currentBatch.getTuple(currentRow); updateTuple(symbol, i, tuple, projectedTuple); addBatchRow(projectedTuple); currentRow++; terminateBatches(); return pullBatch();
public Object clone(){ ProjectNode clonedNode = new ProjectNode(); this.copyTo(clonedNode); return clonedNode; }
void init() { List<? extends Expression> childElements = getChildren()[0].getElements(); this.elementMap = createLookupMap(childElements);