MCPcopy Create free account
hub / github.com/egonelbre/exp / Decode

Method Decode

physicscompress/physics/encoding.go:88–138  ·  view source on GitHub ↗
(snapshot []byte)

Source from the content-addressed store, hash-verified

86}
87
88func (s *State) Decode(snapshot []byte) {
89 dec := arith.NewDecoder(snapshot)
90
91 s.Current().Assign(s.Baseline())
92 historic := s.Historic().Cubes
93 baseline := s.Baseline().Cubes
94 current := s.Current().Cubes
95
96 mzeros := mZeros()
97
98 items := []int{}
99 for i := range current {
100 if mzeros.Decode(dec) == 1 {
101 items = append(items, i)
102 }
103 }
104
105 for _, i := range items {
106 cube := &current[i]
107 cube.Interacting = int32(mzeros.Decode(dec) ^ 1)
108 }
109
110 for _, i := range items {
111 cube, base := &current[i], &baseline[i]
112 v0, v1 := mzeros.Decode(dec), mzeros.Decode(dec)
113 cube.Largest = base.Largest ^ int32(v1<<1|v0)
114 }
115
116 items6 := Index6(items, len(baseline))
117 SortByZ(items6, Delta6(historic, baseline))
118 set6 := SetExtra6(historic, baseline, current)
119
120 nbits := uint(0)
121 for mzeros.Decode(dec) == 0 {
122 nbits += 1
123 }
124
125 if nbits == 0 {
126 for _, i := range items6 {
127 set6(i, 0)
128 }
129 return
130 }
131
132 mvalues := mValues(nbits)
133 for _, i := range items6 {
134 z := mvalues.Decode(dec)
135 v := bit.ZDecode(uint64(z))
136 set6(i, int32(v))
137 }
138}
139
140func Index6(index []int, N int) []int {
141 r := make([]int, 0, len(index)*6)

Callers 1

mainFunction · 0.95

Calls 13

CurrentMethod · 0.95
BaselineMethod · 0.95
HistoricMethod · 0.95
NewDecoderFunction · 0.92
ZDecodeFunction · 0.92
Index6Function · 0.85
Delta6Function · 0.85
SetExtra6Function · 0.85
mZerosFunction · 0.70
SortByZFunction · 0.70
mValuesFunction · 0.70
AssignMethod · 0.65

Tested by

no test coverage detected