|
|
@ -49,6 +49,10 @@ import (
|
|
|
|
"math/bits"
|
|
|
|
"math/bits"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
|
|
|
chunkCompactCapacityThreshold = 32
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// XORChunk holds XOR encoded sample data.
|
|
|
|
// XORChunk holds XOR encoded sample data.
|
|
|
|
type XORChunk struct {
|
|
|
|
type XORChunk struct {
|
|
|
|
b bstream
|
|
|
|
b bstream
|
|
|
@ -75,6 +79,14 @@ func (c *XORChunk) NumSamples() int {
|
|
|
|
return int(binary.BigEndian.Uint16(c.Bytes()))
|
|
|
|
return int(binary.BigEndian.Uint16(c.Bytes()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *XORChunk) Compact() {
|
|
|
|
|
|
|
|
if l := len(c.b.stream); cap(c.b.stream) > l+chunkCompactCapacityThreshold {
|
|
|
|
|
|
|
|
buf := make([]byte, l)
|
|
|
|
|
|
|
|
copy(buf, c.b.stream)
|
|
|
|
|
|
|
|
c.b.stream = buf
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Appender implements the Chunk interface.
|
|
|
|
// Appender implements the Chunk interface.
|
|
|
|
func (c *XORChunk) Appender() (Appender, error) {
|
|
|
|
func (c *XORChunk) Appender() (Appender, error) {
|
|
|
|
it := c.iterator(nil)
|
|
|
|
it := c.iterator(nil)
|
|
|
|