Exemple #1
0
 public bool Equals(DateInterval other)
 {
     return(Start.Equals(other.Start) && End.Equals(other.End));
 }
Exemple #2
0
        public IList <PartitionRowIDRange> IteratePartitions(IEnumerable <IPartitionReader> partitions,
                                                             DateInterval interval, IReadTransactionContext tx)
        {
            if (DateInterval.Any.Equals(interval))
            {
                return
                    (partitions.Select(p => new PartitionRowIDRange(p.PartitionID, 0, tx.GetRowCount(p.PartitionID) - 1))
                     .ToList());
            }

            var result = new List <PartitionRowIDRange>();

            foreach (var reader in partitions)
            {
                if (reader == null)
                {
                    continue;
                }

                long low         = long.MaxValue;
                long hi          = long.MinValue;
                int  partitionID = reader.PartitionID;
                var  partt       = tx.GetPartitionTx(partitionID);

                if (interval.Start < partt.StartDate)
                {
                    low = 0;
                }
                else if (partt.StartDate <= interval.Start && interval.Start < partt.EndDate)
                {
                    // ReSharper disable once PossibleNullReferenceException
                    low = reader.BinarySearchTimestamp(interval.Start, tx);
                    if (low < 0)
                    {
                        low = ~low;
                    }
                }

                // Interval and partition end days
                // are both exclusive
                if (interval.End >= partt.EndDate)
                {
                    hi = tx.GetRowCount(partitionID) - 1;
                }
                else if (partt.StartDate <= interval.End && interval.End < partt.EndDate)
                {
                    // ReSharper disable once PossibleNullReferenceException
                    hi = reader.BinarySearchTimestamp(interval.End, tx);
                    if (hi < 0)
                    {
                        hi = ~hi - 1;
                    }
                    else
                    {
                        hi = hi - 1;
                    }
                }

                if (low <= hi)
                {
                    result.Add(new PartitionRowIDRange(partitionID, low, hi));
                }
            }
            return(result);
        }