Skip to content

Commit 34414d9

Browse files
authored
Merge pull request #885 from ApptiveGrid/add-size-for-cluster
add size calculation for records.
2 parents 9a7329c + 8d747b5 commit 34414d9

5 files changed

+70
-0
lines changed

src/Soil-Core/Object.extension.st

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ Object >> soilEmit [
3535
self asSoilSignal emit
3636
]
3737

38+
{ #category : #'*Soil-Core' }
39+
Object >> soilSizeInMemory [
40+
^ self sizeInMemory
41+
]
42+
3843
{ #category : #'*Soil-Core' }
3944
Object >> theNonSoilProxy [
4045
^ self

src/Soil-Core/SoilObjectId.class.st

+8
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,14 @@ SoilObjectId >> setIndex: anInteger [
176176
index := anInteger
177177
]
178178

179+
{ #category : #comparing }
180+
SoilObjectId >> soilSizeInMemory [
181+
^ self sizeInMemory
182+
+ segment sizeInMemory
183+
+ index sizeInMemory
184+
185+
]
186+
179187
{ #category : #writing }
180188
SoilObjectId >> writeOn: aStream [
181189
"for now fix the segment id to be the 16 upper bits and the index

src/Soil-Core/SoilObjectRepository.class.st

+17
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ SoilObjectRepository >> cacheSegmentAt: index upTo: limit [
8181
put: ((segments at: index) asCachedSegment weight: limit) ]
8282
]
8383

84+
{ #category : #setting }
85+
SoilObjectRepository >> cacheSegmentAt: index using: aBlock [
86+
| segment |
87+
"exchange object segment with a LRU cached segment. The LRU cache
88+
can be setup within aBlock"
89+
(index = 0)
90+
ifTrue: [
91+
metaSegment := metaSegment asCachedSegment.
92+
aBlock value: metaSegment ]
93+
ifFalse: [
94+
segment := (segments at: index) asCachedSegment.
95+
aBlock value: segment.
96+
segments
97+
at: index
98+
put: segment ]
99+
]
100+
84101
{ #category : #'opening/closing' }
85102
SoilObjectRepository >> close [
86103
metaSegment close.

src/Soil-Core/SoilPersistentClusterVersion.class.st

+15
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,18 @@ SoilPersistentClusterVersion >> readFrom: stream [
119119
SoilPersistentClusterVersion >> shouldBeCommitted [
120120
^ changed and: [ committed not ]
121121
]
122+
123+
{ #category : #comparing }
124+
SoilPersistentClusterVersion >> soilSizeInMemory [
125+
^ self sizeInMemory
126+
+ objectId soilSizeInMemory
127+
+ (references sum: #soilSizeInMemory)
128+
+ bytes sizeInMemory
129+
+ committed sizeInMemory
130+
+ previousVersionPosition sizeInMemory
131+
+ version sizeInMemory
132+
+ (behaviorDescriptions sum: #soilSizeInMemory)
133+
+ (indexIds sum: #sizeInMemory)
134+
+ position sizeInMemory
135+
+ changed sizeInMemory
136+
]

src/Soil-Core/SoilSetup.class.st

+25
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ SoilSetup >> cacheObjectRecords: anInteger [
1919
soil objectRepository cacheSegmentAt: n upTo: anInteger ]
2020
]
2121

22+
{ #category : #caching }
23+
SoilSetup >> cacheObjectRecordsUsing: aBlock [
24+
1 to: soil objectRepository segments size do: [:n |
25+
soil objectRepository
26+
cacheSegmentAt: n
27+
using: aBlock ]
28+
]
29+
2230
{ #category : #caching }
2331
SoilSetup >> cacheRecords [
2432
self cacheRecords: self defaultCacheRecordsSize
@@ -31,6 +39,23 @@ SoilSetup >> cacheRecords: anInteger [
3139
cacheObjectRecords: anInteger
3240
]
3341

42+
{ #category : #caching }
43+
SoilSetup >> cacheSegmentAt: index maximumBytes: anInteger [
44+
self
45+
cacheSegmentAt: index
46+
using: [ :cache |
47+
cache
48+
computeWeight: #soilSizeInMemory;
49+
maximumWeight: anInteger ]
50+
]
51+
52+
{ #category : #caching }
53+
SoilSetup >> cacheSegmentAt: index using: aBlock [
54+
soil objectRepository
55+
cacheSegmentAt: index
56+
using: aBlock
57+
]
58+
3459
{ #category : #accessing }
3560
SoilSetup >> defaultCacheRecordsSize [
3661
^ 1000

0 commit comments

Comments
 (0)