// makeBatch returns a new ObservationBatch for |key| consisting of the next
// chunk of observations from |iterator| of size at most |batchSize|.
makeBatch returns a new ObservationBatch for |key| consisting of the next
chunk of observations from |iterator| of size at most |batchSize|.
// makeBatch returns a new ObservationBatch for |key| consisting of the next // chunk of observations from |iterator| of size at most |batchSize| .
func makeBatch(key *cobalt.ObservationMetadata, iterator storage.Iterator, batchSize int) ([]*shuffler.ObservationVal, *cobalt.ObservationBatch) {
	if batchSize <= 0 {
		panic("batchSize must be positive.")
	}
	var encryptedMessages []*cobalt.EncryptedMessage
	var obVals []*shuffler.ObservationVal
	for iterator.Next() {
		obVal, err := iterator.Get()
		if err != nil {
			stackdriver.LogCountMetricf(makeBatchFailed, "makeBatch: iterator.Get() returned an error: %v", err)
			continue
		}
		obVals = append(obVals, obVal)
		encryptedMessages = append(encryptedMessages, obVal.EncryptedObservation)
		if len(encryptedMessages) == batchSize {
			break
		}
	}
	batch := cobalt.ObservationBatch{
		MetaData:             key,
		EncryptedObservation: encryptedMessages,
	}
	return obVals, &batch
}
func makeBatch ( key * cobalt . ObservationMetadata , iterator storage . Iterator , batchSize int ) ( [ ] * shuffler . ObservationVal , * cobalt . ObservationBatch ) { if batchSize <= 0 { panic ( " " ) } var encryptedMessages [ ] * cobalt . EncryptedMessage var obVals [ ] * shuffler . ObservationVal for iterator . Next ( ) { obVal , err := iterator . Get ( ) if err != nil { stackdriver . LogCountMetricf ( makeBatchFailed , " " , err ) continue } obVals = append ( obVals , obVal ) encryptedMessages = append ( encryptedMessages , obVal . EncryptedObservation ) if len ( encryptedMessages ) == batchSize { break } } batch := cobalt . ObservationBatch { MetaData : key , EncryptedObservation : encryptedMessages , } return obVals , & batch }
makeBatch returns a new ObservationBatch for |key| consisting of the next
chunk of observations from |iterator| of size at most |batchSize|.
makeBatch returns a new ObservationBatch for |key| consisting of the next chunk of observations from |iterator| of size at most |batchSize| .