@@ -30,16 +30,16 @@ predicate hasTupleCount(
30
30
float tupleCount
31
31
) {
32
32
inLayer = firstPredicate ( recursive ) and
33
- exists ( PipeLineRun run | run = inLayer .getPipelineRuns ( ) .getRun ( iteration ) |
34
- ordering = run .getRAReference ( ) and
33
+ exists ( PipeLineRun run |
34
+ run = inLayer .getPipelineRuns ( ) .getRun ( iteration ) and ordering = run .getRAReference ( )
35
+ |
35
36
tupleCount = run .getCount ( i )
36
- )
37
- or
38
- exists ( SummaryEvent inLayer0 , float tupleCount0 , PipeLineRun run |
39
- run = inLayer .getPipelineRuns ( ) .getRun ( pragma [ only_bind_into ] ( iteration ) ) and
40
- successor ( recursive , inLayer0 , inLayer ) and
41
- hasTupleCount ( recursive , ordering , inLayer0 , pragma [ only_bind_into ] ( iteration ) , i , tupleCount0 ) and
42
- tupleCount = run .getCount ( i ) + tupleCount0
37
+ or
38
+ exists ( SummaryEvent inLayer0 , float tupleCount0 |
39
+ successor ( recursive , inLayer0 , inLayer ) and
40
+ hasTupleCount ( recursive , ordering , inLayer0 , pragma [ only_bind_into ] ( iteration ) , i , tupleCount0 ) and
41
+ tupleCount = run .getCount ( i ) + tupleCount0
42
+ )
43
43
)
44
44
}
45
45
@@ -58,17 +58,19 @@ predicate hasDuplication(
58
58
ComputeRecursive recursive , string ordering , SummaryEvent inLayer , int iteration , int i ,
59
59
float duplication
60
60
) {
61
- inLayer = firstPredicate ( recursive ) and
62
- exists ( PipeLineRun run | run = inLayer .getPipelineRuns ( ) .getRun ( iteration ) |
63
- ordering = run .getRAReference ( ) and
61
+ exists ( PipeLineRun run |
62
+ run = inLayer .getPipelineRuns ( ) .getRun ( iteration ) and
63
+ ordering = run .getRAReference ( )
64
+ |
65
+ inLayer = firstPredicate ( recursive ) and
64
66
duplication = run .getDuplicationPercentage ( i )
65
- )
66
- or
67
- exists ( SummaryEvent inLayer0 , float duplication0 , PipeLineRun run |
68
- run = inLayer . getPipelineRuns ( ) . getRun ( pragma [ only_bind_into ] ( iteration ) ) and
69
- successor ( recursive , inLayer0 , inLayer ) and
70
- hasDuplication ( recursive , ordering , inLayer0 , pragma [ only_bind_into ] ( iteration ) , i , duplication0 ) and
71
- duplication = run . getDuplicationPercentage ( i ) . maximum ( duplication0 )
67
+ or
68
+ exists ( SummaryEvent inLayer0 , float duplication0 |
69
+ successor ( recursive , inLayer0 , inLayer ) and
70
+ hasDuplication ( recursive , ordering , inLayer0 , pragma [ only_bind_into ] ( iteration ) , i ,
71
+ duplication0 ) and
72
+ duplication = run . getDuplicationPercentage ( i ) . maximum ( duplication0 )
73
+ )
72
74
)
73
75
}
74
76
@@ -90,14 +92,18 @@ predicate hasDuplication(ComputeRecursive recursive, string ordering, int i, flo
90
92
private predicate hasResultSize (
91
93
ComputeRecursive recursive , string ordering , SummaryEvent inLayer , int iteration , float resultSize
92
94
) {
93
- inLayer = firstPredicate ( recursive ) and
94
- ordering = inLayer .getPipelineRuns ( ) .getRun ( iteration ) .getRAReference ( ) and
95
- resultSize = inLayer .getDeltaSize ( iteration )
96
- or
97
- exists ( SummaryEvent inLayer0 , int resultSize0 |
98
- successor ( recursive , inLayer0 , inLayer ) and
99
- hasResultSize ( recursive , ordering , inLayer0 , iteration , resultSize0 ) and
100
- resultSize = inLayer .getDeltaSize ( iteration ) + resultSize0
95
+ exists ( PipeLineRun run |
96
+ run = inLayer .getPipelineRuns ( ) .getRun ( iteration ) and
97
+ ordering = run .getRAReference ( )
98
+ |
99
+ inLayer = firstPredicate ( recursive ) and
100
+ resultSize = inLayer .getDeltaSize ( iteration )
101
+ or
102
+ exists ( SummaryEvent inLayer0 , int resultSize0 |
103
+ successor ( recursive , inLayer0 , inLayer ) and
104
+ hasResultSize ( recursive , ordering , inLayer0 , iteration , resultSize0 ) and
105
+ resultSize = inLayer .getDeltaSize ( iteration ) + resultSize0
106
+ )
101
107
)
102
108
}
103
109
@@ -122,17 +128,20 @@ SummaryEvent getInLayerEventWithName(ComputeRecursive recursive, string predicat
122
128
123
129
bindingset [ predicateName, iteration]
124
130
int getSize ( ComputeRecursive recursive , string predicateName , int iteration , TDeltaKind kind ) {
125
- exists ( int i |
131
+ exists ( int i , SummaryEvent event |
126
132
kind = TPrevious ( ) and
127
133
i = iteration - 1
128
134
or
129
135
kind = TCurrent ( ) and
130
136
i = iteration
131
137
|
132
- result = getInLayerEventWithName ( recursive , predicateName ) .getDeltaSize ( i )
133
- or
134
- not exists ( getInLayerEventWithName ( recursive , predicateName ) .getDeltaSize ( i ) ) and
135
- result = 0
138
+ event = getInLayerEventWithName ( recursive , predicateName ) and
139
+ (
140
+ result = event .getDeltaSize ( i )
141
+ or
142
+ not exists ( event .getDeltaSize ( i ) ) and
143
+ result = 0
144
+ )
136
145
)
137
146
}
138
147
@@ -154,36 +163,53 @@ private predicate isDelta(string predicateName, TDeltaKind kind, string withoutS
154
163
withoutSuffix = predicateName .regexpCapture ( "(.+)#cur_delta" , 1 )
155
164
}
156
165
166
+ bindingset [ iteration]
167
+ float getRecursiveDependencySize (
168
+ ComputeRecursive recursive , string predicateName , int iteration , SummaryEvent inLayer ,
169
+ string ordering , TDeltaKind kind
170
+ ) {
171
+ result = getSize ( recursive , predicateName , iteration , kind ) and
172
+ isDelta ( getAnRaOperation ( inLayer , ordering ) .getARhsPredicate ( ) , kind , predicateName )
173
+ }
174
+
175
+ bindingset [ ordering, iteration]
176
+ predicate hasDependentPredicateSizeImpl (
177
+ ComputeRecursive recursive , string ordering , float size , string predicateName , int iteration ,
178
+ SummaryEvent inLayer
179
+ ) {
180
+ // We treat the base case as a non-recursive case
181
+ if ordering = "base"
182
+ then
183
+ size =
184
+ [
185
+ getDependencyWithName ( recursive .getDependencies ( ) , predicateName ) .getResultSize ( ) ,
186
+ getRecursiveDependencySize ( recursive , predicateName , iteration , inLayer , ordering ,
187
+ TCurrent ( ) )
188
+ ]
189
+ else
190
+ size =
191
+ getRecursiveDependencySize ( recursive , predicateName , iteration , inLayer , ordering , TPrevious ( ) )
192
+ }
193
+
194
+ pragma [ nomagic]
157
195
predicate hasDependentPredicateSize (
158
196
ComputeRecursive recursive , string ordering , SummaryEvent inLayer , int iteration ,
159
197
string predicateName , float size
160
198
) {
161
- exists ( |
162
- inLayer = firstPredicate ( recursive ) and
163
- ordering = inLayer .getPipelineRuns ( ) .getRun ( iteration ) .getRAReference ( )
164
- |
165
- // We treat iteration 0 as a non-recursive case
166
- if ordering = "base"
167
- then size = getDependencyWithName ( recursive .getDependencies ( ) , predicateName ) .getResultSize ( )
168
- else
169
- exists ( TDeltaKind kind |
170
- size = getSize ( recursive , predicateName , iteration , kind ) and
171
- isDelta ( getAnRaOperation ( inLayer , ordering ) .getARhsPredicate ( ) , kind , predicateName )
172
- )
173
- )
174
- or
175
- exists ( SummaryEvent inLayer0 , float size0 |
176
- successor ( recursive , inLayer0 , inLayer ) and
177
- hasDependentPredicateSize ( recursive , ordering , inLayer0 , iteration , predicateName , size0 )
199
+ exists ( PipeLineRun run |
200
+ run = inLayer .getPipelineRuns ( ) .getRun ( pragma [ only_bind_into ] ( iteration ) ) and
201
+ ordering = run .getRAReference ( )
178
202
|
179
- // We treat iteration 0 as a non-recursive case
180
- if ordering = "base"
181
- then size = getDependencyWithName ( recursive .getDependencies ( ) , predicateName ) .getResultSize ( )
182
- else
183
- exists ( TDeltaKind kind |
184
- size = getSize ( recursive , predicateName , iteration , kind ) + size0 and
185
- isDelta ( getAnRaOperation ( inLayer , ordering ) .getARhsPredicate ( ) , kind , predicateName )
186
- )
203
+ inLayer = firstPredicate ( recursive ) and
204
+ hasDependentPredicateSizeImpl ( recursive , ordering , size , predicateName , iteration , inLayer )
205
+ or
206
+ exists ( SummaryEvent inLayer0 , float size0 , float size1 |
207
+ successor ( recursive , inLayer0 , inLayer ) and
208
+ hasDependentPredicateSize ( recursive , ordering , inLayer0 , pragma [ only_bind_into ] ( iteration ) ,
209
+ predicateName , size0 ) and
210
+ hasDependentPredicateSizeImpl ( recursive , ordering , size1 , predicateName , iteration , inLayer ) and
211
+ size = size0 + size1
212
+ )
187
213
)
188
214
}
189
215
0 commit comments