Skip to content

Commit 4390b27

Browse files
committed
fix a redundant opts
1 parent f2fc1c1 commit 4390b27

File tree

3 files changed

+16
-33
lines changed

3 files changed

+16
-33
lines changed

db_test.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,12 @@ func TestLotusDB_Get(t *testing.T) {
206206
}
207207
}
208208

209-
func TestLotusDB_GetKVFromIndexer(t *testing.T) {
210-
// set the threshold bigger that value will be stored only in indexer.
211-
testGetKV(t, 64<<20)
212-
}
213-
214209
func TestLotusDB_GetKeyFromIndexerAndValFromVLog(t *testing.T) {
215-
// set the threshold smaller that value will be stored in value log.
216-
testGetKV(t, 0)
210+
testGetKV(t)
217211
}
218212

219-
func testGetKV(t *testing.T, valueThreshold int) {
213+
func testGetKV(t *testing.T) {
220214
opts := DefaultOptions("/tmp" + separator + "lotusdb")
221-
opts.CfOpts.ValueThreshold = valueThreshold
222215
db, err := Open(opts)
223216
assert.Nil(t, err)
224217
defer destroyDB(db)

flush.go

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,18 @@ func (cf *ColumnFamily) listenAndFlush() {
7070
if mv.typ == byte(logfile.TypeDelete) || (mv.expiredAt != 0 && mv.expiredAt <= time.Now().Unix()) {
7171
deletedKeys = append(deletedKeys, key)
7272
} else {
73-
if len(mv.value) >= cf.opts.ValueThreshold {
74-
valuePos, esize, err := cf.vlog.Write(&logfile.LogEntry{
75-
Key: key,
76-
Value: mv.value,
77-
ExpiredAt: mv.expiredAt,
78-
})
79-
if err != nil {
80-
return err
81-
}
82-
node.Meta = &index.IndexerMeta{
83-
Fid: valuePos.Fid,
84-
Offset: valuePos.Offset,
85-
EntrySize: esize,
86-
}
87-
} else {
88-
node.Meta = &index.IndexerMeta{Value: mv.value}
73+
valuePos, esize, err := cf.vlog.Write(&logfile.LogEntry{
74+
Key: key,
75+
Value: mv.value,
76+
ExpiredAt: mv.expiredAt,
77+
})
78+
if err != nil {
79+
return err
80+
}
81+
node.Meta = &index.IndexerMeta{
82+
Fid: valuePos.Fid,
83+
Offset: valuePos.Offset,
84+
EntrySize: esize,
8985
}
9086
nodes = append(nodes, node)
9187
}

options.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ func DefaultOptions(path string) Options {
2525
WalMMap: false,
2626
ValueLogFileSize: 1024 << 20,
2727
ValueLogMmap: false,
28-
ValueThreshold: 0,
2928
ValueLogGCRatio: 0.5,
3029
ValueLogGCInterval: time.Minute * 10,
3130
},
@@ -43,7 +42,6 @@ func DefaultColumnFamilyOptions(name string) ColumnFamilyOptions {
4342
WalMMap: false,
4443
ValueLogFileSize: 1024 << 20,
4544
ValueLogMmap: false,
46-
ValueThreshold: 0,
4745
ValueLogGCRatio: 0.5,
4846
ValueLogGCInterval: time.Minute * 10,
4947
}
@@ -79,6 +77,7 @@ type ColumnFamilyOptions struct {
7977

8078
// MemSpaceWaitTimeout represents timeout for waiting enough memtable space to write.
8179
// In this scenario will wait: memtable has reached the maximum nums, and has no time to be flushed into disk.
80+
// Default value is 100ms.
8281
MemSpaceWaitTimeout time.Duration
8382

8483
// IndexerDir dir path to store index meta data, default value is dir path.
@@ -108,11 +107,6 @@ type ColumnFamilyOptions struct {
108107
// ValueLogMmap similar to WalMMap, default value is false.
109108
ValueLogMmap bool
110109

111-
// ValueThreshold sets the threshold used to decide whether a value is stored directly in the Index(B+Tree right now) or separately in value log file.
112-
// If the threshold is zero, that means all values will be stored in value log file.
113-
// Default value is 0.
114-
ValueThreshold int
115-
116110
// ValueLogGCRatio if discarded data in value log exceeds this ratio, it can be picked up for compaction(garbage collection)
117111
// And if there are many files reached the ratio, we will pick the highest one by one.
118112
// The recommended ratio is 0.5, half of the file can be compacted.
@@ -145,7 +139,7 @@ type WriteOptions struct {
145139
// Default value is false.
146140
DisableWal bool
147141

148-
// ExpiredAt time to live for the specified key, a time.Unix value.
142+
// ExpiredAt time to live for the specified key, must be a time.Unix value.
149143
// It will be ignored if it`s not a positive number.
150144
// Default value is 0.
151145
ExpiredAt int64

0 commit comments

Comments
 (0)