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

Method registerQuery

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

Accumulate the given statement to previous query statements and generate an overall (raw) plan.

(String query, int startLine, boolean validateEachStatement,
                boolean skipParseForBatch)

Source from the content-addressed store, hash-verified

1736 * an overall (raw) plan.
1737 */
1738 void registerQuery(String query, int startLine, boolean validateEachStatement,
1739 boolean skipParseForBatch) throws IOException {
1740 if( batchMode ) {
1741 if( startLine == currentLineNum ) {
1742 String line = scriptCache.remove( scriptCache.size() - 1 );
1743 scriptCache.add( line + query );
1744 } else {
1745 while( startLine > currentLineNum + 1 ) {
1746 scriptCache.add( "" );
1747 currentLineNum++;
1748 }
1749 BufferedReader br = new BufferedReader(new StringReader(query));
1750 String line = br.readLine();
1751 while (line != null) {
1752 scriptCache.add(line);
1753 currentLineNum++;
1754 line = br.readLine();
1755 }
1756 }
1757 if (skipParseForBatch) {
1758 return;
1759 }
1760 } else {
1761 scriptCache.add( query );
1762 }
1763
1764 if(validateEachStatement){
1765 validateQuery();
1766 }
1767 parseQuery();
1768
1769 if( !batchMode ) {
1770 buildPlan( null );
1771 for( Operator sink : lp.getSinks() ) {
1772 if( sink instanceof LOStore ) {
1773 try {
1774 execute();
1775 } catch (Exception e) {
1776 int errCode = 1002;
1777 String msg = "Unable to store alias "
1778 + ((LOStore) sink).getAlias();
1779 throw new FrontendException(msg, errCode,
1780 PigException.INPUT, e);
1781 }
1782 break; // We should have at most one store, so break here.
1783 }
1784 }
1785 }
1786 }
1787
1788 private void validateQuery() throws FrontendException {
1789 String query = buildQuery();

Callers 1

duplicateMethod · 0.95

Calls 10

validateQueryMethod · 0.95
parseQueryMethod · 0.95
buildPlanMethod · 0.95
removeMethod · 0.65
sizeMethod · 0.65
addMethod · 0.65
getSinksMethod · 0.65
getAliasMethod · 0.65
readLineMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected