-
Notifications
You must be signed in to change notification settings - Fork 53
/
deltabp_test.go
52 lines (46 loc) · 962 Bytes
/
deltabp_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package goparquet
import (
"bytes"
"math/rand"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func buildDataDelta(l int) []int32 {
res := make([]int32, l)
for i := 0; i < l; i++ {
res[i] = rand.Int31()
}
return res
}
func TestDelta(t *testing.T) {
for i := 1; i < 32; i++ {
data := &bytes.Buffer{}
enc := &deltaBitPackEncoder32{
blockSize: 128,
miniBlockCount: 4,
}
assert.NoError(t, enc.init(data))
to1 := buildDataDelta(8*1024 + 5)
for _, i := range to1 {
require.NoError(t, enc.addInt32(i))
}
assert.NoError(t, enc.Close())
buf2 := bytes.NewReader(data.Bytes())
dec := &deltaBitPackDecoder32{
blockSize: 128,
miniBlockCount: 4,
}
assert.NoError(t, dec.init(buf2))
var toR []int32
total := len(to1)
for j := 0; j < total; j++ {
d, err := dec.next()
if err != nil {
break
}
toR = append(toR, d)
}
assert.Equal(t, toR, to1)
}
}