yangzh
(Kevin Yang)
April 29, 2020, 11:55pm
1
Hey, Badger authors (and users):
I have a question about a corner cases: within the same writing Txn, if I happen to write at the same key multiple times (from different functions, with the same *Txn object), what’s the writing behavior from badger? Will it simply honor the latest (among all at the same key)?
Thanks.
Kevin Yang
mrjn
(Manish R Jain)
April 30, 2020, 12:52am
2
The latest one would get applied, rest would be discarded.
}
// Number of pending writes per transaction shouldn't be too big in general.
sort.Slice(entries, func(i, j int) bool {
cmp := bytes.Compare(entries[i].Key, entries[j].Key)
if !reversed {
return cmp < 0
}
return cmp > 0
})
return &pendingWritesIterator{
readTs: txn.readTs,
entries: entries,
reversed: reversed,
}
}
func (txn *Txn) checkSize(e *Entry) error {
count := txn.count + 1
// Extra bytes for the version in key.
size := txn.size + e.estimateSizeAndSetThreshold(txn.db.valueThreshold()) + 10
if count >= txn.db.opt.maxBatchCount || size >= txn.db.opt.maxBatchSize {
yangzh
(Kevin Yang)
April 30, 2020, 1:04am
3
thanks, that’s resonable.
I was hoping Txn can smartly combine everything together though.
You might want to look at the merge functionality.
1 Like