-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vam: Support partials for aggregations (#5416)
- Loading branch information
Showing
7 changed files
with
159 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package agg | ||
|
||
import ( | ||
"github.com/brimdata/super" | ||
"github.com/brimdata/super/vector" | ||
) | ||
|
||
type count struct { | ||
count uint64 | ||
} | ||
|
||
func (a *count) Consume(vec vector.Any) { | ||
a.count += uint64(vec.Len()) | ||
} | ||
|
||
func (a *count) Result(*super.Context) super.Value { | ||
return super.NewUint64(a.count) | ||
} | ||
|
||
func (a *count) ConsumeAsPartial(partial vector.Any) { | ||
c, ok := partial.(*vector.Const) | ||
if !ok || c.Len() != 1 || partial.Type() != super.TypeUint64 { | ||
panic("count: bad partial") | ||
} | ||
a.count += c.Value().Uint() | ||
} | ||
|
||
func (a *count) ResultAsPartial(*super.Context) super.Value { | ||
return a.Result(nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters