MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / tryGet

Method tryGet

tx_btree.go:487–509  ·  view source on GitHub ↗
(bucket string, key []byte, solveRecord func(record *core.Record, entry *core.Entry, found bool, bucketId core.BucketId) error)

Source from the content-addressed store, hash-verified

485}
486
487func (tx *Tx) tryGet(bucket string, key []byte, solveRecord func(record *core.Record, entry *core.Entry, found bool, bucketId core.BucketId) error) error {
488 if err := tx.checkTxIsClosed(); err != nil {
489 return err
490 }
491 status, b := tx.getBucketAndItsStatus(DataStructureBTree, bucket)
492 if isBucketNotFoundStatus(status) {
493 return ErrNotFoundBucket
494 }
495 bucketId := b.Id
496 var (
497 record *core.Record = nil
498 found bool
499 )
500 entry, err := tx.pendingWrites.Get(DataStructureBTree, bucket, key)
501 found = err == nil
502 if idx, ok := tx.db.Index.BTree.exist(bucketId); ok {
503 record, ok = idx.Find(key)
504 if ok {
505 found = true
506 }
507 }
508 return solveRecord(record, entry, found, bucketId)
509}
510
511func (tx *Tx) update(bucket string, key []byte, getNewValue func([]byte) ([]byte, error), getNewTTL func(uint32) (uint32, error)) error {
512 return tx.tryGet(bucket, key, func(record *core.Record, pendingEntry *core.Entry, found bool, bucketId core.BucketId) error {

Callers 2

updateMethod · 0.95
updateOrPutMethod · 0.95

Calls 6

checkTxIsClosedMethod · 0.95
getBucketAndItsStatusMethod · 0.95
isBucketNotFoundStatusFunction · 0.85
existMethod · 0.80
FindMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected