예제 #1
0
        private static RangeToScan Build(Operator op, int firstSortedIndexWithValue, int lastSortedIndexWithValue, int count)
        {
            RangeToScan r = new RangeToScan();

            RangeToScan.TryBuild(op, firstSortedIndexWithValue, lastSortedIndexWithValue, count, ref r);
            return(r);
        }
예제 #2
0
        public override void TryWhere(Operator op, T value, ShortSet result, ExecutionDetails details)
        {
            RangeToScan range   = new RangeToScan();
            bool        rangeOk = true;

            // For StartsWith, for ByteBlocks only, implement using IsPrefixOf
            if (op == Operator.StartsWith)
            {
                if (value is ByteBlock)
                {
                    IComparable <T> prefixComparer = (IComparable <T>)((ByteBlock)(object)value).GetExtendedIComparable(ByteBlock.Comparison.IsPrefixOf);     // trust me C#... I'm a professional...

                    int first = FindFirstWhere(prefixComparer);
                    int last  = FindLastWhere(prefixComparer);
                    if (!RangeToScan.TryBuild(Operator.Equals, first, last, this.Column.Count, ref range))
                    {
                        rangeOk = false;
                        if (details != null)
                        {
                            details.AddError(ExecutionDetails.ColumnDoesNotSupportOperator, op, this.Name);
                        }
                    }
                }
                else
                {
                    rangeOk = false;
                    if (details != null)
                    {
                        details.AddError(ExecutionDetails.ColumnDoesNotSupportOperator, op, this.Name);
                    }
                }
            }
            else
            {
                int first = FindFirstWhere(value);
                int last  = FindLastWhere(value);
                // Determine the range to scan to compute the result
                if (!RangeToScan.TryBuild(op, first, last, this.Column.Count, ref range))
                {
                    rangeOk = false;
                    if (details != null)
                    {
                        details.AddError(ExecutionDetails.ColumnDoesNotSupportOperator, op, this.Name);
                    }
                }
            }

            // Build the result set and return it
            if (rangeOk == true)
            {
                range.AddMatches(this.SortedIDs, result);
            }
        }