Package org.teiid.query.sql.util

Examples of org.teiid.query.sql.util.VariableContext


    private String helpGetDocument(ProcessorInstruction addNodeInstruction, Properties namespaceDeclarations) throws Exception{
       
        XMLContext context = new XMLContext();
        FakeXMLProcessorEnvironment env = new FakeXMLProcessorEnvironment();

        VariableContext varContext = context.getVariableContext();
       
        varContext.setValue(new ElementSymbol(RESULT_SET_NAME + STRING_COLUMN), "Lamp"); //$NON-NLS-1$
        varContext.setValue(new ElementSymbol(RESULT_SET_NAME + NULL_COLUMN), null);
       
        Program program = new Program();
        program.addInstruction(addNodeInstruction);
       
    env.pushProgram(program);
View Full Code Here


            }
          }
      this.subqueries.put(key, state);
    }
    SymbolMap correlatedRefs = container.getCommand().getCorrelatedReferences();
    VariableContext currentContext = null;
    boolean shouldClose = state.done && state.nonDeterministic;
    if (correlatedRefs != null) {
            currentContext = new VariableContext();
            for (Map.Entry<ElementSymbol, Expression> entry : container.getCommand().getCorrelatedReferences().asMap().entrySet()) {
        currentContext.setValue(entry.getKey(), evaluate(entry.getValue(), tuple));
      }
            List<Object> refValues = currentContext.getLocalValues();
            if (!refValues.equals(state.refValues)) {
              state.refValues = refValues;
              shouldClose = true;
            }
    }
View Full Code Here

   
    @Override
    public void open() throws TeiidComponentException,
        TeiidProcessingException {
      CommandContext context  = getContext().clone();
      context.pushVariableContext(new VariableContext());
      this.setContext(context);
      DependentProcedureExecutionNode.shareVariableContext(this, context);
      super.open();
    }
View Full Code Here

  public void open()
    throws TeiidComponentException, TeiidProcessingException {
    super.open();
        // Initialize plan for execution
        CommandContext subContext = getContext().clone();
        subContext.pushVariableContext(new VariableContext());
        plan.initialize(subContext, getDataManager(), this.getBufferManager());       
       
        if (openPlanImmediately() && prepareNextCommand()) {
            needsProcessing = true;
            plan.open();
View Full Code Here

   *             if this processing the plan throws a currentVarContext
   */
  public void process(ProcedurePlan procEnv) throws BlockedException,
      TeiidComponentException, TeiidProcessingException {

    VariableContext localContext = procEnv.getCurrentVariableContext();

    try {
      Object value = procEnv.evaluateExpression(dynamicCommand.getSql());

      if (value == null) {
View Full Code Here

        this.loopProgram = loopProgram;
    }

    public void process(ProcedurePlan procEnv) throws TeiidComponentException {
        List currentRow = procEnv.getCurrentRow(rsName);
        VariableContext varContext = procEnv.getCurrentVariableContext();
        //set results to the variable context(the cursor.element is treated as variable)
        if(this.elements == null){
            List schema = procEnv.getSchema(rsName);
            elements = new ArrayList(schema.size());
            for(int i=0; i< schema.size(); i++){
                // defect 13432 - schema may contain AliasSymbols. Cast to SingleElementSymbol instead of ElementSymbol
                SingleElementSymbol element = (SingleElementSymbol)schema.get(i);
                elements.add(new ElementSymbol(rsName + "." + element.getShortName()));              //$NON-NLS-1$
            }
        }
        for(int i=0; i< elements.size(); i++){
            varContext.setValue((ElementSymbol)elements.get(i), currentRow.get(i));              
        }
    }
View Full Code Here

   * @throws TeiidComponentException if error processing command or expression on this instruction
     */
    public void process(ProcedurePlan procEnv) throws BlockedException,
                                               TeiidComponentException, TeiidProcessingException {

        VariableContext varContext = procEnv.getCurrentVariableContext();
        Object value = null;
        if (this.expression != null) {
          value = procEnv.evaluateExpression(this.expression);
        }
        varContext.setValue(getVariable(), value);
        LogManager.logTrace(LogConstants.CTX_DQP,
                            new Object[] {this.toString() + " The variable " //$NON-NLS-1$
                                          + getVariable() + " in the variablecontext is updated with the value :", value}); //$NON-NLS-1$
    }
View Full Code Here

        commands.add(command);
      }
    }
   
    if (paramValues.size() > 1) {
      this.context.setVariableContext(new VariableContext());
    }
   
    if (paramValues.size() == 1) {
      return; // just use the existing plan, and global reference evaluation
    }
View Full Code Here

   * @throws QueryResolverException
   * @throws QueryValidatorException
   */
  public static void resolveParameterValues(List<Reference> params,
                                      List values, CommandContext context, QueryMetadataInterface metadata) throws QueryResolverException, TeiidComponentException, QueryValidatorException {
    VariableContext result = new VariableContext();
      //the size of the values must be the same as that of the parameters
      if (params.size() != values.size()) {
          String msg = QueryPlugin.Util.getString("QueryUtil.wrong_number_of_values", new Object[] {new Integer(values.size()), new Integer(params.size())}); //$NON-NLS-1$
          throw new QueryResolverException(msg);
      }
 
      //the type must be the same, or the type of the value can be implicitly converted
      //to that of the reference
      for (int i = 0; i < params.size(); i++) {
          Reference param = params.get(i);
          Object value = values.get(i);
         
          //TODO: why is the list check in here
          if(value != null && !(value instanceof List)) {
                try {
                    String targetTypeName = DataTypeManager.getDataTypeName(param.getType());
                    Expression expr = ResolverUtil.convertExpression(new Constant(value), targetTypeName, metadata);
                    value = Evaluator.evaluate(expr);
        } catch (ExpressionEvaluationException e) {
                    String msg = QueryPlugin.Util.getString("QueryUtil.Error_executing_conversion_function_to_convert_value", new Integer(i + 1), value, DataTypeManager.getDataTypeName(param.getType())); //$NON-NLS-1$
                    throw new QueryResolverException(msg);
        } catch (QueryResolverException e) {
          String msg = QueryPlugin.Util.getString("QueryUtil.Error_executing_conversion_function_to_convert_value", new Integer(i + 1), value, DataTypeManager.getDataTypeName(param.getType())); //$NON-NLS-1$
                    throw new QueryResolverException(msg);
        }
          }
                   
          if (param.getConstraint() != null) {
            param.getConstraint().validate(value);
          }
          //bind variable
          result.setGlobalValue(param.getContextSymbol(), value);
      }
     
      context.setVariableContext(result);
  }
View Full Code Here

          pp.setAnalysisRecord(record);
          pp.setCommand(newCommand);
          commandContext.putPlan(query, pp, copy.getDeterminismLevel());
          copy.setDeterminismLevel(determinismLevel);
    }
    copy.pushVariableContext(new VariableContext());
    PreparedStatementRequest.resolveParameterValues(pp.getReferences(), Arrays.asList(params), copy, metadata);
        return new QueryProcessor(pp.getPlan().clone(), copy, bufferMgr, dataMgr);
  }
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.util.VariableContext

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.