Skip to content

Commit

Permalink
Merge pull request #583 from ApptiveGrid/537-asSkipListKeyOfSize-is-c…
Browse files Browse the repository at this point in the history
…onfusing-as-we-use-it-for-BTree-too
  • Loading branch information
noha authored Jan 25, 2024
2 parents f397cdc + 3ba1147 commit 6dc52a5
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions src/Soil-Core-Tests/SoilBTreeTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ SoilBTreeTest >> testPageAddFirst [
self assert: index pages size equals: 2.
page := index headerPage.
self assert: page numberOfItems equals: 1.
self assert: page items first key equals: (#foo asSkipListKeyOfSize: 8) asInteger.
self assert: page items first key equals: (#foo asIndexKeyOfSize: 8) asInteger.
"the index page was updated"
indexPage := index rootPage.
"Index has been updated"
Expand All @@ -309,7 +309,7 @@ SoilBTreeTest >> testPageAddFirstAndLoad [
self assert: index pages size equals: 2.
page := index headerPage.
self assert: page numberOfItems equals: 1.
self assert: page items first key equals: (#foo asSkipListKeyOfSize: 8) asInteger.
self assert: page items first key equals: (#foo asIndexKeyOfSize: 8) asInteger.
"the index page was updated"
indexPage := index rootPage.
"Index has been updated"
Expand All @@ -323,7 +323,7 @@ SoilBTreeTest >> testPageAddFirstAndLoad [
initializeFilesystem;
open.

self assert: page items first key equals: (#foo asSkipListKeyOfSize: 8) asInteger.
self assert: page items first key equals: (#foo asIndexKeyOfSize: 8) asInteger.
"load succeeds"
self assert: (index at: #foo) equals: #[ 1 2 3 4 5 6 7 8 ].

Expand Down
8 changes: 4 additions & 4 deletions src/Soil-Core-Tests/SoilSkipListTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ SoilSkipListTest >> testAddLastFitting [

| page |
1 to: 61 do: [ :n |
index at: (n asString asSkipListKeyOfSize: 8) put: #[ 1 2 3 4 5 6 7 8 ] ].
index at: (n asString asIndexKeyOfSize: 8) put: #[ 1 2 3 4 5 6 7 8 ] ].
self assert: index pages size equals: 1.
index at: (63 asString asSkipListKeyOfSize: 8) put: #[ 1 2 3 4 5 6 7 8 ].
index at: (63 asString asIndexKeyOfSize: 8) put: #[ 1 2 3 4 5 6 7 8 ].
self assert: index pages size equals: 1.
page := index pageAt: 1.
self assert: page numberOfItems equals: 62.
Expand Down Expand Up @@ -331,7 +331,7 @@ SoilSkipListTest >> testLastPage [
{ #category : #tests }
SoilSkipListTest >> testMorePages [
1 to: 512 do: [ :n |
index at: (n asString asSkipListKeyOfSize: 8) put: #[ 1 2 3 4 5 6 7 8 ] ].
index at: (n asString asIndexKeyOfSize: 8) put: #[ 1 2 3 4 5 6 7 8 ] ].
index writePages.
self assert: index pages size equals: 3
]
Expand Down Expand Up @@ -379,7 +379,7 @@ SoilSkipListTest >> testPageAddFirst [
self assert: index pages size equals: 1.
page := index firstPage.
self assert: page numberOfItems equals: 1.
self assert: page items first key equals: (#foo asSkipListKeyOfSize: 8) asInteger
self assert: page items first key equals: (#foo asIndexKeyOfSize: 8) asInteger
]

{ #category : #tests }
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/ByteArray.extension.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Extension { #name : #ByteArray }

{ #category : #'*Soil-Core' }
ByteArray >> asSkipListKeyOfSize: anInteger [
ByteArray >> asIndexKeyOfSize: anInteger [
^ self asByteArrayOfSize: anInteger
]

Expand Down
8 changes: 4 additions & 4 deletions src/Soil-Core/Integer.extension.st
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Extension { #name : #Integer }

{ #category : #'*Soil-Core' }
Integer >> asLogSequenceNumber [
^ SoilLogSequenceNumber value: self
Integer >> asIndexKeyOfSize: keySize [
^ self asByteArrayOfSize: keySize
]

{ #category : #'*Soil-Core' }
Integer >> asSkipListKeyOfSize: keySize [
^ self asByteArrayOfSize: keySize
Integer >> asLogSequenceNumber [
^ SoilLogSequenceNumber value: self
]

{ #category : #'*soil-core' }
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilBasicBTree.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ SoilBasicBTree >> readPageFrom: aStream [
{ #category : #removing }
SoilBasicBTree >> removeKey: aString ifAbsent: aBlock [
| page index key |
key := (aString asSkipListKeyOfSize: self keySize) asInteger.
key := (aString asIndexKeyOfSize: self keySize) asInteger.
page := self newIterator
find: key;
currentPage.
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilBasicSkipList.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SoilBasicSkipList >> newIterator [
{ #category : #removing }
SoilBasicSkipList >> removeKey: aString ifAbsent: aBlock [
| page index key |
key := (aString asSkipListKeyOfSize: self keySize) asInteger.
key := (aString asIndexKeyOfSize: self keySize) asInteger.
page := self newIterator
find: key;
currentPage.
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilIndex.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ SoilIndex >> do: aBlock [
{ #category : #private }
SoilIndex >> find: aString [
^ self newIterator
find: (aString asSkipListKeyOfSize: self keySize) asInteger
find: (aString asIndexKeyOfSize: self keySize) asInteger
]

{ #category : #accessing }
Expand Down
20 changes: 10 additions & 10 deletions src/Soil-Core/SoilIndexIterator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ SoilIndexIterator >> at: aKeyObject [
{ #category : #accessing }
SoilIndexIterator >> at: aKeyObject ifAbsent: aBlock [
| foundValue |
currentKey := (aKeyObject asSkipListKeyOfSize: index keySize) asInteger.
currentKey := (aKeyObject asIndexKeyOfSize: index keySize) asInteger.
foundValue := self find: currentKey ifAbsent: aBlock.
^(self restoreValue: foundValue forKey: currentKey) ifNil: [ aBlock value ]
]

{ #category : #accessing }
SoilIndexIterator >> at: aKeyObject put: anObject [
| key |
key := (aKeyObject asSkipListKeyOfSize: index keySize) asInteger.
key := (aKeyObject asIndexKeyOfSize: index keySize) asInteger.
^ self
basicAt: key
put: anObject
Expand Down Expand Up @@ -276,11 +276,18 @@ SoilIndexIterator >> nextAssociation [
^ nextValue ifNil: [ self nextAssociation ] ifNotNil: [ key -> nextValue ]
]

{ #category : #accessing }
SoilIndexIterator >> nextAssociationAfter: key [

self find: key.
^ self nextAssociation
]

{ #category : #private }
SoilIndexIterator >> nextKeyCloseTo: key [

| binKey |
binKey := (key asSkipListKeyOfSize: index keySize) asInteger.
binKey := (key asIndexKeyOfSize: index keySize) asInteger.
self findPageFor: binKey.
nextKey := currentPage keyOrClosestAfter: binKey.
^ nextKey
Expand All @@ -291,13 +298,6 @@ SoilIndexIterator >> nextKeyCloseTo: key [
currentKey := nextKey ]
]

{ #category : #accessing }
SoilIndexIterator >> nextAssociationAfter: key [

self find: key.
^ self nextAssociation
]

{ #category : #accessing }
SoilIndexIterator >> pageAt: anInteger [
^ index store pageAt: anInteger
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 @@ -75,7 +75,7 @@ SoilIndexedDictionary >> basicAt: aString ifAbsent: aBlock [

{ #category : #accessing }
SoilIndexedDictionary >> binaryKey: aString [
^ (aString asSkipListKeyOfSize: index keySize) asInteger
^ (aString asIndexKeyOfSize: index keySize) asInteger
]

{ #category : #initialization }
Expand Down
4 changes: 2 additions & 2 deletions src/Soil-Core/String.extension.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #String }

{ #category : #'*Soil-Core' }
String >> asSkipListKeyOfSize: anInteger [
^ self asByteArray asSkipListKeyOfSize: anInteger
String >> asIndexKeyOfSize: anInteger [
^ self asByteArray asIndexKeyOfSize: anInteger
]

0 comments on commit 6dc52a5

Please sign in to comment.