Attachment 'idhadoop.java'

Download

   1 import java.io.IOException;
   2 
   3 import org.apache.pig.PigServer;
   4 
   5 
   6 
   7 public class idhadoop {
   8    
   9    public static void main(String[] args) {
  10 
  11    
  12    try {
  13       
  14      PigServer pigServer = new PigServer("mapreduce");
  15       
  16      runIdQuery(pigServer, "passwd");
  17    
  18    }
  19 
  20    
  21    catch(Exception e) {
  22    
  23    }
  24  
  25 }
  26 
  27 
  28 
  29 public static void runIdQuery(PigServer pigServer, String inputFile) throws IOException {
  30    
  31    pigServer.registerQuery("A = load '" + inputFile + "' using PigStorage(':');");
  32        
  33    pigServer.registerQuery("B = foreach A generate $0 as id;");
  34        
  35    pigServer.store("B", "idout");
  36    
  37    }
  38 
  39 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.