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

Function newDecoder

par2/decoder.go:248–290  ·  view source on GitHub ↗
(fileIO fileIO, delegate DecoderDelegate, indexPath string, numGoroutines int)

Source from the content-addressed store, hash-verified

246func (DoNothingDecoderDelegate) OnDataFileWrite(i, n int, path string, byteCount int, err error) {}
247
248func newDecoder(fileIO fileIO, delegate DecoderDelegate, indexPath string, numGoroutines int) (*Decoder, error) {
249 indexBytes, err := fileIO.ReadFile(indexPath)
250 if err != nil {
251 return nil, err
252 }
253
254 setID, indexFile, err := readFile(delegate, nil, indexBytes)
255 if err != nil {
256 return nil, err
257 }
258
259 if indexFile.mainPacket == nil {
260 // TODO: Relax this check.
261 return nil, errors.New("no main packet found")
262 }
263
264 if len(indexFile.recoveryPackets) > 0 {
265 // TODO: Relax this check.
266 return nil, errors.New("recovery packets found in index file")
267 }
268
269 recoverySet, err := makeDecoderInputFileInfos(indexFile.mainPacket.recoverySet, indexFile.fileDescriptionPackets, indexFile.ifscPackets)
270 if err != nil {
271 return nil, err
272 }
273
274 nonRecoverySet, err := makeDecoderInputFileInfos(indexFile.mainPacket.nonRecoverySet, indexFile.fileDescriptionPackets, indexFile.ifscPackets)
275 if err != nil {
276 return nil, err
277 }
278
279 return &Decoder{
280 fileIO, delegate,
281 indexPath,
282 setID,
283 indexFile.clientID, indexFile.mainPacket.sliceByteCount,
284 recoverySet, nonRecoverySet,
285 numGoroutines,
286 nil,
287 nil,
288 nil,
289 }, nil
290}
291
292func sixteenKHash(data []byte) [md5.Size]byte {
293 if len(data) < 16*1024 {

Callers 4

NewDecoderFunction · 0.70
repairFunction · 0.70
verifyFunction · 0.70
newDecoderForTestFunction · 0.70

Calls 3

readFileFunction · 0.85
ReadFileMethod · 0.65

Tested by 1

newDecoderForTestFunction · 0.56