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

Method Decode

physicscompress2/physics/encoding.go:99–144  ·  view source on GitHub ↗
(snapshot []byte)

Source from the content-addressed store, hash-verified

97}
98
99func (s *State) Decode(snapshot []byte) {
100 dec := arith.NewDecoder(snapshot)
101
102 s.Current().Assign(s.Baseline())
103 historic := s.Historic().Cubes
104 _ = historic
105 baseline := s.Baseline().Cubes
106 current := s.Current().Cubes
107
108 mzeros := mZeros()
109
110 items := []int{}
111 for i := range current {
112 if mzeros.Decode(dec) == 1 {
113 items = append(items, i)
114 }
115 }
116
117 for _, i := range items {
118 cube := &current[i]
119 cube.Interacting = mzeros.Decode(dec) == 0
120 }
121
122 props := IndexProps(items, len(baseline))
123 SortByZ(props, Props(baseline))
124 setProp := SetProps(current)
125
126 nbits := uint(0)
127 for mzeros.Decode(dec) == 0 {
128 nbits += 1
129 }
130
131 if nbits == 0 {
132 for _, i := range props {
133 setProp(i, 0)
134 }
135 return
136 }
137
138 mvalues := mValues(nbits)
139 for _, i := range props {
140 z := mvalues.Decode(dec)
141 v := bit.ZDecode(uint64(z))
142 setProp(i, int(v))
143 }
144}
145
146func IndexProps(index []int, N int) []int {
147 r := make([]int, 0, len(index)*7)

Callers 1

mainFunction · 0.95

Calls 13

CurrentMethod · 0.95
BaselineMethod · 0.95
HistoricMethod · 0.95
NewDecoderFunction · 0.92
ZDecodeFunction · 0.92
IndexPropsFunction · 0.85
PropsFunction · 0.85
SetPropsFunction · 0.85
mZerosFunction · 0.70
SortByZFunction · 0.70
mValuesFunction · 0.70
AssignMethod · 0.65

Tested by

no test coverage detected