tweaking perf of gouchstore
This commit is contained in:
parent
1b8c353787
commit
ed308eb253
@ -18,12 +18,15 @@ func newGouchstoreBatch(store *GouchstoreStore) *GouchstoreBatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gb *GouchstoreBatch) Set(key, val []byte) {
|
func (gb *GouchstoreBatch) Set(key, val []byte) {
|
||||||
doc, docInfo := kvToDocDocInfo(key, val)
|
id := string(key)
|
||||||
|
doc := &gouchstore.Document{ID: id, Body: val}
|
||||||
|
docInfo := &gouchstore.DocumentInfo{ID: id, ContentMeta: gouchstore.DOC_IS_COMPRESSED}
|
||||||
gb.bulk.Set(docInfo, doc)
|
gb.bulk.Set(docInfo, doc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gb *GouchstoreBatch) Delete(key []byte) {
|
func (gb *GouchstoreBatch) Delete(key []byte) {
|
||||||
_, docInfo := kvToDocDocInfo(key, nil)
|
id := string(key)
|
||||||
|
docInfo := &gouchstore.DocumentInfo{ID: id, ContentMeta: gouchstore.DOC_IS_COMPRESSED}
|
||||||
gb.bulk.Delete(docInfo)
|
gb.bulk.Delete(docInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,12 +25,17 @@ func Open(path string) (*GouchstoreStore, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gs *GouchstoreStore) Get(key []byte) ([]byte, error) {
|
func (gs *GouchstoreStore) Get(key []byte) ([]byte, error) {
|
||||||
docInfo, err := gs.db.DocumentInfoById(string(key))
|
var docInfo gouchstore.DocumentInfo
|
||||||
|
err := gs.db.DocumentInfoByIdNoAlloc(string(key), &docInfo)
|
||||||
if err != nil && err.Error() != "document not found" {
|
if err != nil && err.Error() != "document not found" {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if docInfo != nil && !docInfo.Deleted {
|
if err != nil && err.Error() == "document not found" {
|
||||||
doc, err := gs.db.DocumentById(string(key))
|
return nil, nil
|
||||||
|
}
|
||||||
|
var doc gouchstore.Document
|
||||||
|
if !docInfo.Deleted {
|
||||||
|
err := gs.db.DocumentByIdNoAlloc(string(key), &doc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user