Package org.apache.hadoop.zebra.schema

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


            + "; found in file: " + version);
      }
      comparator = WritableUtils.readString(in);
      String logicalStr = WritableUtils.readString(in);
      try {
        logical = new Schema(logicalStr);
      }
      catch (Exception e) {
        ;
        throw new IOException("Schema build failed :" + e.getMessage());
      }
View Full Code Here


    pathTable1 = new Path(pathWorking, "1");
    System.out.println("pathTable1 =" + pathTable1);

    BasicTable.Writer writer = new BasicTable.Writer(pathTable1, STR_SCHEMA1,
        STR_STORAGE1, conf);
    Schema schema = writer.getSchema();
    Tuple tuple = TypesUtils.createTuple(schema);

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

    public void configure(JobConf job) {
      bytesKey = new BytesWritable();
      conf = job;
      sortKey = job.get("sortKey");
      try {
        Schema outSchema = BasicTableOutputFormat.getSchema(job);
        tupleRow = TypesUtils.createTuple(outSchema);
        javaObj = BasicTableOutputFormat.getSortKeyGenerator(job);
      } catch (IOException e) {
        throw new RuntimeException(e);
      } catch (org.apache.hadoop.zebra.parser.ParseException e) {
View Full Code Here

public class TestSchemaAnonymousCollection {
  @Test
  public void testSchemaValid1() throws ParseException {
    String strSch = "c1:collection(f1:int, f2:int), c2:collection(collection(record(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.assertNull(f21.getName());
    Assert.assertEquals(ColumnType.COLLECTION, f21.getType());

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

    public void configure(JobConf job) {
      bytesKey = new BytesWritable();
      conf = job;
      sortKey = job.get("sortKey");
      try {
        Schema outSchema = BasicTableOutputFormat.getSchema(job);
        tupleRow = TypesUtils.createTuple(outSchema);
        javaObj = BasicTableOutputFormat.getSortKeyGenerator(job);
      } catch (IOException e) {
        throw new RuntimeException(e);
      } catch (org.apache.hadoop.zebra.parser.ParseException e) {
View Full Code Here

    pathTable = new Path(pathWorking, "TestTableStorer");
    System.out.println("pathTable =" + pathTable);
    BasicTable.Writer writer = new BasicTable.Writer(pathTable,
        "SF_a:string,SF_b:string,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();
    Tuple tuple = TypesUtils.createTuple(schema);

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

    pathTable = new Path(pathWorking, "TestTableSortStorerDesc");
    System.out.println("pathTable =" + pathTable);
    BasicTable.Writer writer = new BasicTable.Writer(pathTable,
        "SF_a:string,SF_b,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();
    Tuple tuple = TypesUtils.createTuple(schema);

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

     * @throws IOException
     */
    public Writer(Path path, String schema, boolean sorted, String name, String serializer,
        String compressor, String owner, String group, short perm,boolean overwrite, Configuration conf)
        throws IOException, ParseException {
      this(path, new Schema(schema), sorted, null, name, serializer, compressor, owner, group, perm, overwrite,
          conf);
    }
View Full Code Here

    }

    public Writer(Path path, String schema, boolean sorted, String comparator, String name, String serializer,
        String compressor, String owner, String group, short perm,boolean overwrite, Configuration conf)
        throws IOException, ParseException {
      this(path, new Schema(schema), sorted, comparator, name, serializer, compressor, owner, group, perm, overwrite,
          conf);
    }
View Full Code Here

 
  private static void createTable(Path path, String schemaString, String storageString, Object[][] tableData) throws IOException {
    // Create table from tableData array
    BasicTable.Writer writer = new BasicTable.Writer(path, schemaString, storageString, conf);
   
    Schema schema = writer.getSchema();
    Tuple tuple = TypesUtils.createTuple(schema);
    TableInserter inserter = writer.getInserter("ins", false);
   
    for (int i = 0; i < tableData.length; ++i) {
      TypesUtils.resetTuple(tuple);
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.