Package org.apache.pig.pigunit

Examples of org.apache.pig.pigunit.PigTest


  }
 
  @Test
  public void comprehensiveBagSplitAndEnumerate() throws Exception
  {
    PigTest test = createPigTest("datafu/bags/comprehensiveBagSplitAndEnumerate.pig");
   
    writeLinesToFile("input",
                     "({(A,1.0),(B,2.0),(C,3.0),(D,4.0),(E,5.0)})");
   
    test.runScript();
   
    assertOutput(test, "data_out",
                 // bag #1
                 "(A,1.0,1)",
                 "(B,2.0,1)",
View Full Code Here


  }
 
  @Test
  public void aliasBagFieldsTest() throws Exception
  {
    PigTest test = createPigTest("datafu/bags/aliasBagFieldsTest.pig");
   
    writeLinesToFile("input",
                     "({(A,1,0),(B,2,0),(C,3,0),(D,4,0),(E,5,0)})");
   
    test.runScript();
   
    assertOutput(test, "data4",
                 "(A,1)",
                 "(B,2)",
                 "(C,3)",
View Full Code Here

  }

  @Test
  public void distinctByTest() throws Exception
  {
    PigTest test = createPigTest("datafu/bags/distinctByTest.pig");
   
    writeLinesToFile("input",
                     "({(Z,1,0),(A,1,0),(A,1,0),(B,2,0),(B,22,1),(C,3,0),(D,4,0),(E,5,0)})");
   
    test.runScript();
   
    assertOutput(test, "data2",
                 "({(Z,1,0),(A,1,0),(B,2,0),(C,3,0),(D,4,0),(E,5,0)})");
  }
View Full Code Here

public class SetTests extends PigTests
{
  @Test
  public void setIntersectTest() throws Exception
  {
    PigTest test = createPigTest("datafu/bags/sets/setIntersectTest.pig");
   
    String[] input = {
      "{(1,10),(2,20),(3,30),(4,40),(5,50),(6,60)}\t{(0,0),(2,20),(4,40),(8,80)}",
      "{(1,10),(1,10),(2,20),(3,30),(3,30),(4,40),(4,40)}\t{(1,10),(3,30)}"
    };
   
    String[] output = {
        "({(2,20),(4,40)})",
        "({(1,10),(3,30)})"
      };
   
    test.assertOutput("data",input,"data2",output);
  }
View Full Code Here

  }
 
  @Test
  public void setIntersectOutOfOrderTest() throws Exception
  {
    PigTest test = createPigTest("datafu/bags/sets/setIntersectTest.pig");
   
    this.writeLinesToFile("input",
                          "{(1,10),(3,30),(2,20),(4,40),(5,50),(6,60)}\t{(0,0),(2,20),(4,40),(8,80)}");
       
    test.runScript();
   
    this.getLinesForAlias(test, "data2");
  }
View Full Code Here

  }
 
  @Test
  public void setUnionTest() throws Exception
  {
    PigTest test = createPigTest("datafu/bags/sets/setUnionTest.pig");
   
    String[] input = {
        "{(1,10),(1,20),(1,30),(1,40),(1,50),(1,60),(1,80)}\t{(1,1),(1,20),(1,25),(1,25),(1,25),(1,40),(1,70),(1,80)}"
    };
   
    String[] output = {
        "({(1,10),(1,20),(1,30),(1,40),(1,50),(1,60),(1,80),(1,1),(1,25),(1,70)})"
      };
   
    test.assertOutput("data",input,"data2",output);
  }
View Full Code Here

public class GeoTests extends PigTests
{
  @Test
  public void haversineTest() throws Exception
  {   
    PigTest test = createPigTest("datafu/geo/haversineTest.pig");
   
    // Approximate latitude and longitude for major cities from maps.google.com
    double[] la = {34.040143,-118.243103};
    double[] tokyo = {35.637209,139.65271};
    double[] ny = {40.716038,-73.99498};
    double[] paris = {48.857713,2.342491};
    double[] sydney = {-33.872696,151.195221};
       
    this.writeLinesToFile("input",
                          coords(la,tokyo),
                          coords(ny,tokyo),
                          coords(ny,sydney),
                          coords(ny,paris));
   
    test.runScript();
   
    List<Tuple> distances = this.getLinesForAlias(test, "data2");
   
    // ensure distance is within 20 miles of expected (distances found online)
    assertWithin(5478.0, distances.get(0), 20.0); // la <-> tokyo
View Full Code Here

public class SessionTests extends PigTests
{
  @Test
  public void sessionizeTest() throws Exception
  {
    PigTest test = createPigTest("datafu/sessions/sessionizeTest.pig",
                                 "TIME_WINDOW=30m",
                                 "JAR_PATH=" + getJarPath());

    this.writeLinesToFile("input",
                          "2010-01-01T01:00:00Z\t1\t10",
                          "2010-01-01T01:15:00Z\t1\t20",
                          "2010-01-01T01:31:00Z\t1\t10",
                          "2010-01-01T01:35:00Z\t1\t20",
                          "2010-01-01T02:30:00Z\t1\t30",

                          "2010-01-01T01:00:00Z\t2\t10",
                          "2010-01-01T01:31:00Z\t2\t20",
                          "2010-01-01T02:10:00Z\t2\t30",
                          "2010-01-01T02:40:30Z\t2\t40",
                          "2010-01-01T03:30:00Z\t2\t50",

                          "2010-01-01T01:00:00Z\t3\t10",
                          "2010-01-01T01:01:00Z\t3\t20",
                          "2010-01-01T01:02:00Z\t3\t5",
                          "2010-01-01T01:10:00Z\t3\t25",
                          "2010-01-01T01:15:00Z\t3\t50",
                          "2010-01-01T01:25:00Z\t3\t30",
                          "2010-01-01T01:30:00Z\t3\t15");
   
    test.runScript();
   
    HashMap<Integer,HashMap<Integer,Boolean>> userValues = new HashMap<Integer,HashMap<Integer,Boolean>>();
   
    for (Tuple t : this.getLinesForAlias(test, "max_value"))
    {
View Full Code Here

                        "n=3",
                        "reducers=1",
                        "input=top_queries_input_data.txt",
                        "output=top_3_queries",
        };
        test = new PigTest(PIG_SCRIPT, args);

        String[] output = {
                        "(yahoo,25)",
                        "(facebook,15)",
                        "(twitter,7)",
View Full Code Here

                        "n=3",
                        "reducers=1",
                        "input=top_queries_input_data.txt",
                        "output=top_3_queries",
        };
        test = new PigTest(PIG_SCRIPT, args);

        String[] output = {
                        "(yahoo,25)",
                        "(facebook,15)",
                        "(twitter,7)",
View Full Code Here

TOP

Related Classes of org.apache.pig.pigunit.PigTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.