Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve free page handling #870

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
]
Loading