コード例 #1
0
 @Test(expected = TupleMRException.class)
 public void testRollupNeedsExplicitSortBy() throws TupleMRException {
   TupleMRConfigBuilder b = new TupleMRConfigBuilder();
   b.addIntermediateSchema(new Schema("schema1", Fields.parse("a:int,b:string")));
   b.setGroupByFields("b", "a");
   b.setRollupFrom("a");
   b.buildConf();
 }
コード例 #2
0
 @Test(expected = TupleMRException.class)
 public void testRollupPrefixGroupBy() throws TupleMRException {
   TupleMRConfigBuilder b = new TupleMRConfigBuilder();
   b.addIntermediateSchema(new Schema("schema1", Fields.parse("a:int,b:string")));
   b.setGroupByFields("b");
   b.setOrderBy(new OrderBy().add("b", Order.DESC));
   b.setRollupFrom(null);
   b.buildConf();
 }
コード例 #3
0
  @Test
  public void testExtended() throws TupleMRException, IOException {
    TupleMRConfigBuilder b = new TupleMRConfigBuilder();
    b.addIntermediateSchema(schema1);
    b.addIntermediateSchema(schema2);
    b.addIntermediateSchema(schema3);
    b.setGroupByFields("int_field");
    b.setOrderBy(
        new OrderBy()
            .add("int_field", Order.DESC)
            .addSchemaOrder(Order.DESC)
            .add("boolean_field", Order.DESC));
    b.setRollupFrom("int_field");
    b.setSpecificOrderBy(
        schema3.getName(),
        new OrderBy()
            .add(
                "thrift_field",
                Order.ASC,
                Criteria.NullOrder.NULL_SMALLEST,
                new DummyComparator()));

    TupleMRConfig conf = b.buildConf();
    Configuration hconf = new Configuration();

    TupleMRConfig.set(conf, hconf);
    TupleMRConfig deserConf = TupleMRConfig.get(hconf);
    System.out.println(conf);
    System.out.println("------------");
    System.out.println(deserConf);

    Assert.assertEquals(conf, deserConf);
    hconf = new Configuration();
    TupleMRConfig.set(deserConf, hconf);
    TupleMRConfig deserConf2 = TupleMRConfig.get(hconf);
    Assert.assertEquals(conf, deserConf2);
  }
コード例 #4
0
  @Test
  public void testWithCustomPartitionFields() throws TupleMRException, IOException {
    TupleMRConfigBuilder b = new TupleMRConfigBuilder();
    b.addIntermediateSchema(schema1);
    b.addIntermediateSchema(schema2);
    b.addIntermediateSchema(schema3);
    b.setGroupByFields("int_field");
    b.setOrderBy(
        new OrderBy()
            .add("int_field", Order.DESC)
            .addSchemaOrder(Order.DESC)
            .add("boolean_field", Order.DESC));
    b.setRollupFrom("int_field");
    b.setSpecificOrderBy(schema3.getName(), new OrderBy().add("thrift_field", Order.ASC));
    b.setCustomPartitionFields("int_field", "boolean_field");

    TupleMRConfig conf = b.buildConf();
    TupleMRConfig deserConf = TupleMRConfig.parse(conf.toString());
    Assert.assertEquals(conf, deserConf);
    TupleMRConfig deserConf2 = TupleMRConfig.parse(deserConf.toString());
    Assert.assertEquals(conf, deserConf2);
    System.out.println(conf);
    System.out.println(deserConf2);
  }