Skip to content

Commit

Permalink
Merge pull request #870 from ApptiveGrid/improve-clean-page-handling
Browse files Browse the repository at this point in the history
Improve free page handling
  • Loading branch information
noha authored Nov 30, 2024
2 parents 3fc25e3 + c9e421f commit af319fe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Soil-Core/SoilBasicSkipList.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,17 @@ SoilBasicSkipList >> nextFreePageIndex [
^ firstFreePage hasFreePages
ifTrue: [
freePageIndex := firstFreePage removeFirstIndex.
self removePageWithIndexIfPresent: freePageIndex.
self addDirtyPage: firstFreePage.
freePageIndex ]
ifFalse: [
"if firstFreePage has a next pointer we set that as
new first free page. Next will return 0 if there is no
next page"
freePageIndex := firstFreePage next.
self headerPage firstFreePageIndex: firstFreePage next.
self removePageWithIndexIfPresent: firstFreePage offset.

self addDirtyPage: self headerPage.
firstFreePage offset ]

Expand Down Expand Up @@ -143,6 +147,12 @@ SoilBasicSkipList >> removePage: aPage [

]

{ #category : #removing }
SoilBasicSkipList >> removePageWithIndexIfPresent: anInteger [
(store includesPageAt: anInteger) ifTrue: [
store removePageAt: anInteger ]
]

{ #category : #accessing }
SoilBasicSkipList >> size [
"if size is -1 the page has been converted from version 1 format and
Expand Down
12 changes: 12 additions & 0 deletions src/Soil-Core/SoilPagedIndexStore.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ SoilPagedIndexStore >> headerPage [
^ self pageAt: 1
]

{ #category : #accessing }
SoilPagedIndexStore >> includesPageAt: anInteger [
^ pages includesKey: anInteger
]

{ #category : #accessing }
SoilPagedIndexStore >> index [
^ index
Expand Down Expand Up @@ -108,6 +113,8 @@ SoilPagedIndexStore >> pageAt: anInteger [
{ #category : #accessing }
SoilPagedIndexStore >> pageAt: anInteger put: aPage [
^ pagesMutex critical: [
(pages includesKey: anInteger)
ifTrue: [ ^ Error signal: 'store already has page with key ', anInteger asString ].
pages
at: anInteger
put: aPage ]
Expand All @@ -122,3 +129,8 @@ SoilPagedIndexStore >> pageFaultAt: anInteger [
SoilPagedIndexStore >> pages [
^ pages
]

{ #category : #accessing }
SoilPagedIndexStore >> removePageAt: anInteger [
pages removeKey: anInteger
]

0 comments on commit af319fe

Please sign in to comment.