Package org.teiid.query.processor.relational

Examples of org.teiid.query.processor.relational.ProjectNode


        switch(accessNodes.size()) {
            case 0:
            {
                if (RelationalNodeUtil.isUpdate(accessNode.getCommand())) {
                  //should return a 0 update count
                  ProjectNode pnode = new ProjectNode(getID());
                  pnode.setElements(accessNode.getElements());
                  pnode.setSelectSymbols(Arrays.asList(new ExpressionSymbol("x", new Constant(0)))); //$NON-NLS-1$
                  return pnode;
                }
                // Replace existing access node with a NullNode
                NullNode nullNode = new NullNode(getID());
                nullNode.setElements(accessNode.getElements());
                return nullNode;        
            }
            case 1:
            {
                // Replace existing access node with new access node (simplified command)
                AccessNode newNode = accessNodes.get(0);
                return newNode;                                               
            }
            default:
            {
              multiSource = true;
              UnionAllNode unionNode = new UnionAllNode(getID());
              unionNode.setElements(accessNode.getElements());
               
                for (AccessNode newNode : accessNodes) {
                  unionNode.addChild(newNode);
                }
             
              RelationalNode parent = unionNode;
             
                // More than 1 access node - replace with a union
              if (RelationalNodeUtil.isUpdate(accessNode.getCommand())) {
                update = true;
                GroupingNode groupNode = new GroupingNode(getID());                   
                AggregateSymbol sumCount = new AggregateSymbol("SumCount", NonReserved.SUM, false, (Expression)accessNode.getElements().get(0)); //$NON-NLS-1$             
                List<Expression> outputElements = new ArrayList<Expression>(1);               
                outputElements.add(sumCount);
                groupNode.setElements(outputElements);
                groupNode.addChild(unionNode);
               
                ProjectNode projectNode = new ProjectNode(getID());
               
                Expression intSum = ResolverUtil.getConversion(sumCount, DataTypeManager.getDataTypeName(sumCount.getType()), DataTypeManager.DefaultDataTypes.INTEGER, false, metadata.getFunctionLibrary());
               
                Expression rowCount = new ExpressionSymbol("RowCount", intSum); //$NON-NLS-1$               
                outputElements = new ArrayList<Expression>(1);               
                outputElements.add(rowCount);                
                projectNode.setElements(outputElements);
                projectNode.setSelectSymbols(outputElements);
                projectNode.addChild(groupNode);
               
                parent = projectNode;
              }
                return parent;
            }
View Full Code Here


      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$
    }
View Full Code Here

        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);
View Full Code Here

                    }

                } else {
                    List symbols = (List) node.getProperty(NodeConstants.Info.PROJECT_COLS);
                   
                    ProjectNode pnode = new ProjectNode(getID());
                    pnode.setSelectSymbols(symbols);
                processNode = pnode;
                }
                break;

      case NodeConstants.Types.JOIN:
View Full Code Here

        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);
        //if the following cast fails it means that we have a dependent temp table - that is not yet possible
        aNode = (AccessNode)prepareToAdd(node, aNode);
        node.setProperty(NodeConstants.Info.OUTPUT_COLS, projectSymbols);
        pnode.addChild(aNode);
        return pnode;
    }
View Full Code Here

                            break batchLoop;
                        }
                    }
                    // If two or more contiguous commands made on the same model were found, then batch them
                    if (batch.size() > 1) {
                        ProjectNode projectNode = new ProjectNode(((IntegerID)idGenerator.create()).getValue());
                        // Create a BatchedUpdateNode that creates a batched request for the connector
                        BatchedUpdateNode batchNode = new BatchedUpdateNode(((IntegerID)idGenerator.create()).getValue(),
                                                                            batch, contexts, shouldEvaluate,
                                                                            modelName);
                        List symbols = batchedUpdateCommand.getProjectedSymbols();
                        projectNode.setSelectSymbols(symbols);
                        projectNode.setElements(symbols);
                       
                        batchNode.setElements(symbols);
                       
                        projectNode.addChild(batchNode);
                        // Add a new RelationalPlan that represents the plan for this batch.
                        childPlans.add(new RelationalPlan(projectNode));
                        if (planContexts != null) {
                          planContexts.add(new VariableContext());
                      }
View Full Code Here

TOP

Related Classes of org.teiid.query.processor.relational.ProjectNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.