@Test
  public void testAliases1() throws TupleMRException {
    TupleMRConfigBuilder b = new TupleMRConfigBuilder();
    b.addIntermediateSchema(
        new Schema("schema1", Fields.parse("ax:int,bx:string,cx:string,blablax:string,p2:string")));
    b.addIntermediateSchema(
        new Schema("schema2", Fields.parse("ay:int,cy:string,by:string,blobloy:string,p:string")));
    {
      Aliases aliases1 = new Aliases();
      aliases1.add("a", "ax");
      aliases1.add("b", "bx");
      aliases1.add("c", "cx");
      aliases1.add("blabla", "blablax");
      aliases1.add("p", "p2");
      b.setFieldAliases("schema1", aliases1);
    }
    {
      Aliases aliases2 = new Aliases();
      aliases2.add("a", "ay");
      aliases2.add("b", "by");
      aliases2.add("c", "cy");
      aliases2.add("bloblo", "blobloy");
      b.setFieldAliases("schema2", aliases2);
    }

    b.setGroupByFields("c", "b");
    b.setOrderBy(
        new OrderBy()
            .add("b", Order.ASC)
            .add("c", Order.DESC)
            .addSchemaOrder(Order.DESC)
            .add("a", Order.DESC));
    b.setSpecificOrderBy("schema1", new OrderBy().add("blabla", Order.DESC));
    b.setCustomPartitionFields("p");
    TupleMRConfig config = b.buildConf();
    SerializationInfo serInfo = config.getSerializationInfo();
    System.out.println(serInfo.getCommonSchema());
    System.out.println(serInfo.getPartitionFieldsIndexes());

    {
      List<SortElement> expectedCommon = new ArrayList<SortElement>();
      expectedCommon.add(new SortElement("b", Order.ASC, Criteria.NullOrder.NULL_SMALLEST));
      expectedCommon.add(new SortElement("c", Order.DESC, Criteria.NullOrder.NULL_SMALLEST));
      Assert.assertEquals(new Criteria(expectedCommon), config.getCommonCriteria());
    }
    {
      List<SortElement> expectedSchema1 = new ArrayList<SortElement>();
      expectedSchema1.add(new SortElement("a", Order.DESC, Criteria.NullOrder.NULL_SMALLEST));
      expectedSchema1.add(new SortElement("blabla", Order.DESC, Criteria.NullOrder.NULL_SMALLEST));
      Assert.assertEquals(new Criteria(expectedSchema1), config.getSpecificOrderBys().get(0));
    }
    {
      List<SortElement> expectedSchema2 = new ArrayList<SortElement>();
      expectedSchema2.add(new SortElement("a", Order.DESC, Criteria.NullOrder.NULL_SMALLEST));
      Assert.assertEquals(new Criteria(expectedSchema2), config.getSpecificOrderBys().get(1));
    }
  }
 @Test
 public void testCustomPartition() throws TupleMRException {
   TupleMRConfigBuilder b = new TupleMRConfigBuilder();
   b.addIntermediateSchema(new Schema("schema1", Fields.parse("a:int,b:string")));
   b.addIntermediateSchema(new Schema("schema2", Fields.parse("b:string,a:int")));
   b.setGroupByFields("a");
   b.setOrderBy(new OrderBy().add("a", Order.ASC));
   b.setCustomPartitionFields("b");
   TupleMRConfig config = b.buildConf();
   System.out.println(config);
   SerializationInfo serInfo = config.getSerializationInfo();
   int[] indexes0 = serInfo.getFieldsToPartition(0);
   int[] indexes1 = serInfo.getFieldsToPartition(1);
   Assert.assertArrayEquals(new int[] {1}, indexes0);
   Assert.assertArrayEquals(new int[] {0}, indexes1);
 }
 /** {@inheritDoc} */
 @Override
 @SuppressWarnings({"unchecked", "rawtypes"})
 public void send(DataOutput stream, T packet) {
   try {
     Class<? extends Packet> iFace = packet.getPacketType();
     List<SerializationInfo> serInfos = getSerializationInfos(iFace);
     /*
      * dirty: we have to have "getProperty()" to get "property"
      */
     ListIterator<SerializationInfo> iterator = serInfos.listIterator();
     while (iterator.hasNext()) {
       SerializationInfo now = iterator.next();
       Method getter = iFace.getMethod(toMethodName(now.getName()));
       Serializor serializor = now.getSerialize().type().getSerializor();
       serializor.write(stream, getter.invoke(packet));
     }
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }