Use actual value of uint16-16 in ErrValueThreshold (#877)

* Use actual value of uint16-16 in ErrValueThreshold

The ErrValueThreshold doesn't really show what should be the max value
of value threshold. This commit adds the actual value of value threshold
to the error message.
This commit is contained in:
Ibrahim Jarif
2019-06-24 13:33:54 +05:30
committed by GitHub
parent b750178cdf
commit d9ccc4d2ef
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -192,7 +192,7 @@ func Open(opt Options) (db *DB, err error) {
opt.maxBatchSize = (15 * opt.MaxTableSize) / 100
opt.maxBatchCount = opt.maxBatchSize / int64(skl.MaxNodeSize)
if opt.ValueThreshold > math.MaxUint16-16 {
if opt.ValueThreshold > ValueThresholdLimit {
return nil, ErrValueThreshold
}
+9 -1
View File
@@ -17,9 +17,16 @@
package badger
import (
"math"
"github.com/pkg/errors"
)
const (
// ValueThresholdLimit is the maximum permissible value of opt.ValueThreshold.
ValueThresholdLimit = math.MaxUint16 - 16 + 1
)
var (
// ErrValueLogSize is returned when opt.ValueLogFileSize option is not within the valid
// range.
@@ -27,7 +34,8 @@ var (
// ErrValueThreshold is returned when ValueThreshold is set to a value close to or greater than
// uint16.
ErrValueThreshold = errors.New("Invalid ValueThreshold, must be lower than uint16")
ErrValueThreshold = errors.Errorf(
"Invalid ValueThreshold, must be less than %d", ValueThresholdLimit)
// ErrKeyNotFound is returned when key isn't found on a txn.Get.
ErrKeyNotFound = errors.New("Key not found")