allocate returns a contiguous block of memory starting at a given page.
(count int)
| 499 | |
| 500 | // allocate returns a contiguous block of memory starting at a given page. |
| 501 | func (tx *Tx) allocate(count int) (*common.Page, error) { |
| 502 | lg := tx.db.Logger() |
| 503 | p, err := tx.db.allocate(tx.meta.Txid(), count) |
| 504 | if err != nil { |
| 505 | lg.Errorf("allocating failed, txid: %d, count: %d, error: %v", tx.meta.Txid(), count, err) |
| 506 | return nil, err |
| 507 | } |
| 508 | |
| 509 | // Save to our page cache. |
| 510 | tx.pages[p.Id()] = p |
| 511 | |
| 512 | // Update statistics. |
| 513 | tx.stats.IncPageCount(int64(count)) |
| 514 | tx.stats.IncPageAlloc(int64(count * tx.db.pageSize)) |
| 515 | |
| 516 | return p, nil |
| 517 | } |
| 518 | |
| 519 | // write writes any dirty pages to disk. |
| 520 | func (tx *Tx) write() error { |