Skip to content

Commit

Permalink
Merge pull request #598 from ApptiveGrid/unify-hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
noha authored Feb 8, 2024
2 parents 4a3b2b6 + 1351d83 commit 1711c2e
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 92 deletions.
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilBTreeDataPage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SoilBTreeDataPage >> initialize [
next := 0
]

{ #category : #accessing }
{ #category : #adding }
SoilBTreeDataPage >> insertItem: anItem for: iterator [

| newPage pageWithItem return |
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilBTreeIndexPage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SoilBTreeIndexPage >> headerSize [
+ 2 "items size"
]

{ #category : #searching }
{ #category : #adding }
SoilBTreeIndexPage >> insertItem: item for: iterator [
| foundItem return newPage |

Expand Down
40 changes: 4 additions & 36 deletions src/Soil-Core/SoilBTreePage.class.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
Class {
#name : #SoilBTreePage,
#superclass : #SoilIndexItemsPage,
#instVars : [
'keySize',
'lastTransaction'
],
#category : #'Soil-Core-Index-BTree'
}

Expand Down Expand Up @@ -40,29 +36,9 @@ SoilBTreePage >> initialize [
dirty := true
]

{ #category : #testing }
SoilBTreePage >> isOlderThan: aVersionNumber [
^ lastTransaction <= aVersionNumber
]

{ #category : #accessing }
SoilBTreePage >> keySize [
^ keySize
]

{ #category : #accessing }
SoilBTreePage >> keySize: anInteger [
keySize := anInteger
]

{ #category : #accessing }
SoilBTreePage >> lastTransaction [
^ lastTransaction
]

{ #category : #accessing }
SoilBTreePage >> lastTransaction: anInteger [
lastTransaction := anInteger
{ #category : #adding }
SoilBTreePage >> insertItem: anItem for: iterator [
^ self subclassResponsibility
]

{ #category : #accessing }
Expand All @@ -86,11 +62,6 @@ SoilBTreePage >> readItemsFrom: aStream [
items add: (aStream next: self keySize) asInteger -> (aStream next: self valueSize) ]
]

{ #category : #writing }
SoilBTreePage >> readLastTransactionFrom: aStream [
lastTransaction := (aStream next: 8) asInteger.
]

{ #category : #private }
SoilBTreePage >> split: newPage [
| middle |
Expand All @@ -113,10 +84,7 @@ SoilBTreePage >> writeHeaderOn: aStream [
SoilBTreePage >> writeItemsOn: aStream [
aStream
nextPutAll: (items size asByteArrayOfSize: self itemsSizeSize).
items do: [ :assoc |
aStream
nextPutAll: (assoc key asByteArrayOfSize: self keySize);
nextPutAll: (assoc value asByteArrayOfSize: self valueSize)]
super writeItemsOn: aStream
]

{ #category : #writing }
Expand Down
59 changes: 58 additions & 1 deletion src/Soil-Core/SoilIndexItemsPage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Class {
#name : #SoilIndexItemsPage,
#superclass : #SoilIndexPage,
#instVars : [
'items'
'items',
'lastTransaction',
'keySize'
],
#category : #'Soil-Core-Index-Common'
}
Expand Down Expand Up @@ -68,6 +70,11 @@ SoilIndexItemsPage >> isEmpty [
^ items isEmpty
]

{ #category : #testing }
SoilIndexItemsPage >> isOlderThan: aVersionNumber [
^ lastTransaction <= aVersionNumber
]

{ #category : #accessing }
SoilIndexItemsPage >> itemAfter: key [
| i item |
Expand Down Expand Up @@ -153,6 +160,17 @@ SoilIndexItemsPage >> keyOrClosestAfter: key [
(items at: (b min: items size)) key ]
]

{ #category : #accessing }
SoilIndexItemsPage >> keySize [
^ keySize
]

{ #category : #accessing }
SoilIndexItemsPage >> keySize: anInteger [
(anInteger = 0) ifTrue: [ Error signal: 'cannot use key size 0' ].
keySize := anInteger
]

{ #category : #accessing }
SoilIndexItemsPage >> lastItem [

Expand All @@ -165,6 +183,16 @@ SoilIndexItemsPage >> lastKey [
^ items isNotEmpty ifTrue: [ items last key ]
]

{ #category : #accessing }
SoilIndexItemsPage >> lastTransaction [
^ lastTransaction
]

{ #category : #accessing }
SoilIndexItemsPage >> lastTransaction: anInteger [
lastTransaction := anInteger
]

{ #category : #accessing }
SoilIndexItemsPage >> numberOfItems [
^ items size
Expand All @@ -176,6 +204,21 @@ SoilIndexItemsPage >> postCopy [
items := items copy.
]

{ #category : #reading }
SoilIndexItemsPage >> readItemsFrom: aStream [
| numberOfItems |
numberOfItems := (aStream next: self itemsSizeSize) asInteger.
items := SortedCollection new: numberOfItems.
numberOfItems timesRepeat: [
items add: ((aStream next: self keySize) asInteger -> (aStream next: self valueSize) asSoilObjectId) ]
]

{ #category : #writing }
SoilIndexItemsPage >> readLastTransactionFrom: aStream [
lastTransaction := (aStream next: 8) asInteger.

]

{ #category : #accessing }
SoilIndexItemsPage >> setItems: aCollection [
items := aCollection
Expand Down Expand Up @@ -204,3 +247,17 @@ SoilIndexItemsPage >> valueAt: anInteger ifAbsent: aBlock [
SoilIndexItemsPage >> valueSize [
^ self subclassResponsibility
]

{ #category : #accessing }
SoilIndexItemsPage >> valueSize: anInteger [
^ self subclassResponsibility
]

{ #category : #writing }
SoilIndexItemsPage >> writeItemsOn: aStream [
items do: [ :assoc |
aStream
nextPutAll: (assoc key asByteArrayOfSize: self keySize);
nextPutAll: (assoc value asByteArrayOfSize: self valueSize)].

]
54 changes: 1 addition & 53 deletions src/Soil-Core/SoilSkipListPage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ Class {
#superclass : #SoilIndexItemsPage,
#instVars : [
'right',
'keySize',
'valueSize',
'lastTransaction'
'valueSize'
],
#category : #'Soil-Core-Index-SkipList'
}
Expand Down Expand Up @@ -59,32 +57,6 @@ SoilSkipListPage >> isLastPage [
^ (right at: 1) = 0
]

{ #category : #testing }
SoilSkipListPage >> isOlderThan: aVersionNumber [
^ lastTransaction <= aVersionNumber
]

{ #category : #accessing }
SoilSkipListPage >> keySize [
^ keySize
]

{ #category : #accessing }
SoilSkipListPage >> keySize: anInteger [
(anInteger = 0) ifTrue: [ Error signal: 'cannot use key size 0' ].
keySize := anInteger.
]

{ #category : #accessing }
SoilSkipListPage >> lastTransaction [
^ lastTransaction
]

{ #category : #accessing }
SoilSkipListPage >> lastTransaction: anInteger [
lastTransaction := anInteger
]

{ #category : #accessing }
SoilSkipListPage >> level [
^ right size
Expand All @@ -107,21 +79,6 @@ SoilSkipListPage >> readFrom: aStream [
self readLastTransactionFrom: aStream
]

{ #category : #writing }
SoilSkipListPage >> readItemsFrom: aStream [
| numberOfItems |
numberOfItems := (aStream next: self itemsSizeSize) asInteger.
items := SortedCollection new: numberOfItems.
numberOfItems timesRepeat: [
items add: ((aStream next: self keySize) asInteger -> (aStream next: self valueSize) asSoilObjectId) ]
]

{ #category : #writing }
SoilSkipListPage >> readLastTransactionFrom: aStream [
lastTransaction := (aStream next: 8) asInteger.

]

{ #category : #writing }
SoilSkipListPage >> readLevelsFrom: aStream [
| level |
Expand Down Expand Up @@ -188,15 +145,6 @@ SoilSkipListPage >> writeHeaderOn: aStream [

]

{ #category : #writing }
SoilSkipListPage >> writeItemsOn: aStream [
items do: [ :assoc |
aStream
nextPutAll: (assoc key asByteArrayOfSize: self keySize);
nextPutAll: (assoc value asByteArrayOfSize: self valueSize)].

]

{ #category : #writing }
SoilSkipListPage >> writeLevelsOn: aStream [
aStream
Expand Down

0 comments on commit 1711c2e

Please sign in to comment.