MCPcopy Create free account
hub / github.com/brimdata/super / isKeyOfAggregate

Function isKeyOfAggregate

compiler/optimizer/op.go:103–119  ·  view source on GitHub ↗

isKeyOfAggregate returns true iff any of a's grouping keys is the same as the given primary-key sort order or an order-preserving function thereof.

(a *dag.AggregateOp, in order.SortKeys)

Source from the content-addressed store, hash-verified

101// same as the given primary-key sort order or an order-preserving function
102// thereof.
103func isKeyOfAggregate(a *dag.AggregateOp, in order.SortKeys) bool {
104 if in.IsNil() {
105 return false
106 }
107 key := in[0].Key
108 for _, outputKeyExpr := range a.Keys {
109 groupingKey := fieldOf(outputKeyExpr.LHS)
110 if groupingKey.Equal(key) {
111 rhsExpr := outputKeyExpr.RHS
112 rhs := fieldOf(rhsExpr)
113 if rhs.Equal(key) || orderPreservingCall(rhsExpr, groupingKey) {
114 return true
115 }
116 }
117 }
118 return false
119}
120
121func orderPreservingCall(e dag.Expr, key field.Path) bool {
122 if call, ok := e.(*dag.CallExpr); ok {

Callers 2

analyzeSortKeysMethod · 0.85
concurrentPathMethod · 0.85

Calls 4

fieldOfFunction · 0.85
orderPreservingCallFunction · 0.85
IsNilMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected