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

Method openIterator

src/org/apache/pig/PigServer.java:989–1022  ·  view source on GitHub ↗

Executes a Pig Latin script up to and including indicated alias. That is, if a user does: PigServer server = new PigServer(); server.registerQuery("A = load 'foo';"); server.registerQuery("B = filter A by $0 > 0;"); server.registerQuery("C = order B by $1;"); Then server.openI

(String id)

Source from the content-addressed store, hash-verified

987 * @throws IOException
988 */
989 public Iterator<Tuple> openIterator(String id) throws IOException {
990 try {
991 pigContext.getProperties().setProperty( PigContext.JOB_NAME, jobName );
992 if( jobPriority != null ) {
993 pigContext.getProperties().setProperty( PigContext.JOB_PRIORITY, jobPriority );
994 }
995 ExecJob job = store(id, FileLocalizer.getTemporaryPath(pigContext)
996 .toString(), Utils.getTmpFileCompressorName(pigContext)
997 + "()");
998
999 // invocation of "execute" is synchronous!
1000
1001 if (job.getStatus() == JOB_STATUS.COMPLETED) {
1002 return job.getResults();
1003 } else if (job.getStatus() == JOB_STATUS.FAILED
1004 && job.getException() != null) {
1005 // throw the backend exception in the failed case
1006 Exception e = job.getException();
1007 int errCode = 1066;
1008 String msg = "Unable to open iterator for alias " + id
1009 + ". Backend error : " + e.getMessage();
1010 throw new FrontendException(msg, errCode, PigException.INPUT, e);
1011 } else {
1012 throw new IOException("Job terminated with anomalous status "
1013 + job.getStatus().toString());
1014 }
1015 } catch (FrontendException e) {
1016 throw e;
1017 } catch (Exception e) {
1018 int errCode = 1066;
1019 String msg = "Unable to open iterator for alias " + id;
1020 throw new FrontendException(msg, errCode, PigException.INPUT, e);
1021 }
1022 }
1023
1024 /**
1025 * Executes a Pig Latin script up to and including indicated alias and stores the resulting

Calls 10

storeMethod · 0.95
getTemporaryPathMethod · 0.95
getStatusMethod · 0.95
getResultsMethod · 0.95
getExceptionMethod · 0.95
setPropertyMethod · 0.65
getPropertiesMethod · 0.45
toStringMethod · 0.45
getMessageMethod · 0.45