@@ -11,7 +11,7 @@ import (
1111// pidSet holds the set of starting pgids which have the same span size
1212type pidSet map [common.Pgid ]struct {}
1313
14- type HashMap struct {
14+ type hashMap struct {
1515 shared
1616
1717 freePagesCount uint64 // count of free pages(hashmap version)
@@ -20,7 +20,7 @@ type HashMap struct {
2020 backwardMap map [common.Pgid ]uint64 // key is end pgid, value is its span size
2121}
2222
23- func (f * HashMap ) Init (pgids common.Pgids ) {
23+ func (f * hashMap ) Init (pgids common.Pgids ) {
2424 if len (pgids ) == 0 {
2525 return
2626 }
@@ -58,7 +58,7 @@ func (f *HashMap) Init(pgids common.Pgids) {
5858 f .reindex (f .FreePageIds (), f .pendingPageIds ())
5959}
6060
61- func (f * HashMap ) Allocate (txid common.Txid , n int ) common.Pgid {
61+ func (f * hashMap ) Allocate (txid common.Txid , n int ) common.Pgid {
6262 if n == 0 {
6363 return 0
6464 }
@@ -105,11 +105,11 @@ func (f *HashMap) Allocate(txid common.Txid, n int) common.Pgid {
105105 return 0
106106}
107107
108- func (f * HashMap ) Count () int {
108+ func (f * hashMap ) Count () int {
109109 return f .FreeCount () + f .PendingCount ()
110110}
111111
112- func (f * HashMap ) FreeCount () int {
112+ func (f * hashMap ) FreeCount () int {
113113 common .Verify (func () {
114114 expectedFreePageCount := f .hashmapFreeCountSlow ()
115115 common .Assert (int (f .freePagesCount ) == expectedFreePageCount ,
@@ -118,7 +118,7 @@ func (f *HashMap) FreeCount() int {
118118 return int (f .freePagesCount )
119119}
120120
121- func (f * HashMap ) FreePageIds () common.Pgids {
121+ func (f * hashMap ) FreePageIds () common.Pgids {
122122 count := f .FreeCount ()
123123 if count == 0 {
124124 return nil
@@ -143,15 +143,15 @@ func (f *HashMap) FreePageIds() common.Pgids {
143143 return m
144144}
145145
146- func (f * HashMap ) hashmapFreeCountSlow () int {
146+ func (f * hashMap ) hashmapFreeCountSlow () int {
147147 count := 0
148148 for _ , size := range f .forwardMap {
149149 count += int (size )
150150 }
151151 return count
152152}
153153
154- func (f * HashMap ) addSpan (start common.Pgid , size uint64 ) {
154+ func (f * hashMap ) addSpan (start common.Pgid , size uint64 ) {
155155 f .backwardMap [start - 1 + common .Pgid (size )] = size
156156 f .forwardMap [start ] = size
157157 if _ , ok := f .freemaps [size ]; ! ok {
@@ -162,7 +162,7 @@ func (f *HashMap) addSpan(start common.Pgid, size uint64) {
162162 f .freePagesCount += size
163163}
164164
165- func (f * HashMap ) delSpan (start common.Pgid , size uint64 ) {
165+ func (f * hashMap ) delSpan (start common.Pgid , size uint64 ) {
166166 delete (f .forwardMap , start )
167167 delete (f .backwardMap , start + common .Pgid (size - 1 ))
168168 delete (f .freemaps [size ], start )
@@ -172,7 +172,7 @@ func (f *HashMap) delSpan(start common.Pgid, size uint64) {
172172 f .freePagesCount -= size
173173}
174174
175- func (f * HashMap ) mergeSpans (ids common.Pgids ) {
175+ func (f * hashMap ) mergeSpans (ids common.Pgids ) {
176176 common .Verify (func () {
177177 ids1Freemap := f .idsFromFreemaps ()
178178 ids2Forward := f .idsFromForwardMap ()
@@ -207,7 +207,7 @@ func (f *HashMap) mergeSpans(ids common.Pgids) {
207207}
208208
209209// mergeWithExistingSpan merges pid to the existing free spans, try to merge it backward and forward
210- func (f * HashMap ) mergeWithExistingSpan (pid common.Pgid ) {
210+ func (f * hashMap ) mergeWithExistingSpan (pid common.Pgid ) {
211211 prev := pid - 1
212212 next := pid + 1
213213
@@ -236,7 +236,7 @@ func (f *HashMap) mergeWithExistingSpan(pid common.Pgid) {
236236
237237// idsFromFreemaps get all free page IDs from f.freemaps.
238238// used by test only.
239- func (f * HashMap ) idsFromFreemaps () map [common.Pgid ]struct {} {
239+ func (f * hashMap ) idsFromFreemaps () map [common.Pgid ]struct {} {
240240 ids := make (map [common.Pgid ]struct {})
241241 for size , idSet := range f .freemaps {
242242 for start := range idSet {
@@ -254,7 +254,7 @@ func (f *HashMap) idsFromFreemaps() map[common.Pgid]struct{} {
254254
255255// idsFromForwardMap get all free page IDs from f.forwardMap.
256256// used by test only.
257- func (f * HashMap ) idsFromForwardMap () map [common.Pgid ]struct {} {
257+ func (f * hashMap ) idsFromForwardMap () map [common.Pgid ]struct {} {
258258 ids := make (map [common.Pgid ]struct {})
259259 for start , size := range f .forwardMap {
260260 for i := 0 ; i < int (size ); i ++ {
@@ -270,7 +270,7 @@ func (f *HashMap) idsFromForwardMap() map[common.Pgid]struct{} {
270270
271271// idsFromBackwardMap get all free page IDs from f.backwardMap.
272272// used by test only.
273- func (f * HashMap ) idsFromBackwardMap () map [common.Pgid ]struct {} {
273+ func (f * hashMap ) idsFromBackwardMap () map [common.Pgid ]struct {} {
274274 ids := make (map [common.Pgid ]struct {})
275275 for end , size := range f .backwardMap {
276276 for i := 0 ; i < int (size ); i ++ {
@@ -284,8 +284,8 @@ func (f *HashMap) idsFromBackwardMap() map[common.Pgid]struct{} {
284284 return ids
285285}
286286
287- func NewHashMap () * HashMap {
288- hm := & HashMap {
287+ func NewHashMapFreelist () Interface {
288+ hm := & hashMap {
289289 shared : shared {
290290 allocs : make (map [common.Pgid ]common.Txid ),
291291 cache : make (map [common.Pgid ]struct {}),
0 commit comments