Fix vet issues
parent
887e4ba4d4
commit
f680ab0f0d
|
@ -265,7 +265,7 @@ max-select-point = 100
|
|||
} else if c.OpenTSDBInputs[0].BindAddress != ":2000" {
|
||||
t.Fatalf("unexpected opentsdb bind address: %s", c.OpenTSDBInputs[0].BindAddress)
|
||||
} else if c.Coordinator.MaxSelectPointN != 100 {
|
||||
t.Fatalf("unexpected coordinator max select points: %s", c.Coordinator.MaxSelectPointN)
|
||||
t.Fatalf("unexpected coordinator max select points: %d", c.Coordinator.MaxSelectPointN)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1583,7 +1583,7 @@ func (s *SelectStatement) validateAggregates(tr targetRequirement) error {
|
|||
if fc.Name != "distinct" || expr.Name != "count" {
|
||||
return fmt.Errorf("expected field argument in %s()", c.Name)
|
||||
} else if exp, got := 1, len(fc.Args); got != exp {
|
||||
return fmt.Errorf("count(distinct <field>) can only have one argument", fc.Name, exp, got)
|
||||
return fmt.Errorf("count(distinct %s) can only have %d argument(s), got %d", fc.Name, exp, got)
|
||||
} else if _, ok := fc.Args[0].(*VarRef); !ok {
|
||||
return fmt.Errorf("expected field argument in distinct()")
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ func TestFileStore_Read(t *testing.T) {
|
|||
|
||||
for i, v := range exp.values {
|
||||
if got, exp := values[i].Value(), v.Value(); got != exp {
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %d", i, got, exp)
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %v", i, got, exp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ func TestFileStore_SeekToAsc_FromStart(t *testing.T) {
|
|||
|
||||
for i, v := range exp.values {
|
||||
if got, exp := values[i].Value(), v.Value(); got != exp {
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %d", i, got, exp)
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %v", i, got, exp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -498,7 +498,7 @@ func TestFileStore_SeekToAsc_Middle(t *testing.T) {
|
|||
|
||||
for i, v := range exp.values {
|
||||
if got, exp := values[i].Value(), v.Value(); got != exp {
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %d", i, got, exp)
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %v", i, got, exp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -536,7 +536,7 @@ func TestFileStore_SeekToAsc_End(t *testing.T) {
|
|||
|
||||
for i, v := range exp.values {
|
||||
if got, exp := values[i].Value(), v.Value(); got != exp {
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %d", i, got, exp)
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %v", i, got, exp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ func TestFileStore_SeekToDesc_FromStart(t *testing.T) {
|
|||
|
||||
for i, v := range exp.values {
|
||||
if got, exp := values[i].Value(), v.Value(); got != exp {
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %d", i, got, exp)
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %v", i, got, exp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1102,7 +1102,7 @@ func TestFileStore_SeekToDesc_Middle(t *testing.T) {
|
|||
|
||||
for i, v := range exp.values {
|
||||
if got, exp := values[i].Value(), v.Value(); got != exp {
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %d", i, got, exp)
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %v", i, got, exp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1140,7 +1140,7 @@ func TestFileStore_SeekToDesc_End(t *testing.T) {
|
|||
|
||||
for i, v := range exp.values {
|
||||
if got, exp := values[i].Value(), v.Value(); got != exp {
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %d", i, got, exp)
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %v", i, got, exp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1183,7 +1183,7 @@ func TestKeyCursor_TombstoneRange(t *testing.T) {
|
|||
}
|
||||
|
||||
if got, exp := values[0].String(), exp.values[0].String(); got != exp {
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %d", 0, got, exp)
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %v", 0, got, exp)
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
|
@ -1228,7 +1228,7 @@ func TestKeyCursor_TombstoneRange_PartialFloat(t *testing.T) {
|
|||
}
|
||||
|
||||
if got, exp := values[i].String(), exp.String(); got != exp {
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %d", 0, got, exp)
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %v", 0, got, exp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1272,7 +1272,7 @@ func TestKeyCursor_TombstoneRange_PartialInteger(t *testing.T) {
|
|||
}
|
||||
|
||||
if got, exp := values[i].String(), exp.String(); got != exp {
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %d", 0, got, exp)
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %v", 0, got, exp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1316,7 +1316,7 @@ func TestKeyCursor_TombstoneRange_PartialString(t *testing.T) {
|
|||
}
|
||||
|
||||
if got, exp := values[i].String(), exp.String(); got != exp {
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %d", 0, got, exp)
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %v", 0, got, exp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1360,7 +1360,7 @@ func TestKeyCursor_TombstoneRange_PartialBoolean(t *testing.T) {
|
|||
}
|
||||
|
||||
if got, exp := values[i].String(), exp.String(); got != exp {
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %d", 0, got, exp)
|
||||
t.Fatalf("read value mismatch(%d): got %v, exp %v", 0, got, exp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,7 +271,6 @@ func (t *Tombstoner) readTombstoneV2(f *os.File) ([]Tombstone, error) {
|
|||
Max: max,
|
||||
})
|
||||
}
|
||||
return tombstones, nil
|
||||
}
|
||||
|
||||
func (t *Tombstoner) tombstonePath() string {
|
||||
|
|
|
@ -153,7 +153,7 @@ type IndexWriter interface {
|
|||
MarshalBinary() ([]byte, error)
|
||||
|
||||
// WriteTo writes the index contents to a writer
|
||||
WriteTo(w io.Writer) error
|
||||
WriteTo(w io.Writer) (int64, error)
|
||||
}
|
||||
|
||||
// IndexEntry is the index information for a given block in a TSM file.
|
||||
|
@ -305,7 +305,7 @@ func (d *directIndex) addEntries(key string, entries *indexEntries) {
|
|||
existing.entries = append(existing.entries, entries.entries...)
|
||||
}
|
||||
|
||||
func (d *directIndex) WriteTo(w io.Writer) error {
|
||||
func (d *directIndex) WriteTo(w io.Writer) (int64, error) {
|
||||
d.mu.RLock()
|
||||
defer d.mu.RUnlock()
|
||||
|
||||
|
@ -316,16 +316,19 @@ func (d *directIndex) WriteTo(w io.Writer) error {
|
|||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
var buf [5]byte
|
||||
var err error
|
||||
var (
|
||||
n int
|
||||
err error
|
||||
buf [5]byte
|
||||
N int64
|
||||
)
|
||||
|
||||
// For each key, individual entries are sorted by time
|
||||
for _, key := range keys {
|
||||
entries := d.blocks[key]
|
||||
|
||||
if entries.Len() > maxIndexEntries {
|
||||
return fmt.Errorf("key '%s' exceeds max index entries: %d > %d",
|
||||
key, entries.Len(), maxIndexEntries)
|
||||
return N, fmt.Errorf("key '%s' exceeds max index entries: %d > %d", key, entries.Len(), maxIndexEntries)
|
||||
}
|
||||
sort.Sort(entries)
|
||||
|
||||
|
@ -334,30 +337,36 @@ func (d *directIndex) WriteTo(w io.Writer) error {
|
|||
binary.BigEndian.PutUint16(buf[3:5], uint16(entries.Len()))
|
||||
|
||||
// Append the key length and key
|
||||
if _, err = w.Write(buf[0:2]); err != nil {
|
||||
return fmt.Errorf("write: writer key length error: %v", err)
|
||||
if n, err = w.Write(buf[0:2]); err != nil {
|
||||
return int64(n) + N, fmt.Errorf("write: writer key length error: %v", err)
|
||||
}
|
||||
N += int64(n)
|
||||
|
||||
if _, err = io.WriteString(w, key); err != nil {
|
||||
return fmt.Errorf("write: writer key error: %v", err)
|
||||
if n, err = io.WriteString(w, key); err != nil {
|
||||
return int64(n) + N, fmt.Errorf("write: writer key error: %v", err)
|
||||
}
|
||||
N += int64(n)
|
||||
|
||||
// Append the block type and count
|
||||
if _, err = w.Write(buf[2:5]); err != nil {
|
||||
return fmt.Errorf("write: writer block type and count error: %v", err)
|
||||
if n, err = w.Write(buf[2:5]); err != nil {
|
||||
return int64(n) + N, fmt.Errorf("write: writer block type and count error: %v", err)
|
||||
}
|
||||
N += int64(n)
|
||||
|
||||
// Append each index entry for all blocks for this key
|
||||
if _, err = entries.WriteTo(w); err != nil {
|
||||
return fmt.Errorf("write: writer entries error: %v", err)
|
||||
var n64 int64
|
||||
if n64, err = entries.WriteTo(w); err != nil {
|
||||
return n64 + N, fmt.Errorf("write: writer entries error: %v", err)
|
||||
}
|
||||
N += n64
|
||||
|
||||
}
|
||||
return nil
|
||||
return N, nil
|
||||
}
|
||||
|
||||
func (d *directIndex) MarshalBinary() ([]byte, error) {
|
||||
var b bytes.Buffer
|
||||
if err := d.WriteTo(&b); err != nil {
|
||||
if _, err := d.WriteTo(&b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b.Bytes(), nil
|
||||
|
@ -522,7 +531,7 @@ func (t *tsmWriter) WriteIndex() error {
|
|||
}
|
||||
|
||||
// Write the index
|
||||
if err := t.index.WriteTo(t.w); err != nil {
|
||||
if _, err := t.index.WriteTo(t.w); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -592,7 +592,7 @@ func (a Shards) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
|||
type MeasurementFields struct {
|
||||
mu sync.RWMutex
|
||||
|
||||
fields map[string]*Field `json:"fields"`
|
||||
fields map[string]*Field
|
||||
Codec *FieldCodec
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue