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

Method validateNorm

zstd/fse_encoder.go:457–484  ·  view source on GitHub ↗

validateNorm validates the normalized histogram table.

()

Source from the content-addressed store, hash-verified

455
456// validateNorm validates the normalized histogram table.
457func (s *fseEncoder) validateNorm() (err error) {
458 var total int
459 for _, v := range s.norm[:s.symbolLen] {
460 if v >= 0 {
461 total += int(v)
462 } else {
463 total -= int(v)
464 }
465 }
466 defer func() {
467 if err == nil {
468 return
469 }
470 fmt.Printf("selected TableLog: %d, Symbol length: %d\n", s.actualTableLog, s.symbolLen)
471 for i, v := range s.norm[:s.symbolLen] {
472 fmt.Printf("%3d: %5d -> %4d \n", i, s.count[i], v)
473 }
474 }()
475 if total != (1 << s.actualTableLog) {
476 return fmt.Errorf("warning: Total == %d != %d", total, 1<<s.actualTableLog)
477 }
478 for i, v := range s.count[s.symbolLen:] {
479 if v != 0 {
480 return fmt.Errorf("warning: Found symbol out of range, %d after cut", i)
481 }
482 }
483 return nil
484}
485
486// writeCount will write the normalized histogram count to header.
487// This is read back by readNCount.

Callers 1

normalizeCountMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected