@@ -16,26 +16,24 @@ type ReadWriter interface {
16
16
EstimatedWritePageSize () int
17
17
}
18
18
19
- type Interface interface {
20
- ReadWriter
21
-
19
+ type allocator interface {
22
20
// Init initializes this freelist with the given list of pages.
23
21
Init (ids common.Pgids )
24
22
25
- // Allocate tries to allocate the given number of contiguous pages
26
- // from the free list pages. It returns the starting page ID if
27
- // available; otherwise, it returns 0.
28
- Allocate (txid common.Txid , numPages int ) common.Pgid
29
-
30
- // Count returns the number of free and pending pages.
31
- Count () int
32
-
33
23
// FreeCount returns the number of free pages.
34
24
FreeCount () int
35
25
36
- // PendingCount returns the number of pending pages.
37
- PendingCount () int
26
+ // freePageIds returns the IDs of all free pages.
27
+ freePageIds () common. Pgids
38
28
29
+ // mergeSpans is merging the given pages into the freelist
30
+ mergeSpans (ids common.Pgids )
31
+
32
+ // TODO(thomas): this is necessary to decouple, but leaks internals
33
+ alloc (txid common.Txid , numPages int , allocs * map [common.Pgid ]common.Txid , cache * map [common.Pgid ]struct {}) common.Pgid
34
+ }
35
+
36
+ type txManager interface {
39
37
// AddReadonlyTXID adds a given read-only transaction id for pending page tracking.
40
38
AddReadonlyTXID (txid common.Txid )
41
39
@@ -45,6 +43,32 @@ type Interface interface {
45
43
// ReleasePendingPages releases any pages associated with closed read-only transactions.
46
44
ReleasePendingPages ()
47
45
46
+ // pendingPageIds returns all pending pages by transaction id.
47
+ pendingPageIds () map [common.Txid ]* txPending
48
+
49
+ // release moves all page ids for a transaction id (or older) to the freelist.
50
+ release (txId common.Txid )
51
+
52
+ // releaseRange moves pending pages allocated within an extent [begin,end] to the free list.
53
+ releaseRange (begin , end common.Txid )
54
+ }
55
+
56
+ type Interface interface {
57
+ ReadWriter
58
+ allocator
59
+ txManager
60
+
61
+ // Allocate tries to allocate the given number of contiguous pages
62
+ // from the free list pages. It returns the starting page ID if
63
+ // available; otherwise, it returns 0.
64
+ Allocate (txid common.Txid , numPages int ) common.Pgid
65
+
66
+ // Count returns the number of free and pending pages.
67
+ Count () int
68
+
69
+ // PendingCount returns the number of pending pages.
70
+ PendingCount () int
71
+
48
72
// Free releases a page and its overflow for a given transaction id.
49
73
// If the page is already free then a panic will occur.
50
74
Free (txId common.Txid , p * common.Page )
@@ -64,19 +88,4 @@ type Interface interface {
64
88
65
89
// NoSyncReload reads the freelist from Pgids and filters out pending items.
66
90
NoSyncReload (pgIds common.Pgids )
67
-
68
- // freePageIds returns the IDs of all free pages.
69
- freePageIds () common.Pgids
70
-
71
- // pendingPageIds returns all pending pages by transaction id.
72
- pendingPageIds () map [common.Txid ]* txPending
73
-
74
- // release moves all page ids for a transaction id (or older) to the freelist.
75
- release (txId common.Txid )
76
-
77
- // releaseRange moves pending pages allocated within an extent [begin,end] to the free list.
78
- releaseRange (begin , end common.Txid )
79
-
80
- // mergeSpans is merging the given pages into the freelist
81
- mergeSpans (ids common.Pgids )
82
91
}
0 commit comments