mirror of
https://github.com/logos-storage/nim-leveldb.git
synced 2026-01-08 00:23:12 +00:00
rename LevelDbBatch to LevelDbWriteBatch
This commit is contained in:
parent
964d1b5069
commit
44c16e08c7
@ -5,12 +5,12 @@ type
|
|||||||
LevelDb* = ref object
|
LevelDb* = ref object
|
||||||
path*: string
|
path*: string
|
||||||
db: ptr leveldb_t
|
db: ptr leveldb_t
|
||||||
|
cache: ptr leveldb_cache_t
|
||||||
|
readOptions: ptr leveldb_readoptions_t
|
||||||
syncWriteOptions: ptr leveldb_writeoptions_t
|
syncWriteOptions: ptr leveldb_writeoptions_t
|
||||||
asyncWriteOptions: ptr leveldb_writeoptions_t
|
asyncWriteOptions: ptr leveldb_writeoptions_t
|
||||||
readOptions: ptr leveldb_readoptions_t
|
|
||||||
cache: ptr leveldb_cache_t
|
|
||||||
|
|
||||||
LevelDbBatch* = ref object
|
LevelDbWriteBatch* = ref object
|
||||||
batch: ptr leveldb_writebatch_t
|
batch: ptr leveldb_writebatch_t
|
||||||
|
|
||||||
CompressionType* = enum
|
CompressionType* = enum
|
||||||
@ -144,29 +144,29 @@ proc delete*(self: LevelDb, key: string, sync = true) =
|
|||||||
leveldb_delete(self.db, writeOptions, key, key.len, addr errPtr)
|
leveldb_delete(self.db, writeOptions, key, key.len, addr errPtr)
|
||||||
checkError(errPtr)
|
checkError(errPtr)
|
||||||
|
|
||||||
proc destroy*(self: LevelDbBatch) =
|
proc destroy*(self: LevelDbWriteBatch) =
|
||||||
if self.batch == nil:
|
if self.batch == nil:
|
||||||
return
|
return
|
||||||
leveldb_writebatch_destroy(self.batch)
|
leveldb_writebatch_destroy(self.batch)
|
||||||
self.batch = nil
|
self.batch = nil
|
||||||
|
|
||||||
proc newBatch*(): LevelDbBatch =
|
proc newBatch*(): LevelDbWriteBatch =
|
||||||
new(result, destroy)
|
new(result, destroy)
|
||||||
result.batch = leveldb_writebatch_create()
|
result.batch = leveldb_writebatch_create()
|
||||||
|
|
||||||
proc put*(self: LevelDbBatch, key: string, value: string, sync = true) =
|
proc put*(self: LevelDbWriteBatch, key: string, value: string, sync = true) =
|
||||||
leveldb_writebatch_put(self.batch, key, key.len.csize, value, value.len.csize)
|
leveldb_writebatch_put(self.batch, key, key.len.csize, value, value.len.csize)
|
||||||
|
|
||||||
proc append*(self, source: LevelDbBatch) =
|
proc append*(self, source: LevelDbWriteBatch) =
|
||||||
leveldb_writebatch_append(self.batch, source.batch)
|
leveldb_writebatch_append(self.batch, source.batch)
|
||||||
|
|
||||||
proc delete*(self: LevelDbBatch, key: string) =
|
proc delete*(self: LevelDbWriteBatch, key: string) =
|
||||||
leveldb_writebatch_delete(self.batch, key, key.len.csize)
|
leveldb_writebatch_delete(self.batch, key, key.len.csize)
|
||||||
|
|
||||||
proc clear*(self: LevelDbBatch) =
|
proc clear*(self: LevelDbWriteBatch) =
|
||||||
leveldb_writebatch_clear(self.batch)
|
leveldb_writebatch_clear(self.batch)
|
||||||
|
|
||||||
proc write*(self: LevelDb, batch: LevelDbBatch) =
|
proc write*(self: LevelDb, batch: LevelDbWriteBatch) =
|
||||||
var errPtr: cstring = nil
|
var errPtr: cstring = nil
|
||||||
leveldb_write(self.db, self.syncWriteOptions, batch.batch, addr errPtr)
|
leveldb_write(self.db, self.syncWriteOptions, batch.batch, addr errPtr)
|
||||||
checkError(errPtr)
|
checkError(errPtr)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user