Package org.apache.hadoop.zebra.schema

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


    fs.setPermission(path, new FsPermission((short) 0777));
    login(USER1);
    BasicTable.Writer writer = new BasicTable.Writer(path1, schema, storage, conf);
    writer.finish();

    Schema schema1 = writer.getSchema();
    insertData(USER1.getUserName(), schema1, path1);
    writer.close();
    load(USER1.getUserName(), path1, "s1,s2", false, false);

    login(USER3);
View Full Code Here


    login(SUPERUSER);
    BasicTable.Writer writer = new BasicTable.Writer(path1, schema, storage, conf);
    writer.finish();

    Schema schema1 = writer.getSchema();
    insertData(SUPERUSER.getUserName(), schema1, path1);
    writer.close();

    login(USER3);
    try {
View Full Code Here

    fs.setPermission(path, new FsPermission((short) 0777));

    BasicTable.Writer writer = new BasicTable.Writer(path1, schema, storage, conf);
    writer.finish();

    Schema schema1 = writer.getSchema();
    insertData(SUPERUSER.getUserName(), schema1, path1);
    writer.close();
    load(SUPERUSER.getUserName(), path1, "s1,s2", false, false);

    login(USER3);
View Full Code Here

*/
public class TestZebraTupleTostring {
  @Test
  public void testSimple() throws IOException, ParseException {
    String STR_SCHEMA = "s1:bool, s2:int, s3:long, s4:float, s5:string, s6:bytes";
    Schema schema = new Schema(STR_SCHEMA);
    Tuple tuple = TypesUtils.createTuple(schema);
    Assert.assertTrue(tuple instanceof ZebraTuple);
    TypesUtils.resetTuple(tuple);

    tuple.set(0, true); // bool
View Full Code Here

  }
 
  @Test
  public void testRecord() throws IOException, ParseException {
    String STR_SCHEMA = "r1:record(f1:int, f2:long), r2:record(r3:record(f3:float, f4))";
    Schema schema = new Schema(STR_SCHEMA);
    Tuple tuple = TypesUtils.createTuple(schema);
    TypesUtils.resetTuple(tuple);

    Tuple tupRecord1;
    Schema r1Schema = new Schema("f1:int, f2:long");
    tupRecord1 = TypesUtils.createTuple(r1Schema);
    TypesUtils.resetTuple(tupRecord1);
   
    Tuple tupRecord2;
    Schema r2Schema = new Schema("r3:record(f3:float, f4)");
    tupRecord2 = TypesUtils.createTuple(r2Schema);
    TypesUtils.resetTuple(tupRecord2);
   
    Tuple tupRecord3;
    Schema r3Schema = new Schema("f3:float, f4");
    tupRecord3 = TypesUtils.createTuple(r3Schema);
    TypesUtils.resetTuple(tupRecord3);
   
    // r1:record(f1:int, f2:long)
    tupRecord1.set(0, 1);
View Full Code Here

  }

  @Test
  public void testMap() throws IOException, ParseException {
    String STR_SCHEMA = "m1:map(string),m2:map(map(int))";
    Schema schema = new Schema(STR_SCHEMA);
    Tuple tuple = TypesUtils.createTuple(schema);
    TypesUtils.resetTuple(tuple);

    // m1:map(string)
    Map<String, String> m1 = new HashMap<String, String>();
View Full Code Here

 
  @Test
  public void testCollection() throws IOException, ParseException {
    String STR_SCHEMA =
      "c1:collection(a:double, b:float, c:bytes),c2:collection(r1:record(f1:int, f2:string), d:string),c3:collection(c3_1:collection(e:int,f:bool))";
    Schema schema = new Schema(STR_SCHEMA);
    Tuple tuple = TypesUtils.createTuple(schema);
    TypesUtils.resetTuple(tuple);
   
    DataBag bag1 = TypesUtils.createBag();
    Schema schColl = new Schema("a:double, b:float, c:bytes");
    Tuple tupColl1 = TypesUtils.createTuple(schColl);
    Tuple tupColl2 = TypesUtils.createTuple(schColl);

    DataBag bag2 = TypesUtils.createBag();
    Schema schColl2 = new Schema("r1:record(f1:int, f2:string), d:string");
    Tuple tupColl2_1 = TypesUtils.createTuple(schColl2);
    Tuple tupColl2_2 = TypesUtils.createTuple(schColl2);
   
    Tuple collRecord1;
    try {
      collRecord1 = TypesUtils.createTuple(new Schema("f1:int, f2:string"));
    } catch (ParseException e) {
      e.printStackTrace();
      throw new IOException(e);
    }
    Tuple collRecord2;
    try {
      collRecord2 = TypesUtils.createTuple(new Schema("f1:int, f2:string"));
    } catch (ParseException e) {
      e.printStackTrace();
      throw new IOException(e);
    }

    // c3:collection(c3_1:collection(e:int,f:bool))
    DataBag bag3 = TypesUtils.createBag();
    DataBag bag3_1 = TypesUtils.createBag();
    DataBag bag3_2 = TypesUtils.createBag();

    Tuple tupColl3_1 = null;
    try {
      tupColl3_1 = TypesUtils.createTuple(new Schema("e:int,f:bool"));
    } catch (ParseException e) {
      e.printStackTrace();
      throw new IOException(e);
    }
    Tuple tupColl3_2;
    try {
      tupColl3_2 = TypesUtils.createTuple(new Schema("e:int,f:bool"));
    } catch (ParseException e) {
      e.printStackTrace();
      throw new IOException(e);
    }

    Tuple tupColl3_3 = null;
    try {
      tupColl3_3 = TypesUtils.createTuple(new Schema("e:int,f:bool"));
    } catch (ParseException e) {
      e.printStackTrace();
      throw new IOException(e);
    }
    Tuple tupColl3_4;
    try {
      tupColl3_4 = TypesUtils.createTuple(new Schema("e:int,f:bool"));
    } catch (ParseException e) {
      e.printStackTrace();
      throw new IOException(e);
    }
View Full Code Here

    pathTable = new Path(pathWorking, "TestTableStorer");
    System.out.println("pathTable =" + pathTable);
    BasicTable.Writer writer = new BasicTable.Writer(pathTable,
        "SF_a:int,SF_b:int,SF_c,SF_d,SF_e,SF_f,SF_g",
        "[SF_a, SF_b, SF_c]; [SF_e, SF_f, SF_g]", conf);
    Schema schema = writer.getSchema();
    System.out.println("typeName" + schema.getColumn("SF_a").getType().pigDataType());
    Tuple tuple = TypesUtils.createTuple(schema);

    final int numsBatch = 10;
    final int numsInserters = 1;
    TableInserter[] inserters = new TableInserter[numsInserters];
View Full Code Here

public class TestSchemaCollection {
  @Test
  public void testSchemaValid1() throws ParseException {
    String strSch = "c1:collection(f1:int, f2:int), c2:collection(c3:collection(f3:float, f4))";
    TableSchemaParser parser;
    Schema schema;

    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);
    Assert.assertEquals("f1", f11.getName());
    Assert.assertEquals(ColumnType.INT, f11.getType());
    ColumnSchema f12 = f1Schema.getColumn(1);
    Assert.assertEquals("f2", f12.getName());
    Assert.assertEquals(ColumnType.INT, f12.getType());

    Schema f2Schema = f2.getSchema();
    ColumnSchema f21 = f2Schema.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);
    Assert.assertEquals("f3", f211.getName());
    Assert.assertEquals(ColumnType.FLOAT, f211.getType());
    ColumnSchema f212 = f21Schema.getColumn(1);
    Assert.assertEquals("f4", f212.getName());
    Assert.assertEquals(ColumnType.BYTES, f212.getType());
  }
View Full Code Here

  @Test
  public void testSchemaInvalid1() throws ParseException, Exception {
    try {
      String strSch = "c1:collection(f1:int, f2:int), c2:collection(c3:collection(f3:float, f4)))";
      TableSchemaParser parser;
      Schema schema;

      parser = new TableSchemaParser(new StringReader(strSch));
      schema = parser.RecordSchema(null);
      System.out.println(schema);
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.apache.hadoop.zebra.schema.Schema

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.