MCPcopy Index your code
hub / github.com/klauspost/compress / decode

Method decode

zstd/seqdec_asm.go:176–238  ·  view source on GitHub ↗

decode sequences from the stream without the provided history.

(seqs []seqVals)

Source from the content-addressed store, hash-verified

174
175// decode sequences from the stream without the provided history.
176func (s *sequenceDecs) decode(seqs []seqVals) error {
177 br := s.br
178
179 maxBlockSize := min(s.windowSize, maxCompressedBlockSize)
180
181 ctx := decodeAsmContext{
182 llTable: s.litLengths.fse.dt[:maxTablesize],
183 mlTable: s.matchLengths.fse.dt[:maxTablesize],
184 ofTable: s.offsets.fse.dt[:maxTablesize],
185 llState: uint64(s.litLengths.state.state),
186 mlState: uint64(s.matchLengths.state.state),
187 ofState: uint64(s.offsets.state.state),
188 seqs: seqs,
189 iteration: len(seqs) - 1,
190 litRemain: len(s.literals),
191 }
192
193 if debugDecoder {
194 println("decode: decoding", len(seqs), "sequences", br.remain(), "bits remain on stream")
195 }
196
197 s.seqSize = 0
198 lte56bits := s.maxBits+s.offsets.fse.actualTableLog+s.matchLengths.fse.actualTableLog+s.litLengths.fse.actualTableLog <= 56
199 errCode := decodeAsm(s, br, &ctx, lte56bits)
200 if errCode != 0 {
201 i := len(seqs) - ctx.iteration - 1
202 switch errCode {
203 case errorMatchLenOfsMismatch:
204 ml := ctx.seqs[i].ml
205 return fmt.Errorf("zero matchoff and matchlen (%d) > 0", ml)
206
207 case errorMatchLenTooBig:
208 ml := ctx.seqs[i].ml
209 return fmt.Errorf("match len (%d) bigger than max allowed length", ml)
210
211 case errorNotEnoughLiterals:
212 ll := ctx.seqs[i].ll
213 return fmt.Errorf("unexpected literal count, want %d bytes, but only %d is available", ll, ctx.litRemain+ll)
214 case errorOverread:
215 return io.ErrUnexpectedEOF
216 }
217
218 return fmt.Errorf("sequenceDecs_decode_amd64 returned erroneous code %d", errCode)
219 }
220
221 if ctx.litRemain < 0 {
222 return fmt.Errorf("literal count is too big: total available %d, total requested %d",
223 len(s.literals), len(s.literals)-ctx.litRemain)
224 }
225
226 s.seqSize += ctx.litRemain
227 if s.seqSize > maxBlockSize {
228 return fmt.Errorf("output bigger than max block size (%d)", maxBlockSize)
229 }
230 if debugDecoder {
231 println("decode: ", br.remain(), "bits remain on stream. code:", errCode)
232 }
233 err := br.close()

Callers 6

decodeSequencesMethod · 0.45
Test_seqdec_decoderFunction · 0.45
Test_seqdec_executeFunction · 0.45
benchmark_seqdec_decodeFunction · 0.45
Benchmark_seqdec_executeFunction · 0.45

Calls 5

printlnFunction · 0.85
printfFunction · 0.85
decodeAsmFunction · 0.70
remainMethod · 0.45
closeMethod · 0.45

Tested by 5

Test_seqdec_decoderFunction · 0.36
Test_seqdec_executeFunction · 0.36
benchmark_seqdec_decodeFunction · 0.36
Benchmark_seqdec_executeFunction · 0.36