Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

compression does not work well #1

Open
CodingCrush opened this issue Jun 15, 2022 · 2 comments
Open

compression does not work well #1

CodingCrush opened this issue Jun 15, 2022 · 2 comments

Comments

@CodingCrush
Copy link

func Test_gorilla(t *testing.T) {
	var buf bytes.Buffer
	c, finish, err := gorilla.NewCompressor(&buf, 27550378*60)
	assert.NoError(t, err)

	for i := 27550378; i < 27550388; i++ {
		t.Log("write: ", uint32(i*60), float64(i))
		assert.NoError(t, c.Compress(uint32(i*60), float64(i)))
	}
	assert.NoError(t, finish())

	d, _, err := gorilla.NewDecompressor(bytes.NewReader(buf.Bytes()))
	assert.NoError(t, err)

	itr := d.Iterator()
	for itr.Next() {
		fmt.Println(itr.At())
	}
}

the output is

1653022680 2.7550378e+07
1653022740 3.190115827897793e+84
1653022800 2.054801063973621e-147
1653022860 2.3792970816456578e-70
1653022920 1.5325406469947978e-301
1653022980 1.7745608335663593e-224
1653023040 1.774561542092724e-224
1653023100 1.7745614776812363e-224
1653023160 1.7745616709156994e-224
1653023220 1.7745616065042117e-224
@CodingCrush
Copy link
Author

CodingCrush commented Jun 15, 2022

fix function compressValue

	leadingZeros := uint8(bits.LeadingZeros64(xor))
	trailingZeros := uint8(bits.TrailingZeros64(xor))

	if leadingZeros >= 32 {
		leadingZeros = 31
	}
        if c.leadingZeros != ^uint8(0) && c.leadingZeros <= leadingZeros && c.trailingZeros <= trailingZeros {
                // do something
        }

@aleskandro
Copy link

aleskandro commented Feb 19, 2024 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@aleskandro @CodingCrush and others