(opts *Options)
| 375 | } |
| 376 | |
| 377 | func validateOptions(opts *Options) *Options { |
| 378 | if opts == nil { |
| 379 | opts = DefaultOptions() |
| 380 | } |
| 381 | if opts.WALSegmentSize <= 0 { |
| 382 | opts.WALSegmentSize = wlog.DefaultSegmentSize |
| 383 | } |
| 384 | |
| 385 | if opts.WALCompression == "" { |
| 386 | opts.WALCompression = compression.None |
| 387 | } |
| 388 | |
| 389 | // Revert StripeSize to DefaultStripeSize if StripeSize is either 0 or not a power of 2. |
| 390 | if opts.StripeSize <= 0 || ((opts.StripeSize & (opts.StripeSize - 1)) != 0) { |
| 391 | opts.StripeSize = tsdb.DefaultStripeSize |
| 392 | } |
| 393 | if opts.TruncateFrequency <= 0 { |
| 394 | opts.TruncateFrequency = DefaultTruncateFrequency |
| 395 | } |
| 396 | if opts.MinWALTime <= 0 { |
| 397 | opts.MinWALTime = DefaultMinWALTime |
| 398 | } |
| 399 | if opts.MaxWALTime <= 0 { |
| 400 | opts.MaxWALTime = DefaultMaxWALTime |
| 401 | } |
| 402 | if opts.MinWALTime > opts.MaxWALTime { |
| 403 | opts.MaxWALTime = opts.MinWALTime |
| 404 | } |
| 405 | |
| 406 | if t := int64(opts.TruncateFrequency / time.Millisecond); opts.MaxWALTime < t { |
| 407 | opts.MaxWALTime = t |
| 408 | } |
| 409 | return opts |
| 410 | } |
| 411 | |
| 412 | func (db *DB) replayWAL() error { |
| 413 | db.logger.Info("replaying WAL, this may take a while", "dir", db.wal.Dir()) |
searching dependent graphs…