MCPcopy Create free account
hub / github.com/apache/pig / run

Method run

test/org/apache/pig/spark/TestSparkCompiler.java:142–179  ·  view source on GitHub ↗
(String query, String expectedFile, PlanPrinter planPrinter)

Source from the content-addressed store, hash-verified

140 }
141
142 private void run(String query, String expectedFile, PlanPrinter planPrinter) throws Exception {
143 PhysicalPlan pp = Util.buildPp(pigServer, query);
144 SparkLauncher launcher = new SparkLauncher();
145 pc.inExplain = true;
146 SparkOperPlan sparkOperPlan = launcher.compile(pp, pc);
147
148 ByteArrayOutputStream baos = new ByteArrayOutputStream();
149 PrintStream ps = new PrintStream(baos);
150 planPrinter.doPrint(ps, sparkOperPlan);
151 String compiledPlan = baos.toString();
152 System.out.println();
153 System.out.println("<<<" + compiledPlan + ">>>");
154
155 if (generate) {
156 FileOutputStream fos = new FileOutputStream(expectedFile);
157 fos.write(baos.toByteArray());
158 fos.close();
159 return;
160 }
161 FileInputStream fis = new FileInputStream(expectedFile);
162 byte[] b = new byte[MAX_SIZE];
163 int len = fis.read(b);
164 fis.close();
165 String goldenPlan = new String(b, 0, len);
166 if (goldenPlan.charAt(len-1) == '\n') {
167 goldenPlan = goldenPlan.substring(0, len-1);
168 }
169
170 System.out.println("-------------");
171 System.out.println("Golden");
172 System.out.println("<<<" + goldenPlan + ">>>");
173 System.out.println("-------------");
174
175 String goldenPlanClean = Util.standardizeNewline(goldenPlan).trim();
176 String compiledPlanClean = Util.standardizeNewline(compiledPlan).trim();
177 assertEquals(TestHelper.sortUDFs(Util.removeSignature(goldenPlanClean)),
178 TestHelper.sortUDFs(Util.removeSignature(compiledPlanClean)));
179 }
180
181}
182

Callers 1

testStoreLoadMethod · 0.95

Calls 11

buildPpMethod · 0.95
compileMethod · 0.95
standardizeNewlineMethod · 0.95
sortUDFsMethod · 0.95
removeSignatureMethod · 0.95
doPrintMethod · 0.80
closeMethod · 0.65
toStringMethod · 0.45
writeMethod · 0.45
readMethod · 0.45
assertEqualsMethod · 0.45

Tested by

no test coverage detected