Skip to content

Commit 8afd4ff

Browse files
committed
Always use file IO with 32-bit arch
1 parent efdf068 commit 8afd4ff

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

datastore.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,8 @@ func init() {
108108
// reading (in some tests).
109109
DefaultOptions.Options.ValueLogLoadingMode = options.FileIO
110110

111-
if os.Getenv("GOARCH") == "386" {
112-
DefaultOptions.Options.TableLoadingMode = options.FileIO
113-
} else {
114-
// Explicitly set this to mmap. This doesn't use much memory anyways.
115-
DefaultOptions.Options.TableLoadingMode = options.MemoryMap
116-
}
111+
// Explicitly set this to mmap. This doesn't use much memory anyways.
112+
DefaultOptions.Options.TableLoadingMode = options.MemoryMap
117113

118114
// Reduce this from 64MiB to 16MiB. That means badger will hold on to
119115
// 20MiB by default instead of 80MiB.
@@ -133,22 +129,26 @@ var _ ds.Batching = (*Datastore)(nil)
133129
// NewDatastore creates a new badger datastore.
134130
//
135131
// DO NOT set the Dir and/or ValuePath fields of opt, they will be set for you.
136-
func NewDatastore(path string, options *Options) (*Datastore, error) {
132+
func NewDatastore(path string, opts *Options) (*Datastore, error) {
137133
// Copy the options because we modify them.
138134
var opt badger.Options
139135
var gcDiscardRatio float64
140136
var gcSleep time.Duration
141137
var gcInterval time.Duration
142-
if options == nil {
138+
if opts == nil {
143139
opt = badger.DefaultOptions("")
144140
gcDiscardRatio = DefaultOptions.GcDiscardRatio
145141
gcSleep = DefaultOptions.GcSleep
146142
gcInterval = DefaultOptions.GcInterval
147143
} else {
148-
opt = options.Options
149-
gcDiscardRatio = options.GcDiscardRatio
150-
gcSleep = options.GcSleep
151-
gcInterval = options.GcInterval
144+
opt = opts.Options
145+
gcDiscardRatio = opts.GcDiscardRatio
146+
gcSleep = opts.GcSleep
147+
gcInterval = opts.GcInterval
148+
}
149+
150+
if os.Getenv("GOARCH") == "386" {
151+
opt.TableLoadingMode = options.FileIO
152152
}
153153

154154
if gcSleep <= 0 {

0 commit comments

Comments
 (0)