private BoundRelation PushOverTop(BoundFilterRelation node, BoundTopRelation input) { var newFilter = RewriteRelation(node.Update(input.Input, node.Condition)); var newInput = input.Update(newFilter, input.Limit, input.TieEntries); return(newInput); }
private static CardinalityEstimate EstimateTopRelation(BoundTopRelation relation) { var input = Estimate(relation.Input); return(relation.TieEntries.Any() ? input : new CardinalityEstimate(input.Minimum, relation.Limit)); }
private Iterator BuildTopWithTies(BoundTopRelation relation) { var input = BuildRelation(relation.Input); var rowBufferAllocation = BuildRowBufferAllocation(relation.Input, input.RowBuffer); var tieEntries = relation.TieEntries.Select(t => rowBufferAllocation[t.ValueSlot]).ToImmutableArray(); var tieComparers = relation.TieEntries.Select(t => t.Comparer).ToImmutableArray(); return(new TopWithTiesIterator(input, relation.Limit, tieEntries, tieComparers)); }
protected override BoundRelation RewriteTopRelation(BoundTopRelation node) { _recorder.Record(node.TieEntries); return(base.RewriteTopRelation(node)); }
private static ShowPlanNode BuildTop(BoundTopRelation node) { var tieEntries = string.Join(@", ", node.TieEntries.Select(v => v.ValueSlot.Name)); var operatorName = $"Top {node.Limit}{(!node.TieEntries.Any() ? string.Empty : $" With Ties ({tieEntries})")}";
private Iterator BuildTopWithoutTies(BoundTopRelation relation) { var input = BuildRelation(relation.Input); return(new TopIterator(input, relation.Limit)); }
private Iterator BuildTop(BoundTopRelation relation) { return(relation.TieEntries.Any() ? BuildTopWithTies(relation) : BuildTopWithoutTies(relation)); }