From ab6a98a8b195e0570ea981119534f1c311bc55cb Mon Sep 17 00:00:00 2001 From: Mauro Delazeri Date: Fri, 6 Jan 2023 17:29:58 -0300 Subject: [PATCH] wip --- leveldb/batch.go | 4 ---- leveldb/db_transaction.go | 1 + leveldb/db_write.go | 9 ++++----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/leveldb/batch.go b/leveldb/batch.go index e64f668..063eb95 100644 --- a/leveldb/batch.go +++ b/leveldb/batch.go @@ -347,10 +347,6 @@ func encodeBatchHeader(dst []byte, seq uint64, batchLen int) []byte { dst = ensureBuffer(dst, batchHeaderLen) binary.LittleEndian.PutUint64(dst, seq) binary.LittleEndian.PutUint32(dst[8:], uint32(batchLen)) - - s := fmt.Sprintf("leveldb encodeBatchHeader key %v len %v seq %v data %v.\n", string(dst[8:]), uint32(batchLen), seq, string(dst)) - fmt.Println(s) - return dst } diff --git a/leveldb/db_transaction.go b/leveldb/db_transaction.go index 9bda1e1..2e6bbc9 100644 --- a/leveldb/db_transaction.go +++ b/leveldb/db_transaction.go @@ -174,6 +174,7 @@ func (tr *Transaction) Write(b *Batch, wo *opt.WriteOptions) error { if tr.closed { return errTransactionDone } + return b.replayInternal(func(i int, kt keyType, k, v []byte) error { return tr.put(kt, k, v) }) diff --git a/leveldb/db_write.go b/leveldb/db_write.go index 1e56920..e5b2eeb 100644 --- a/leveldb/db_write.go +++ b/leveldb/db_write.go @@ -7,7 +7,6 @@ package leveldb import ( - "fmt" "sync/atomic" "time" @@ -274,8 +273,8 @@ func (db *DB) writeLocked(batch, ourBatch *Batch, merge, sync bool) error { // It is safe to modify the contents of the arguments after Write returns but // not before. Write will not modify content of the batch. func (db *DB) Write(batch *Batch, wo *opt.WriteOptions) error { - s := fmt.Sprintf("leveldb WriteEEEEEEEEEEEEEEEE len %v dump %v data %v", batch.Dump(), batch.Len(), string(batch.data)) - fmt.Println(s) + // s := fmt.Sprintf("leveldb WriteEEEEEEEEEEEEEEEE len %v dump %v data %v", batch.Dump(), batch.Len(), string(batch.data)) + // fmt.Println(s) if err := db.ok(); err != nil || batch == nil || batch.Len() == 0 { return err @@ -399,8 +398,8 @@ func (db *DB) Put(key, value []byte, wo *opt.WriteOptions) error { // It is safe to modify the contents of the arguments after Delete returns but // not before. func (db *DB) Delete(key []byte, wo *opt.WriteOptions) error { - s := fmt.Sprintf("leveldb DELETE %v", string(key)) - fmt.Println(s) + // s := fmt.Sprintf("leveldb DELETE %v", string(key)) + // fmt.Println(s) return db.putRec(keyTypeDel, key, nil, wo) }