Merge pull request #7775 from zegl/master
Removed ineffective assignments, and added checks for errors that pre…pull/7323/head^2
commit
c783c3d05f
|
@ -113,12 +113,9 @@ func (cmd *Command) dump() error {
|
|||
pos++
|
||||
split := strings.Split(string(key), "#!~#")
|
||||
|
||||
// We dont' know know if we have fields so use an informative default
|
||||
var measurement, field string = "UNKNOWN", "UNKNOWN"
|
||||
|
||||
// Possible corruption? Try to read as much as we can and point to the problem.
|
||||
measurement = split[0]
|
||||
field = split[1]
|
||||
measurement := split[0]
|
||||
field := split[1]
|
||||
|
||||
if cmd.filterKey != "" && !strings.Contains(string(key), cmd.filterKey) {
|
||||
continue
|
||||
|
|
|
@ -172,6 +172,10 @@ func (d *Database) Shards() ([]*ShardInfo, error) {
|
|||
|
||||
// Process each shard
|
||||
shards, err := rpfd.Readdirnames(-1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, sh := range shards {
|
||||
fmt, sz, err := shardFormat(filepath.Join(d.path, rp, sh))
|
||||
if err != nil {
|
||||
|
|
|
@ -157,9 +157,9 @@ func (cmd *Command) unpackMeta() error {
|
|||
i += int(length)
|
||||
|
||||
// Size of the node.json bytes
|
||||
length = int(binary.BigEndian.Uint64(b[i : i+8]))
|
||||
i += 8
|
||||
nodeBytes := b[i:]
|
||||
length = int(binary.BigEndian.Uint64(b[i : i+8]))
|
||||
nodeBytes := b[i : i+length]
|
||||
|
||||
// Unpack into metadata.
|
||||
var data meta.Data
|
||||
|
|
|
@ -202,7 +202,7 @@ func NewQueryExecutor() *QueryExecutor {
|
|||
}
|
||||
e.QueryExecutor.WithLogger(zap.New(
|
||||
zap.NewTextEncoder(),
|
||||
zap.Output(os.Stderr),
|
||||
zap.Output(zap.AddSync(out)),
|
||||
))
|
||||
|
||||
return e
|
||||
|
|
|
@ -657,7 +657,6 @@ func (r *FloatHoltWintersReducer) forecast(h int, params []float64) []float64 {
|
|||
|
||||
lT := params[4]
|
||||
bT := params[5]
|
||||
sT := 0.0
|
||||
|
||||
// seasonals is a ring buffer of past sT values
|
||||
var seasonals []float64
|
||||
|
@ -683,6 +682,7 @@ func (r *FloatHoltWintersReducer) forecast(h int, params []float64) []float64 {
|
|||
stm = seasonals[(t-m+so)%m]
|
||||
stmh = seasonals[(t-m+hm+so)%m]
|
||||
}
|
||||
var sT float64
|
||||
yT, lT, bT, sT = r.next(
|
||||
params[0], // alpha
|
||||
params[1], // beta
|
||||
|
|
|
@ -143,11 +143,6 @@ func TestQueryExecutor_Abort(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestQueryExecutor_ShowQueries(t *testing.T) {
|
||||
q, err := influxql.ParseQuery(`SELECT count(value) FROM cpu`)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
e := NewQueryExecutor()
|
||||
e.StatementExecutor = &StatementExecutor{
|
||||
ExecuteStatementFn: func(stmt influxql.Statement, ctx influxql.ExecutionContext) error {
|
||||
|
@ -161,7 +156,7 @@ func TestQueryExecutor_ShowQueries(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
q, err = influxql.ParseQuery(`SHOW QUERIES`)
|
||||
q, err := influxql.ParseQuery(`SHOW QUERIES`)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
5
node.go
5
node.go
|
@ -95,7 +95,12 @@ func upgradeNodeFile(path string) error {
|
|||
}
|
||||
return err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(pb, &peers)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(peers) > 1 {
|
||||
return fmt.Errorf("to upgrade a cluster, please contact support at influxdata")
|
||||
}
|
||||
|
|
|
@ -679,6 +679,9 @@ func TestApplyTemplateField(t *testing.T) {
|
|||
}
|
||||
|
||||
measurement, _, field, err := p.ApplyTemplate("current.users.logged_in")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if measurement != "current_users" {
|
||||
t.Errorf("Parser.ApplyTemplate unexpected result. got %s, exp %s",
|
||||
|
|
|
@ -44,7 +44,6 @@ func (c *Client) MetastoreBackup() (*meta.Data, error) {
|
|||
length := int(binary.BigEndian.Uint64(b[i : i+8]))
|
||||
i += 8
|
||||
metaBytes := b[i : i+length]
|
||||
i += int(length)
|
||||
|
||||
// Unpack meta data.
|
||||
var data meta.Data
|
||||
|
|
|
@ -23,6 +23,9 @@ func NewHTTP(addr string, timeout time.Duration) (*HTTP, error) {
|
|||
// NewHTTPS returns a new HTTPS points writer with default options and HTTPS configured
|
||||
func NewHTTPS(addr string, timeout time.Duration, unsafeSsl bool, caCerts string) (*HTTP, error) {
|
||||
tlsConfig, err := createTlsConfig(caCerts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
conf := client.HTTPConfig{
|
||||
Addr: addr,
|
||||
|
|
|
@ -608,13 +608,13 @@ func (p *Parser) ParseFunction() (*statement.Function, error) {
|
|||
|
||||
fn := &statement.Function{}
|
||||
|
||||
tok, lit := p.scanIgnoreWhitespace()
|
||||
_, lit := p.scanIgnoreWhitespace()
|
||||
fn.Type = lit
|
||||
|
||||
tok, lit = p.scanIgnoreWhitespace()
|
||||
_, lit = p.scanIgnoreWhitespace()
|
||||
fn.Fn = lit
|
||||
|
||||
tok, lit = p.scanIgnoreWhitespace()
|
||||
tok, lit := p.scanIgnoreWhitespace()
|
||||
if tok != LPAREN {
|
||||
return nil, fmt.Errorf("Error parsing Insert template function\n Expected: LPAREN\n Found: %v\n", lit)
|
||||
}
|
||||
|
|
|
@ -17,6 +17,9 @@ func TestBitStreamEOF(t *testing.T) {
|
|||
br := tsm1.NewBitReader([]byte("0"))
|
||||
|
||||
b, err := br.ReadBits(8)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if b != '0' {
|
||||
t.Error("ReadBits(8) didn't return first byte")
|
||||
}
|
||||
|
|
|
@ -845,9 +845,16 @@ func ParseTSMFileName(name string) (int, int, error) {
|
|||
}
|
||||
|
||||
generation, err := strconv.ParseUint(id[:idx], 10, 32)
|
||||
sequence, err := strconv.ParseUint(id[idx+1:], 10, 32)
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("file %s is named incorrectly", name)
|
||||
}
|
||||
|
||||
return int(generation), int(sequence), err
|
||||
sequence, err := strconv.ParseUint(id[idx+1:], 10, 32)
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("file %s is named incorrectly", name)
|
||||
}
|
||||
|
||||
return int(generation), int(sequence), nil
|
||||
}
|
||||
|
||||
type KeyCursor struct {
|
||||
|
|
|
@ -153,6 +153,10 @@ func TestFileStore_SeekToAsc_Duplicate(t *testing.T) {
|
|||
|
||||
c.Next()
|
||||
values, err = c.ReadFloatBlock(&buf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
exp = nil
|
||||
if got, exp := len(values), len(exp); got != exp {
|
||||
t.Fatalf("value length mismatch: got %v, exp %v", got, exp)
|
||||
|
@ -533,6 +537,10 @@ func TestFileStore_SeekToAsc_OverlapMinFloat(t *testing.T) {
|
|||
|
||||
c.Next()
|
||||
values, err = c.ReadFloatBlock(&buf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
exp = nil
|
||||
if got, exp := len(values), len(exp); got != exp {
|
||||
t.Fatalf("value length mismatch: got %v, exp %v", got, exp)
|
||||
|
@ -608,6 +616,10 @@ func TestFileStore_SeekToAsc_OverlapMinInteger(t *testing.T) {
|
|||
|
||||
c.Next()
|
||||
values, err = c.ReadIntegerBlock(&buf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
exp = nil
|
||||
if got, exp := len(values), len(exp); got != exp {
|
||||
t.Fatalf("value length mismatch: got %v, exp %v", got, exp)
|
||||
|
@ -683,6 +695,10 @@ func TestFileStore_SeekToAsc_OverlapMinBoolean(t *testing.T) {
|
|||
|
||||
c.Next()
|
||||
values, err = c.ReadBooleanBlock(&buf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
exp = nil
|
||||
if got, exp := len(values), len(exp); got != exp {
|
||||
t.Fatalf("value length mismatch: got %v, exp %v", got, exp)
|
||||
|
@ -758,6 +774,10 @@ func TestFileStore_SeekToAsc_OverlapMinString(t *testing.T) {
|
|||
|
||||
c.Next()
|
||||
values, err = c.ReadStringBlock(&buf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
exp = nil
|
||||
if got, exp := len(values), len(exp); got != exp {
|
||||
t.Fatalf("value length mismatch: got %v, exp %v", got, exp)
|
||||
|
@ -2070,11 +2090,18 @@ func TestFileStore_Replace(t *testing.T) {
|
|||
cur.Next()
|
||||
buf := make([]tsm1.FloatValue, 10)
|
||||
values, err := cur.ReadFloatBlock(&buf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, exp := len(values), 1; got != exp {
|
||||
t.Fatalf("value len mismatch: got %v, exp %v", got, exp)
|
||||
}
|
||||
|
||||
cur.Next()
|
||||
values, err = cur.ReadFloatBlock(&buf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, exp := len(values), 1; got != exp {
|
||||
t.Fatalf("value len mismatch: got %v, exp %v", got, exp)
|
||||
}
|
||||
|
@ -2082,6 +2109,9 @@ func TestFileStore_Replace(t *testing.T) {
|
|||
// No more blocks for this cursor
|
||||
cur.Next()
|
||||
values, err = cur.ReadFloatBlock(&buf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, exp := len(values), 0; got != exp {
|
||||
t.Fatalf("value len mismatch: got %v, exp %v", got, exp)
|
||||
}
|
||||
|
|
|
@ -763,6 +763,9 @@ func TestIndirectIndex_Type(t *testing.T) {
|
|||
index.Add("cpu", tsm1.BlockInteger, 0, 1, 10, 20)
|
||||
|
||||
b, err := index.MarshalBinary()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ind := tsm1.NewIndirectIndex()
|
||||
if err := ind.UnmarshalBinary(b); err != nil {
|
||||
|
|
|
@ -173,12 +173,12 @@ func TestTombstoner_ReadV1(t *testing.T) {
|
|||
|
||||
ts := &tsm1.Tombstoner{Path: f.Name()}
|
||||
|
||||
entries, err := ts.ReadAll()
|
||||
_, err := ts.ReadAll()
|
||||
if err != nil {
|
||||
fatal(t, "ReadAll", err)
|
||||
}
|
||||
|
||||
entries, err = ts.ReadAll()
|
||||
entries, err := ts.ReadAll()
|
||||
if err != nil {
|
||||
fatal(t, "ReadAll", err)
|
||||
}
|
||||
|
@ -220,12 +220,12 @@ func TestTombstoner_ReadEmptyV1(t *testing.T) {
|
|||
|
||||
ts := &tsm1.Tombstoner{Path: f.Name()}
|
||||
|
||||
entries, err := ts.ReadAll()
|
||||
_, err := ts.ReadAll()
|
||||
if err != nil {
|
||||
fatal(t, "ReadAll", err)
|
||||
}
|
||||
|
||||
entries, err = ts.ReadAll()
|
||||
entries, err := ts.ReadAll()
|
||||
if err != nil {
|
||||
fatal(t, "ReadAll", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue