Examples of ColumnSchema


Examples of org.apache.hadoop.zebra.schema.Schema.ColumnSchema

      }
      CGSchema cgs1 = cgschemas[0];
      CGSchema cgs2 = cgschemas[1];
      CGSchema cgs3 = cgschemas[2];

      ColumnSchema f11 = cgs1.getSchema().getColumn(0);
      Assert.assertEquals("r.r.f1", f11.getName());
      Assert.assertEquals(ColumnType.INT, f11.getType());
      ColumnSchema f12 = cgs1.getSchema().getColumn(1);
      Assert.assertEquals("r.f2", f12.getName());
      Assert.assertEquals(ColumnType.MAP, f12.getType());

      ColumnSchema f21 = cgs2.getSchema().getColumn(0);
      Assert.assertEquals("r.r.f2", f21.getName());
      Assert.assertEquals(ColumnType.INT, f21.getType());
      ColumnSchema f22 = cgs2.getSchema().getColumn(1);
      Assert.assertEquals("r.f2", f22.getName());
      Assert.assertEquals(ColumnType.MAP, f22.getType());

      ColumnSchema f31 = cgs3.getSchema().getColumn(0);
      Assert.assertEquals("r.f2", f31.getName());
      Assert.assertEquals(ColumnType.MAP, f31.getType());

      System.out.println("*********** Column Map **********");
      Map<String, HashSet<Partition.PartitionInfo.ColumnMappingEntry>> colmap = p
          .getPartitionInfo().getColMap();
      Assert.assertEquals(colmap.size(), 3);
View Full Code Here

Examples of org.apache.hadoop.zebra.schema.Schema.ColumnSchema

    parser = new TableSchemaParser(new StringReader(strSch));
    schema = parser.RecordSchema(null);
    System.out.println(schema);

    // test 1st level schema;
    ColumnSchema f1 = schema.getColumn(0);
    Assert.assertEquals("c1", f1.getName());
    Assert.assertEquals(ColumnType.COLLECTION, f1.getType());

    ColumnSchema f2 = schema.getColumn(1);
    Assert.assertEquals("c2", f2.getName());
    Assert.assertEquals(ColumnType.COLLECTION, f2.getType());

    // test 2nd level schema;
    Schema f1Schema = f1.getSchema();
    ColumnSchema f11 = f1Schema.getColumn(0).getSchema().getColumn(0);
    Assert.assertEquals("f1", f11.getName());
    Assert.assertEquals(ColumnType.INT, f11.getType());
    ColumnSchema f12 = f1Schema.getColumn(0).getSchema().getColumn(1);
    Assert.assertEquals("f2", f12.getName());
    Assert.assertEquals(ColumnType.INT, f12.getType());

    Schema f2Schema = f2.getSchema();
    ColumnSchema f21 = f2Schema.getColumn(0).getSchema().getColumn(0);
    Assert.assertEquals("c3", f21.getName());
    Assert.assertEquals(ColumnType.COLLECTION, f21.getType());

    // test 3rd level schema;
    Schema f21Schema = f21.getSchema();
    ColumnSchema f211 = f21Schema.getColumn(0).getSchema().getColumn(0);
    Assert.assertEquals("f3", f211.getName());
    Assert.assertEquals(ColumnType.FLOAT, f211.getType());
    ColumnSchema f212 = f21Schema.getColumn(0).getSchema().getColumn(1);
    Assert.assertEquals("f4", f212.getName());
    Assert.assertEquals(ColumnType.BYTES, f212.getType());
  }
View Full Code Here

Examples of org.apache.hadoop.zebra.schema.Schema.ColumnSchema

  @Test
  public void testSchema() throws ParseException {
    System.out.println(schema);

    // test 1st level schema;
    ColumnSchema f1 = schema.getColumn(0);
    Assert.assertEquals("c", f1.getName());
    Assert.assertEquals(ColumnType.COLLECTION, f1.getType());
    ColumnSchema f2 = schema.getColumn(1);
    Assert.assertEquals("m1", f2.getName());
    Assert.assertEquals(ColumnType.MAP, f2.getType());

    // test 2nd level schema;
    Schema f1Schema = f1.getSchema();
    ColumnSchema f11 = f1Schema.getColumn(0);
    Assert.assertEquals("r", f11.getName());
    Assert.assertEquals(ColumnType.RECORD, f11.getType());

    Schema f2Schema = f2.getSchema();
    ColumnSchema f21 = f2Schema.getColumn(0);
    // Assert.assertEquals("", f21.getName());
    Assert.assertEquals(ColumnType.INT, f21.getType());

    // test 3rd level schema;
    Schema f11Schema = f11.getSchema();
    ColumnSchema f111 = f11Schema.getColumn(0);
    Assert.assertEquals("r", f111.getName());
    Assert.assertEquals(ColumnType.RECORD, f111.getType());
    ColumnSchema f112 = f11Schema.getColumn(1);
    Assert.assertEquals("f2", f112.getName());
    Assert.assertEquals(ColumnType.MAP, f112.getType());

    // test 4th level schema;
    Schema f111Schema = f111.getSchema();
    ColumnSchema f1111 = f111Schema.getColumn(0);
    Assert.assertEquals("f1", f1111.getName());
    Assert.assertEquals(ColumnType.INT, f1111.getType());
    ColumnSchema f1112 = f111Schema.getColumn(1);
    Assert.assertEquals("f2", f1112.getName());
    Assert.assertEquals(ColumnType.INT, f1112.getType());

    Schema f112Schema = f112.getSchema();
    ColumnSchema f1121 = f112Schema.getColumn(0);
    // Assert.assertEquals("", f1121.getName());
    Assert.assertEquals(ColumnType.BYTES, f1121.getType());
  }
View Full Code Here

Examples of org.apache.hadoop.zebra.schema.Schema.ColumnSchema

        System.out.println("--------------------------------");
      }
      CGSchema cgs1 = cgschemas[0];
      CGSchema cgs2 = cgschemas[1];

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

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

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

      System.out.println("*********** Column Map **********");
 
View Full Code Here

Examples of org.apache.hadoop.zebra.schema.Schema.ColumnSchema

      }
      CGSchema cgs1 = cgschemas[0];
      CGSchema cgs2 = cgschemas[1];
      CGSchema cgs3 = cgschemas[2];

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

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

      ColumnSchema f31 = cgs3.getSchema().getColumn(0);
      Assert.assertEquals("m1", f31.getName());
      Assert.assertEquals(ColumnType.MAP, f31.getType());

      System.out.println("*********** Column Map **********");
      Map<String, HashSet<Partition.PartitionInfo.ColumnMappingEntry>> colmap = p
          .getPartitionInfo().getColMap();
      Assert.assertEquals(colmap.size(), 2);
View Full Code Here

Examples of org.apache.hadoop.zebra.schema.Schema.ColumnSchema

  private static void checkMapColumn(Map<String, Object> m, ColumnSchema cs) throws IOException {
    checkColumnType(cs, ColumnType.MAP);
    Schema schema = cs.getSchema();
    Assert.assertTrue(schema.getNumColumns() == 1);
   
    ColumnSchema tempColumnSchema = schema.getColumn(0);
    if (tempColumnSchema.getType() == ColumnType.BYTES) { // We do not check inside of map if its value type is BYTES;
                                            // This is for Pig, since it only supports BYTES as map value type.
      return;
    }
       
    Map<String, Object> m1 = (Map<String, Object>)m;
View Full Code Here

Examples of org.apache.hadoop.zebra.schema.Schema.ColumnSchema

   *          Table schema
   * @throws IOException
   */ 
  public static void checkCompatible(Tuple tuple, Schema schema) throws IOException {
    // Create a dummy record ColumnSchema since we do not have it;
    ColumnSchema dummy = new ColumnSchema("dummy", schema);

    checkRecordColumn(tuple, dummy);
  }
View Full Code Here

Examples of org.apache.hadoop.zebra.schema.Schema.ColumnSchema

            String projectionStr = "";
           
            Iterator<RequiredField> it= rFields.iterator();
            while( it.hasNext() ) {
                RequiredField rField = (RequiredField) it.next();
                ColumnSchema cs = projectionSchema.getColumn(rField.getIndex());
               
                if(cs == null) {
                    throw new FrontendException
                    ("Null column schema in projection schema in fieldsToRead at index " + rField.getIndex());
                }
               
                if(cs.getType() != ColumnType.MAP && (rField.getSubFields() != null)) {       
                    throw new FrontendException
                    ("Zebra cannot have subfields for a non-map column type in fieldsToRead " +
                     "ColumnType:" + cs.getType() + " index in zebra projection schema: " + rField.getIndex()
                    );
                }
                String name = cs.getName();
                projectionStr = projectionStr + name ;
                if(cs.getType() == ColumnType.MAP) {       
                    List<RequiredField> subFields = rField.getSubFields();
                   
                    if( subFields != null ) {
                   
                        Iterator<RequiredField> its= subFields.iterator();
View Full Code Here

Examples of org.apache.hadoop.zebra.schema.Schema.ColumnSchema

            String projectionStr = "";
           
            Iterator<RequiredField> it= rFields.iterator();
            while( it.hasNext() ) {
                RequiredField rField = (RequiredField) it.next();
                ColumnSchema cs = projectionSchema.getColumn(rField.getIndex());
               
                if(cs == null) {
                    throw new FrontendException
                    ("Null column schema in projection schema in fieldsToRead at index " + rField.getIndex());
                }
               
                if(cs.getType() != ColumnType.MAP && (rField.getSubFields() != null)) {       
                    throw new FrontendException
                    ("Zebra cannot have subfields for a non-map column type in fieldsToRead " +
                     "ColumnType:" + cs.getType() + " index in zebra projection schema: " + rField.getIndex()
                    );
                }
                String name = cs.getName();
                projectionStr = projectionStr + name ;
                if(cs.getType() == ColumnType.MAP) {       
                    List<RequiredField> subFields = rField.getSubFields();
                   
                    if( subFields != null ) {
                   
                        Iterator<RequiredField> its= subFields.iterator();
View Full Code Here

Examples of org.apache.hadoop.zebra.schema.Schema.ColumnSchema

    parser = new TableSchemaParser(new StringReader(strSch));
    schema = parser.RecordSchema(null);
    System.out.println(schema);

    // test 1st level schema;
    ColumnSchema f1 = schema.getColumn(0);
    Assert.assertEquals("f1", f1.getName());
    Assert.assertEquals(ColumnType.INT, f1.getType());

    ColumnSchema f2 = schema.getColumn(1);
    Assert.assertEquals("m1", f2.getName());
    Assert.assertEquals(ColumnType.MAP, f2.getType());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.