Merge pull request #6618 from influxdata/jw-shard-load

Optimize shard index loading
pull/6625/head
Jason Wilder 2016-05-13 14:16:17 -06:00
commit 11871958c6
2 changed files with 12 additions and 4 deletions

View File

@ -14,6 +14,7 @@
### Bugfixes
- [#6604](https://github.com/influxdata/influxdb/pull/6604): Remove old cluster code
- [#6618](https://github.com/influxdata/influxdb/pull/6618): Optimize shard loading
## v0.13.0 [2016-05-12]

View File

@ -379,6 +379,12 @@ func (e *Engine) readFileFromBackup(tr *tar.Reader, shardRelativePath string) er
// database index and measurement fields
func (e *Engine) addToIndexFromKey(shardID uint64, key string, fieldType influxql.DataType, index *tsdb.DatabaseIndex) error {
seriesKey, field := seriesAndFieldFromCompositeKey(key)
// Have we already indexed this series?
ss := index.Series(seriesKey)
if ss != nil {
return nil
}
measurement := tsdb.MeasurementFromSeriesKey(seriesKey)
m := index.CreateMeasurementIndexIfNotExists(measurement)
@ -1230,9 +1236,10 @@ func tsmFieldTypeToInfluxQLDataType(typ byte) (influxql.DataType, error) {
}
func seriesAndFieldFromCompositeKey(key string) (string, string) {
parts := strings.Split(key, keyFieldSeparator)
if len(parts) != 0 {
return parts[0], strings.Join(parts[1:], keyFieldSeparator)
sep := strings.Index(key, keyFieldSeparator)
if sep == -1 {
// No field???
return key, ""
}
return parts[0], parts[1]
return key[:sep], key[sep+len(keyFieldSeparator):]
}