{"action":"created","issue":{"url":"https://api.github.com/repos/dgryski/go-tsz/issues/4","labels_url":"https://api.github.com/repos/dgryski/go-tsz/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/dgryski/go-tsz/issues/4/comments","events_url":"https://api.github.com/repos/dgryski/go-tsz/issues/4/events","html_url":"https://github.com/dgryski/go-tsz/issues/4","id":110282985,"number":4,"title":"Encoding similar values fails to decode properly","user":{"login":"jwilder","id":219935,"avatar_url":"https://avatars.githubusercontent.com/u/219935?v=3","gravatar_id":"","url":"https://api.github.com/users/jwilder","html_url":"https://github.com/jwilder","followers_url":"https://api.github.com/users/jwilder/followers","following_url":"https://api.github.com/users/jwilder/following{/other_user}","gists_url":"https://api.github.com/users/jwilder/gists{/gist_id}","starred_url":"https://api.github.com/users/jwilder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwilder/subscriptions","organizations_url":"https://api.github.com/users/jwilder/orgs","repos_url":"https://api.github.com/users/jwilder/repos","events_url":"https://api.github.com/users/jwilder/events{/privacy}","received_events_url":"https://api.github.com/users/jwilder/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-10-07T18:02:10Z","updated_at":"2015-10-07T19:17:38Z","closed_at":null,"body":"While investigating https://github.com/influxdb/influxdb/issues/4357, it looks like the root issue is that the float encoding is not decoding the original values correctly.  \r\n\r\nThis test reproduces the issue:\r\n \r\n```\r\nfunc TestEncodeSimilarFloats(t *testing.T) {\r\n\ttunix := uint32(time.Unix(0, 0).Unix())\r\n\ts := New(tunix)\r\n\twant := []struct {\r\n\t\tt uint32\r\n\t\tv float64\r\n\t}{\r\n\t\t{tunix, 6.00065e+06},\r\n\t\t{tunix + 1, 6.000656e+06},\r\n\t\t{tunix + 2, 6.000657e+06},\r\n\t\t{tunix + 3, 6.000659e+06},\r\n\t\t{tunix + 4, 6.000661e+06},\r\n\t}\r\n\r\n\tfor _, v := range want {\r\n\t\ts.Push(v.t, v.v)\r\n\t}\r\n\r\n\ts.Finish()\r\n\r\n\tit := s.Iter()\r\n\r\n\tfor _, w := range want {\r\n\t\tif !it.Next() {\r\n\t\t\tt.Fatalf(\"Next()=false, want true\")\r\n\t\t}\r\n\t\ttt, vv := it.Values()\r\n\t\tif w.t != tt || w.v != vv {\r\n\t\t\tt.Errorf(\"Values()=(%v,%v), want (%v,%v)\\n\", tt, vv, w.t, w.v)\r\n\t\t}\r\n\t}\r\n\r\n\tif it.Next() {\r\n\t\tt.Fatalf(\"Next()=true, want false\")\r\n\t}\r\n\r\n\tif err := it.Err(); err != nil {\r\n\t\tt.Errorf(\"it.Err()=%v, want nil\", err)\r\n\t}\r\n}\r\n```\r\n\r\n```\r\ninfluxdb:go-tsz jason$ go test ./...\r\n--- FAIL: TestEncodeSimilarFloats (0.00s)\r\n\ttsz_test.go:112: Values()=(2,3.337975699873597e-302), want (2,6.000657e+06)\r\n\ttsz_test.go:112: Values()=(3,-3.337975699873597e-302), want (3,6.000659e+06)\r\n\ttsz_test.go:112: Values()=(4,-3.337979037484385e-302), want (4,6.000661e+06)\r\nFAIL\r\nFAIL\tgithub.com/dgryski/go-tsz\t0.006s\r\n```"},"comment":{"url":"https://api.github.com/repos/dgryski/go-tsz/issues/comments/146300742","html_url":"https://github.com/dgryski/go-tsz/issues/4#issuecomment-146300742","issue_url":"https://api.github.com/repos/dgryski/go-tsz/issues/4","id":146300742,"user":{"login":"dgryski","id":970862,"avatar_url":"https://avatars.githubusercontent.com/u/970862?v=3","gravatar_id":"","url":"https://api.github.com/users/dgryski","html_url":"https://github.com/dgryski","followers_url":"https://api.github.com/users/dgryski/followers","following_url":"https://api.github.com/users/dgryski/following{/other_user}","gists_url":"https://api.github.com/users/dgryski/gists{/gist_id}","starred_url":"https://api.github.com/users/dgryski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgryski/subscriptions","organizations_url":"https://api.github.com/users/dgryski/orgs","repos_url":"https://api.github.com/users/dgryski/repos","events_url":"https://api.github.com/users/dgryski/events{/privacy}","received_events_url":"https://api.github.com/users/dgryski/received_events","type":"User","site_admin":false},"created_at":"2015-10-07T19:17:38Z","updated_at":"2015-10-07T19:17:38Z","body":"I think it needs to be immediately after we calculate `leading`.\r\n\r\nFWIW, increasing the number of bits adds only a single byte to the 2h worth of minutely data in `TwoHoursData`, and no extra bytes on 2h of second-level production metrics (not included in the repo)."}}