Author: olga
Date: Wed Apr  8 01:27:31 2009
New Revision: 763072

URL: http://svn.apache.org/viewvc?rev=763072&view=rev
Log:
PIG-627: merge from trunk to branch

Added:
    
hadoop/pig/branches/multiquery/src/org/apache/pig/tools/grunt/PigCompletorAliases.java
      - copied unchanged from r763050, 
hadoop/pig/trunk/src/org/apache/pig/tools/grunt/PigCompletorAliases.java
    
hadoop/pig/branches/multiquery/src/org/apache/pig/tools/grunt/autocomplete_aliases
      - copied unchanged from r763050, 
hadoop/pig/trunk/src/org/apache/pig/tools/grunt/autocomplete_aliases
Modified:
    hadoop/pig/branches/multiquery/   (props changed)
    hadoop/pig/branches/multiquery/CHANGES.txt
    hadoop/pig/branches/multiquery/KEYS
    hadoop/pig/branches/multiquery/README.txt
    hadoop/pig/branches/multiquery/RELEASE_NOTES.txt
    hadoop/pig/branches/multiquery/build.xml
    hadoop/pig/branches/multiquery/src/org/apache/pig/Main.java
    hadoop/pig/branches/multiquery/src/org/apache/pig/PigServer.java
    hadoop/pig/branches/multiquery/src/org/apache/pig/tools/grunt/Grunt.java
    
hadoop/pig/branches/multiquery/src/org/apache/pig/tools/grunt/PigCompletor.java
    
hadoop/pig/branches/multiquery/test/org/apache/pig/test/utils/dotGraph/DOTParser.jjt
   (props changed)

Propchange: hadoop/pig/branches/multiquery/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Apr  8 01:27:31 2009
@@ -1 +1 @@
-/hadoop/pig/trunk:741728-758069
+/hadoop/pig/trunk:741728-763050

Modified: hadoop/pig/branches/multiquery/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/CHANGES.txt?rev=763072&r1=763071&r2=763072&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/CHANGES.txt (original)
+++ hadoop/pig/branches/multiquery/CHANGES.txt Wed Apr  8 01:27:31 2009
@@ -34,7 +34,7 @@
 PIG-725: javadoc: warning - Multiple sources of package comments found for
 package "org.apache.commons.logging" (gkesavan via sms)
 
-Release 1.0.0 - Unreleased
+Release 0.2.0 - Unreleased
 
 INCOMPATIBLE CHANGES
 
@@ -53,6 +53,9 @@
        Changed semantics of DEFINE to define last used alias if no argument is
        given (ericg via gates).
 
+       PIG-713 Added alias completion as part of tab completion in grunt (ericg
+       via gates).
+
 IMPROVEMENTS
 
     PIG-270: proper line number for parse errors (daijy via olgan)

Modified: hadoop/pig/branches/multiquery/KEYS
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/KEYS?rev=763072&r1=763071&r2=763072&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/KEYS (original)
+++ hadoop/pig/branches/multiquery/KEYS Wed Apr  8 01:27:31 2009
@@ -27,3 +27,27 @@
 LMYTpbXVonowdEk4YL45jQCfY2/fXDhD2IwYB+PGmdcsWeEv10Y=
 =WLZG
 -----END PGP PUBLIC KEY BLOCK-----
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v1.2.6 (GNU/Linux)
+
+mQGiBEnNUFYRBACdB2/nTuzObFu/B6dqTo301jF0BiD0J4Nl1qz9cP5IwrJArCzw
+BQGSzN5UX0gKTpi9FWzXPWrc/On3jAk65q9FgkUTbKQqwtRK2UUjD7GpsMiryIBx
+3+f1d8MEkOsFVg+bOzKqIY2VbvksM3GElCusKaWTZpgdsY27UkdHZIj/3wCg4Qq4
+ftOTc25XTEPNgAiAE8kO5qcD/27pjtQu3nzA47VdAvWGNAiNjdwsan/bWUUAvl81
+XmQ0GHlo9D0iyOd2GX9WHuguZ4/tf203f0oOHmgvYFllsF6OttBTIfd57HXyrdQd
+VuI8JuKxqM0FYaQkDKNseJZH1X80d604IOWWPVcxPs0Aqdcw1F9e6e5XUPqkBXye
+6IKeA/9YxJpY5QFb4EP/AyyGjIj1CsmukwBHJ+fNKribdyY5YgaX0THAjXlYLRmC
+HZugmtVIF71EiDutHfq9RPiLP1O13nh3zapo9MD9CrqJqPE7SavGSQ+l1Tnedp6Y
+UGWffmL7e0XBCSvB3QKf+ZxOLIK2s72Wl5Mwd6gfBEdcBxBqsLQtQWxhbiBHYXRl
+cyAoTm8gY29tbWVudCkgPGdhdGVzQHlhaG9vLWluYy5jb20+iF4EExECAB4FAknN
+UFYCGwMGCwkIBwMCAxUCAwMWAgECHgECF4AACgkQiL0/VwTZuDLWUACfWFyJwm6D
+oAW88ITpvypdOtRakYsAoM22YGm4jla+y9lryous9eIHNu1VuQENBEnNUFgQBADK
+2OL+zY/4V80Bans/v0sRf8cUzB82eW84vMgxRmMS+Kwty8CBwEV4sgWbv0vJwifo
+9ZhlMLjqmBwGTR3wIXqtRQAyk8rLYod31KWFyt64vZaubbxZNDxiM5CMFO+q3xjL
+hbsMnIC/QliKT2d0K2radTp+jNz7lOkmSvZ9iQ7/0wADBgP/TWsRYmViLcUcOa1N
+4Cij8Y3c1tD2qYI5b9eDY5GiOeECss0CudJN/cIvDNstLtLa4JbX5INRpskVTVsx
+Duermrsj5/tONUb9GwBnhUuzA0GW1WCkpZXJG2Z2iwKcJ8wQ5KaPj9TNdahF5h7q
+outJyNeVe9TC2PytS0tfCzd2lnOISQQYEQIACQUCSc1QWAIbDAAKCRCIvT9XBNm4
+MrvDAJ4ySDj+5CSCB+DQ8PotTK5oX7fDcQCfc0d5dQrqc2ul8/4WDB/LmNcXuhI=
+=B5eJ
+-----END PGP PUBLIC KEY BLOCK-----

Modified: hadoop/pig/branches/multiquery/README.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/README.txt?rev=763072&r1=763071&r2=763072&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/README.txt (original)
+++ hadoop/pig/branches/multiquery/README.txt Wed Apr  8 01:27:31 2009
@@ -17,7 +17,7 @@
 
 For the latest information about Pig, please visit our website at:
 
-   http://incubator.apache.org/pig/
+   http://hadoop.apache.org/pig/
 
 and our wiki, at:
 
@@ -37,14 +37,3 @@
 We welcome all contributions. For the details, please, visit
 http://wiki.apache.org/pig/HowToContribute.
 
-Incubator Disclaimer
-=====================
-
-Apache Pig is an effort undergoing incubation at The Apache Software
-Foundation (ASF). Incubation is required of all newly accepted projects 
-until a further review indicates that the infrastructure, communications, 
-and decision making process have stabilized in a manner consistent with 
-other successful ASF projects. While incubation status is not necessarily
-a reflection of the completeness or stability of the code, it does indicate
-that the project has yet to be fully endorsed by the ASF.
-

Modified: hadoop/pig/branches/multiquery/RELEASE_NOTES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/RELEASE_NOTES.txt?rev=763072&r1=763071&r2=763072&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/RELEASE_NOTES.txt (original)
+++ hadoop/pig/branches/multiquery/RELEASE_NOTES.txt Wed Apr  8 01:27:31 2009
@@ -1,4 +1,4 @@
-This notes are for Pig 1.0.0 release.
+These notes are for Pig 0.2.0 release.
 
 Highlights
 ==========
@@ -12,15 +12,15 @@
 1. Java 1.6.x or newer, preferably from Sun. Set JAVA_HOME to the root of your
 Java installation
 2. Ant build tool:  http://ant.apache.org - to build source only
-3. Sigwin: http://www.cygwin.com/ - to run under windows 
+3. Cygwin: http://www.cygwin.com/ - to run under Windows 
 4. This release is compatible with Hadoop 0.18.x releases
 
 Trying the Release
 ==================
 
-1. Download pig-1.0.0.tar.gz
-2. Unpack the file: tar -xzvf pig-1.0.0.tar.gz
-3. Move into the installation directory: cd pig-1.0.0
+1. Download pig-0.2.0.tar.gz
+2. Unpack the file: tar -xzvf pig-0.2.0.tar.gz
+3. Move into the installation directory: cd pig-0.2.0
 4. To run pig without Hadoop cluster, execute the command below. This will
 take you into an interactive shell called grunt that allows you to navigate
 the local file system and execute Pig commands against the local files
@@ -47,8 +47,9 @@
 Relevant Documentation
 ======================
 
-Pig Language Manual(including Grant commands):
+Pig Language Manual(including Grunt commands):
 http://wiki.apache.org/pig-data/attachments/FrontPage/attachments/plrm.htm 
 UDF Manual: http://wiki.apache.org/pig/UDFManual
 Piggy Bank: http://wiki.apache.org/pig/PiggyBank
 Pig Tutorial: http://wiki.apache.org/pig/PigTutorial
+Pig Eclipse Plugin (PigPen):  http://wiki.apache.org/pig/PigPen

Modified: hadoop/pig/branches/multiquery/build.xml
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/build.xml?rev=763072&r1=763071&r2=763072&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/build.xml (original)
+++ hadoop/pig/branches/multiquery/build.xml Wed Apr  8 01:27:31 2009
@@ -25,7 +25,7 @@
     <!-- name and version properties -->
     <property name="name" value="pig" />
     <property name="Name" value="Pig" />
-    <property name="version" value="1.0.1-dev" />
+    <property name="version" value="0.3.0-dev" />
     <property name="final.name" value="${name}-${version}" />
     <condition property="isWindows">
         <os family="windows"/>
@@ -255,6 +255,7 @@
                <classpath refid="${cp}" />
         </javac>
         <copy file="${src.dir}/org/apache/pig/tools/grunt/autocomplete" 
todir="${build.classes}/org/apache/pig/tools/grunt"/>
+        <copy 
file="${src.dir}/org/apache/pig/tools/grunt/autocomplete_aliases" 
todir="${build.classes}/org/apache/pig/tools/grunt"/>
     </target>
         
     <!-- this target is for compilation with all warnings enabled -->

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/Main.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/Main.java?rev=763072&r1=763071&r2=763072&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/Main.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/Main.java Wed Apr  8 
01:27:31 2009
@@ -39,7 +39,6 @@
 import org.apache.pig.impl.util.PropertiesUtil;
 import org.apache.pig.tools.cmdline.CmdLineParser;
 import org.apache.pig.tools.grunt.Grunt;
-import org.apache.pig.tools.grunt.PigCompletor;
 import org.apache.pig.impl.util.LogUtils;
 import org.apache.pig.tools.timer.PerformanceTimerFactory;
 import org.apache.pig.tools.parameters.ParameterSubstitutionPreprocessor;
@@ -317,7 +316,6 @@
             // Interactive
             mode = ExecMode.SHELL;
             ConsoleReader reader = new ConsoleReader(System.in, new 
OutputStreamWriter(System.out));
-            reader.addCompletor(new PigCompletor());
             reader.setDefaultPrompt("grunt> ");
             final String HISTORYFILE = ".pig_history";
             String historyFile = System.getProperty("user.home") + 
File.separator  + HISTORYFILE;

Modified: hadoop/pig/branches/multiquery/src/org/apache/pig/PigServer.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/PigServer.java?rev=763072&r1=763071&r2=763072&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/PigServer.java (original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/PigServer.java Wed Apr  8 
01:27:31 2009
@@ -35,7 +35,6 @@
 import java.util.Properties;
 import java.util.Set;
 import java.util.Stack;
-
 import org.apache.pig.impl.plan.PlanException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -687,6 +686,10 @@
         // pigContext.getExecutionEngine().reclaimScope(this.scope);
     }
 
+    public Set<String> getAliasKeySet() {
+        return currDAG.getAliasOp().keySet();
+    }
+
     public Map<LogicalOperator, DataBag> getExamples(String alias) {
         LogicalPlan plan = null;
         try {

Modified: 
hadoop/pig/branches/multiquery/src/org/apache/pig/tools/grunt/Grunt.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/tools/grunt/Grunt.java?rev=763072&r1=763071&r2=763072&view=diff
==============================================================================
--- hadoop/pig/branches/multiquery/src/org/apache/pig/tools/grunt/Grunt.java 
(original)
+++ hadoop/pig/branches/multiquery/src/org/apache/pig/tools/grunt/Grunt.java 
Wed Apr  8 01:27:31 2009
@@ -25,12 +25,15 @@
 import java.io.FileOutputStream;
 
 import jline.ConsoleReader;
+import jline.Completor;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pig.PigServer;
 import org.apache.pig.impl.PigContext;
 import org.apache.pig.tools.grunt.GruntParser;
+import org.apache.pig.tools.grunt.PigCompletor;
+import org.apache.pig.tools.grunt.PigCompletorAliases;
 import org.apache.pig.PigException;
 import org.apache.pig.backend.executionengine.ExecException;
 import org.apache.pig.tools.pigscript.parser.*;
@@ -59,8 +62,11 @@
 
     public void setConsoleReader(ConsoleReader c)
     {
+        c.addCompletor(new PigCompletorAliases(pig));
+        c.addCompletor(new PigCompletor());
         parser.setConsoleReader(c);
     }
+
     public void run() {        
         boolean verbose = 
"true".equalsIgnoreCase(pig.getPigContext().getProperties().getProperty("verbose"));
         while(true) {

Modified: 
hadoop/pig/branches/multiquery/src/org/apache/pig/tools/grunt/PigCompletor.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/multiquery/src/org/apache/pig/tools/grunt/PigCompletor.java?rev=763072&r1=763071&r2=763072&view=diff
==============================================================================
--- 
hadoop/pig/branches/multiquery/src/org/apache/pig/tools/grunt/PigCompletor.java 
(original)
+++ 
hadoop/pig/branches/multiquery/src/org/apache/pig/tools/grunt/PigCompletor.java 
Wed Apr  8 01:27:31 2009
@@ -50,16 +50,12 @@
             try
             {
                 keywordStream = new FileInputStream(AUTOCOMPLETE_FILENAME);
+                PigCompletor.loadCandidateKeywords(keywordStream, candidates);
             }
             catch (FileNotFoundException e)
             {
                 log.debug("Can not find autocomplete file in current 
directory, skipped");
             }
-            if (keywordStream!=null)
-            {
-                processKeywordStream(keywordStream);
-                keywordStream.close();
-            }
             
             // try to find all keyword file in CLASSPATH
             Enumeration<URL> itr = 
getClass().getClassLoader().getResources(AUTOCOMPLETE_FILENAME);
@@ -67,30 +63,25 @@
             {
                 URL url = itr.nextElement();
                 keywordStream = url.openStream();
-                if (keywordStream!=null)
-                {
-                    processKeywordStream(keywordStream);
-                    keywordStream.close();
-                }
-                else
+                if (!PigCompletor.loadCandidateKeywords(keywordStream, 
candidates))
                     log.debug("Error loading " + url + ", skipped");
             }
             
             // try to use default keyword file
             keywordStream = 
getClass().getResourceAsStream("/org/apache/pig/tools/grunt/autocomplete");
-            if (keywordStream!=null)
-            {
-                processKeywordStream(keywordStream);
-                keywordStream.close();
+            PigCompletor.loadCandidateKeywords(keywordStream, candidates);
             }
-        }
         catch (IOException e) {
             log.warn("Error occurs when reading internal autocomplete file, 
skipped");
         }
     }
 
-    private void processKeywordStream(InputStream stream) throws IOException
+    public static boolean loadCandidateKeywords(InputStream stream, 
Set<String> candidates)
+    throws IOException
     {
+        if (stream==null)
+          return false;
+
         BufferedReader reader = new BufferedReader(new 
InputStreamReader(stream));
         String line;
         while ((line=reader.readLine())!=null)
@@ -99,28 +90,18 @@
             {
                 line = line.trim();
                 if (!line.equals(""))
-                    addCandidateString(line);
+                    candidates.add(line);
             }
                 
         }
         reader.close();
-    }
-
-    public void addCandidateString(final String candidateString) {
-        for (int i=0;i<candidateString.length();i++)
-        {
-            if (isDelimit(candidateString.charAt(i)))
-            {
-                log.warn("Auto-complete keyword \"" + candidateString + "\" is 
skipped because it contains white spaces");
-                return;
-            }
-        }
-        candidates.add(candidateString);
+        stream.close();
+        return true;
     }
 
     public int complete(String buffer, int cursor, List candidates) {
         if (cursor == 0)
-            return 0;
+            return -1;
         int p = cursor;
         p--;
         while (p > 0) {
@@ -138,12 +119,17 @@
         if (!sb.toString().equals("")) {
             List<String> matches = searchCandidate(sb.toString());
             if (matches != null) {
+                if(matches.size()==1) {
+                    candidates.add(matches.get(0)+" ");
+                }
+                else {
                 for (String match:matches)
                     candidates.add(match);
+                }
                 return p;
             }
         }
-        return 0;
+        return -1;
     }
 
     private boolean isDelimit(char c) {
@@ -155,7 +141,7 @@
     private List<String> searchCandidate(String s) {
         List<String> list = new ArrayList<String>();
         for (String can : candidates) {
-            if (can.startsWith(s) && !can.equals(s))
+            if (can.startsWith(s))
                 list.add(can);
         }
         return list;

Propchange: 
hadoop/pig/branches/multiquery/test/org/apache/pig/test/utils/dotGraph/DOTParser.jjt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Apr  8 01:27:31 2009
@@ -0,0 +1 @@
+/hadoop/pig/trunk/test/org/apache/pig/test/utils/dotGraph/DOTParser.jjt:758070-763050


Reply via email to