Package org.apache.trevni

Examples of org.apache.trevni.ColumnMetaData


  private static final int COUNT = 100;
  private static final File FILE = new File("target", "test.trv");

  @Test public void testPrimitives() throws Exception {
    check(Schema.create(Schema.Type.NULL),
          new ColumnMetaData("null", ValueType.NULL));
    check(Schema.create(Schema.Type.BOOLEAN),
          new ColumnMetaData("boolean", ValueType.BOOLEAN));

    check(Schema.create(Schema.Type.INT),
          new ColumnMetaData("int", ValueType.INT));
    check(Schema.create(Schema.Type.LONG),
          new ColumnMetaData("long", ValueType.LONG));

    check(Schema.create(Schema.Type.FLOAT),
          new ColumnMetaData("float", ValueType.FLOAT));
    check(Schema.create(Schema.Type.DOUBLE),
          new ColumnMetaData("double", ValueType.DOUBLE));

    check(Schema.create(Schema.Type.BYTES),
          new ColumnMetaData("bytes", ValueType.BYTES));
    check(Schema.create(Schema.Type.STRING),
          new ColumnMetaData("string", ValueType.STRING));

    check(Schema.createEnum("E", null, null, Arrays.asList("X","Y","Z")),
          new ColumnMetaData("E", ValueType.INT));
    check(Schema.createFixed("F", null, null, 5),
          new ColumnMetaData("F", ValueType.BYTES));
  }
View Full Code Here


    +SIMPLE_FIELDS
    +"]}";

  @Test public void testSimpleRecord() throws Exception {
    check(Schema.parse(SIMPLE_RECORD),
          new ColumnMetaData("x", ValueType.INT),
          new ColumnMetaData("y", ValueType.STRING));
  }
View Full Code Here

      +"{\"name\":\"x\",\"type\":\"int\"},"
      +"{\"name\":\"R\",\"type\":"+SIMPLE_RECORD+"},"
      +"{\"name\":\"y\",\"type\":\"string\"}"
      +"]}";
    check(Schema.parse(s),
          new ColumnMetaData("x", ValueType.INT),
          new ColumnMetaData("R#x", ValueType.INT),
          new ColumnMetaData("R#y", ValueType.STRING),
          new ColumnMetaData("y", ValueType.STRING));
  }
View Full Code Here

        "{\"type\":\"record\",\"name\":\"S\",\"fields\":["
        +"{\"name\":\"R1\",\"type\":"+SIMPLE_RECORD+"},"
        +"{\"name\":\"R2\",\"type\":\"R\"}"
        +"]}";
      check(Schema.parse(s),
            new ColumnMetaData("R1#x", ValueType.INT),
            new ColumnMetaData("R1#y", ValueType.STRING),
            new ColumnMetaData("R2#x", ValueType.INT),
            new ColumnMetaData("R2#y", ValueType.STRING));
    }
View Full Code Here

    }
 
  @Test public void testSimpleArray() throws Exception {
    String s = "{\"type\":\"array\",\"items\":\"long\"}";
    check(Schema.parse(s),
          new ColumnMetaData("[]", ValueType.LONG).isArray(true));
  }
View Full Code Here

  private static final String RECORD_ARRAY =
    "{\"type\":\"array\",\"items\":"+SIMPLE_RECORD+"}";

  @Test public void testArray() throws Exception {
    ColumnMetaData p = new ColumnMetaData("[]", ValueType.NULL).isArray(true);
    check(Schema.parse(RECORD_ARRAY),
          p,
          new ColumnMetaData("[]#x", ValueType.INT).setParent(p),
          new ColumnMetaData("[]#y", ValueType.STRING).setParent(p));
  }
View Full Code Here

  }

  @Test public void testSimpleUnion() throws Exception {
    String s = "[\"int\",\"string\"]";
    check(Schema.parse(s),
          new ColumnMetaData("int", ValueType.INT).isArray(true),
          new ColumnMetaData("string", ValueType.STRING).isArray(true));
  }
View Full Code Here

  }

  @Test public void testSimpleOptional() throws Exception {
    String s = "[\"null\",\"string\"]";
    check(Schema.parse(s),
          new ColumnMetaData("string", ValueType.STRING).isArray(true));
  }
View Full Code Here

  }

  private static final String UNION = "[\"null\",\"int\","+SIMPLE_RECORD+"]";

  @Test public void testUnion() throws Exception {
    ColumnMetaData p = new ColumnMetaData("R", ValueType.NULL).isArray(true);
    check(Schema.parse(UNION),
          new ColumnMetaData("int", ValueType.INT).isArray(true),
          p,
          new ColumnMetaData("R#x", ValueType.INT).setParent(p),
          new ColumnMetaData("R#y", ValueType.STRING).setParent(p));
  }
View Full Code Here

      "{\"type\":\"record\",\"name\":\"S\",\"fields\":["
      +"{\"name\":\"x\",\"type\":\"int\"},"
      +"{\"name\":\"A\",\"type\":"+RECORD_ARRAY+"},"
      +"{\"name\":\"y\",\"type\":\"string\"}"
      +"]}";
    ColumnMetaData p = new ColumnMetaData("A[]", ValueType.NULL).isArray(true);
    check(Schema.parse(s),
          new ColumnMetaData("x", ValueType.INT),
          p,
          new ColumnMetaData("A[]#x", ValueType.INT).setParent(p),
          new ColumnMetaData("A[]#y", ValueType.STRING).setParent(p),
          new ColumnMetaData("y", ValueType.STRING));
  }
View Full Code Here

TOP

Related Classes of org.apache.trevni.ColumnMetaData

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.