update dep: simple8b @ b421ab40
parent
5070f69bb2
commit
286072f65a
2
Godeps
2
Godeps
|
@ -12,7 +12,7 @@ github.com/hashicorp/go-msgpack fa3f63826f7c23912c15263591e65d54d080b458
|
|||
github.com/hashicorp/raft 8fd9a2fdfd154f4b393aa24cff91e3c317efe839
|
||||
github.com/hashicorp/raft-boltdb d1e82c1ec3f15ee991f7cc7ffd5b67ff6f5bbaee
|
||||
github.com/influxdata/usage-client 475977e68d79883d9c8d67131c84e4241523f452
|
||||
github.com/jwilder/encoding 07d88d4f35eec497617bee0c7bfe651a796dae13
|
||||
github.com/jwilder/encoding b421ab402545ef5a119f4f827784c6551d9bfc37
|
||||
github.com/kimor79/gollectd 61d0deeb4ffcc167b2a1baa8efd72365692811bc
|
||||
github.com/paulbellamy/ratecounter 5a11f585a31379765c190c033b6ad39956584447
|
||||
github.com/peterh/liner ad1edfd30321d8f006ccf05f1e0524adeb943060
|
||||
|
|
|
@ -163,7 +163,7 @@ func DecodeBlock(block []byte, vals []Value) ([]Value, error) {
|
|||
switch blockType {
|
||||
case BlockFloat64:
|
||||
var buf []FloatValue
|
||||
decoded, err := DecodeFloatBlock(block, NewTimeDecoder(), &FloatDecoder{}, &buf)
|
||||
decoded, err := DecodeFloatBlock(block, &TimeDecoder{}, &FloatDecoder{}, &buf)
|
||||
if len(vals) < len(decoded) {
|
||||
vals = make([]Value, len(decoded))
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ func DecodeBlock(block []byte, vals []Value) ([]Value, error) {
|
|||
return vals[:len(decoded)], err
|
||||
case BlockInteger:
|
||||
var buf []IntegerValue
|
||||
decoded, err := DecodeIntegerBlock(block, NewTimeDecoder(), &IntegerDecoder{}, &buf)
|
||||
decoded, err := DecodeIntegerBlock(block, &TimeDecoder{}, &IntegerDecoder{}, &buf)
|
||||
if len(vals) < len(decoded) {
|
||||
vals = make([]Value, len(decoded))
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ func DecodeBlock(block []byte, vals []Value) ([]Value, error) {
|
|||
|
||||
case BlockBoolean:
|
||||
var buf []BooleanValue
|
||||
decoded, err := DecodeBooleanBlock(block, NewTimeDecoder(), &BooleanDecoder{}, &buf)
|
||||
decoded, err := DecodeBooleanBlock(block, &TimeDecoder{}, &BooleanDecoder{}, &buf)
|
||||
if len(vals) < len(decoded) {
|
||||
vals = make([]Value, len(decoded))
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ func DecodeBlock(block []byte, vals []Value) ([]Value, error) {
|
|||
|
||||
case BlockString:
|
||||
var buf []StringValue
|
||||
decoded, err := DecodeStringBlock(block, NewTimeDecoder(), &StringDecoder{}, &buf)
|
||||
decoded, err := DecodeStringBlock(block, &TimeDecoder{}, &StringDecoder{}, &buf)
|
||||
if len(vals) < len(decoded) {
|
||||
vals = make([]Value, len(decoded))
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ func encodeFloatBlock(buf []byte, values []Value) ([]byte, error) {
|
|||
return block, nil
|
||||
}
|
||||
|
||||
func DecodeFloatBlock(block []byte, tdec TimeDecoder, vdec *FloatDecoder, a *[]FloatValue) ([]FloatValue, error) {
|
||||
func DecodeFloatBlock(block []byte, tdec *TimeDecoder, vdec *FloatDecoder, a *[]FloatValue) ([]FloatValue, error) {
|
||||
// Block type is the next block, make sure we actually have a float block
|
||||
blockType := block[0]
|
||||
if blockType != BlockFloat64 {
|
||||
|
@ -417,7 +417,7 @@ func encodeBooleanBlock(buf []byte, values []Value) ([]byte, error) {
|
|||
return block, nil
|
||||
}
|
||||
|
||||
func DecodeBooleanBlock(block []byte, tdec TimeDecoder, vdec *BooleanDecoder, a *[]BooleanValue) ([]BooleanValue, error) {
|
||||
func DecodeBooleanBlock(block []byte, tdec *TimeDecoder, vdec *BooleanDecoder, a *[]BooleanValue) ([]BooleanValue, error) {
|
||||
// Block type is the next block, make sure we actually have a float block
|
||||
blockType := block[0]
|
||||
if blockType != BlockBoolean {
|
||||
|
@ -528,7 +528,7 @@ func encodeIntegerBlock(buf []byte, values []Value) ([]byte, error) {
|
|||
return append(block, packBlock(tb, vb)...), nil
|
||||
}
|
||||
|
||||
func DecodeIntegerBlock(block []byte, tdec TimeDecoder, vdec *IntegerDecoder, a *[]IntegerValue) ([]IntegerValue, error) {
|
||||
func DecodeIntegerBlock(block []byte, tdec *TimeDecoder, vdec *IntegerDecoder, a *[]IntegerValue) ([]IntegerValue, error) {
|
||||
blockType := block[0]
|
||||
if blockType != BlockInteger {
|
||||
return nil, fmt.Errorf("invalid block type: exp %d, got %d", BlockInteger, blockType)
|
||||
|
@ -640,7 +640,7 @@ func encodeStringBlock(buf []byte, values []Value) ([]byte, error) {
|
|||
return append(block, packBlock(tb, vb)...), nil
|
||||
}
|
||||
|
||||
func DecodeStringBlock(block []byte, tdec TimeDecoder, vdec *StringDecoder, a *[]StringValue) ([]StringValue, error) {
|
||||
func DecodeStringBlock(block []byte, tdec *TimeDecoder, vdec *StringDecoder, a *[]StringValue) ([]StringValue, error) {
|
||||
blockType := block[0]
|
||||
if blockType != BlockString {
|
||||
return nil, fmt.Errorf("invalid block type: exp %d, got %d", BlockString, blockType)
|
||||
|
|
|
@ -327,7 +327,7 @@ func BenchmarkDecodeBlock_Float_TypeSpecific(b *testing.B) {
|
|||
decodedValues := make([]tsm1.FloatValue, len(values))
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err = tsm1.DecodeFloatBlock(bytes, tsm1.NewTimeDecoder(), &tsm1.FloatDecoder{}, &decodedValues)
|
||||
_, err = tsm1.DecodeFloatBlock(bytes, &tsm1.TimeDecoder{}, &tsm1.FloatDecoder{}, &decodedValues)
|
||||
if err != nil {
|
||||
b.Fatalf("unexpected error decoding block: %v", err)
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ func BenchmarkDecodeBlock_Integer_TypeSpecific(b *testing.B) {
|
|||
decodedValues := make([]tsm1.IntegerValue, len(values))
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err = tsm1.DecodeIntegerBlock(bytes, tsm1.NewTimeDecoder(), &tsm1.IntegerDecoder{}, &decodedValues)
|
||||
_, err = tsm1.DecodeIntegerBlock(bytes, &tsm1.TimeDecoder{}, &tsm1.IntegerDecoder{}, &decodedValues)
|
||||
if err != nil {
|
||||
b.Fatalf("unexpected error decoding block: %v", err)
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ func BenchmarkDecodeBlock_Boolean_TypeSpecific(b *testing.B) {
|
|||
decodedValues := make([]tsm1.BooleanValue, len(values))
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err = tsm1.DecodeBooleanBlock(bytes, tsm1.NewTimeDecoder(), &tsm1.BooleanDecoder{}, &decodedValues)
|
||||
_, err = tsm1.DecodeBooleanBlock(bytes, &tsm1.TimeDecoder{}, &tsm1.BooleanDecoder{}, &decodedValues)
|
||||
if err != nil {
|
||||
b.Fatalf("unexpected error decoding block: %v", err)
|
||||
}
|
||||
|
@ -534,7 +534,7 @@ func BenchmarkDecodeBlock_String_TypeSpecific(b *testing.B) {
|
|||
decodedValues := make([]tsm1.StringValue, len(values))
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err = tsm1.DecodeStringBlock(bytes, tsm1.NewTimeDecoder(), &tsm1.StringDecoder{}, &decodedValues)
|
||||
_, err = tsm1.DecodeStringBlock(bytes, &tsm1.TimeDecoder{}, &tsm1.StringDecoder{}, &decodedValues)
|
||||
if err != nil {
|
||||
b.Fatalf("unexpected error decoding block: %v", err)
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ type TSMFile interface {
|
|||
|
||||
// ReadAt returns all the values in the block identified by entry.
|
||||
ReadAt(entry *IndexEntry, values []Value) ([]Value, error)
|
||||
ReadFloatBlockAt(entry *IndexEntry, tdec TimeDecoder, vdec *FloatDecoder, values *[]FloatValue) ([]FloatValue, error)
|
||||
ReadIntegerBlockAt(entry *IndexEntry, tdec TimeDecoder, vdec *IntegerDecoder, values *[]IntegerValue) ([]IntegerValue, error)
|
||||
ReadStringBlockAt(entry *IndexEntry, tdec TimeDecoder, vdec *StringDecoder, values *[]StringValue) ([]StringValue, error)
|
||||
ReadBooleanBlockAt(entry *IndexEntry, tdec TimeDecoder, vdec *BooleanDecoder, values *[]BooleanValue) ([]BooleanValue, error)
|
||||
ReadFloatBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *FloatDecoder, values *[]FloatValue) ([]FloatValue, error)
|
||||
ReadIntegerBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *IntegerDecoder, values *[]IntegerValue) ([]IntegerValue, error)
|
||||
ReadStringBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *StringDecoder, values *[]StringValue) ([]StringValue, error)
|
||||
ReadBooleanBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *BooleanDecoder, values *[]BooleanValue) ([]BooleanValue, error)
|
||||
|
||||
// Entries returns the index entries for all blocks for the given key.
|
||||
Entries(key string) []IndexEntry
|
||||
|
@ -796,7 +796,7 @@ func (c *KeyCursor) nextDescending() {
|
|||
}
|
||||
|
||||
// ReadFloatBlock reads the next block as a set of float values.
|
||||
func (c *KeyCursor) ReadFloatBlock(tdec TimeDecoder, fdec *FloatDecoder, buf *[]FloatValue) ([]FloatValue, error) {
|
||||
func (c *KeyCursor) ReadFloatBlock(tdec *TimeDecoder, fdec *FloatDecoder, buf *[]FloatValue) ([]FloatValue, error) {
|
||||
// No matching blocks to decode
|
||||
if len(c.current) == 0 {
|
||||
return nil, nil
|
||||
|
@ -844,7 +844,7 @@ func (c *KeyCursor) ReadFloatBlock(tdec TimeDecoder, fdec *FloatDecoder, buf *[]
|
|||
}
|
||||
|
||||
// ReadIntegerBlock reads the next block as a set of integer values.
|
||||
func (c *KeyCursor) ReadIntegerBlock(tdec TimeDecoder, vdec *IntegerDecoder, buf *[]IntegerValue) ([]IntegerValue, error) {
|
||||
func (c *KeyCursor) ReadIntegerBlock(tdec *TimeDecoder, vdec *IntegerDecoder, buf *[]IntegerValue) ([]IntegerValue, error) {
|
||||
// No matching blocks to decode
|
||||
if len(c.current) == 0 {
|
||||
return nil, nil
|
||||
|
@ -892,7 +892,7 @@ func (c *KeyCursor) ReadIntegerBlock(tdec TimeDecoder, vdec *IntegerDecoder, buf
|
|||
}
|
||||
|
||||
// ReadStringBlock reads the next block as a set of string values.
|
||||
func (c *KeyCursor) ReadStringBlock(tdec TimeDecoder, vdec *StringDecoder, buf *[]StringValue) ([]StringValue, error) {
|
||||
func (c *KeyCursor) ReadStringBlock(tdec *TimeDecoder, vdec *StringDecoder, buf *[]StringValue) ([]StringValue, error) {
|
||||
// No matching blocks to decode
|
||||
if len(c.current) == 0 {
|
||||
return nil, nil
|
||||
|
@ -939,7 +939,7 @@ func (c *KeyCursor) ReadStringBlock(tdec TimeDecoder, vdec *StringDecoder, buf *
|
|||
}
|
||||
|
||||
// ReadBooleanBlock reads the next block as a set of boolean values.
|
||||
func (c *KeyCursor) ReadBooleanBlock(tdec TimeDecoder, vdec *BooleanDecoder, buf *[]BooleanValue) ([]BooleanValue, error) {
|
||||
func (c *KeyCursor) ReadBooleanBlock(tdec *TimeDecoder, vdec *BooleanDecoder, buf *[]BooleanValue) ([]BooleanValue, error) {
|
||||
// No matching blocks to decode
|
||||
if len(c.current) == 0 {
|
||||
return nil, nil
|
||||
|
|
|
@ -66,7 +66,7 @@ func TestFileStore_SeekToAsc_FromStart(t *testing.T) {
|
|||
buf := make([]tsm1.FloatValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 0, true)
|
||||
// Search for an entry that exists in the second file
|
||||
values, err := c.ReadFloatBlock(tsm1.NewTimeDecoder(), &tsm1.FloatDecoder{}, &buf)
|
||||
values, err := c.ReadFloatBlock(&tsm1.TimeDecoder{}, &tsm1.FloatDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ func TestFileStore_SeekToAsc_Duplicate(t *testing.T) {
|
|||
buf := make([]tsm1.FloatValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 0, true)
|
||||
// Search for an entry that exists in the second file
|
||||
values, err := c.ReadFloatBlock(tsm1.NewTimeDecoder(), &tsm1.FloatDecoder{}, &buf)
|
||||
values, err := c.ReadFloatBlock(&tsm1.TimeDecoder{}, &tsm1.FloatDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ func TestFileStore_SeekToAsc_Duplicate(t *testing.T) {
|
|||
|
||||
// Check that calling Next will dedupe points
|
||||
c.Next()
|
||||
values, err = c.ReadFloatBlock(tsm1.NewTimeDecoder(), &tsm1.FloatDecoder{}, &buf)
|
||||
values, err = c.ReadFloatBlock(&tsm1.TimeDecoder{}, &tsm1.FloatDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ func TestFileStore_SeekToAsc_BeforeStart(t *testing.T) {
|
|||
// Search for an entry that exists in the second file
|
||||
buf := make([]tsm1.FloatValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 0, true)
|
||||
values, err := c.ReadFloatBlock(tsm1.NewTimeDecoder(), &tsm1.FloatDecoder{}, &buf)
|
||||
values, err := c.ReadFloatBlock(&tsm1.TimeDecoder{}, &tsm1.FloatDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ func TestFileStore_SeekToAsc_BeforeStart_OverlapFloat(t *testing.T) {
|
|||
// Search for an entry that exists in the second file
|
||||
buf := make([]tsm1.FloatValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 0, true)
|
||||
values, err := c.ReadFloatBlock(tsm1.NewTimeDecoder(), &tsm1.FloatDecoder{}, &buf)
|
||||
values, err := c.ReadFloatBlock(&tsm1.TimeDecoder{}, &tsm1.FloatDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ func TestFileStore_SeekToAsc_BeforeStart_OverlapInteger(t *testing.T) {
|
|||
// Search for an entry that exists in the second file
|
||||
buf := make([]tsm1.IntegerValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 0, true)
|
||||
values, err := c.ReadIntegerBlock(tsm1.NewTimeDecoder(), &tsm1.IntegerDecoder{}, &buf)
|
||||
values, err := c.ReadIntegerBlock(&tsm1.TimeDecoder{}, &tsm1.IntegerDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ func TestFileStore_SeekToAsc_BeforeStart_OverlapBoolean(t *testing.T) {
|
|||
// Search for an entry that exists in the second file
|
||||
buf := make([]tsm1.BooleanValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 0, true)
|
||||
values, err := c.ReadBooleanBlock(tsm1.NewTimeDecoder(), &tsm1.BooleanDecoder{}, &buf)
|
||||
values, err := c.ReadBooleanBlock(&tsm1.TimeDecoder{}, &tsm1.BooleanDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ func TestFileStore_SeekToAsc_BeforeStart_OverlapString(t *testing.T) {
|
|||
// Search for an entry that exists in the second file
|
||||
buf := make([]tsm1.StringValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 0, true)
|
||||
values, err := c.ReadStringBlock(tsm1.NewTimeDecoder(), &tsm1.StringDecoder{}, &buf)
|
||||
values, err := c.ReadStringBlock(&tsm1.TimeDecoder{}, &tsm1.StringDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ func TestFileStore_SeekToAsc_Middle(t *testing.T) {
|
|||
// Search for an entry that exists in the second file
|
||||
buf := make([]tsm1.FloatValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 3, true)
|
||||
values, err := c.ReadFloatBlock(tsm1.NewTimeDecoder(), &tsm1.FloatDecoder{}, &buf)
|
||||
values, err := c.ReadFloatBlock(&tsm1.TimeDecoder{}, &tsm1.FloatDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ func TestFileStore_SeekToAsc_End(t *testing.T) {
|
|||
|
||||
buf := make([]tsm1.FloatValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 2, true)
|
||||
values, err := c.ReadFloatBlock(tsm1.NewTimeDecoder(), &tsm1.FloatDecoder{}, &buf)
|
||||
values, err := c.ReadFloatBlock(&tsm1.TimeDecoder{}, &tsm1.FloatDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ func TestFileStore_SeekToDesc_FromStart(t *testing.T) {
|
|||
// Search for an entry that exists in the second file
|
||||
buf := make([]tsm1.FloatValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 0, false)
|
||||
values, err := c.ReadFloatBlock(tsm1.NewTimeDecoder(), &tsm1.FloatDecoder{}, &buf)
|
||||
values, err := c.ReadFloatBlock(&tsm1.TimeDecoder{}, &tsm1.FloatDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ func TestFileStore_SeekToDesc_Duplicate(t *testing.T) {
|
|||
// Search for an entry that exists in the second file
|
||||
buf := make([]tsm1.FloatValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 2, false)
|
||||
values, err := c.ReadFloatBlock(tsm1.NewTimeDecoder(), &tsm1.FloatDecoder{}, &buf)
|
||||
values, err := c.ReadFloatBlock(&tsm1.TimeDecoder{}, &tsm1.FloatDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -526,7 +526,7 @@ func TestFileStore_SeekToDesc_AfterEnd(t *testing.T) {
|
|||
|
||||
buf := make([]tsm1.FloatValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 4, false)
|
||||
values, err := c.ReadFloatBlock(tsm1.NewTimeDecoder(), &tsm1.FloatDecoder{}, &buf)
|
||||
values, err := c.ReadFloatBlock(&tsm1.TimeDecoder{}, &tsm1.FloatDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ func TestFileStore_SeekToDesc_AfterEnd_OverlapFloat(t *testing.T) {
|
|||
|
||||
buf := make([]tsm1.FloatValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 8, false)
|
||||
values, err := c.ReadFloatBlock(tsm1.NewTimeDecoder(), &tsm1.FloatDecoder{}, &buf)
|
||||
values, err := c.ReadFloatBlock(&tsm1.TimeDecoder{}, &tsm1.FloatDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ func TestFileStore_SeekToDesc_AfterEnd_OverlapInteger(t *testing.T) {
|
|||
|
||||
buf := make([]tsm1.IntegerValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 8, false)
|
||||
values, err := c.ReadIntegerBlock(tsm1.NewTimeDecoder(), &tsm1.IntegerDecoder{}, &buf)
|
||||
values, err := c.ReadIntegerBlock(&tsm1.TimeDecoder{}, &tsm1.IntegerDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -651,7 +651,7 @@ func TestFileStore_SeekToDesc_AfterEnd_OverlapBoolean(t *testing.T) {
|
|||
|
||||
buf := make([]tsm1.BooleanValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 8, false)
|
||||
values, err := c.ReadBooleanBlock(tsm1.NewTimeDecoder(), &tsm1.BooleanDecoder{}, &buf)
|
||||
values, err := c.ReadBooleanBlock(&tsm1.TimeDecoder{}, &tsm1.BooleanDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -695,7 +695,7 @@ func TestFileStore_SeekToDesc_AfterEnd_OverlapString(t *testing.T) {
|
|||
|
||||
buf := make([]tsm1.StringValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 8, false)
|
||||
values, err := c.ReadStringBlock(tsm1.NewTimeDecoder(), &tsm1.StringDecoder{}, &buf)
|
||||
values, err := c.ReadStringBlock(&tsm1.TimeDecoder{}, &tsm1.StringDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -742,7 +742,7 @@ func TestFileStore_SeekToDesc_Middle(t *testing.T) {
|
|||
// Search for an entry that exists in the second file
|
||||
buf := make([]tsm1.FloatValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 3, false)
|
||||
values, err := c.ReadFloatBlock(tsm1.NewTimeDecoder(), &tsm1.FloatDecoder{}, &buf)
|
||||
values, err := c.ReadFloatBlock(&tsm1.TimeDecoder{}, &tsm1.FloatDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
@ -778,7 +778,7 @@ func TestFileStore_SeekToDesc_End(t *testing.T) {
|
|||
|
||||
buf := make([]tsm1.FloatValue, 1000)
|
||||
c := fs.KeyCursor("cpu", 2, false)
|
||||
values, err := c.ReadFloatBlock(tsm1.NewTimeDecoder(), &tsm1.FloatDecoder{}, &buf)
|
||||
values, err := c.ReadFloatBlock(&tsm1.TimeDecoder{}, &tsm1.FloatDecoder{}, &buf)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error reading values: %v", err)
|
||||
}
|
||||
|
|
|
@ -257,7 +257,7 @@ func (d *IntegerDecoder) decodePacked() {
|
|||
d.n = 1
|
||||
d.values[0] = v
|
||||
} else {
|
||||
n, err := simple8b.Decode(d.values[:], v)
|
||||
n, err := simple8b.Decode(&d.values, v)
|
||||
if err != nil {
|
||||
// Should never happen, only error that could be returned is if the the value to be decoded was not
|
||||
// actually encoded by simple8b encoder.
|
||||
|
|
|
@ -305,10 +305,9 @@ func newFloatAscendingCursor(seek int64, cacheValues Values, tsmKeyCursor *KeyCu
|
|||
return c.cache.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
||||
c.tsm.tdec = NewTimeDecoder()
|
||||
c.tsm.keyCursor = tsmKeyCursor
|
||||
c.tsm.buf = make([]FloatValue, 10)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadFloatBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadFloatBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.pos = sort.Search(len(c.tsm.values), func(i int) bool {
|
||||
return c.tsm.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
@ -380,7 +379,7 @@ func (c *floatAscendingCursor) nextTSM() {
|
|||
c.tsm.pos++
|
||||
if c.tsm.pos >= len(c.tsm.values) {
|
||||
c.tsm.keyCursor.Next()
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadFloatBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadFloatBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
if len(c.tsm.values) == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -415,10 +414,9 @@ func newFloatDescendingCursor(seek int64, cacheValues Values, tsmKeyCursor *KeyC
|
|||
c.cache.pos--
|
||||
}
|
||||
|
||||
c.tsm.tdec = NewTimeDecoder()
|
||||
c.tsm.keyCursor = tsmKeyCursor
|
||||
c.tsm.buf = make([]FloatValue, 10)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadFloatBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadFloatBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.pos = sort.Search(len(c.tsm.values), func(i int) bool {
|
||||
return c.tsm.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
@ -493,7 +491,7 @@ func (c *floatDescendingCursor) nextTSM() {
|
|||
c.tsm.pos--
|
||||
if c.tsm.pos < 0 {
|
||||
c.tsm.keyCursor.Next()
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadFloatBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadFloatBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
if len(c.tsm.values) == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -717,10 +715,9 @@ func newIntegerAscendingCursor(seek int64, cacheValues Values, tsmKeyCursor *Key
|
|||
return c.cache.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
||||
c.tsm.tdec = NewTimeDecoder()
|
||||
c.tsm.keyCursor = tsmKeyCursor
|
||||
c.tsm.buf = make([]IntegerValue, 10)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadIntegerBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadIntegerBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.pos = sort.Search(len(c.tsm.values), func(i int) bool {
|
||||
return c.tsm.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
@ -792,7 +789,7 @@ func (c *integerAscendingCursor) nextTSM() {
|
|||
c.tsm.pos++
|
||||
if c.tsm.pos >= len(c.tsm.values) {
|
||||
c.tsm.keyCursor.Next()
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadIntegerBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadIntegerBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
if len(c.tsm.values) == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -827,10 +824,9 @@ func newIntegerDescendingCursor(seek int64, cacheValues Values, tsmKeyCursor *Ke
|
|||
c.cache.pos--
|
||||
}
|
||||
|
||||
c.tsm.tdec = NewTimeDecoder()
|
||||
c.tsm.keyCursor = tsmKeyCursor
|
||||
c.tsm.buf = make([]IntegerValue, 10)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadIntegerBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadIntegerBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.pos = sort.Search(len(c.tsm.values), func(i int) bool {
|
||||
return c.tsm.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
@ -905,7 +901,7 @@ func (c *integerDescendingCursor) nextTSM() {
|
|||
c.tsm.pos--
|
||||
if c.tsm.pos < 0 {
|
||||
c.tsm.keyCursor.Next()
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadIntegerBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadIntegerBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
if len(c.tsm.values) == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -1129,10 +1125,9 @@ func newStringAscendingCursor(seek int64, cacheValues Values, tsmKeyCursor *KeyC
|
|||
return c.cache.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
||||
c.tsm.tdec = NewTimeDecoder()
|
||||
c.tsm.keyCursor = tsmKeyCursor
|
||||
c.tsm.buf = make([]StringValue, 10)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadStringBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadStringBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.pos = sort.Search(len(c.tsm.values), func(i int) bool {
|
||||
return c.tsm.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
@ -1204,7 +1199,7 @@ func (c *stringAscendingCursor) nextTSM() {
|
|||
c.tsm.pos++
|
||||
if c.tsm.pos >= len(c.tsm.values) {
|
||||
c.tsm.keyCursor.Next()
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadStringBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadStringBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
if len(c.tsm.values) == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -1239,10 +1234,9 @@ func newStringDescendingCursor(seek int64, cacheValues Values, tsmKeyCursor *Key
|
|||
c.cache.pos--
|
||||
}
|
||||
|
||||
c.tsm.tdec = NewTimeDecoder()
|
||||
c.tsm.keyCursor = tsmKeyCursor
|
||||
c.tsm.buf = make([]StringValue, 10)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadStringBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadStringBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.pos = sort.Search(len(c.tsm.values), func(i int) bool {
|
||||
return c.tsm.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
@ -1317,7 +1311,7 @@ func (c *stringDescendingCursor) nextTSM() {
|
|||
c.tsm.pos--
|
||||
if c.tsm.pos < 0 {
|
||||
c.tsm.keyCursor.Next()
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadStringBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadStringBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
if len(c.tsm.values) == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -1541,10 +1535,9 @@ func newBooleanAscendingCursor(seek int64, cacheValues Values, tsmKeyCursor *Key
|
|||
return c.cache.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
||||
c.tsm.tdec = NewTimeDecoder()
|
||||
c.tsm.keyCursor = tsmKeyCursor
|
||||
c.tsm.buf = make([]BooleanValue, 10)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadBooleanBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadBooleanBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.pos = sort.Search(len(c.tsm.values), func(i int) bool {
|
||||
return c.tsm.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
@ -1616,7 +1609,7 @@ func (c *booleanAscendingCursor) nextTSM() {
|
|||
c.tsm.pos++
|
||||
if c.tsm.pos >= len(c.tsm.values) {
|
||||
c.tsm.keyCursor.Next()
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadBooleanBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadBooleanBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
if len(c.tsm.values) == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -1651,10 +1644,9 @@ func newBooleanDescendingCursor(seek int64, cacheValues Values, tsmKeyCursor *Ke
|
|||
c.cache.pos--
|
||||
}
|
||||
|
||||
c.tsm.tdec = NewTimeDecoder()
|
||||
c.tsm.keyCursor = tsmKeyCursor
|
||||
c.tsm.buf = make([]BooleanValue, 10)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadBooleanBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadBooleanBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.pos = sort.Search(len(c.tsm.values), func(i int) bool {
|
||||
return c.tsm.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
@ -1729,7 +1721,7 @@ func (c *booleanDescendingCursor) nextTSM() {
|
|||
c.tsm.pos--
|
||||
if c.tsm.pos < 0 {
|
||||
c.tsm.keyCursor.Next()
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadBooleanBlock(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.ReadBooleanBlock(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
if len(c.tsm.values) == 0 {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -301,10 +301,9 @@ func new{{.Name}}AscendingCursor(seek int64, cacheValues Values, tsmKeyCursor *K
|
|||
return c.cache.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
||||
c.tsm.tdec = NewTimeDecoder()
|
||||
c.tsm.keyCursor = tsmKeyCursor
|
||||
c.tsm.buf = make([]{{.Name}}Value, 10)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.Read{{.Name}}Block(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.Read{{.Name}}Block(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.pos = sort.Search(len(c.tsm.values), func(i int) bool {
|
||||
return c.tsm.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
@ -376,7 +375,7 @@ func (c *{{.name}}AscendingCursor) nextTSM() {
|
|||
c.tsm.pos++
|
||||
if c.tsm.pos >= len(c.tsm.values) {
|
||||
c.tsm.keyCursor.Next()
|
||||
c.tsm.values, _ = c.tsm.keyCursor.Read{{.Name}}Block(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.Read{{.Name}}Block(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
if len(c.tsm.values) == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -411,10 +410,9 @@ func new{{.Name}}DescendingCursor(seek int64, cacheValues Values, tsmKeyCursor *
|
|||
c.cache.pos--
|
||||
}
|
||||
|
||||
c.tsm.tdec = NewTimeDecoder()
|
||||
c.tsm.keyCursor = tsmKeyCursor
|
||||
c.tsm.buf = make([]{{.Name}}Value, 10)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.Read{{.Name}}Block(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.Read{{.Name}}Block(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.pos = sort.Search(len(c.tsm.values), func(i int) bool {
|
||||
return c.tsm.values[i].UnixNano() >= seek
|
||||
})
|
||||
|
@ -489,7 +487,7 @@ func (c *{{.name}}DescendingCursor) nextTSM() {
|
|||
c.tsm.pos--
|
||||
if c.tsm.pos < 0 {
|
||||
c.tsm.keyCursor.Next()
|
||||
c.tsm.values, _ = c.tsm.keyCursor.Read{{.Name}}Block(c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
c.tsm.values, _ = c.tsm.keyCursor.Read{{.Name}}Block(&c.tsm.tdec, &c.tsm.vdec, &c.tsm.buf)
|
||||
if len(c.tsm.values) == 0 {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -95,10 +95,10 @@ type blockAccessor interface {
|
|||
read(key string, timestamp int64) ([]Value, error)
|
||||
readAll(key string) ([]Value, error)
|
||||
readBlock(entry *IndexEntry, values []Value) ([]Value, error)
|
||||
readFloatBlock(entry *IndexEntry, tdec TimeDecoder, fdec *FloatDecoder, values *[]FloatValue) ([]FloatValue, error)
|
||||
readIntegerBlock(entry *IndexEntry, tdec TimeDecoder, vdec *IntegerDecoder, values *[]IntegerValue) ([]IntegerValue, error)
|
||||
readStringBlock(entry *IndexEntry, tdec TimeDecoder, vdec *StringDecoder, values *[]StringValue) ([]StringValue, error)
|
||||
readBooleanBlock(entry *IndexEntry, tdec TimeDecoder, vdec *BooleanDecoder, values *[]BooleanValue) ([]BooleanValue, error)
|
||||
readFloatBlock(entry *IndexEntry, tdec *TimeDecoder, fdec *FloatDecoder, values *[]FloatValue) ([]FloatValue, error)
|
||||
readIntegerBlock(entry *IndexEntry, tdec *TimeDecoder, vdec *IntegerDecoder, values *[]IntegerValue) ([]IntegerValue, error)
|
||||
readStringBlock(entry *IndexEntry, tdec *TimeDecoder, vdec *StringDecoder, values *[]StringValue) ([]StringValue, error)
|
||||
readBooleanBlock(entry *IndexEntry, tdec *TimeDecoder, vdec *BooleanDecoder, values *[]BooleanValue) ([]BooleanValue, error)
|
||||
readBytes(entry *IndexEntry, buf []byte) (uint32, []byte, error)
|
||||
path() string
|
||||
close() error
|
||||
|
@ -208,25 +208,25 @@ func (t *TSMReader) ReadAt(entry *IndexEntry, vals []Value) ([]Value, error) {
|
|||
return t.accessor.readBlock(entry, vals)
|
||||
}
|
||||
|
||||
func (t *TSMReader) ReadFloatBlockAt(entry *IndexEntry, tdec TimeDecoder, vdec *FloatDecoder, vals *[]FloatValue) ([]FloatValue, error) {
|
||||
func (t *TSMReader) ReadFloatBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *FloatDecoder, vals *[]FloatValue) ([]FloatValue, error) {
|
||||
t.mu.RLock()
|
||||
defer t.mu.RUnlock()
|
||||
return t.accessor.readFloatBlock(entry, tdec, vdec, vals)
|
||||
}
|
||||
|
||||
func (t *TSMReader) ReadIntegerBlockAt(entry *IndexEntry, tdec TimeDecoder, vdec *IntegerDecoder, vals *[]IntegerValue) ([]IntegerValue, error) {
|
||||
func (t *TSMReader) ReadIntegerBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *IntegerDecoder, vals *[]IntegerValue) ([]IntegerValue, error) {
|
||||
t.mu.RLock()
|
||||
defer t.mu.RUnlock()
|
||||
return t.accessor.readIntegerBlock(entry, tdec, vdec, vals)
|
||||
}
|
||||
|
||||
func (t *TSMReader) ReadStringBlockAt(entry *IndexEntry, tdec TimeDecoder, vdec *StringDecoder, vals *[]StringValue) ([]StringValue, error) {
|
||||
func (t *TSMReader) ReadStringBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *StringDecoder, vals *[]StringValue) ([]StringValue, error) {
|
||||
t.mu.RLock()
|
||||
defer t.mu.RUnlock()
|
||||
return t.accessor.readStringBlock(entry, tdec, vdec, vals)
|
||||
}
|
||||
|
||||
func (t *TSMReader) ReadBooleanBlockAt(entry *IndexEntry, tdec TimeDecoder, vdec *BooleanDecoder, vals *[]BooleanValue) ([]BooleanValue, error) {
|
||||
func (t *TSMReader) ReadBooleanBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *BooleanDecoder, vals *[]BooleanValue) ([]BooleanValue, error) {
|
||||
t.mu.RLock()
|
||||
defer t.mu.RUnlock()
|
||||
return t.accessor.readBooleanBlock(entry, tdec, vdec, vals)
|
||||
|
@ -802,7 +802,7 @@ func (f *fileAccessor) readBlock(entry *IndexEntry, values []Value) ([]Value, er
|
|||
return values, nil
|
||||
}
|
||||
|
||||
func (f *fileAccessor) readFloatBlock(entry *IndexEntry, tdec TimeDecoder, vdec *FloatDecoder, values *[]FloatValue) ([]FloatValue, error) {
|
||||
func (f *fileAccessor) readFloatBlock(entry *IndexEntry, tdec *TimeDecoder, vdec *FloatDecoder, values *[]FloatValue) ([]FloatValue, error) {
|
||||
_, b, err := f.readBytes(entry, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -817,7 +817,7 @@ func (f *fileAccessor) readFloatBlock(entry *IndexEntry, tdec TimeDecoder, vdec
|
|||
return a, nil
|
||||
}
|
||||
|
||||
func (f *fileAccessor) readIntegerBlock(entry *IndexEntry, tdec TimeDecoder, vdec *IntegerDecoder, values *[]IntegerValue) ([]IntegerValue, error) {
|
||||
func (f *fileAccessor) readIntegerBlock(entry *IndexEntry, tdec *TimeDecoder, vdec *IntegerDecoder, values *[]IntegerValue) ([]IntegerValue, error) {
|
||||
_, b, err := f.readBytes(entry, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -832,7 +832,7 @@ func (f *fileAccessor) readIntegerBlock(entry *IndexEntry, tdec TimeDecoder, vde
|
|||
return a, nil
|
||||
}
|
||||
|
||||
func (f *fileAccessor) readStringBlock(entry *IndexEntry, tdec TimeDecoder, vdec *StringDecoder, values *[]StringValue) ([]StringValue, error) {
|
||||
func (f *fileAccessor) readStringBlock(entry *IndexEntry, tdec *TimeDecoder, vdec *StringDecoder, values *[]StringValue) ([]StringValue, error) {
|
||||
_, b, err := f.readBytes(entry, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -847,7 +847,7 @@ func (f *fileAccessor) readStringBlock(entry *IndexEntry, tdec TimeDecoder, vdec
|
|||
return a, nil
|
||||
}
|
||||
|
||||
func (f *fileAccessor) readBooleanBlock(entry *IndexEntry, tdec TimeDecoder, vdec *BooleanDecoder, values *[]BooleanValue) ([]BooleanValue, error) {
|
||||
func (f *fileAccessor) readBooleanBlock(entry *IndexEntry, tdec *TimeDecoder, vdec *BooleanDecoder, values *[]BooleanValue) ([]BooleanValue, error) {
|
||||
|
||||
_, b, err := f.readBytes(entry, nil)
|
||||
if err != nil {
|
||||
|
@ -1011,7 +1011,7 @@ func (m *mmapAccessor) readBlock(entry *IndexEntry, values []Value) ([]Value, er
|
|||
return values, nil
|
||||
}
|
||||
|
||||
func (m *mmapAccessor) readFloatBlock(entry *IndexEntry, tdec TimeDecoder, vdec *FloatDecoder, values *[]FloatValue) ([]FloatValue, error) {
|
||||
func (m *mmapAccessor) readFloatBlock(entry *IndexEntry, tdec *TimeDecoder, vdec *FloatDecoder, values *[]FloatValue) ([]FloatValue, error) {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
|
@ -1027,7 +1027,7 @@ func (m *mmapAccessor) readFloatBlock(entry *IndexEntry, tdec TimeDecoder, vdec
|
|||
return a, nil
|
||||
}
|
||||
|
||||
func (m *mmapAccessor) readIntegerBlock(entry *IndexEntry, tdec TimeDecoder, vdec *IntegerDecoder, values *[]IntegerValue) ([]IntegerValue, error) {
|
||||
func (m *mmapAccessor) readIntegerBlock(entry *IndexEntry, tdec *TimeDecoder, vdec *IntegerDecoder, values *[]IntegerValue) ([]IntegerValue, error) {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
|
@ -1043,7 +1043,7 @@ func (m *mmapAccessor) readIntegerBlock(entry *IndexEntry, tdec TimeDecoder, vde
|
|||
return a, nil
|
||||
}
|
||||
|
||||
func (m *mmapAccessor) readStringBlock(entry *IndexEntry, tdec TimeDecoder, vdec *StringDecoder, values *[]StringValue) ([]StringValue, error) {
|
||||
func (m *mmapAccessor) readStringBlock(entry *IndexEntry, tdec *TimeDecoder, vdec *StringDecoder, values *[]StringValue) ([]StringValue, error) {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
|
@ -1059,7 +1059,7 @@ func (m *mmapAccessor) readStringBlock(entry *IndexEntry, tdec TimeDecoder, vdec
|
|||
return a, nil
|
||||
}
|
||||
|
||||
func (m *mmapAccessor) readBooleanBlock(entry *IndexEntry, tdec TimeDecoder, vdec *BooleanDecoder, values *[]BooleanValue) ([]BooleanValue, error) {
|
||||
func (m *mmapAccessor) readBooleanBlock(entry *IndexEntry, tdec *TimeDecoder, vdec *BooleanDecoder, values *[]BooleanValue) ([]BooleanValue, error) {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
|
|
|
@ -55,14 +55,6 @@ type TimeEncoder interface {
|
|||
Bytes() ([]byte, error)
|
||||
}
|
||||
|
||||
// TimeDecoder decodes byte slices to time.Time values.
|
||||
type TimeDecoder interface {
|
||||
Init(b []byte)
|
||||
Next() bool
|
||||
Read() int64
|
||||
Error() error
|
||||
}
|
||||
|
||||
type encoder struct {
|
||||
ts []uint64
|
||||
}
|
||||
|
@ -191,7 +183,7 @@ func (e *encoder) encodeRLE(first, delta, div uint64, n int) ([]byte, error) {
|
|||
return b[:i], nil
|
||||
}
|
||||
|
||||
type decoder struct {
|
||||
type TimeDecoder struct {
|
||||
v int64
|
||||
i int
|
||||
ts []uint64
|
||||
|
@ -199,13 +191,7 @@ type decoder struct {
|
|||
err error
|
||||
}
|
||||
|
||||
func NewTimeDecoder() TimeDecoder {
|
||||
return &decoder{
|
||||
dec: simple8b.NewDecoder(nil),
|
||||
}
|
||||
}
|
||||
|
||||
func (d *decoder) Init(b []byte) {
|
||||
func (d *TimeDecoder) Init(b []byte) {
|
||||
d.v = 0
|
||||
d.i = 0
|
||||
d.ts = d.ts[:0]
|
||||
|
@ -213,7 +199,7 @@ func (d *decoder) Init(b []byte) {
|
|||
d.decode(b)
|
||||
}
|
||||
|
||||
func (d *decoder) Next() bool {
|
||||
func (d *TimeDecoder) Next() bool {
|
||||
if d.i >= len(d.ts) {
|
||||
return false
|
||||
}
|
||||
|
@ -222,15 +208,15 @@ func (d *decoder) Next() bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (d *decoder) Read() int64 {
|
||||
func (d *TimeDecoder) Read() int64 {
|
||||
return d.v
|
||||
}
|
||||
|
||||
func (d *decoder) Error() error {
|
||||
func (d *TimeDecoder) Error() error {
|
||||
return d.err
|
||||
}
|
||||
|
||||
func (d *decoder) decode(b []byte) {
|
||||
func (d *TimeDecoder) decode(b []byte) {
|
||||
if len(b) == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -249,7 +235,7 @@ func (d *decoder) decode(b []byte) {
|
|||
}
|
||||
}
|
||||
|
||||
func (d *decoder) decodePacked(b []byte) {
|
||||
func (d *TimeDecoder) decodePacked(b []byte) {
|
||||
div := uint64(math.Pow10(int(b[0] & 0xF)))
|
||||
first := uint64(binary.BigEndian.Uint64(b[1:9]))
|
||||
|
||||
|
@ -272,7 +258,7 @@ func (d *decoder) decodePacked(b []byte) {
|
|||
d.ts = deltas
|
||||
}
|
||||
|
||||
func (d *decoder) decodeRLE(b []byte) {
|
||||
func (d *TimeDecoder) decodeRLE(b []byte) {
|
||||
var i, n int
|
||||
|
||||
// Lower 4 bits hold the 10 based exponent so we can scale the values back up
|
||||
|
@ -309,7 +295,7 @@ func (d *decoder) decodeRLE(b []byte) {
|
|||
d.ts = deltas
|
||||
}
|
||||
|
||||
func (d *decoder) decodeRaw(b []byte) {
|
||||
func (d *TimeDecoder) decodeRaw(b []byte) {
|
||||
d.i = 0
|
||||
d.ts = make([]uint64, len(b)/8)
|
||||
for i := range d.ts {
|
||||
|
|
|
@ -28,7 +28,7 @@ func Test_TimeEncoder(t *testing.T) {
|
|||
t.Fatalf("Wrong encoding used: expected rle, got %v", got)
|
||||
}
|
||||
|
||||
dec := NewTimeDecoder()
|
||||
var dec TimeDecoder
|
||||
dec.Init(b)
|
||||
for i, v := range x {
|
||||
if !dec.Next() {
|
||||
|
@ -48,7 +48,7 @@ func Test_TimeEncoder_NoValues(t *testing.T) {
|
|||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
dec := NewTimeDecoder()
|
||||
var dec TimeDecoder
|
||||
dec.Init(b)
|
||||
if dec.Next() {
|
||||
t.Fatalf("unexpected next value: got true, exp false")
|
||||
|
@ -69,7 +69,7 @@ func Test_TimeEncoder_One(t *testing.T) {
|
|||
t.Fatalf("Wrong encoding used: expected uncompressed, got %v", got)
|
||||
}
|
||||
|
||||
dec := NewTimeDecoder()
|
||||
var dec TimeDecoder
|
||||
dec.Init(b)
|
||||
if !dec.Next() {
|
||||
t.Fatalf("unexpected next value: got true, exp false")
|
||||
|
@ -96,7 +96,7 @@ func Test_TimeEncoder_Two(t *testing.T) {
|
|||
t.Fatalf("Wrong encoding used: expected rle, got %v", got)
|
||||
}
|
||||
|
||||
dec := NewTimeDecoder()
|
||||
var dec TimeDecoder
|
||||
dec.Init(b)
|
||||
if !dec.Next() {
|
||||
t.Fatalf("unexpected next value: got true, exp false")
|
||||
|
@ -134,7 +134,7 @@ func Test_TimeEncoder_Three(t *testing.T) {
|
|||
t.Fatalf("Wrong encoding used: expected rle, got %v", got)
|
||||
}
|
||||
|
||||
dec := NewTimeDecoder()
|
||||
var dec TimeDecoder
|
||||
dec.Init(b)
|
||||
if !dec.Next() {
|
||||
t.Fatalf("unexpected next value: got true, exp false")
|
||||
|
@ -176,7 +176,7 @@ func Test_TimeEncoder_Large_Range(t *testing.T) {
|
|||
t.Fatalf("Wrong encoding used: expected rle, got %v", got)
|
||||
}
|
||||
|
||||
dec := NewTimeDecoder()
|
||||
var dec TimeDecoder
|
||||
dec.Init(b)
|
||||
if !dec.Next() {
|
||||
t.Fatalf("unexpected next value: got true, exp false")
|
||||
|
@ -220,7 +220,7 @@ func Test_TimeEncoder_Uncompressed(t *testing.T) {
|
|||
t.Fatalf("Wrong encoding used: expected uncompressed, got %v", got)
|
||||
}
|
||||
|
||||
dec := NewTimeDecoder()
|
||||
var dec TimeDecoder
|
||||
dec.Init(b)
|
||||
if !dec.Next() {
|
||||
t.Fatalf("unexpected next value: got true, exp false")
|
||||
|
@ -271,7 +271,7 @@ func Test_TimeEncoder_RLE(t *testing.T) {
|
|||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
dec := NewTimeDecoder()
|
||||
var dec TimeDecoder
|
||||
dec.Init(b)
|
||||
for i, v := range ts {
|
||||
if !dec.Next() {
|
||||
|
@ -309,7 +309,7 @@ func Test_TimeEncoder_Reverse(t *testing.T) {
|
|||
t.Fatalf("Wrong encoding used: expected uncompressed, got %v", got)
|
||||
}
|
||||
|
||||
dec := NewTimeDecoder()
|
||||
var dec TimeDecoder
|
||||
dec.Init(b)
|
||||
i := 0
|
||||
for dec.Next() {
|
||||
|
@ -346,7 +346,7 @@ func Test_TimeEncoder_220SecondDelta(t *testing.T) {
|
|||
t.Fatalf("Wrong encoding used: expected uncompressed, got %v", got)
|
||||
}
|
||||
|
||||
dec := NewTimeDecoder()
|
||||
var dec TimeDecoder
|
||||
dec.Init(b)
|
||||
i := 0
|
||||
for dec.Next() {
|
||||
|
@ -383,7 +383,7 @@ func Test_TimeEncoder_Quick(t *testing.T) {
|
|||
|
||||
// Read values out of decoder.
|
||||
got := make([]int64, 0, len(values))
|
||||
dec := NewTimeDecoder()
|
||||
var dec TimeDecoder
|
||||
dec.Init(buf)
|
||||
for dec.Next() {
|
||||
if err := dec.Error(); err != nil {
|
||||
|
@ -425,7 +425,7 @@ func Test_TimeEncoder_RLESeconds(t *testing.T) {
|
|||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
dec := NewTimeDecoder()
|
||||
var dec TimeDecoder
|
||||
dec.Init(b)
|
||||
for i, v := range ts {
|
||||
if !dec.Next() {
|
||||
|
@ -551,7 +551,7 @@ func BenchmarkTimeDecoder_Packed(b *testing.B) {
|
|||
b.ResetTimer()
|
||||
|
||||
b.StopTimer()
|
||||
dec := NewTimeDecoder()
|
||||
var dec TimeDecoder
|
||||
b.StartTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
@ -573,7 +573,7 @@ func BenchmarkTimeDecoder_RLE(b *testing.B) {
|
|||
b.ResetTimer()
|
||||
|
||||
b.StopTimer()
|
||||
dec := NewTimeDecoder()
|
||||
var dec TimeDecoder
|
||||
b.StartTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
|
Loading…
Reference in New Issue