(PhysicalPlan pp, String expectedFile)
| 1153 | } |
| 1154 | |
| 1155 | private void run(PhysicalPlan pp, String expectedFile) throws Exception { |
| 1156 | String compiledPlan, goldenPlan = null; |
| 1157 | int MAX_SIZE = 100000; |
| 1158 | MRCompiler comp = new MRCompiler(pp, pc); |
| 1159 | comp.compile(); |
| 1160 | |
| 1161 | MROperPlan mrp = comp.getMRPlan(); |
| 1162 | PlanPrinter ppp = new PlanPrinter(mrp); |
| 1163 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| 1164 | ppp.print(baos); |
| 1165 | compiledPlan = baos.toString(); |
| 1166 | |
| 1167 | if(generate){ |
| 1168 | FileOutputStream fos = new FileOutputStream(expectedFile); |
| 1169 | fos.write(baos.toByteArray()); |
| 1170 | return; |
| 1171 | } |
| 1172 | FileInputStream fis = new FileInputStream(expectedFile); |
| 1173 | byte[] b = new byte[MAX_SIZE]; |
| 1174 | int len = fis.read(b); |
| 1175 | goldenPlan = new String(b, 0, len); |
| 1176 | if (goldenPlan.charAt(len-1) == '\n') |
| 1177 | goldenPlan = goldenPlan.substring(0, len-1); |
| 1178 | |
| 1179 | pp.explain(System.out); |
| 1180 | System.out.println(); |
| 1181 | System.out.println("<<<" + compiledPlan + ">>>"); |
| 1182 | System.out.println("-------------"); |
| 1183 | System.out.println("Golden"); |
| 1184 | System.out.println("<<<" + goldenPlan + ">>>"); |
| 1185 | System.out.println("-------------"); |
| 1186 | |
| 1187 | String goldenPlanClean = Util.standardizeNewline(goldenPlan); |
| 1188 | String compiledPlanClean = Util.standardizeNewline(compiledPlan); |
| 1189 | assertEquals(TestHelper.sortUDFs(Util.removeSignature(goldenPlanClean)), |
| 1190 | TestHelper.sortUDFs(Util.removeSignature(compiledPlanClean))); |
| 1191 | } |
| 1192 | |
| 1193 | public static class TestCollectableLoadFunc extends PigStorage implements CollectableLoadFunc { |
| 1194 | @Override |
no test coverage detected