Exemple #1
0
 private void OptimizeFilters(IJournalCore journal, IReadTransactionContext tx)
 {
     if (_andFilters != null)
     {
         _andFilters.Sort(new DescendingCardinalityComparer(journal, tx));
     }
 }
Exemple #2
0
 public long GetCardinality(IJournalCore journal, IReadTransactionContext tx)
 {
     if (_keys == null)
     {
         return(_journal.QueryStatistics.GetColumnDistinctCardinality(tx, _column));
     }
     return(_keys.Count);
 }
Exemple #3
0
 public long Cardinality(IJournalCore journal, IReadTransactionContext tx)
 {
     if (!_cardinality.HasValue)
     {
         _cardinality = journal.QueryStatistics.GetColumnDistinctCardinality(tx, _column);
     }
     return(_cardinality.Value);
 }
Exemple #4
0
        public IEnumerable <long> Execute(IJournalCore journal, IReadTransactionContext tx, ERowIDSortDirection sortDirection)
        {
            var intervalFilter = new PartitionIntervalIterator();
            var symbolFilter   = new LatestByFilter <T>(journal, _column, _keys);

            return(Timestamps.AllIntervals.Reverse().SelectMany(interval =>
                                                                symbolFilter.Filter(intervalFilter.IteratePartitions(
                                                                                        tx.ReverseReadPartitions, interval, tx), tx, sortDirection)
                                                                ));
        }
 public long Cardinality(IJournalCore journal, IReadTransactionContext tx)
 {
     if (!_caridnality.HasValue)
     {
         var intervalFilter = new PartitionIntervalIterator();
         _caridnality =
             Timestamps
             .AllIntervals
             .Sum(p => intervalFilter.IteratePartitions(tx.ReadPartitions, p, tx).Sum(p2 => p2.High - p2.Low));
     }
     return(_caridnality.Value);
 }
Exemple #6
0
 public long Cardinality(IJournalCore journal, IReadTransactionContext tx)
 {
     if (!_cardin.HasValue)
     {
         if (_andFilters != null)
         {
             _cardin = _andFilters.Min(f => f.GetCardinality(journal, tx));
         }
         else
         {
             _cardin = long.MaxValue;
         }
     }
     return(_cardin.Value);
 }
        public IEnumerable <long> Execute(IJournalCore journal, IReadTransactionContext tx, ERowIDSortDirection sort)
        {
            var intervalFilter = new PartitionIntervalIterator();

            if (sort == ERowIDSortDirection.Desc)
            {
                return(Timestamps.AllIntervals.Reverse().SelectMany(
                           interval => GetIdsDesc(
                               intervalFilter.IteratePartitions(
                                   tx.ReadPartitions.Reverse(), interval, tx))
                           ));
            }
            return(Timestamps.AllIntervals.SelectMany(
                       interval => GetIdsAsc(
                           intervalFilter.IteratePartitions(tx.ReadPartitions, interval, tx))
                       ));
        }
Exemple #8
0
        public IEnumerable <long> Execute(IJournalCore journal, IReadTransactionContext tx, ERowIDSortDirection sort)
        {
            // Timestamp restricted
            if (_left is TimestampRangePlanItem)
            {
                return(_right.Execute(journal, tx, sort));
            }

            if (_right is TimestampRangePlanItem)
            {
                return(_left.Execute(journal, tx, sort));
            }

            if (_left.Cardinality(journal, tx) < _right.Cardinality(journal, tx))
            {
                return(Intersect(_left.Execute(journal, tx, sort), _right.Execute(journal, tx, sort), sort));
            }
            return(Intersect(_right.Execute(journal, tx, sort), _left.Execute(journal, tx, sort), sort));
        }
Exemple #9
0
        public IEnumerable <long> Execute(IJournalCore journal, IReadTransactionContext tx,
                                          ERowIDSortDirection sort)
        {
            var intervalFilter = new PartitionIntervalIterator();
            var intervals      = Timestamps.AllIntervals.SelectMany(
                i => intervalFilter.IteratePartitions(tx.ReadPartitions, i, tx)).ToList();

            if (sort == ERowIDSortDirection.Desc)
            {
                intervals.Reverse();
            }

            if (_partitionFilter != null)
            {
                if (_andFilters == null)
                {
                    return(_partitionFilter.Filter(intervals, tx, sort));
                }
                OptimizeFilters(journal, tx);
                return(ApplyFilters(_partitionFilter.Filter(intervals, tx, sort), tx));
            }
            OptimizeFilters(journal, tx);
            return(FilterRowsRange(tx, intervals, sort));
        }
 public ResultSetBuilder(IJournalCore journal, IReadTransactionContext tx)
 {
     _journal  = journal;
     _tx       = tx;
     _planHead = new TimestampRangePlanItem(DateInterval.Any);
 }
 internal ExpressionEvaluatorVisitor(IJournalCore journal, IReadTransactionContext tx, Type itemType)
 {
     _journal  = journal;
     _tx       = tx;
     _itemType = itemType;
 }
Exemple #12
0
 public RecordQuery(IJournalCore journal, IReadTransactionContext tx)
 {
     _journal = journal;
     _tx      = tx;
 }
Exemple #13
0
 public LatestByFilter(IJournalCore journal, IColumnMetadata column, IList <T> keys)
 {
     _journal = journal;
     _column  = column;
     _keys    = keys;
 }
 public JournalQueryProvider(IJournalCore journal, IReadTransactionContext tx)
 {
     _journal = journal;
     _tx      = tx;
 }
Exemple #15
0
 public RowScanPlanItem(IJournalCore journal, IReadTransactionContext tx)
 {
     _journal   = journal;
     _tx        = tx;
     Timestamps = new DateRange();
 }
Exemple #16
0
 public DescendingCardinalityComparer(IJournalCore journal, IReadTransactionContext rtx)
 {
     _journal = journal;
     _rtx     = rtx;
 }
 internal ExpressionEvaluatorVisitor(IJournalCore journal, IReadTransactionContext tx, QlParameter[] parameters)
 {
     _journal    = journal;
     _tx         = tx;
     _parameters = parameters;
 }
Exemple #18
0
 public override long GetCardinality(IJournalCore journal, IReadTransactionContext tx)
 {
     return(long.MaxValue);
 }
 public QueryPlanBinder(IJournalCore journal, IReadTransactionContext tx)
 {
     _journal = journal;
     _tx      = tx;
 }
Exemple #20
0
 public override long GetCardinality(IJournalCore journal, IReadTransactionContext tx)
 {
     return(journal.QueryStatistics.GetCardinalityByColumnValue(tx, _column, _values ?? new[] { _value }));
 }
 public abstract long GetCardinality(IJournalCore journal, IReadTransactionContext tx);
Exemple #22
0
 public long Cardinality(IJournalCore journal, IReadTransactionContext tx)
 {
     return(Math.Min(_left.Cardinality(journal, tx), _right.Cardinality(journal, tx)));
 }
Exemple #23
0
 public IEnumerable <long> Execute(IJournalCore journal, IReadTransactionContext tx, ERowIDSortDirection sort)
 {
     return(MergeDistinct(_left.Execute(journal, tx, sort), _right.Execute(journal, tx, sort), sort));
 }