コード例 #1
0
        public static void WhereNull(XArray left, bool isValue, BitVector vector)
        {
            bool[] leftArray = (bool[])left.NullRows;
            if (leftArray == null)
            {
                if (isValue == false)
                {
                    vector.All(left.Count);
                }
                return;
            }

            // Check how the arrays are configured and run the fastest loop possible for the configuration.
            if (left.Selector.Indices != null)
            {
                // Slow Path: Look up indices on both sides. ~55ms for 16M
                for (int i = 0; i < left.Count; ++i)
                {
                    if (leftArray[left.Index(i)] == isValue)
                    {
                        vector.Set(i);
                    }
                }
            }
            else if (!left.Selector.IsSingleValue)
            {
                // Fastest Path: Contiguous Array to constant. ~15ms for 16M
                int zeroOffset = left.Selector.StartIndexInclusive;

                if (s_WhereSingleNative != null)
                {
                    s_WhereSingleNative(leftArray, left.Selector.StartIndexInclusive, left.Selector.Count, (byte)CompareOperator.Equal, isValue, (byte)BooleanOperator.Or, vector.Array, 0);
                }
                else
                {
                    for (int i = left.Selector.StartIndexInclusive; i < left.Selector.EndIndexExclusive; ++i)
                    {
                        if (leftArray[i] == isValue)
                        {
                            vector.Set(i - zeroOffset);
                        }
                    }
                }
            }
            else
            {
                // Single Static comparison. ~0.7ms for 16M [called every 10,240 rows]
                if (leftArray[left.Selector.StartIndexInclusive] == isValue)
                {
                    vector.All(left.Count);
                }
                else
                {
                    vector.None();
                }
            }
        }
コード例 #2
0
        public void BitVector_Basics()
        {
            BitVector set = new BitVector(999);

            // Verify Count, All, None
            Assert.AreEqual(0, set.Count, "Set should start empty");

            set.All(999);
            Assert.AreEqual(999, set.Count, "All should set through length only.");

            set.ClearAbove(900);
            Assert.AreEqual(900, set.Count, "ClearAbove should clear past length only.");

            set.None();
            Assert.AreEqual(0, set.Count, "None should clear");

            // Verify individual set and get
            byte[] values = new byte[999];
            for (int i = 0; i < 999; ++i)
            {
                // Set only 'i' via setter and verify
                set.None();
                set[i] = true;
                AssertOnly(set, 999, i);
            }
        }
コード例 #3
0
        public void Evaluate(BitVector vector)
        {
            Allocator.AllocateToSize(ref _termVector, vector.Capacity);
            vector.All(vector.Capacity);

            foreach (IExpression term in _terms)
            {
                _termVector.None();
                term.Evaluate(_termVector);
                vector.And(_termVector);
            }
        }
コード例 #4
0
ファイル: SetComparer.cs プロジェクト: lulzzz/elfie-arriba
        public void Evaluate(XArray left, XArray unused, BitVector vector)
        {
            byte[] leftArray = (byte[])left.Array;

            // Check how the arrays are configured and run the fastest loop possible for the configuration.
            if (left.HasNulls)
            {
                // Slowest Path: Null checks and look up indices on both sides
                for (int i = 0; i < left.Count; ++i)
                {
                    int leftIndex = left.Index(i);
                    if (left.NullRows[leftIndex])
                    {
                        continue;
                    }
                    if (_array[leftArray[leftIndex]])
                    {
                        vector.Set(i);
                    }
                }
            }
            else if (left.Selector.Indices != null)
            {
                // Slow Path: Look up indices on both sides.
                for (int i = 0; i < left.Count; ++i)
                {
                    if (_array[leftArray[left.Index(i)]])
                    {
                        vector.Set(i);
                    }
                }
            }
            else if (!left.Selector.IsSingleValue)
            {
                // Fastest Path: Contiguous Array to constant.
                int zeroOffset = left.Selector.StartIndexInclusive;
                for (int i = left.Selector.StartIndexInclusive; i < left.Selector.EndIndexExclusive; ++i)
                {
                    if (_array[leftArray[i]])
                    {
                        vector.Set(i - zeroOffset);
                    }
                }
            }
            else
            {
                // Single Static comparison.
                if (_array[leftArray[left.Selector.StartIndexInclusive]])
                {
                    vector.All(left.Count);
                }
            }
        }
コード例 #5
0
        public void WhereGreaterThanOrEqual(XArray left, XArray right, BitVector vector)
        {
            short[] leftArray  = (short[])left.Array;
            short[] rightArray = (short[])right.Array;

            // Check how the XArrays are configured and run the fastest loop possible for the configuration.
            if (left.Selector.Indices != null || right.Selector.Indices != null)
            {
                // Slow Path: Look up indices on both sides. ~55ms for 16M
                for (int i = 0; i < left.Count; ++i)
                {
                    if (leftArray[left.Index(i)] >= rightArray[right.Index(i)])
                    {
                        vector.Set(i);
                    }
                }
            }
            else if (!right.Selector.IsSingleValue)
            {
                // Faster Path: Compare contiguous arrays. ~20ms for 16M
                if (s_WhereNative != null)
                {
                    s_WhereNative(leftArray, left.Selector.StartIndexInclusive, (byte)CompareOperator.GreaterThanOrEqual, rightArray, right.Selector.StartIndexInclusive, left.Selector.Count, (byte)BooleanOperator.Or, vector.Array, 0);
                }
                else
                {
                    int zeroOffset            = left.Selector.StartIndexInclusive;
                    int leftIndexToRightIndex = right.Selector.StartIndexInclusive - left.Selector.StartIndexInclusive;
                    for (int i = left.Selector.StartIndexInclusive; i < left.Selector.EndIndexExclusive; ++i)
                    {
                        if (leftArray[i] >= rightArray[i + leftIndexToRightIndex])
                        {
                            vector.Set(i - zeroOffset);
                        }
                    }
                }
            }
            else if (!left.Selector.IsSingleValue)
            {
                // Fastest Path: Contiguous Array to constant. ~15ms for 16M
                int   zeroOffset = left.Selector.StartIndexInclusive;
                short rightValue = rightArray[0];

                if (s_WhereSingleNative != null)
                {
                    s_WhereSingleNative(leftArray, left.Selector.StartIndexInclusive, left.Selector.Count, (byte)CompareOperator.GreaterThanOrEqual, rightValue, (byte)BooleanOperator.Or, vector.Array, 0);
                }
                else
                {
                    for (int i = left.Selector.StartIndexInclusive; i < left.Selector.EndIndexExclusive; ++i)
                    {
                        if (leftArray[i] >= rightValue)
                        {
                            vector.Set(i - zeroOffset);
                        }
                    }
                }
            }
            else
            {
                // Single Static comparison. ~0.7ms for 16M [called every 10,240 rows]
                if (leftArray[left.Selector.StartIndexInclusive] >= rightArray[right.Selector.StartIndexInclusive])
                {
                    vector.All(left.Count);
                }
            }

            // Remove nulls from matches
            BoolComparer.AndNotNull(left, vector);
            BoolComparer.AndNotNull(right, vector);
        }
コード例 #6
0
ファイル: SetComparer.cs プロジェクト: lulzzz/elfie-arriba
 public static void All(XArray left, XArray unused, BitVector vector)
 {
     vector.All(left.Count);
 }