@@ -2,30 +2,21 @@ Class {
2
2
#name : #SoilBackupVisitor ,
3
3
#superclass : #SoilVisitor ,
4
4
#instVars : [
5
- ' source' ,
6
- ' target' ,
7
- ' seen' ,
8
- ' toBeProcessed' ,
9
- ' version'
5
+ ' target'
10
6
],
11
7
#category : #' Soil-Core-Visitor'
12
8
}
13
9
14
10
{ #category : #api }
15
11
SoilBackupVisitor >> backup: aSoil [
16
- | objectId |
17
- source := aSoil.
12
+ soil := aSoil.
18
13
" if there is no version set we take the actual database version. This
19
14
is to create a consistent backup regardless if transactions are committed
20
15
while we are doing the backup"
21
- version ifNil: [
22
- version := aSoil control databaseVersion ].
16
+ databaseVersion ifNil: [
17
+ databaseVersion := aSoil control databaseVersion ].
23
18
24
- self visit: source.
25
-
26
- [ toBeProcessed isEmpty ] whileFalse: [
27
- objectId := toBeProcessed removeFirst.
28
- self visit: (source objectRepository at: objectId version: version) ].
19
+ self visit: soil.
29
20
target close
30
21
]
31
22
@@ -35,7 +26,7 @@ SoilBackupVisitor >> copyAllClusterVersions: aSoilPersistentClusterVersion [
35
26
" if there is no previous version is a single copy"
36
27
aSoilPersistentClusterVersion hasPreviousVersion
37
28
ifFalse: [ ^ self copySourceCluster: aSoilPersistentClusterVersion ].
38
- versions := (source objectRepository segmentAt: aSoilPersistentClusterVersion objectId segment)
29
+ versions := (soil objectRepository segmentAt: aSoilPersistentClusterVersion objectId segment)
39
30
allVersionsAt: aSoilPersistentClusterVersion objectId index.
40
31
position := 0 .
41
32
" for multiple versions we need to iterate from oldest to newest to set the
@@ -53,7 +44,7 @@ SoilBackupVisitor >> copyCluster: aSoilPersistentClusterVersion [
53
44
at: aSoilPersistentClusterVersion objectId
54
45
putBytes: aSoilPersistentClusterVersion serialize.
55
46
aSoilPersistentClusterVersion references do: [ :reference |
56
- self process : reference ].
47
+ self processObjectId : reference ].
57
48
aSoilPersistentClusterVersion indexIds do: [ :indexId |
58
49
self copyIndexAt: indexId segment: aSoilPersistentClusterVersion segment ].
59
50
^ position
@@ -64,7 +55,7 @@ SoilBackupVisitor >> copyCluster: aSoilPersistentClusterVersion [
64
55
SoilBackupVisitor >> copyIndexAt: indexId segment: segmentId [
65
56
| sourceSegment sourceIndex targetSegment targetIndex iterator assoc |
66
57
67
- sourceSegment := source objectRepository segmentAt: segmentId.
58
+ sourceSegment := soil objectRepository segmentAt: segmentId.
68
59
sourceIndex := sourceSegment indexManager
69
60
loadIndexWithId: indexId
70
61
ifNone: [ ^ self indexNotFound: indexId ].
@@ -82,7 +73,7 @@ SoilBackupVisitor >> copyIndexAt: indexId segment: segmentId [
82
73
assoc value isRemoved ifFalse: [
83
74
targetIndex basicAt: assoc key put: assoc value.
84
75
" recurse further into the values of the index"
85
- self process : assoc value asSoilObjectId ] ].
76
+ self processObjectId : assoc value asSoilObjectId ] ].
86
77
targetIndex
87
78
flush;
88
79
close.
@@ -95,18 +86,17 @@ SoilBackupVisitor >> copySourceCluster: aSoilPersistentClusterVersion [
95
86
^ self copyCluster: clusterCopy
96
87
]
97
88
89
+ { #category : #accessing }
90
+ SoilBackupVisitor >> databaseVersion: anObject [
91
+
92
+ databaseVersion := anObject
93
+ ]
94
+
98
95
{ #category : #visiting }
99
96
SoilBackupVisitor >> indexNotFound: indexId [
100
97
Error signal : ' cannot find index with id ' , indexId printString
101
98
]
102
99
103
- { #category : #initialization }
104
- SoilBackupVisitor >> initialize [
105
- super initialize.
106
- seen := Set new .
107
- toBeProcessed := OrderedCollection new
108
- ]
109
-
110
100
{ #category : #visiting }
111
101
SoilBackupVisitor >> makeCopy: aSoilPersistentClusterVersion [
112
102
^ aSoilPersistentClusterVersion copy
@@ -117,13 +107,10 @@ SoilBackupVisitor >> makeCopy: aSoilPersistentClusterVersion [
117
107
resetPreviousVersion.
118
108
]
119
109
120
- { #category : #accessing }
121
- SoilBackupVisitor >> process: aSoilObjectId [
122
- " don't continue if the objectId is the behavior description meta object"
123
- ((aSoilObjectId segment = 0 ) and : [ aSoilObjectId index = 2 ]) ifTrue: [ ^ self ].
124
- (seen includes: aSoilObjectId) ifTrue: [ ^ self ].
125
- seen add: aSoilObjectId.
126
- toBeProcessed add: aSoilObjectId
110
+ { #category : #api }
111
+ SoilBackupVisitor >> processLoop [
112
+ super processLoop.
113
+ target close
127
114
]
128
115
129
116
{ #category : #accessing }
@@ -134,7 +121,7 @@ SoilBackupVisitor >> target: aSoil [
134
121
{ #category : #accessing }
135
122
SoilBackupVisitor >> version: anObject [
136
123
137
- version := anObject
124
+ databaseVersion := anObject
138
125
]
139
126
140
127
{ #category : #visiting }
@@ -167,7 +154,7 @@ SoilBackupVisitor >> visitMetaSegment: aSoilMetaSegment [
167
154
168
155
{ #category : #visiting }
169
156
SoilBackupVisitor >> visitObjectSegment: aSoilObjectSegment [
170
- self process : SoilObjectId root.
157
+ self processObjectId : SoilObjectId root.
171
158
super visitObjectSegment: aSoilObjectSegment.
172
159
]
173
160
0 commit comments