Package org.apache.hadoop.zebra.types

Examples of org.apache.hadoop.zebra.types.Partition$PartitionInfo$PartitionFieldInfo


  @Test
  public void testStorageValid1() {
    try {
      String strStorage = "[m1#{k1}]; [m2#{k1}, f3]";
      Partition p = new Partition(schema.toString(), strStorage);
      CGSchema[] cgschemas = p.getCGSchemas();

      // 3 column group;
      int size = cgschemas.length;
      Assert.assertEquals(size, 3);
      System.out.println("********** Column Groups **********");
      for (int i = 0; i < cgschemas.length; i++) {
        System.out.println(cgschemas[i]);
        System.out.println("--------------------------------");
      }
      CGSchema cgs1 = cgschemas[0];
      CGSchema cgs2 = cgschemas[1];
      CGSchema cgs3 = cgschemas[2];

      ColumnSchema f11 = cgs1.getSchema().getColumn(0);
      Assert.assertEquals(f11.name, "m1");
      Assert.assertEquals(ColumnType.MAP, f11.type);

      ColumnSchema f21 = cgs2.getSchema().getColumn(0);
      Assert.assertEquals(f21.name, "m2");
      // TODO: type should be MAP!
      Assert.assertEquals(ColumnType.MAP, f21.type);

      ColumnSchema f22 = cgs2.getSchema().getColumn(1);
      Assert.assertEquals(f22.name, "f3");
      Assert.assertEquals(ColumnType.INT, f22.type);
      ColumnSchema f31 = cgs3.getSchema().getColumn(0);
      Assert.assertEquals(f31.name, "m1");
      Assert.assertEquals(ColumnType.MAP, f31.type);
      ColumnSchema f32 = cgs3.getSchema().getColumn(1);
      Assert.assertEquals(f32.name, "m2");
      Assert.assertEquals(ColumnType.MAP, f32.type);

      System.out.println("*********** Column Map **********");
      Map<String, HashSet<Partition.PartitionInfo.ColumnMappingEntry>> colmap = p
          .getPartitionInfo().getColMap();
      Assert.assertEquals(colmap.size(), 3);
      Iterator<Map.Entry<String, HashSet<Partition.PartitionInfo.ColumnMappingEntry>>> it = colmap
          .entrySet().iterator();
      for (int i = 0; i < colmap.size(); i++) {
View Full Code Here


  @Test
  public void testStorageValid2() {
    try {
      String strStorage = "[m1#{k1}]; [m1#{k2}, f3]";
      Partition p = new Partition(schema.toString(), strStorage);
      CGSchema[] cgschemas = p.getCGSchemas();

      // 3 column group;
      int size = cgschemas.length;
      Assert.assertEquals(size, 3);
      System.out.println("********** Column Groups **********");
      for (int i = 0; i < cgschemas.length; i++) {
        System.out.println(cgschemas[i]);
        System.out.println("--------------------------------");
      }
      CGSchema cgs1 = cgschemas[0];
      CGSchema cgs2 = cgschemas[1];
      CGSchema cgs3 = cgschemas[2];

      ColumnSchema f11 = cgs1.getSchema().getColumn(0);
      Assert.assertEquals(f11.name, "m1");
      Assert.assertEquals(ColumnType.MAP, f11.type);
      ColumnSchema f21 = cgs2.getSchema().getColumn(0);
      Assert.assertEquals(f21.name, "m1");
      Assert.assertEquals(ColumnType.MAP, f21.type);
      ColumnSchema f22 = cgs2.getSchema().getColumn(1);
      Assert.assertEquals(f22.name, "f3");
      Assert.assertEquals(ColumnType.INT, f22.type);
      ColumnSchema f31 = cgs3.getSchema().getColumn(0);
      Assert.assertEquals(f31.name, "m1");
      Assert.assertEquals(ColumnType.MAP, f31.type);
      ColumnSchema f32 = cgs3.getSchema().getColumn(1);
      Assert.assertEquals(f32.name, "m2");
      Assert.assertEquals(ColumnType.MAP, f32.type);

      System.out.println("*********** Column Map **********");
      Map<String, HashSet<Partition.PartitionInfo.ColumnMappingEntry>> colmap = p
          .getPartitionInfo().getColMap();
      Assert.assertEquals(colmap.size(), 3);
      Iterator<Map.Entry<String, HashSet<Partition.PartitionInfo.ColumnMappingEntry>>> it = colmap
          .entrySet().iterator();
      for (int i = 0; i < colmap.size(); i++) {
View Full Code Here

  @Test
  public void testStorageInvalid1() {
    try {
      String strStorage = "m1#{k1}";
      Partition p = new Partition(schema.toString(), strStorage);
      CGSchema[] cgschemas = p.getCGSchemas();
      CGSchema cgs1 = cgschemas[0];
      System.out.println(cgs1);
    } catch (Exception e) {
      String errMsg = e.getMessage();
      String str = "Encountered \" <IDENTIFIER> \"m1 \"\" at line 1, column 1.";
View Full Code Here

  @Test
  public void testStorageInvalid2() {
    try {
      String strStorage = "[m1#{k1}] abc; [m1#{k2}, f3] xyz";
      Partition p = new Partition(schema.toString(), strStorage);
      CGSchema[] cgschemas = p.getCGSchemas();
      CGSchema cgs1 = cgschemas[0];
      System.out.println(cgs1);
    } catch (Exception e) {
      String errMsg = e.getMessage();
      String str = "Encountered \" <IDENTIFIER> \"abc \"\" at line 1, column 11.";
View Full Code Here

  @Test
  public void testStorageInvalid3() {
    try {
      String strStorage = "[m1{#k1}{#k2}]";
      Partition p = new Partition(schema.toString(), strStorage);
      CGSchema[] cgschemas = p.getCGSchemas();
      CGSchema cgs1 = cgschemas[0];
      System.out.println(cgs1);
    } catch (Exception e) {
      String errMsg = e.getMessage();
      String str = "Encountered \" \"[\" \"[ \"\" at line 1, column 1.";
View Full Code Here

  @Test
  public void testStorageValid1() {
    try {
      String strStorage = "[c] compress by gzip; [m1] serialize by avro";
      Partition p = new Partition(schema.toString(), strStorage);
      CGSchema[] cgschemas = p.getCGSchemas();

      // 2 column group;
      int size = cgschemas.length;
      Assert.assertEquals(size, 2);
      System.out.println("********** Column Groups **********");
      for (int i = 0; i < cgschemas.length; i++) {
        System.out.println(cgschemas[i]);
        System.out.println("--------------------------------");
      }
      CGSchema cgs1 = cgschemas[0];
      CGSchema cgs2 = cgschemas[1];

      ColumnSchema f11 = cgs1.getSchema().getColumn(0);
      Assert.assertEquals("c", f11.name);
      Assert.assertEquals(ColumnType.COLLECTION, f11.type);

      ColumnSchema f21 = cgs2.getSchema().getColumn(0);
      Assert.assertEquals("m1", f21.name);
      Assert.assertEquals(ColumnType.MAP, f21.type);

      Assert.assertEquals(cgs1.getCompressor(), "gzip");
      Assert.assertEquals(cgs2.getSerializer(), "avro");

      System.out.println("*********** Column Map **********");
      Map<String, HashSet<Partition.PartitionInfo.ColumnMappingEntry>> colmap = p
          .getPartitionInfo().getColMap();
      Assert.assertEquals(colmap.size(), 2);
      Iterator<Map.Entry<String, HashSet<Partition.PartitionInfo.ColumnMappingEntry>>> it = colmap
          .entrySet().iterator();
      for (int i = 0; i < colmap.size(); i++) {
View Full Code Here

  @Test
  public void testStorageValid2() {
    try {
      String strStorage = "[c.r] compress by gzip; [m1] serialize by avro";
      Partition p = new Partition(schema.toString(), strStorage);
      Assert.assertTrue(false);
      CGSchema[] cgschemas = p.getCGSchemas();

      // 2 column group;
      int size = cgschemas.length;
      Assert.assertEquals(size, 2);
      System.out.println("********** Column Groups **********");
      for (int i = 0; i < cgschemas.length; i++) {
        System.out.println(cgschemas[i]);
        System.out.println("--------------------------------");
      }
      CGSchema cgs1 = cgschemas[0];
      CGSchema cgs2 = cgschemas[1];

      ColumnSchema f11 = cgs1.getSchema().getColumn(0);
      Assert.assertEquals("c.r", f11.name);
      Assert.assertEquals(ColumnType.RECORD, f11.type);

      ColumnSchema f21 = cgs2.getSchema().getColumn(0);
      Assert.assertEquals("m1", f21.name);
      Assert.assertEquals(ColumnType.MAP, f21.type);

      Assert.assertEquals(cgs1.getCompressor(), "gzip");
      Assert.assertEquals(cgs2.getSerializer(), "avro");

      System.out.println("*********** Column Map **********");
      Map<String, HashSet<Partition.PartitionInfo.ColumnMappingEntry>> colmap = p
          .getPartitionInfo().getColMap();
      Assert.assertEquals(colmap.size(), 2);
      Iterator<Map.Entry<String, HashSet<Partition.PartitionInfo.ColumnMappingEntry>>> it = colmap
          .entrySet().iterator();
      for (int i = 0; i < colmap.size(); i++) {
View Full Code Here

  @Test
  public void testStorageValid3() {
    try {
      String strStorage = "[c.r.f1] compress by gzip; [m1] serialize by avro";
      Partition p = new Partition(schema.toString(), strStorage);
      Assert.assertTrue(false);
      CGSchema[] cgschemas = p.getCGSchemas();

      // 3 column group;
      int size = cgschemas.length;
      Assert.assertEquals(size, 3);
      System.out.println("********** Column Groups **********");
      for (int i = 0; i < cgschemas.length; i++) {
        System.out.println(cgschemas[i]);
        System.out.println("--------------------------------");
      }
      CGSchema cgs1 = cgschemas[0];
      CGSchema cgs2 = cgschemas[1];
      CGSchema cgs3 = cgschemas[2];

      ColumnSchema f11 = cgs1.getSchema().getColumn(0);
      Assert.assertEquals("c.r.f1", f11.name);
      Assert.assertEquals(ColumnType.INT, f11.type);

      ColumnSchema f21 = cgs2.getSchema().getColumn(0);
      Assert.assertEquals("m1", f21.name);
      Assert.assertEquals(ColumnType.MAP, f21.type);

      ColumnSchema f31 = cgs3.getSchema().getColumn(0);
      Assert.assertEquals("c.r.f2", f31.name);
      Assert.assertEquals(ColumnType.INT, f31.type);

      Assert.assertEquals(cgs1.getCompressor(), "gzip");
      Assert.assertEquals(cgs1.getSerializer(), "pig");
      Assert.assertEquals(cgs2.getCompressor(), "lzo2");
      Assert.assertEquals(cgs2.getSerializer(), "avro");
      Assert.assertEquals(cgs3.getCompressor(), "lzo2");
      Assert.assertEquals(cgs3.getSerializer(), "pig");

      System.out.println("*********** Column Map **********");
      Map<String, HashSet<Partition.PartitionInfo.ColumnMappingEntry>> colmap = p
          .getPartitionInfo().getColMap();
      Assert.assertEquals(colmap.size(), 3);
      Iterator<Map.Entry<String, HashSet<Partition.PartitionInfo.ColumnMappingEntry>>> it = colmap
          .entrySet().iterator();
      for (int i = 0; i < colmap.size(); i++) {
View Full Code Here

  @Test
  public void testStorageValid1() {
    try {
      String strStorage = "[r1.f1, r2.r3.f3]; [r1.f2, r2.r3.f4]";
      Partition p = new Partition(schema.toString(), strStorage);
      CGSchema[] cgschemas = p.getCGSchemas();

      // 2 column group;
      int size = cgschemas.length;
      Assert.assertEquals(size, 2);
      System.out.println("********** Column Groups **********");
      for (int i = 0; i < cgschemas.length; i++) {
        System.out.println(cgschemas[i]);
        System.out.println("--------------------------------");
      }
      CGSchema cgs1 = cgschemas[0];
      CGSchema cgs2 = cgschemas[1];

      ColumnSchema f11 = cgs1.getSchema().getColumn(0);
      Assert.assertEquals("r1.f1", f11.name);
      Assert.assertEquals(ColumnType.INT, f11.type);
      ColumnSchema f12 = cgs1.getSchema().getColumn(1);
      Assert.assertEquals("r2.r3.f3", f12.name);
      Assert.assertEquals(ColumnType.FLOAT, f12.type);

      ColumnSchema f21 = cgs2.getSchema().getColumn(0);
      Assert.assertEquals("r1.f2", f21.name);
      Assert.assertEquals(ColumnType.INT, f21.type);
      ColumnSchema f22 = cgs2.getSchema().getColumn(1);
      Assert.assertEquals("r2.r3.f4", f22.name);
      Assert.assertEquals(ColumnType.BYTES, f22.type);

      System.out.println("*********** Column Map **********");
      Map<String, HashSet<Partition.PartitionInfo.ColumnMappingEntry>> colmap = p
          .getPartitionInfo().getColMap();
      Assert.assertEquals(colmap.size(), 4);
      Iterator<Map.Entry<String, HashSet<Partition.PartitionInfo.ColumnMappingEntry>>> it = colmap
          .entrySet().iterator();
      for (int i = 0; i < colmap.size(); i++) {
View Full Code Here

        // set default projection that contains everything
        schema = schemaFile.getLogical();
        projection = new Projection(schema);
        String storage = schemaFile.getStorageString();
        String comparator = schemaFile.getComparator();
        partition = new Partition(schema, projection, storage, comparator);
        for (int nx = 0; nx < numCGs; nx++) {
          if (!schemaFile.isCGDeleted(nx)) {
            colGroups[nx] =
              new ColumnGroup.Reader(new Path(path, partition.getCGSchema(nx).getName()),
                                     conf, mapper);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.zebra.types.Partition$PartitionInfo$PartitionFieldInfo

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.