From 2da56cfc1e2387710539001590d796cff3263ea1 Mon Sep 17 00:00:00 2001 From: Marcus Denker Date: Tue, 29 Oct 2024 14:06:06 +0100 Subject: [PATCH] - rename testRemovePage to testRecyclePage - categorize uncategorized --- src/Soil-Core-Tests/SoilBTreeTest.class.st | 66 ++++++++--------- src/Soil-Core-Tests/SoilSkipListTest.class.st | 72 +++++++++---------- src/Soil-Core/SoilCopyOnWriteBTree.class.st | 2 +- .../SoilCopyOnWriteSkipList.class.st | 2 +- src/Soil-Core/SoilIndex.class.st | 6 +- src/Soil-Core/SoilIndexItemsPage.class.st | 2 +- src/Soil-Core/SoilIndexedDictionary.class.st | 2 +- src/Soil-Core/SoilSkipList.class.st | 2 +- src/Soil-Core/SoilSkipListHeaderPage.class.st | 4 +- src/Soil-Core/SoilTransaction.class.st | 2 +- src/Soil-Core/SoilTransactionManager.class.st | 8 +-- 11 files changed, 84 insertions(+), 84 deletions(-) diff --git a/src/Soil-Core-Tests/SoilBTreeTest.class.st b/src/Soil-Core-Tests/SoilBTreeTest.class.st index d359f825..9b8a1784 100644 --- a/src/Soil-Core-Tests/SoilBTreeTest.class.st +++ b/src/Soil-Core-Tests/SoilBTreeTest.class.st @@ -409,6 +409,39 @@ SoilBTreeTest >> testPageAddFirstAndLoad [ ] +{ #category : #tests } +SoilBTreeTest >> testRecyclePage [ + + | capacityFirst offset capacity iterator counter | + capacityFirst := index firstPage itemCapacity. + 1 to: capacityFirst do: [ :n | + index at: n put: (n asByteArrayOfSize: 8) ]. + self assert: index pages size equals: 3. + offset := capacityFirst. + iterator := index newIterator. + 2 to: 6 do: [ :p | + index at: offset + 1 put: ((offset + 1) asByteArrayOfSize: 8). + capacity := index lastPage itemCapacity. + offset + 2 to: (offset + capacity) do: [:n | . + index at: n put: (n asByteArrayOfSize: 8) ]. + offset := offset + capacity ]. + self assert: index pages size equals: 13. + index recyclePage: (index pages at: 3). + self assert: index pages size equals: 13. + "page 3 is the recycled page" + self assert: index firstFreePage offset equals: 3. + "the page is a free page" + self assert: index firstFreePage class equals: SoilFreePage. + "after, index 3 should not be a value in any index page item" + index indexPages do: [ :indexPage | self assert: (indexPage items noneSatisfy: [ :item | item value == 3 ]) ]. + "if we follow the next pointer, we find only the non-recyled data pages" + iterator := index newIterator. + counter := 0. + iterator pagesDo: [ :page | counter := counter + 1]. + "13 - 1 indexPage - 1 recycled page" + self assert: counter equals: 11. +] + { #category : #tests } SoilBTreeTest >> testRemoveFromIndex [ | entries | @@ -500,39 +533,6 @@ SoilBTreeTest >> testRemoveKey [ self should: [ index removeKey: 20 ] raise: KeyNotFound. ] -{ #category : #tests } -SoilBTreeTest >> testRemovePage [ - - | capacityFirst offset capacity iterator counter | - capacityFirst := index firstPage itemCapacity. - 1 to: capacityFirst do: [ :n | - index at: n put: (n asByteArrayOfSize: 8) ]. - self assert: index pages size equals: 3. - offset := capacityFirst. - iterator := index newIterator. - 2 to: 6 do: [ :p | - index at: offset + 1 put: ((offset + 1) asByteArrayOfSize: 8). - capacity := index lastPage itemCapacity. - offset + 2 to: (offset + capacity) do: [:n | . - index at: n put: (n asByteArrayOfSize: 8) ]. - offset := offset + capacity ]. - self assert: index pages size equals: 13. - index recyclePage: (index pages at: 3). - self assert: index pages size equals: 13. - "page 3 is the recycled page" - self assert: index firstFreePage offset equals: 3. - "the page is a free page" - self assert: index firstFreePage class equals: SoilFreePage. - "after, index 3 should not be a value in any index page item" - index indexPages do: [ :indexPage | self assert: (indexPage items noneSatisfy: [ :item | item value == 3 ]) ]. - "if we follow the next pointer, we find only the non-recyled data pages" - iterator := index newIterator. - counter := 0. - iterator pagesDo: [ :page | counter := counter + 1]. - "13 - 1 indexPage - 1 recycled page" - self assert: counter equals: 11. -] - { #category : #tests } SoilBTreeTest >> testSize [ diff --git a/src/Soil-Core-Tests/SoilSkipListTest.class.st b/src/Soil-Core-Tests/SoilSkipListTest.class.st index 45185b3f..80a64d90 100644 --- a/src/Soil-Core-Tests/SoilSkipListTest.class.st +++ b/src/Soil-Core-Tests/SoilSkipListTest.class.st @@ -420,6 +420,42 @@ SoilSkipListTest >> testPageCodeNoDuplicates [ | pageCodes | pageCodes := (SoilIndexPage allSubclasses collect: #pageCode) reject: [:each | each isZero ]. self assert: pageCodes size equals: pageCodes asSet size +] + +{ #category : #tests } +SoilSkipListTest >> testRecyclePage [ + + | capacityFirst offset capacity iterator counter | + capacityFirst := index firstPage itemCapacity. + 1 to: capacityFirst do: [ :n | + index at: n put: (n asByteArrayOfSize: 8) ]. + self assert: index pages size equals: 1. + offset := capacityFirst. + iterator := index newIterator. + 2 to: 6 do: [ :p | + index at: offset + 1 put: ((offset + 1) asByteArrayOfSize: 8). + capacity := index lastPage itemCapacity. + offset + 2 to: (offset + capacity) do: [:n | . + index at: n put: (n asByteArrayOfSize: 8) ]. + offset := offset + capacity ]. + self assert: index pages size equals: 6. + index recyclePage: (index pages at: 3). + self assert: index pages size equals: 6. + + "page 3 is the recycled page" + self assert: index firstFreePage offset equals: 3. + "and it is a FreePage" + self assert: index firstFreePage class equals: SoilFreePage. + "if we follow the next pointer, we find only the non-recyled data pages" + iterator := index newIterator. + counter := 0. + iterator pagesDo: [ :page | counter := counter + 1]. + "6 minus 1 recycled page" + self assert: counter equals: 5 + + + + ] { #category : #tests } @@ -463,42 +499,6 @@ SoilSkipListTest >> testRemoveKey [ self assert: (index at: 20) equals:(20 asByteArrayOfSize: 8). self should: [ index removeKey: capacity + 1 ] raise: KeyNotFound -] - -{ #category : #tests } -SoilSkipListTest >> testRemovePage [ - - | capacityFirst offset capacity iterator counter | - capacityFirst := index firstPage itemCapacity. - 1 to: capacityFirst do: [ :n | - index at: n put: (n asByteArrayOfSize: 8) ]. - self assert: index pages size equals: 1. - offset := capacityFirst. - iterator := index newIterator. - 2 to: 6 do: [ :p | - index at: offset + 1 put: ((offset + 1) asByteArrayOfSize: 8). - capacity := index lastPage itemCapacity. - offset + 2 to: (offset + capacity) do: [:n | . - index at: n put: (n asByteArrayOfSize: 8) ]. - offset := offset + capacity ]. - self assert: index pages size equals: 6. - index recyclePage: (index pages at: 3). - self assert: index pages size equals: 6. - - "page 3 is the recycled page" - self assert: index firstFreePage offset equals: 3. - "and it is a FreePage" - self assert: index firstFreePage class equals: SoilFreePage. - "if we follow the next pointer, we find only the non-recyled data pages" - iterator := index newIterator. - counter := 0. - iterator pagesDo: [ :page | counter := counter + 1]. - "6 minus 1 recycled page" - self assert: counter equals: 5 - - - - ] { #category : #tests } diff --git a/src/Soil-Core/SoilCopyOnWriteBTree.class.st b/src/Soil-Core/SoilCopyOnWriteBTree.class.st index 84174326..11c6f942 100644 --- a/src/Soil-Core/SoilCopyOnWriteBTree.class.st +++ b/src/Soil-Core/SoilCopyOnWriteBTree.class.st @@ -21,7 +21,7 @@ SoilCopyOnWriteBTree >> newPage [ ^ wrapped allocatePage ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } SoilCopyOnWriteBTree >> persistentIndex [ ^ wrapped persistentIndex ] diff --git a/src/Soil-Core/SoilCopyOnWriteSkipList.class.st b/src/Soil-Core/SoilCopyOnWriteSkipList.class.st index 84e83539..1d23bf40 100644 --- a/src/Soil-Core/SoilCopyOnWriteSkipList.class.st +++ b/src/Soil-Core/SoilCopyOnWriteSkipList.class.st @@ -27,7 +27,7 @@ SoilCopyOnWriteSkipList >> newPage [ ^ wrapped allocatePage ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } SoilCopyOnWriteSkipList >> persistentIndex [ ^ wrapped persistentIndex ] diff --git a/src/Soil-Core/SoilIndex.class.st b/src/Soil-Core/SoilIndex.class.st index af1012c0..9c3d998f 100644 --- a/src/Soil-Core/SoilIndex.class.st +++ b/src/Soil-Core/SoilIndex.class.st @@ -97,7 +97,7 @@ SoilIndex >> close [ store := nil ] -{ #category : #'as yet unclassified' } +{ #category : #utilities } SoilIndex >> decreaseSize [ self headerPage decreaseSize ] @@ -169,7 +169,7 @@ SoilIndex >> id: anObject [ id := anObject ] -{ #category : #'as yet unclassified' } +{ #category : #utilities } SoilIndex >> increaseSize [ self headerPage increaseSize ] @@ -256,7 +256,7 @@ SoilIndex >> pages [ ^ self store pages ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } SoilIndex >> persistentIndex [ ^ self ] diff --git a/src/Soil-Core/SoilIndexItemsPage.class.st b/src/Soil-Core/SoilIndexItemsPage.class.st index 4556451c..40c5153a 100644 --- a/src/Soil-Core/SoilIndexItemsPage.class.st +++ b/src/Soil-Core/SoilIndexItemsPage.class.st @@ -257,7 +257,7 @@ SoilIndexItemsPage >> postCopy [ items := items copy. ] -{ #category : #'as yet unclassified' } +{ #category : #utilities } SoilIndexItemsPage >> presentItemCount [ ^ (items reject: [ :each | each value isRemoved ]) size ] diff --git a/src/Soil-Core/SoilIndexedDictionary.class.st b/src/Soil-Core/SoilIndexedDictionary.class.st index 7219f38b..6ff03f02 100644 --- a/src/Soil-Core/SoilIndexedDictionary.class.st +++ b/src/Soil-Core/SoilIndexedDictionary.class.st @@ -172,7 +172,7 @@ SoilIndexedDictionary >> nextCloseTo: aKey [ ^ self newIterator nextCloseTo: aKey ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } SoilIndexedDictionary >> persistentIndex [ ^ index persistentIndex ] diff --git a/src/Soil-Core/SoilSkipList.class.st b/src/Soil-Core/SoilSkipList.class.st index c0369982..408d0a2e 100644 --- a/src/Soil-Core/SoilSkipList.class.st +++ b/src/Soil-Core/SoilSkipList.class.st @@ -111,7 +111,7 @@ SoilSkipList >> newPluggableRewriter [ index: self ] -{ #category : #'as yet unclassified' } +{ #category : #private } SoilSkipList >> nextFreePage [ | firstPage freePage | firstPage := self firstFreePage ifNil: [ diff --git a/src/Soil-Core/SoilSkipListHeaderPage.class.st b/src/Soil-Core/SoilSkipListHeaderPage.class.st index 1fdd7011..af8d3106 100644 --- a/src/Soil-Core/SoilSkipListHeaderPage.class.st +++ b/src/Soil-Core/SoilSkipListHeaderPage.class.st @@ -33,7 +33,7 @@ SoilSkipListHeaderPage >> canBeRemoved [ ^ false ] -{ #category : #'as yet unclassified' } +{ #category : #utilities } SoilSkipListHeaderPage >> decreaseSize [ (size = -1) ifTrue: [ ^ self ]. size := size - 1. @@ -62,7 +62,7 @@ SoilSkipListHeaderPage >> headerSize [ ] -{ #category : #'as yet unclassified' } +{ #category : #utilities } SoilSkipListHeaderPage >> increaseSize [ (size = -1) ifTrue: [ ^ self ]. size := size + 1. diff --git a/src/Soil-Core/SoilTransaction.class.st b/src/Soil-Core/SoilTransaction.class.st index e116fe2b..d11ec0f6 100644 --- a/src/Soil-Core/SoilTransaction.class.st +++ b/src/Soil-Core/SoilTransaction.class.st @@ -642,7 +642,7 @@ SoilTransaction >> transactionManager [ ^ soil transactionManager ] -{ #category : #'as yet unclassified' } +{ #category : #indexes } SoilTransaction >> updatedIndexDictionary: indexedDictionary [ | segment realIndex | segment := self segmentAt: (self objectIdOf: indexedDictionary) segment. diff --git a/src/Soil-Core/SoilTransactionManager.class.st b/src/Soil-Core/SoilTransactionManager.class.st index 0e2c0db9..2d706f08 100644 --- a/src/Soil-Core/SoilTransactionManager.class.st +++ b/src/Soil-Core/SoilTransactionManager.class.st @@ -9,7 +9,7 @@ Class { #category : #'Soil-Core-Model' } -{ #category : #'as yet unclassified' } +{ #category : #'commit/abort' } SoilTransactionManager >> abortTransaction: aTransaction [ soil ifNotNil: [ soil notificationHandler transactionAborted: self ]. @@ -24,7 +24,7 @@ SoilTransactionManager >> addTransaction: aSoilTransaction [ transactions add: aSoilTransaction ] ] -{ #category : #'as yet unclassified' } +{ #category : #'commit/abort' } SoilTransactionManager >> commitAndContinueTransaction: aTransaction [ aTransaction basicCommit. aTransaction hasModifications ifTrue: [ @@ -32,7 +32,7 @@ SoilTransactionManager >> commitAndContinueTransaction: aTransaction [ aTransaction continue ] -{ #category : #'as yet unclassified' } +{ #category : #'commit/abort' } SoilTransactionManager >> commitTransaction: aTransaction [ | modified | aTransaction basicCommit. @@ -70,7 +70,7 @@ SoilTransactionManager >> removeTransaction: aSoilTransaction [ transactions remove: aSoilTransaction ] ] -{ #category : #'as yet unclassified' } +{ #category : #versions } SoilTransactionManager >> smallestReadVersion [ "detect the smallest read version currently in use" ^ transactions