Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SoilIndexedDictionary: implement size to restore values #544

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/Soil-Core-Tests/SoilIndexedDictionaryTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,7 @@ SoilIndexedDictionaryTest >> testConcurrentIsEmpty [
tx3 commit.
"invisible: tx2 still has the key"
self deny: tx2 root isEmpty.
"to fix: size is wrong as it does not restore the value"
self flag: #isRemoved.
self assert: tx2 root size equals: 0
self assert: tx2 root size equals: 1
]

{ #category : #tests }
Expand Down
7 changes: 6 additions & 1 deletion src/Soil-Core/SoilIndexedDictionary.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,12 @@ SoilIndexedDictionary >> second [
{ #category : #accessing }
SoilIndexedDictionary >> size [
^ transaction
ifNotNil: [ self index size ]
ifNotNil: [
"We should just call size on index, but the do: here can restore values"
| sum |
sum := 0.
self do: [ :each | sum := sum + 1 ].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not scale at all. Not sure how we do it until now but doing a linear scan counting is not the way to go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we do already do the same linear scam on the index...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SoilBasicSkipList>>#size
	"We iterate over all elements to get the size. Slow!"
	^ self newIterator size 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was already #226, I updated it.

sum ]
ifNil: [ newValues size ]
]

Expand Down
Loading