(bucket string, key []byte, solveRecord func(record *core.Record, entry *core.Entry, found bool, bucketId core.BucketId) error)
| 485 | } |
| 486 | |
| 487 | func (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 | |
| 511 | func (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 { |
no test coverage detected