Ejemplo n.º 1
0
  @Test
  public void testFilter19() throws Exception {
    System.out.println("testFilter19");

    PigServer pigServer = new PigServer(pigContext);

    pigServer.registerQuery(
        "G1 = load "
            + GalaxyPair3
            + " using PigStorage() as (objID1 : long, ra : float, dec : float, modelMag_u1 : float, modelMag_g1 : float, modelMag_r1 : float, modelMag_i1 : float, modelMag_z1 : float, petroR50_r1 : float, petrorad_u1 : float, petrorad_g1 : float, petrorad_r1 : float, petrorad_i1 : float, petrorad_z1 : float, petroRadErr_g1 : float, petroMag_g1 : float);");
    pigServer.registerQuery(
        "AG1 = filter G1 by petrorad_u1 > 0.0 and petrorad_g1 > 0.0 and petrorad_r1 > 0.0 and petrorad_i1 > 0.0 and petrorad_z1 > 0.0 and petroRadErr_g1 > 0.0 and petroMag_g1 >= 16.0 and  petroMag_g1 <= 21.0 and modelMag_u1 > -9999.0 and modelMag_g1 > -9999.0 and modelMag_r1 > -9999.0 and modelMag_i1 > -9999.0 and modelMag_z1 > -9999.0;");
    pigServer.registerQuery(
        "G2 = load "
            + GalaxyPair4
            + " using PigStorage() as (objID2 : long, ra : float, dec : float, modelMag_u2 : float, modelMag_g2 : float, modelMag_r2 : float, modelMag_i2 : float, modelMag_z2 : float, petroR50_r2 : float, petrorad_u2 : float, petrorad_g2 : float, petrorad_r2 : float, petrorad_i2 : float, petrorad_z2 : float, petroRadErr_g2: float, petroMag_g2 : float);");
    pigServer.registerQuery(
        "AG2 = filter G2 by petrorad_u2 > 0.0 and petrorad_g2 > 0.0 and petrorad_r2 > 0.0 and petrorad_i2 > 0.0 and petrorad_z2 > 0.0 and petroRadErr_g2 > 0.0;");
    Map<Operator, DataBag> derivedData = pigServer.getExamples2("AG1");
    Map<Operator, DataBag> derivedData2 = pigServer.getExamples2("AG2");

    assertTrue(derivedData != null);
    assertTrue(derivedData2 != null);
  } //
Ejemplo n.º 2
0
  // org.apache.pig.test.udf.storefunc.PigPerformanceLoader()
  @Test
  public void testScriptL1() throws Exception {
    System.out.println("testScriptL1");
    PigServer pigServer = new PigServer(pigContext);
    pigServer.setBatchOn();
    // pigServer.registerJar("/home/kaituo/code/pig3/trunk/pigperf.jar");
    pigServer.registerQuery(
        "A = load '"
            + page_viewsX.toString()
            + "/part-m-00000' using org.apache.pig.test.udf.storefunc.PigPerformanceLoader()  as (user: chararray, action:int, timespent:int, query_term:chararray, ip_addr:long, timestamp:long,estimated_revenue:double, page_info:map[], page_links:bag{t:(p:map[])});");
    // as (user, action, timespent, query_term, ip_addr, timestamp, estimated_revenue, page_info,
    // page_links);");
    pigServer.registerQuery(
        "B = foreach A generate user, action, page_info, flatten(page_links) as page_links;");
    // user, (int)action as action, (map[])page_info as page_info,
    // flatten((bag{tuple(map[])})page_links) as page_links;");
    pigServer.registerQuery(
        "C = foreach B generate user, (action == 1 ? page_info#'a' : page_links#'b') as header;");
    pigServer.registerQuery("D = group C by user parallel 40;");
    pigServer.registerQuery("E = foreach D generate group, COUNT(C) as cnt;");
    Map<Operator, DataBag> derivedData = pigServer.getExamples2("E");

    assertTrue(derivedData != null);
  }