// makeTestStore returns a sample test store with |numObservations| for a single
// ObservationMetadata key and its generated |obVals| or an error.
//
// The observations are divided in such a way that first 1/4th of the
// observations are generated for the |currentDayIndex|, next 1/4th are
// generated for |currentDayIndex - 1| and so on spanning a range of 4
// dayIndexes.
//
// The test store created is an in-memory store if |useMemStore| is true.
// Otherwise, a LevelDB persistent store is used.
makeTestStore returns a sample test store with |numObservations| for a single
ObservationMetadata key and its generated |obVals| or an error.

The observations are divided in such a way that first 1/4th of the
observations are generated for the |currentDayIndex|, next 1/4th are
generated for |currentDayIndex - 1| and so on spanning a range of 4
dayIndexes.

The test store created is an in-memory store if |useMemStore| is true.
Otherwise, a LevelDB persistent store is used.
// makeTestStore returns a sample test store with |numObservations| for a single // ObservationMetadata key and its generated |obVals| or an error . // // The observations are divided in such a way that first 1 / 4th of the // observations are generated for the |currentDayIndex| next 1 / 4th are // generated for |currentDayIndex - 1| and so on spanning a range of 4 // dayIndexes . // // The test store created is an in - memory store if |useMemStore| is true . // Otherwise a LevelDB persistent store is used .
func makeTestStore(numObservations int, currentDayIndex uint32, useMemStore bool) (storage.Store, *cobalt.ObservationMetadata, []*shuffler.ObservationVal, error) {
	var store storage.Store
	var err error
	if useMemStore {
		store = storage.NewMemStore()
	} else {
		if store, err = storage.NewLevelDBStore("/tmp/dispatcher_db"); err != nil {
			return nil, nil, nil, err
		}
	}
	om := storage.NewObservationMetaData(22)
	dayIndexRange := []uint32{
		currentDayIndex - 1,
		currentDayIndex - 2,
		currentDayIndex - 3,
		currentDayIndex - 4}
	for _, di := range dayIndexRange {
		batch := &cobalt.ObservationBatch{
			MetaData:             om,
			EncryptedObservation: storage.MakeRandomEncryptedMsgs(numObservations / 4),
		}
		if err = store.AddAllObservations([]*cobalt.ObservationBatch{batch}, di); err != nil {
			return nil, nil, nil, err
		}
	}
	iter, err := store.GetObservations(om)
	if err != nil {
		return nil, nil, nil, err
	}
	if iter == nil {
		return nil, nil, nil, fmt.Errorf("GetObservations: got empty iterator for metadata [%v]", om)
	}
	var obVals []*shuffler.ObservationVal
	for iter.Next() {
		obVal, iErr := iter.Get()
		if iErr != nil {
			return nil, nil, nil, iErr
		}
		obVals = append(obVals, obVal)
	}
	if err := iter.Release(); err != nil {
		return nil, nil, nil, err
	}
	return store, om, obVals, nil
}
func makeTestStore ( numObservations int , currentDayIndex uint32 , useMemStore bool ) ( storage . Store , * cobalt . ObservationMetadata , [ ] * shuffler . ObservationVal , error ) { var store storage . Store var err error if useMemStore { store = storage . NewMemStore ( ) } else { if store , err = storage . NewLevelDBStore ( " " ) ; err != nil { return nil , nil , nil , err } } om := storage . NewObservationMetaData ( 22 ) dayIndexRange := [ ] uint32 { currentDayIndex - 1 , currentDayIndex - 2 , currentDayIndex - 3 , currentDayIndex - 4 } for _ , di := range dayIndexRange { batch := & cobalt . ObservationBatch { MetaData : om , EncryptedObservation : storage . MakeRandomEncryptedMsgs ( numObservations / 4 ) , } if err = store . AddAllObservations ( [ ] * cobalt . ObservationBatch { batch } , di ) ; err != nil { return nil , nil , nil , err } } iter , err := store . GetObservations ( om ) if err != nil { return nil , nil , nil , err } if iter == nil { return nil , nil , nil , fmt . Errorf ( " " , om ) } var obVals [ ] * shuffler . ObservationVal for iter . Next ( ) { obVal , iErr := iter . Get ( ) if iErr != nil { return nil , nil , nil , iErr } obVals = append ( obVals , obVal ) } if err := iter . Release ( ) ; err != nil { return nil , nil , nil , err } return store , om , obVals , nil }
makeTestStore returns a sample test store with |numObservations| for a single
ObservationMetadata key and its generated |obVals| or an error.
makeTestStore returns a sample test store with |numObservations| for a single ObservationMetadata key and its generated |obVals| or an error .
// Get all observations in one big chunk