コード例 #1
0
bool ForIterator::nextImpl(store::Item_t& aResult, PlanState& aPlanState) const 
{
  ForState* lState;
  store::Item_t lItem;
      
  DEFAULT_STACK_INIT(ForState, lState, aPlanState);

  while (consumeNext(aResult, theChild0, aPlanState)) 
  {
    while (consumeNext(lItem, theChild1, aPlanState)) 
    {
      bindVariables(lItem, theVarRefs, aPlanState);

      if (theHasPosVars) 
      {
        store::Item_t lPosItem;
        GENV_ITEMFACTORY->createInteger(lPosItem,
                                        xs_integer(lState->incReturnPosition()));
        bindVariables(lPosItem, thePosVarRefs, aPlanState);
      }
      STACK_PUSH(true, lState);
    }

    lState->resetPosition();

    theChild1->reset(aPlanState);
  }

  STACK_END(lState);
}
コード例 #2
0
ファイル: window_iterator.cpp プロジェクト: buchenberg/zorba
/*******************************************************************************
  Binds the variables outside the window clause.

  @param planState The PlanState
  @param inputSeq The underlying input sequence
  @param pos The position of the current item within the input sequence
                   (counting starts with 1).
********************************************************************************/
void WindowVars::bindExtern(
    PlanState& planState,
    const store::TempSeq_t& inputSeq,
    const ulong pos) const
{
  store::Item_t item;

  if (!theCurOuterVars.empty())
  {
    inputSeq->getItem(xs_integer(pos), item);

    bindVariables(item, theCurOuterVars, planState);
  }

  if (!thePrevOuterVars.empty())
  {
    if (pos > 1)
      inputSeq->getItem(xs_integer(pos - 1), item);
    else
      item = NULL;

    bindVariables(item, thePrevOuterVars, planState);
  }

  if (!theNextOuterVars.empty())
  {
    inputSeq->getItem(xs_integer(pos + 1), item);

    bindVariables(item, theNextOuterVars, planState);
  }

  if (!thePosOuterVars.empty())
  {
    GENV_ITEMFACTORY->createInteger(item, Integer(pos));

    bindVariables(item, thePosOuterVars, planState);
  }
}