99 "bytes"
1010 "context"
1111 "encoding/binary"
12- stderrors "errors"
12+ "errors"
1313 "expvar"
1414 "fmt"
1515 "math"
@@ -22,7 +22,6 @@ import (
2222 "time"
2323
2424 humanize "github.com/dustin/go-humanize"
25- "github.com/pkg/errors"
2625
2726 "github.com/dgraph-io/badger/v4/fb"
2827 "github.com/dgraph-io/badger/v4/options"
@@ -145,14 +144,14 @@ func checkAndSetOptions(opt *Options) error {
145144
146145 // We are limiting opt.ValueThreshold to maxValueThreshold for now.
147146 if opt .ValueThreshold > maxValueThreshold {
148- return errors .Errorf ("Invalid ValueThreshold, must be less or equal to %d" ,
147+ return fmt .Errorf ("Invalid ValueThreshold, must be less or equal to %d" ,
149148 maxValueThreshold )
150149 }
151150
152151 // If ValueThreshold is greater than opt.maxBatchSize, we won't be able to push any data using
153152 // the transaction APIs. Transaction batches entries into batches of size opt.maxBatchSize.
154153 if opt .ValueThreshold > opt .maxBatchSize {
155- return errors .Errorf ("Valuethreshold %d greater than max batch size of %d. Either " +
154+ return fmt .Errorf ("Valuethreshold %d greater than max batch size of %d. Either " +
156155 "reduce opt.ValueThreshold or increase opt.BaseTableSize." ,
157156 opt .ValueThreshold , opt .maxBatchSize )
158157 }
@@ -373,7 +372,7 @@ func Open(opt Options) (*DB, error) {
373372 go db .threshold .listenForValueThresholdUpdate ()
374373
375374 if err := db .initBannedNamespaces (); err != nil {
376- return db , errors . Wrapf ( err , "While setting banned keys" )
375+ return db , fmt . Errorf ( "While setting banned keys: %w" , err )
377376 }
378377
379378 db .closers .writes = z .NewCloser (1 )
@@ -787,7 +786,7 @@ func (db *DB) writeToLSM(b *request) error {
787786 // running in InMemory mode. In InMemory mode, we don't write anything to the
788787 // value log and that's why the length of b.Ptrs will always be zero.
789788 if ! db .opt .InMemory && len (b .Ptrs ) != len (b .Entries ) {
790- return errors .Errorf ("Ptrs and Entries don't match: %+v" , b )
789+ return fmt .Errorf ("Ptrs and Entries don't match: %+v" , b )
791790 }
792791
793792 for i , entry := range b .Entries {
@@ -1005,7 +1004,7 @@ func (db *DB) batchSetAsync(entries []*Entry, f func(error)) error {
10051004 return nil
10061005}
10071006
1008- var errNoRoom = stderrors .New ("No room for write" )
1007+ var errNoRoom = errors .New ("No room for write" )
10091008
10101009// ensureRoomForWrite is always called serially.
10111010func (db * DB ) ensureRoomForWrite () error {
@@ -1963,7 +1962,7 @@ func createDirs(opt Options) error {
19631962 }
19641963 if ! dirExists {
19651964 if opt .ReadOnly {
1966- return errors .Errorf ("Cannot find directory %q for read-only open" , path )
1965+ return fmt .Errorf ("Cannot find directory %q for read-only open" , path )
19671966 }
19681967 // Try to create the directory
19691968 err = os .MkdirAll (path , 0700 )
@@ -2035,7 +2034,7 @@ func (db *DB) CacheMaxCost(cache CacheType, maxCost int64) (int64, error) {
20352034 case IndexCache :
20362035 return db .indexCache .MaxCost (), nil
20372036 default :
2038- return 0 , errors .Errorf ("invalid cache type" )
2037+ return 0 , errors .New ("invalid cache type" )
20392038 }
20402039 }
20412040
@@ -2047,7 +2046,7 @@ func (db *DB) CacheMaxCost(cache CacheType, maxCost int64) (int64, error) {
20472046 db .indexCache .UpdateMaxCost (maxCost )
20482047 return maxCost , nil
20492048 default :
2050- return 0 , errors .Errorf ("invalid cache type" )
2049+ return 0 , errors .New ("invalid cache type" )
20512050 }
20522051}
20532052
0 commit comments