Skip to content

Commit

Permalink
- remove #firstAssociation, #lastAssociation, #nextAssociationAfter: …
Browse files Browse the repository at this point in the history
…on the SoilIndexedDictionary

- add #nextAfter: SoilIndexIterator and use it

fixes #595
  • Loading branch information
MarcusDenker committed Feb 9, 2024
1 parent 1711c2e commit b16ac8e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 107 deletions.
82 changes: 0 additions & 82 deletions src/Soil-Core-Tests/SoilIndexedDictionaryTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -265,40 +265,6 @@ SoilIndexedDictionaryTest >> testDoWithTransAction [

]

{ #category : #tests }
SoilIndexedDictionaryTest >> testFirstAssociationWithTransaction [
| tx tx2 |
tx := soil newTransaction.
tx root: dict.
dict at: #one put: #onevalue.
dict at: #two put: #twovalue.
tx commit.
"open a second transaction ..."
tx2 := soil newTransaction.
"and test last"
self assert: tx2 root firstAssociation value equals: #onevalue.

]

{ #category : #tests }
SoilIndexedDictionaryTest >> testFirstAssociationWithTransactionRemoved [
| tx tx1 tx2 |
tx := soil newTransaction.
tx root: dict.
dict at: #one put: #onevalue.
dict at: #two put: #twovalue.
tx commit.

"open a two transactions ..."
tx1 := soil newTransaction.
tx2 := soil newTransaction.
tx2 root removeKey: #one.
tx2 commit.
"in tx1 the removed one is not removed"
self assert: tx1 root firstAssociation value equals: #onevalue.

]

{ #category : #tests }
SoilIndexedDictionaryTest >> testFirstWithTransaction [
| tx tx2 |
Expand Down Expand Up @@ -419,40 +385,6 @@ SoilIndexedDictionaryTest >> testIsEmpty [
self deny: tx1 root isEmpty.
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testLastAssociationWithTransaction [
| tx tx2 |
tx := soil newTransaction.
tx root: dict.
dict at: #two put: #twovalue.
dict at: #one put: #onevalue.

tx commit.
"open a second transaction ..."
tx2 := soil newTransaction.
"and test last, not: key order"
self assert: tx2 root lastAssociation value equals: #twovalue
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testLastAssociationWithTransactionRemoved [
| tx tx1 tx2 |
tx := soil newTransaction.
tx root: dict.
dict at: #one put: #onevalue.
dict at: #two put: #twovalue.
tx commit.

"open a two transactions ..."
tx1 := soil newTransaction.
tx2 := soil newTransaction.
tx2 root removeKey: #two.
tx2 commit.
"in tx1 the removed one is not removed"
self assert: tx1 root lastAssociation value equals: #twovalue.

]

{ #category : #tests }
SoilIndexedDictionaryTest >> testLastWithTransaction [
| tx tx2 |
Expand Down Expand Up @@ -518,20 +450,6 @@ SoilIndexedDictionaryTest >> testNextAfterWithTransaction [
self assert: (tx2 root nextAfter: #one) value equals: #twovalue
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testNextAssociationAfterWithTransaction [
| tx tx2 |
tx := soil newTransaction.
tx root: dict.
dict at: #one put: #onevalue.
dict at: #two put: #twovalue.
tx commit.
"open a second transaction ..."
tx2 := soil newTransaction.
"and test last"
self assert: (tx2 root nextAssociationAfter: #one) value equals: #twovalue
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testNextKeyCloseToWithTransaction [
| tx tx2 |
Expand Down
5 changes: 5 additions & 0 deletions src/Soil-Core/SoilIndexIterator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ SoilIndexIterator >> next: anInteger [
^ result
]

{ #category : #accessing }
SoilIndexIterator >> nextAfter: key [
^ (self nextAssociationAfter: key) value
]

{ #category : #accessing }
SoilIndexIterator >> nextAssociation [
"Note: key will be binary key"
Expand Down
26 changes: 1 addition & 25 deletions src/Soil-Core/SoilIndexedDictionary.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,6 @@ SoilIndexedDictionary >> first: anInteger [
self proxyFromByteArray: each ]
]

{ #category : #accessing }
SoilIndexedDictionary >> firstAssociation [
"Note: key will be binary key"
^ self newIterator firstAssociation ifNotNil: [ :assoc |
assoc key -> (transaction objectWithId: assoc value asSoilObjectId) ]
]

{ #category : #testing }
SoilIndexedDictionary >> hasIndexUpdates [
self isRegistered ifFalse: [ ^ true ].
Expand Down Expand Up @@ -146,14 +139,6 @@ SoilIndexedDictionary >> last [

]

{ #category : #accessing }
SoilIndexedDictionary >> lastAssociation [
"Note: key will be binary key"
^ self newIterator lastAssociation ifNotNil: [ :assoc |
assoc key -> (transaction objectWithId: assoc value asSoilObjectId) ]

]

{ #category : #private }
SoilIndexedDictionary >> loadFrom: aFileReference [
^ SoilSkipList new
Expand All @@ -177,16 +162,7 @@ SoilIndexedDictionary >> newIterator [

{ #category : #accessing }
SoilIndexedDictionary >> nextAfter: key [
^ (self nextAssociationAfter: key) value

]

{ #category : #accessing }
SoilIndexedDictionary >> nextAssociationAfter: key [
"Note: key will be binary key"
^ (self newIterator nextAssociationAfter: key)
ifNotNil: [ :assoc |
assoc key -> (transaction objectWithId: assoc value asSoilObjectId) ]
^ self proxyFromByteArray: (self newIterator nextAfter: key) value
]

{ #category : #private }
Expand Down

0 comments on commit b16ac8e

Please sign in to comment.