MCPcopy
hub / github.com/etcd-io/bbolt / Page

Method Page

tx.go:668–695  ·  view source on GitHub ↗

Page returns page information for a given page number. This is only safe for concurrent use when used by a writable transaction.

(id int)

Source from the content-addressed store, hash-verified

666// Page returns page information for a given page number.
667// This is only safe for concurrent use when used by a writable transaction.
668func (tx *Tx) Page(id int) (*common.PageInfo, error) {
669 if tx.db == nil {
670 return nil, berrors.ErrTxClosed
671 } else if common.Pgid(id) >= tx.meta.Pgid() {
672 return nil, nil
673 }
674
675 if tx.db.freelist == nil {
676 return nil, berrors.ErrFreePagesNotLoaded
677 }
678
679 // Build the page info.
680 p := tx.db.page(common.Pgid(id))
681 info := &common.PageInfo{
682 ID: id,
683 Count: int(p.Count()),
684 OverflowCount: int(p.Overflow()),
685 }
686
687 // Determine the type (or if it's free).
688 if tx.db.freelist.Freed(common.Pgid(id)) {
689 info.Type = "free"
690 } else {
691 info.Type = p.Typ()
692 }
693
694 return info, nil
695}
696
697// TxStats represents statistics about the actions performed by the transaction.
698type TxStats struct {

Callers 3

TestMethodPageFunction · 0.80
TestDB_ConsistencyFunction · 0.80
pagesFuncFunction · 0.80

Calls 7

PgidTypeAlias · 0.92
OverflowMethod · 0.80
TypMethod · 0.80
CountMethod · 0.65
FreedMethod · 0.65
PgidMethod · 0.45
pageMethod · 0.45

Tested by 2

TestMethodPageFunction · 0.64
TestDB_ConsistencyFunction · 0.64