Skip to content

Commit

Permalink
Move all methods using the iterator up to SoilIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusDenker committed Dec 16, 2023
1 parent 7edacde commit 0d9f409
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 298 deletions.
139 changes: 1 addition & 138 deletions src/Soil-Core/SoilBasicBTree.class.st
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
Class {
#name : #SoilBasicBTree,
#superclass : #Object,
#instVars : [
'store'
],
#superclass : #SoilIndex,
#category : #'Soil-Core-Index-BTree'
}

Expand All @@ -20,55 +17,6 @@ SoilBasicBTree >> asCopyOnWrite [
yourself
]

{ #category : #accessing }
SoilBasicBTree >> at: key [
^ self
at: key
ifAbsent: [ KeyNotFound signalFor: key in: self ]
]

{ #category : #accessing }
SoilBasicBTree >> at: anObject ifAbsent: aBlock [
^ (self find: anObject)
ifNotNil: [:node | node value ]
ifNil: [ aBlock value ]
]

{ #category : #accessing }
SoilBasicBTree >> at: aKeyObject put: anObject [

self newIterator
at: aKeyObject
put: anObject.

]

{ #category : #accessing }
SoilBasicBTree >> atIndex: anInteger [
^ self newIterator atIndex: anInteger
]

{ #category : #'open/close' }
SoilBasicBTree >> close [
self store close
]

{ #category : #private }
SoilBasicBTree >> find: aString [
^ self newIterator
find: (aString asSkipListKeyOfSize: self keySize) asInteger
]

{ #category : #accessing }
SoilBasicBTree >> first [
^ self newIterator first
]

{ #category : #accessing }
SoilBasicBTree >> first: anInteger [
^ self newIterator first: anInteger
]

{ #category : #accessing }
SoilBasicBTree >> firstPage [
^ self headerPage
Expand All @@ -79,16 +27,6 @@ SoilBasicBTree >> flush [
self store flush
]

{ #category : #accessing }
SoilBasicBTree >> flushCachedPages [
store flushCachedPages
]

{ #category : #accessing }
SoilBasicBTree >> headerPage [
^ self store headerPage
]

{ #category : #initialization }
SoilBasicBTree >> initializeFilesystem [
self store initializeFilesystem
Expand All @@ -104,38 +42,13 @@ SoilBasicBTree >> initializeHeaderPage [
self store pageAt: rootIndexPage index put: rootIndexPage
]

{ #category : #testing }
SoilBasicBTree >> isEmpty [
^ self store headerPage isEmpty
]

{ #category : #testing }
SoilBasicBTree >> isRegistered [
^ self subclassResponsibility
]

{ #category : #accessing }
SoilBasicBTree >> keySize [
^ self headerPage keySize
]

{ #category : #accessing }
SoilBasicBTree >> keySize: anInteger [
self headerPage keySize: anInteger.
"we have to set the keySize of the rootPage, too, as the page gets created before the keySize is known"
self rootPage keySize: anInteger
]

{ #category : #accessing }
SoilBasicBTree >> last [
^ self newIterator last
]

{ #category : #accessing }
SoilBasicBTree >> lastPage [
^ self newIterator lastPage
]

{ #category : #accessing }
SoilBasicBTree >> maxLevel: anIntegeer [
"ignored, this allows to switch SkiList and BTree easily"
Expand Down Expand Up @@ -202,21 +115,11 @@ SoilBasicBTree >> open [
self store open
]

{ #category : #accessing }
SoilBasicBTree >> pageAt: anInteger [
^ self store pageAt: anInteger
]

{ #category : #initialization }
SoilBasicBTree >> pageClass [
^ SoilBTreeDataPage
]

{ #category : #accessing }
SoilBasicBTree >> pageSize [
^ 4 * 1024
]

{ #category : #accessing }
SoilBasicBTree >> pages [
^ self store pages
Expand All @@ -227,13 +130,6 @@ SoilBasicBTree >> readPageFrom: aStream [
^ SoilBTreePage readPageFrom: aStream keySize: self keySize valueSize: self valueSize
]

{ #category : #removing }
SoilBasicBTree >> removeKey: key [
^ self
removeKey: key
ifAbsent: [ KeyNotFound signalFor: key in: self ]
]

{ #category : #removing }
SoilBasicBTree >> removeKey: aString ifAbsent: aBlock [
| page index key |
Expand All @@ -251,12 +147,6 @@ SoilBasicBTree >> rootPage [
^ self store pageAt: 2
]

{ #category : #accessing }
SoilBasicBTree >> size [
"We iterate over all elements to get the size. Slow!"
^ self newIterator size
]

{ #category : #splitting }
SoilBasicBTree >> splitIndexPage: page [
| newPage |
Expand All @@ -276,33 +166,6 @@ SoilBasicBTree >> splitPage: page [
^ newPage
]

{ #category : #accessing }
SoilBasicBTree >> store [
^ store ifNil: [
store := self newFileStore ]
]

{ #category : #accessing }
SoilBasicBTree >> store: anObject [
anObject index: self.
store := anObject
]

{ #category : #converting }
SoilBasicBTree >> thePersistentInstance [
^ self subclassResponsibility
]

{ #category : #accessing }
SoilBasicBTree >> valueSize [
^ self headerPage valueSize
]

{ #category : #accessing }
SoilBasicBTree >> valueSize: anInteger [
self headerPage valueSize: anInteger
]

{ #category : #writing }
SoilBasicBTree >> writePages [
self store flushPages
Expand Down
Loading

0 comments on commit 0d9f409

Please sign in to comment.