Skip to content

Commit

Permalink
Merge pull request #534 from ApptiveGrid/unifyImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
noha authored Dec 6, 2023
2 parents f1ce5b2 + 85cba79 commit 3f291cd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 44 deletions.
19 changes: 2 additions & 17 deletions src/Soil-Core/SoilBTreeIterator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ Class {
#category : #'Soil-Core-Index-BTree'
}

{ #category : #accessing }
SoilBTreeIterator >> at: aKeyObject ifAbsent: aBlock [
currentKey := (aKeyObject asSkipListKeyOfSize: index keySize) asInteger.
^ self find: currentKey ifAbsent: aBlock
]

{ #category : #accessing }
SoilBTreeIterator >> basicAt: key put: anObject [
| posiblePrioValue |
Expand All @@ -19,17 +13,8 @@ SoilBTreeIterator >> basicAt: key put: anObject [
]

{ #category : #private }
SoilBTreeIterator >> find: key [
currentKey := key.
currentPage := index rootPage find: key with: index.
^ currentPage valueAt: currentKey
]

{ #category : #private }
SoilBTreeIterator >> find: key ifAbsent: aBlock [
currentKey := key.
currentPage := index rootPage find: key with: index.
^ currentPage valueAt: currentKey ifAbsent: aBlock
SoilBTreeIterator >> findPageFor: key [
^currentPage := index rootPage find: key with: index
]

{ #category : #accessing }
Expand Down
24 changes: 21 additions & 3 deletions src/Soil-Core/SoilIndexIterator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ SoilIndexIterator >> at: aKeyObject [
]

{ #category : #accessing }
SoilIndexIterator >> at: aKeyObject ifAbsent: aBlock [
^ self subclassResponsibility
SoilIndexIterator >> at: aKeyObject ifAbsent: aBlock [
currentKey := (aKeyObject asSkipListKeyOfSize: index keySize) asInteger.
^self find: currentKey ifAbsent: aBlock
]

{ #category : #accessing }
Expand All @@ -41,6 +42,11 @@ SoilIndexIterator >> at: aKeyObject put: anObject [
put: anObject
]

{ #category : #accessing }
SoilIndexIterator >> basicAt: key put: anObject [
self subclassResponsibility
]

{ #category : #accessing }
SoilIndexIterator >> currentPage [

Expand All @@ -61,7 +67,19 @@ SoilIndexIterator >> do: aBlock [
]

{ #category : #private }
SoilIndexIterator >> find: key [
SoilIndexIterator >> find: key [
^ self find: key ifAbsent: [ ]
]

{ #category : #private }
SoilIndexIterator >> find: key ifAbsent: aBlock [
currentKey := key.
self findPageFor: key.
^ currentPage valueAt: key ifAbsent: aBlock
]

{ #category : #private }
SoilIndexIterator >> findPageFor: key [
^ self subclassResponsibility
]

Expand Down
28 changes: 4 additions & 24 deletions src/Soil-Core/SoilSkipListIterator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ Class {
#category : #'Soil-Core-Index-SkipList'
}

{ #category : #private }
SoilSkipListIterator >> at: aKeyObject ifAbsent: aBlock [
currentKey := (aKeyObject asSkipListKeyOfSize: index keySize) asInteger.
self
findPageFor: currentKey
startingAt: index headerPage.
^ currentPage
valueAt: currentKey
ifAbsent: aBlock
]

{ #category : #accessing }
SoilSkipListIterator >> atLevel: key put: anObject [
levels at: key put: anObject
Expand All @@ -27,7 +16,7 @@ SoilSkipListIterator >> atLevel: key put: anObject [
SoilSkipListIterator >> basicAt: key put: anObject [

|itemIndex |
self findPageFor: key startingAt: index headerPage.
self findPageFor: key.
itemIndex := currentPage indexOfKey: key.
"as an optimization we return the prior value stored in the list. If
there was none we return nil"
Expand All @@ -44,18 +33,9 @@ SoilSkipListIterator >> basicAt: key put: anObject [
]

{ #category : #private }
SoilSkipListIterator >> find: key [
currentKey := key.
self
findPageFor: key
startingAt: index headerPage.
^ currentPage valueAt: currentKey
]

{ #category : #private }
SoilSkipListIterator >> findPageFor: key startingAt: page [
SoilSkipListIterator >> findPageFor: key [
| pageIndex candidatePage |
currentPage := page.
currentPage := index headerPage.
levels size to: 1 by: -1 do: [ :level |
[
pageIndex := currentPage rightAt: level.
Expand Down Expand Up @@ -105,7 +85,7 @@ SoilSkipListIterator >> nextKeyCloseTo: key [

| binKey |
binKey := (key asSkipListKeyOfSize: index keySize) asInteger.
self findPageFor: binKey startingAt: index headerPage.
self findPageFor: binKey.
nextKey := currentPage keyOrClosestAfter: binKey.
nextKey
ifNil: [ "if there is no close key found, we position the cursor at the end, so that asking for the next association will return nil"
Expand Down

0 comments on commit 3f291cd

Please sign in to comment.