Added storage limits (#28270)

This commit is contained in:
divyaac
2024-09-10 08:46:15 -07:00
committed by GitHub
parent 392412829b
commit 582035e162

View File

@@ -153,10 +153,19 @@ func (s *singleMonthActivityClients) populateSegments() (map[int][]*activity.Ent
return segments, nil
}
totalSegmentCount := 1
// determine how many segments are necessary to store the clients for this month
// using the default storage limits
numNecessarySegments := len(s.clients) / ActivitySegmentClientCapacity
if len(s.clients)%ActivitySegmentClientCapacity != 0 {
numNecessarySegments++
}
totalSegmentCount := numNecessarySegments
// override the segment count if set by client
if s.generationParameters.GetNumSegments() > 0 {
totalSegmentCount = int(s.generationParameters.GetNumSegments())
}
numNonUsable := len(skipIndexes) + len(emptyIndexes)
usableSegmentCount := totalSegmentCount - numNonUsable
if usableSegmentCount <= 0 {
@@ -169,6 +178,10 @@ func (s *singleMonthActivityClients) populateSegments() (map[int][]*activity.Ent
segmentSizes++
}
if segmentSizes > ActivitySegmentClientCapacity {
return nil, fmt.Errorf("the number of segments is too low, it must be greater than %d in order to meet storage limits", numNecessarySegments)
}
clientIndex := 0
for i := 0; i < totalSegmentCount; i++ {
if clientIndex >= len(s.clients) {