@@ -79,6 +79,10 @@ public Node leave(Node old, Node n, NodeVisitor v){
79
79
template = template .replace ("<input-name>" , inputDataName +"_" +lcName );
80
80
template = template .replace (inputDataName +"[" +lcName +"]" , inputDataName +"_" +lcName );
81
81
82
+ for (String constVar : ext .constMapping .keySet ()){
83
+ template = template .replace (ext .constMapping .get (constVar ), constVar );
84
+ }
85
+
82
86
for (Variable inVar : ext .inputVars ){
83
87
if (!ext .outputVars .contains (inVar ) && inVar .category != Variable .ARRAY_ACCESS )
84
88
template = template .replaceAll ("\\ b" +inVar .varName +"\\ b" ,inVar .varName +"_final" );
@@ -171,41 +175,51 @@ private String generateCreateRDD(MyWhileExt ext) {
171
175
172
176
private String generateMapEmits (MyWhileExt ext ) {
173
177
String emits = "" ;
174
- for (GenerateScaffold .KvPair kvp : ext .mapEmits .get ("noCondition" )){
175
- // Fix function calls
176
- for (SketchCall call : ext .methodOperators ){
177
- Pattern r = Pattern .compile ("^(" +call .name +")\\ ((..*)\\ )$" );
178
- Matcher m ;
179
-
180
- m = r .matcher (kvp .key );
181
- if (m .find ()){
182
- System .err .println ("key:" + m );
178
+ for (String cond : ext .mapEmits .keySet ()){
179
+ for (GenerateScaffold .KvPair kvp : ext .mapEmits .get (cond )){
180
+ // Fix function calls
181
+ for (SketchCall call : ext .methodOperators ){
182
+ Pattern r = Pattern .compile ("^(" +call .name +")\\ ((..*)\\ )$" );
183
+ Matcher m ;
184
+
185
+ m = r .matcher (kvp .key );
186
+ if (m .find ()){
187
+ }
188
+
189
+ m = r .matcher (kvp .key2 );
190
+ if (m .find ()){
191
+ }
192
+
193
+ m = r .matcher (kvp .value );
194
+ if (m .find ()){
195
+ if (call .target .equals ("first-arg" )){
196
+ String target = m .group (2 ).substring (0 , m .group (2 ).indexOf ("," ));
197
+ String args = m .group (2 ).substring (m .group (2 ).indexOf ("," )+1 , m .group (2 ).length ());
198
+ kvp .value = kvp .value .replace (m .group (0 ), target +"." +call .nameOrig +"(" +args +")" );
199
+ }
200
+ else {
201
+ String args = m .group (2 );
202
+ kvp .value = kvp .value .replace (m .group (0 ), call .nameOrig +"(" +args +")" );
203
+ }
204
+ }
183
205
}
184
-
185
- m = r .matcher (kvp .key2 );
186
- if (m .find ()){
187
- System .err .println ("key2:" + m );
206
+ if (kvp .key2 == "" ){
207
+ if (cond .equals ("noCondition" )){
208
+ emits += "emits.add(new Tuple2(" +kvp .key +"," +kvp .value +"));\n " ;
209
+ }
210
+ else {
211
+ emits += "if(" +cond +") emits.add(new Tuple2(" +kvp .key +"," +kvp .value +"));\n " ;
212
+ }
188
213
}
189
-
190
- m = r .matcher (kvp .value );
191
- if (m .find ()){
192
- if (call .target .equals ("first-arg" )){
193
- String target = m .group (2 ).substring (0 , m .group (2 ).indexOf ("," ));
194
- String args = m .group (2 ).substring (m .group (2 ).indexOf ("," )+1 , m .group (2 ).length ());
195
- kvp .value = kvp .value .replace (m .group (0 ), target +"." +call .nameOrig +"(" +args +")" );
214
+ else {
215
+ if (cond .equals ("noCondition" )){
216
+ emits += "emits.add(new Tuple2(new Tuple2(" +kvp .key +"," +kvp .key2 +"), " +kvp .value +"));\n " ;
196
217
}
197
218
else {
198
- String args = m .group (2 );
199
- kvp .value = kvp .value .replace (m .group (0 ), call .nameOrig +"(" +args +")" );
219
+ emits += "if(" +cond +") emits.add(new Tuple2(new Tuple2(" +kvp .key +"," +kvp .key2 +"), " +kvp .value +"));\n " ;
200
220
}
201
221
}
202
222
}
203
- if (kvp .key2 == "" ){
204
- emits += "emits.add(new Tuple2(" +kvp .key +"," +kvp .value +"));\n " ;
205
- }
206
- else {
207
- emits += "emits.add(new Tuple2(new Tuple2(" +kvp .key +"," +kvp .key2 +"), " +kvp .value +"));\n " ;
208
- }
209
223
}
210
224
return emits ;
211
225
}
0 commit comments