type txid … type Tx … // init initializes the transaction. func (tx *Tx) init(db *DB) { … } // ID returns the transaction id. func (tx *Tx) ID() int { … } // DB returns a reference to the database that created the transaction. func (tx *Tx) DB() *DB { … } // Size returns current database size in bytes as seen by this transaction. func (tx *Tx) Size() int64 { … } // Writable returns whether the transaction can perform write operations. func (tx *Tx) Writable() bool { … } // Cursor creates a cursor associated with the root bucket. // All items in the cursor will return a nil value because all root bucket keys point to buckets. // The cursor is only valid as long as the transaction is open. // Do not use a cursor after the transaction is closed. func (tx *Tx) Cursor() *Cursor { … } // Stats retrieves a copy of the current transaction statistics. func (tx *Tx) Stats() TxStats { … } // Bucket retrieves a bucket by name. // Returns nil if the bucket does not exist. // The bucket instance is only valid for the lifetime of the transaction. func (tx *Tx) Bucket(name []byte) *Bucket { … } // CreateBucket creates a new bucket. // Returns an error if the bucket already exists, if the bucket name is blank, or if the bucket name is too long. // The bucket instance is only valid for the lifetime of the transaction. func (tx *Tx) CreateBucket(name []byte) (*Bucket, error) { … } // CreateBucketIfNotExists creates a new bucket if it doesn't already exist. // Returns an error if the bucket name is blank, or if the bucket name is too long. // The bucket instance is only valid for the lifetime of the transaction. func (tx *Tx) CreateBucketIfNotExists(name []byte) (*Bucket, error) { … } // DeleteBucket deletes a bucket. // Returns an error if the bucket cannot be found or if the key represents a non-bucket value. func (tx *Tx) DeleteBucket(name []byte) error { … } // ForEach executes a function for each bucket in the root. // If the provided function returns an error then the iteration is stopped and // the error is returned to the caller. func (tx *Tx) ForEach(fn func(name []byte, b *Bucket) error) error { … } // OnCommit adds a handler function to be executed after the transaction successfully commits. func (tx *Tx) OnCommit(fn func()) { … } // Commit writes all changes to disk and updates the meta page. // Returns an error if a disk write error occurs, or if Commit is // called on a read-only transaction. func (tx *Tx) Commit() error { … } func (tx *Tx) commitFreelist() error { … } // Rollback closes the transaction and ignores all previous updates. Read-only // transactions must be rolled back and not committed. func (tx *Tx) Rollback() error { … } // nonPhysicalRollback is called when user calls Rollback directly, in this case we do not need to reload the free pages from disk. func (tx *Tx) nonPhysicalRollback() { … } // rollback needs to reload the free pages from disk in case some system error happens like fsync error. func (tx *Tx) rollback() { … } func (tx *Tx) close() { … } // Copy writes the entire database to a writer. // This function exists for backwards compatibility. // // Deprecated; Use WriteTo() instead. func (tx *Tx) Copy(w io.Writer) error { … } // WriteTo writes the entire database to a writer. // If err == nil then exactly tx.Size() bytes will be written into the writer. func (tx *Tx) WriteTo(w io.Writer) (n int64, err error) { … } // CopyFile copies the entire database to file at the given path. // A reader transaction is maintained during the copy so it is safe to continue // using the database while a copy is in progress. func (tx *Tx) CopyFile(path string, mode os.FileMode) error { … } // allocate returns a contiguous block of memory starting at a given page. func (tx *Tx) allocate(count int) (*page, error) { … } // write writes any dirty pages to disk. func (tx *Tx) write() error { … } // writeMeta writes the meta to the disk. func (tx *Tx) writeMeta() error { … } // page returns a reference to the page with a given id. // If page has been written to then a temporary buffered page is returned. func (tx *Tx) page(id pgid) *page { … } // forEachPage iterates over every page within a given page and executes a function. func (tx *Tx) forEachPage(pgidnum pgid, fn func(*page, int, []pgid)) { … } func (tx *Tx) forEachPageInternal(pgidstack []pgid, fn func(*page, int, []pgid)) { … } // Page returns page information for a given page number. // This is only safe for concurrent use when used by a writable transaction. func (tx *Tx) Page(id int) (*PageInfo, error) { … } type TxStats … func (s *TxStats) add(other *TxStats) { … } // Sub calculates and returns the difference between two sets of transaction stats. // This is useful when obtaining stats at two different points and time and // you need the performance counters that occurred within that time span. func (s *TxStats) Sub(other *TxStats) TxStats { … } // GetPageCount returns PageCount atomically. func (s *TxStats) GetPageCount() int64 { … } // IncPageCount increases PageCount atomically and returns the new value. func (s *TxStats) IncPageCount(delta int64) int64 { … } // GetPageAlloc returns PageAlloc atomically. func (s *TxStats) GetPageAlloc() int64 { … } // IncPageAlloc increases PageAlloc atomically and returns the new value. func (s *TxStats) IncPageAlloc(delta int64) int64 { … } // GetCursorCount returns CursorCount atomically. func (s *TxStats) GetCursorCount() int64 { … } // IncCursorCount increases CursorCount atomically and return the new value. func (s *TxStats) IncCursorCount(delta int64) int64 { … } // GetNodeCount returns NodeCount atomically. func (s *TxStats) GetNodeCount() int64 { … } // IncNodeCount increases NodeCount atomically and returns the new value. func (s *TxStats) IncNodeCount(delta int64) int64 { … } // GetNodeDeref returns NodeDeref atomically. func (s *TxStats) GetNodeDeref() int64 { … } // IncNodeDeref increases NodeDeref atomically and returns the new value. func (s *TxStats) IncNodeDeref(delta int64) int64 { … } // GetRebalance returns Rebalance atomically. func (s *TxStats) GetRebalance() int64 { … } // IncRebalance increases Rebalance atomically and returns the new value. func (s *TxStats) IncRebalance(delta int64) int64 { … } // GetRebalanceTime returns RebalanceTime atomically. func (s *TxStats) GetRebalanceTime() time.Duration { … } // IncRebalanceTime increases RebalanceTime atomically and returns the new value. func (s *TxStats) IncRebalanceTime(delta time.Duration) time.Duration { … } // GetSplit returns Split atomically. func (s *TxStats) GetSplit() int64 { … } // IncSplit increases Split atomically and returns the new value. func (s *TxStats) IncSplit(delta int64) int64 { … } // GetSpill returns Spill atomically. func (s *TxStats) GetSpill() int64 { … } // IncSpill increases Spill atomically and returns the new value. func (s *TxStats) IncSpill(delta int64) int64 { … } // GetSpillTime returns SpillTime atomically. func (s *TxStats) GetSpillTime() time.Duration { … } // IncSpillTime increases SpillTime atomically and returns the new value. func (s *TxStats) IncSpillTime(delta time.Duration) time.Duration { … } // GetWrite returns Write atomically. func (s *TxStats) GetWrite() int64 { … } // IncWrite increases Write atomically and returns the new value. func (s *TxStats) IncWrite(delta int64) int64 { … } // GetWriteTime returns WriteTime atomically. func (s *TxStats) GetWriteTime() time.Duration { … } // IncWriteTime increases WriteTime atomically and returns the new value. func (s *TxStats) IncWriteTime(delta time.Duration) time.Duration { … } func atomicAddDuration(ptr *time.Duration, du time.Duration) time.Duration { … } func atomicLoadDuration(ptr *time.Duration) time.Duration { … }