Skip to content

Commit

Permalink
Merge pull request #857 from ApptiveGrid/More-Cleanup
Browse files Browse the repository at this point in the history
Another trival cleanup: categorize
  • Loading branch information
noha authored Oct 29, 2024
2 parents c0ac644 + 2da56cf commit c870cfd
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 84 deletions.
66 changes: 33 additions & 33 deletions src/Soil-Core-Tests/SoilBTreeTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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 [

Expand Down
72 changes: 36 additions & 36 deletions src/Soil-Core-Tests/SoilSkipListTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilCopyOnWriteBTree.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SoilCopyOnWriteBTree >> newPage [
^ wrapped allocatePage
]

{ #category : #'as yet unclassified' }
{ #category : #accessing }
SoilCopyOnWriteBTree >> persistentIndex [
^ wrapped persistentIndex
]
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilCopyOnWriteSkipList.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SoilCopyOnWriteSkipList >> newPage [
^ wrapped allocatePage
]

{ #category : #'as yet unclassified' }
{ #category : #accessing }
SoilCopyOnWriteSkipList >> persistentIndex [
^ wrapped persistentIndex
]
Expand Down
6 changes: 3 additions & 3 deletions src/Soil-Core/SoilIndex.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ SoilIndex >> close [
store := nil
]

{ #category : #'as yet unclassified' }
{ #category : #utilities }
SoilIndex >> decreaseSize [
self headerPage decreaseSize
]
Expand Down Expand Up @@ -169,7 +169,7 @@ SoilIndex >> id: anObject [
id := anObject
]

{ #category : #'as yet unclassified' }
{ #category : #utilities }
SoilIndex >> increaseSize [
self headerPage increaseSize
]
Expand Down Expand Up @@ -256,7 +256,7 @@ SoilIndex >> pages [
^ self store pages
]

{ #category : #'as yet unclassified' }
{ #category : #accessing }
SoilIndex >> persistentIndex [
^ self
]
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilIndexItemsPage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ SoilIndexItemsPage >> postCopy [
items := items copy.
]

{ #category : #'as yet unclassified' }
{ #category : #utilities }
SoilIndexItemsPage >> presentItemCount [
^ (items reject: [ :each | each value isRemoved ]) size
]
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilIndexedDictionary.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ SoilIndexedDictionary >> nextCloseTo: aKey [
^ self newIterator nextCloseTo: aKey
]

{ #category : #'as yet unclassified' }
{ #category : #accessing }
SoilIndexedDictionary >> persistentIndex [
^ index persistentIndex
]
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilSkipList.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ SoilSkipList >> newPluggableRewriter [
index: self
]

{ #category : #'as yet unclassified' }
{ #category : #private }
SoilSkipList >> nextFreePage [
| firstPage freePage |
firstPage := self firstFreePage ifNil: [
Expand Down
4 changes: 2 additions & 2 deletions src/Soil-Core/SoilSkipListHeaderPage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SoilSkipListHeaderPage >> canBeRemoved [
^ false
]

{ #category : #'as yet unclassified' }
{ #category : #utilities }
SoilSkipListHeaderPage >> decreaseSize [
(size = -1) ifTrue: [ ^ self ].
size := size - 1.
Expand Down Expand Up @@ -62,7 +62,7 @@ SoilSkipListHeaderPage >> headerSize [

]

{ #category : #'as yet unclassified' }
{ #category : #utilities }
SoilSkipListHeaderPage >> increaseSize [
(size = -1) ifTrue: [ ^ self ].
size := size + 1.
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilTransaction.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/Soil-Core/SoilTransactionManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 ].
Expand All @@ -24,15 +24,15 @@ SoilTransactionManager >> addTransaction: aSoilTransaction [
transactions add: aSoilTransaction ]
]

{ #category : #'as yet unclassified' }
{ #category : #'commit/abort' }
SoilTransactionManager >> commitAndContinueTransaction: aTransaction [
aTransaction basicCommit.
aTransaction hasModifications ifTrue: [
soil checkpoint ].
aTransaction continue
]

{ #category : #'as yet unclassified' }
{ #category : #'commit/abort' }
SoilTransactionManager >> commitTransaction: aTransaction [
| modified |
aTransaction basicCommit.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c870cfd

Please sign in to comment.