func mergeBlockStreams(ph *partHeader, bsw *blockStreamWriter, bsrs []*blockStreamReader, stopCh <-chan struct{}, itemsMerged *uint64) error {
	bsm := bsmPool.Get().(*blockStreamMerger)
	if err := bsm.Init(bsrs); err != nil {
		return fmt.Errorf("cannot initialize blockStreamMerger: %s", err)
	}
	err := bsm.Merge(bsw, ph, stopCh, itemsMerged)
	bsm.reset()
	bsmPool.Put(bsm)
	bsw.MustClose()
	if err == nil {
		return nil
	}
	if err == errForciblyStopped {
		return err
	}
	return fmt.Errorf("cannot merge block streams: %s", err)
}
// mergeBlockStreams merges bsrs and writes result to bsw.
//
// It also fills ph.
//
// The function immediately returns when stopCh is closed.
//
// It also atomically adds the number of items merged to itemsMerged.
mergeBlockStreams merges bsrs and writes result to bsw.

It also fills ph.

The function immediately returns when stopCh is closed.

It also atomically adds the number of items merged to itemsMerged.
// mergeBlockStreams merges bsrs and writes result to bsw . // // It also fills ph . // // The function immediately returns when stopCh is closed . // // It also atomically adds the number of items merged to itemsMerged .
func mergeBlockStreams(ph *partHeader, bsw *blockStreamWriter, bsrs []*blockStreamReader, stopCh <-chan struct{}, itemsMerged *uint64) error {
	bsm := bsmPool.Get().(*blockStreamMerger)
	if err := bsm.Init(bsrs); err != nil {
		return fmt.Errorf("cannot initialize blockStreamMerger: %s", err)
	}
	err := bsm.Merge(bsw, ph, stopCh, itemsMerged)
	bsm.reset()
	bsmPool.Put(bsm)
	bsw.MustClose()
	if err == nil {
		return nil
	}
	if err == errForciblyStopped {
		return err
	}
	return fmt.Errorf("cannot merge block streams: %s", err)
}
func mergeBlockStreams ( ph * partHeader , bsw * blockStreamWriter , bsrs [ ] * blockStreamReader , stopCh <- chan struct { } , itemsMerged * uint64 ) error { bsm := bsmPool . Get ( ) . ( * blockStreamMerger ) if err := bsm . Init ( bsrs ) ; err != nil { return fmt . Errorf ( " " , err ) } err := bsm . Merge ( bsw , ph , stopCh , itemsMerged ) bsm . reset ( ) bsmPool . Put ( bsm ) bsw . MustClose ( ) if err == nil { return nil } if err == errForciblyStopped { return err } return fmt . Errorf ( " " , err ) }
mergeBlockStreams merges bsrs and writes result to bsw.
mergeBlockStreams merges bsrs and writes result to bsw .