MCPcopy Create free account
hub / github.com/akalin/gopar / newCoderAndShards

Method newCoderAndShards

par2/decoder.go:561–582  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

559}
560
561func (d *Decoder) newCoderAndShards() (rsec16.Coder, [][]byte, error) {
562 if len(d.fileIntegrityInfos) == 0 {
563 return rsec16.Coder{}, nil, errors.New("no file integrity info")
564 }
565
566 if len(d.parityShards) == 0 {
567 return rsec16.Coder{}, nil, errors.New("no parity shards")
568 }
569
570 var dataShards [][]byte
571 for _, info := range d.fileIntegrityInfos {
572 for _, shardInfo := range info.shardInfos {
573 dataShards = append(dataShards, shardInfo.data)
574 }
575 }
576 coder, err := rsec16.NewCoderPAR2Vandermonde(len(dataShards), len(d.parityShards), d.numGoroutines)
577 if err != nil {
578 return rsec16.Coder{}, nil, err
579 }
580
581 return coder, dataShards, err
582}
583
584// ShardCounts contains shard counts which can be used to deduce
585// whether repair is necessary and/or possible.

Callers 1

RepairMethod · 0.95

Calls 1

NewCoderPAR2VandermondeFunction · 0.92

Tested by

no test coverage detected