From 90f9d116e974fc1348eb6b9fca73f5f700eabc01 Mon Sep 17 00:00:00 2001 From: Marcus Denker Date: Thu, 7 Dec 2023 10:28:19 +0100 Subject: [PATCH] another small cleanup - push up and use removeKey: - push up index accessor --- src/Soil-Core/SoilBTreeIterator.class.st | 5 ----- src/Soil-Core/SoilIndexIterator.class.st | 14 +++++++++++++- src/Soil-Core/SoilIndexedDictionary.class.st | 3 +-- src/Soil-Core/SoilSkipListIterator.class.st | 11 ++--------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Soil-Core/SoilBTreeIterator.class.st b/src/Soil-Core/SoilBTreeIterator.class.st index 9cb678a0..f8a76a5c 100644 --- a/src/Soil-Core/SoilBTreeIterator.class.st +++ b/src/Soil-Core/SoilBTreeIterator.class.st @@ -17,11 +17,6 @@ SoilBTreeIterator >> findPageFor: key [ ^currentPage := index rootPage find: key with: index ] -{ #category : #accessing } -SoilBTreeIterator >> index [ - ^index -] - { #category : #accessing } SoilBTreeIterator >> lastPage [ | pageNumber | diff --git a/src/Soil-Core/SoilIndexIterator.class.st b/src/Soil-Core/SoilIndexIterator.class.st index 5b63af29..f5c005e3 100644 --- a/src/Soil-Core/SoilIndexIterator.class.st +++ b/src/Soil-Core/SoilIndexIterator.class.st @@ -103,6 +103,11 @@ SoilIndexIterator >> firstAssociation [ ^ item ] +{ #category : #accessing } +SoilIndexIterator >> index [ + ^index +] + { #category : #accessing } SoilIndexIterator >> index: anIndex [ index := anIndex @@ -199,11 +204,18 @@ SoilIndexIterator >> nextPresentAssociation [ ^ assoc ] -{ #category : #accessing } +{ #category : #private } SoilIndexIterator >> pageAt: anInteger [ ^ index store pageAt: anInteger ] +{ #category : #removing } +SoilIndexIterator >> removeKey: key [ + ^ self + at: key + put: (SoilObjectId segment: 0 index: 0) +] + { #category : #accessing } SoilIndexIterator >> size [ "We iterate over all elements to get the size. Slow!" diff --git a/src/Soil-Core/SoilIndexedDictionary.class.st b/src/Soil-Core/SoilIndexedDictionary.class.st index 397e41ce..0005634b 100644 --- a/src/Soil-Core/SoilIndexedDictionary.class.st +++ b/src/Soil-Core/SoilIndexedDictionary.class.st @@ -45,7 +45,6 @@ SoilIndexedDictionary >> at: key put: anObject [ | objectId iterator | objectId := transaction makeRoot: anObject. - "binKey := (key asSkipListKeyOfSize: index keySize) asInteger." iterator := self index newIterator. (iterator at: key put: objectId) ifNotNil: [ :value | oldValues @@ -258,7 +257,7 @@ SoilIndexedDictionary >> removeKey: key ifAbsent: aBlock [ removedValues at: key put: v asSoilObjectId. - ^ iterator at: key put: (SoilObjectId segment: 0 index: 0) + ^ iterator removeKey: key ] { #category : #private } diff --git a/src/Soil-Core/SoilSkipListIterator.class.st b/src/Soil-Core/SoilSkipListIterator.class.st index 33854973..6b1ef92d 100644 --- a/src/Soil-Core/SoilSkipListIterator.class.st +++ b/src/Soil-Core/SoilSkipListIterator.class.st @@ -7,7 +7,7 @@ Class { #category : #'Soil-Core-Index-SkipList' } -{ #category : #accessing } +{ #category : #skiplist } SoilSkipListIterator >> atLevel: key put: anObject [ levels at: key put: anObject ] @@ -75,7 +75,7 @@ SoilSkipListIterator >> lastPage [ ^ currentPage ] -{ #category : #accessing } +{ #category : #skiplist } SoilSkipListIterator >> levelAt: anInteger [ ^ levels at: anInteger ] @@ -99,10 +99,3 @@ SoilSkipListIterator >> nextKeyCloseTo: key [ SoilSkipListIterator >> printOn: aStream [ aStream << 'path: ' << levels asString ] - -{ #category : #removing } -SoilSkipListIterator >> removeKey: key [ - ^ self - at: key - put: (SoilObjectId segment: 0 index: 0) -]