Skip to content

Commit

Permalink
chore: impl feedback on unnecessary sz checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jdockerty committed Jan 14, 2024
1 parent 2556e38 commit de044d4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions tsdb/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -2454,7 +2454,7 @@ func (is IndexSet) MeasurementSeriesKeysByExpr(name []byte, expr influxql.Expr)
}

name, tags := ParseSeriesKey(seriesKey)
if name == nil && tags == nil {
if name == nil || tags == nil {
continue
}
keys = append(keys, models.MakeKey(name, tags))
Expand Down Expand Up @@ -2941,8 +2941,8 @@ func (is IndexSet) tagValuesByKeyAndExpr(auth query.FineAuthorizer, name []byte,
}
}

sz, buf := ReadSeriesKeyLen(buf)
if sz == 0 && len(buf) == 0 {
_, buf = ReadSeriesKeyLen(buf)
if len(buf) == 0 {
continue
}
_, buf = ReadSeriesKeyMeasurement(buf)
Expand Down
4 changes: 2 additions & 2 deletions tsdb/index/tsi1/log_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,8 @@ func (f *LogFile) execSeriesEntry(e *LogEntry) {
deleted := e.Flag == LogEntrySeriesTombstoneFlag

// Read key size.
sz, remainder := tsdb.ReadSeriesKeyLen(seriesKey)
if sz == 0 && len(remainder) == 0 {
_, remainder := tsdb.ReadSeriesKeyLen(seriesKey)
if len(remainder) == 0 {
return
}

Expand Down
4 changes: 2 additions & 2 deletions tsdb/series_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ func ParseSeriesKeyInto(data []byte, dstTags models.Tags) ([]byte, models.Tags)
// different length and capacity to those provided.
func parseSeriesKey(data []byte, dst models.Tags) ([]byte, models.Tags) {
var name []byte
sz, data := ReadSeriesKeyLen(data)
if sz == 0 && len(data) == 0 {
_, data = ReadSeriesKeyLen(data)
if len(data) == 0 {
return nil, nil
}
name, data = ReadSeriesKeyMeasurement(data)
Expand Down
7 changes: 5 additions & 2 deletions tsdb/series_partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,14 @@ func (p *SeriesPartition) CreateSeriesListIfNotExists(keys [][]byte, keyPartitio
newIDs[string(key)] = id
newKeyRanges = append(newKeyRanges, keyRange{id, offset})
if tracker.AddedMeasurementSeries != nil {
sz, remainder := ReadSeriesKeyLen(key)
if sz == 0 && len(remainder) == 0 {
_, remainder := ReadSeriesKeyLen(key)
if len(remainder) == 0 {
continue
}
measurement, _ := ReadSeriesKeyMeasurement(remainder)
if len(measurement) == 0 {
continue
}
tracker.AddedMeasurementSeries(measurement, 1)
}
}
Expand Down

0 comments on commit de044d4

Please sign in to comment.