0
0

tweaking perf of gouchstore

This commit is contained in:
Marty Schoch 2014-05-16 15:00:51 -04:00
parent 1b8c353787
commit ed308eb253
2 changed files with 13 additions and 5 deletions

View File

@ -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)
} }

View File

@ -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
} }