Exemplo n.º 1
0
        /// <summary>
        /// Determines the order index state for the output operator
        /// </summary>
        private void InitOrderIndexState()
        {
            // SkipWhile/TakeWhile needs an increasing index. However, if the predicate expression depends on the index,
            // the index needs to be correct, not just increasing.

            OrdinalIndexState requiredIndexState = OrdinalIndexState.Increasing;
            OrdinalIndexState childIndexState    = Child.OrdinalIndexState;

            if (_indexedPredicate != null)
            {
                requiredIndexState = OrdinalIndexState.Correct;
                _limitsParallelism = childIndexState == OrdinalIndexState.Increasing;
            }

            OrdinalIndexState indexState = ExchangeUtilities.Worse(childIndexState, OrdinalIndexState.Correct);

            if (indexState.IsWorseThan(requiredIndexState))
            {
                _prematureMerge = true;
            }

            if (!_take)
            {
                // If the index was correct, now it is only increasing.
                indexState = indexState.Worse(OrdinalIndexState.Increasing);
            }

            SetOrdinalIndexState(indexState);
        }
 private void QuickSortIndicesInPlace(GrowingArray <TKey> keys, List <TInputOutput> values, OrdinalIndexState ordinalIndexState)
 {
     int[] indices = new int[values.Count];
     for (int i = 0; i < indices.Length; i++)
     {
         indices[i] = i;
     }
     if ((indices.Length > 1) && ordinalIndexState.IsWorseThan(OrdinalIndexState.Increasing))
     {
         this.QuickSort(0, indices.Length - 1, keys.InternalArray, indices, this.m_groupState.CancellationState.MergedCancellationToken);
     }
     if (this.m_partitionCount == 1)
     {
         TInputOutput[] localArray = new TInputOutput[values.Count];
         for (int j = 0; j < indices.Length; j++)
         {
             localArray[j] = values[indices[j]];
         }
         this.m_sharedValues[this.m_partitionIndex] = localArray;
     }
     else
     {
         this.m_sharedIndices[this.m_partitionIndex] = indices;
         this.m_sharedKeys[this.m_partitionIndex]    = keys;
         this.m_sharedValues[this.m_partitionIndex]  = new TInputOutput[values.Count];
         values.CopyTo(this.m_sharedValues[this.m_partitionIndex]);
     }
 }
        /// <summary>
        /// Determines the order index state for the output operator
        /// </summary>
        private OrdinalIndexState OutputOrderIndexState()
        {
            // SkipWhile/TakeWhile needs an increasing index. However, if the predicate expression depends on the index,
            // the index needs to be correct, not just increasing.

            OrdinalIndexState requiredIndexState = OrdinalIndexState.Increasing;

            if (m_indexedPredicate != null)
            {
                requiredIndexState = OrdinalIndexState.Correct;
            }

            OrdinalIndexState indexState = ExchangeUtilities.Worse(Child.OrdinalIndexState, OrdinalIndexState.Correct);

            if (indexState.IsWorseThan(requiredIndexState))
            {
                m_prematureMerge = true;
            }

            if (!m_take)
            {
                // If the index was correct, now it is only increasing.
                indexState = indexState.Worse(OrdinalIndexState.Increasing);
            }
            return(indexState);
        }
Exemplo n.º 4
0
        private OrdinalIndexState OutputOrdinalIndexState()
        {
            OrdinalIndexState ordinalIndexState = base.Child.OrdinalIndexState;

            if (ordinalIndexState == OrdinalIndexState.Indexible)
            {
                return(OrdinalIndexState.Indexible);
            }
            if (ordinalIndexState.IsWorseThan(OrdinalIndexState.Increasing))
            {
                this.m_prematureMerge = true;
                ordinalIndexState     = OrdinalIndexState.Correct;
            }
            if (!this.m_take && (ordinalIndexState == OrdinalIndexState.Correct))
            {
                ordinalIndexState = OrdinalIndexState.Increasing;
            }
            return(ordinalIndexState);
        }
        private OrdinalIndexState OutputOrderIndexState()
        {
            OrdinalIndexState increasing = OrdinalIndexState.Increasing;

            if (this.m_indexedPredicate != null)
            {
                increasing = OrdinalIndexState.Correct;
            }
            OrdinalIndexState state2 = base.Child.OrdinalIndexState.Worse(OrdinalIndexState.Correct);

            if (state2.IsWorseThan(increasing))
            {
                this.m_prematureMerge = true;
            }
            if (!this.m_take)
            {
                state2 = state2.Worse(OrdinalIndexState.Increasing);
            }
            return(state2);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Determines the order index state for the output operator
        /// </summary>
        private OrdinalIndexState OutputOrdinalIndexState()
        {
            OrdinalIndexState indexState = Child.OrdinalIndexState;

            if (indexState == OrdinalIndexState.Indexable)
            {
                return(OrdinalIndexState.Indexable);
            }

            if (indexState.IsWorseThan(OrdinalIndexState.Increasing))
            {
                _prematureMerge = true;
                indexState      = OrdinalIndexState.Correct;
            }

            // If the operator is skip and the index was correct, now it is only increasing.
            if (!_take && indexState == OrdinalIndexState.Correct)
            {
                indexState = OrdinalIndexState.Increasing;
            }

            return(indexState);
        }