@@ -30,16 +30,16 @@ predicate hasTupleCount(
3030 float tupleCount
3131) {
3232 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+ |
3536 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+ )
4343 )
4444}
4545
@@ -58,17 +58,19 @@ predicate hasDuplication(
5858 ComputeRecursive recursive , string ordering , SummaryEvent inLayer , int iteration , int i ,
5959 float duplication
6060) {
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
6466 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+ )
7274 )
7375}
7476
@@ -90,14 +92,18 @@ predicate hasDuplication(ComputeRecursive recursive, string ordering, int i, flo
9092private predicate hasResultSize (
9193 ComputeRecursive recursive , string ordering , SummaryEvent inLayer , int iteration , float resultSize
9294) {
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+ )
101107 )
102108}
103109
@@ -122,17 +128,20 @@ SummaryEvent getInLayerEventWithName(ComputeRecursive recursive, string predicat
122128
123129bindingset [ predicateName, iteration]
124130int getSize ( ComputeRecursive recursive , string predicateName , int iteration , TDeltaKind kind ) {
125- exists ( int i |
131+ exists ( int i , SummaryEvent event |
126132 kind = TPrevious ( ) and
127133 i = iteration - 1
128134 or
129135 kind = TCurrent ( ) and
130136 i = iteration
131137 |
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+ )
136145 )
137146}
138147
@@ -154,36 +163,53 @@ private predicate isDelta(string predicateName, TDeltaKind kind, string withoutS
154163 withoutSuffix = predicateName .regexpCapture ( "(.+)#cur_delta" , 1 )
155164}
156165
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]
157195predicate hasDependentPredicateSize (
158196 ComputeRecursive recursive , string ordering , SummaryEvent inLayer , int iteration ,
159197 string predicateName , float size
160198) {
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 ( )
178202 |
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+ )
187213 )
188214}
189215
0 commit comments