Skip to content

Added MaxContributions to privacy-on-beam/pbeam/count.go#337

Open
kutay25 wants to merge 2 commits intogoogle:mainfrom
kutay25:main
Open

Added MaxContributions to privacy-on-beam/pbeam/count.go#337
kutay25 wants to merge 2 commits intogoogle:mainfrom
kutay25:main

Conversation

@kutay25
Copy link

@kutay25 kutay25 commented Sep 24, 2025

Added MaxContributions to privacy-on-beam/pbeam/count.go and the associated codepath at go/dpagg.

The proposal can be found in this document.

@miracvbasaran miracvbasaran self-requested a review September 24, 2025 14:31
Copy link
Collaborator

@miracvbasaran miracvbasaran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG overall, thanks a lot for working on this!

@kutay25 kutay25 marked this pull request as ready for review February 10, 2026 14:36

if maxContributionsSet {
// MaxContributions configuration must be used
if maxValue != 0 || maxPartitionsContributed != 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use if maxValueSet || maxPartitionsContributedSet here, or get rid of {maxContributionsSet, maxValueSet, maxPartitionsContributedSet} and just check for positive in the if statements

return fmt.Errorf("when MaxContributions is set, MaxValue and MaxPartitionsContributed must be 0")
}
return nil
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for else, we return in the previous segment

PreThreshold int64
// MaxPartitionsContributed is the number of distinct partitions a single
// privacy unit can contribute to. Required.
// privacy unit can contribute to. For PreAggSelectPartition, MaxPartitionsContributed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "For PreAggSelectionPartition, setting MaxPartitionsContributed is functionally the same as setting MaxContributions, but are kept separate for consistency with other aggregations."

(also the same below)

// This does not hold for privacy-ID count aggregations, where l0=MaxContributions and lInf=1.
lInf = opt.MaxContributions
// When using MaxContributions, no per-partition contribution bounding is performed.
// upper is set to math.MaxInt64 to avoid clamping any contributions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: upper is set to a default of match.MaxInt64 because it is being used in the Add function below, making it a no-op.

Comment on lines +189 to +190
if maxContributions <= 0 && maxPartitionsContributed <= 0 {
return 0, fmt.Errorf("Exactly one of MaxContributions and MaxPartitionsContributed must be set")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to use checks package here, no?

}
if maxContributions > 0 {
return 1, nil
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, no need for else after returning

Comment on lines +260 to +263
return fmt.Errorf("MaxContributions and MaxPartitionsContributed are both set, exactly one should be set.")
}
if maxContributions <= 0 && maxPartitionsContributed <= 0 {
return fmt.Errorf("MaxContributions and MaxPartitionsContributed are both unset, exactly one should be set.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super-nit: no punctuation should be used at the end of error strings in golang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants