当前位置: 首页>>代码示例>>Java>>正文


Java Schema.createFixed方法代码示例

本文整理汇总了Java中org.apache.avro.Schema.createFixed方法的典型用法代码示例。如果您正苦于以下问题:Java Schema.createFixed方法的具体用法?Java Schema.createFixed怎么用?Java Schema.createFixed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.avro.Schema的用法示例。


在下文中一共展示了Schema.createFixed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSupportedParquetTypes

import org.apache.avro.Schema; //导入方法依赖的package包/类
public void testSupportedParquetTypes() throws IOException, SQLException {
  String[] argv = {};
  final int TOTAL_RECORDS = 1 * 10;

  byte[] b = new byte[] { (byte) 1, (byte) 2 };
  Schema fixed = Schema.createFixed("myfixed", null, null, 2);
  Schema enumeration = Schema.createEnum("myenum", null, null,
      Lists.newArrayList("a", "b"));

  ColumnGenerator[] gens = new ColumnGenerator[] {
    colGenerator(true, Schema.create(Schema.Type.BOOLEAN), true, "BIT"),
    colGenerator(100, Schema.create(Schema.Type.INT), 100, "INTEGER"),
    colGenerator(200L, Schema.create(Schema.Type.LONG), 200L, "BIGINT"),
    // HSQLDB maps REAL to double, not float:
    colGenerator(1.0f, Schema.create(Schema.Type.FLOAT), 1.0d, "REAL"),
    colGenerator(2.0d, Schema.create(Schema.Type.DOUBLE), 2.0d, "DOUBLE"),
    colGenerator("s", Schema.create(Schema.Type.STRING), "s", "VARCHAR(8)"),
    colGenerator(ByteBuffer.wrap(b), Schema.create(Schema.Type.BYTES),
        b, "VARBINARY(8)"),
    colGenerator(new GenericData.Fixed(fixed, b), fixed,
        b, "BINARY(2)"),
    colGenerator(new GenericData.EnumSymbol(enumeration, "a"), enumeration,
        "a", "VARCHAR(8)"),
  };
  createParquetFile(0, TOTAL_RECORDS, gens);
  createTable(gens);
  runExport(getArgv(true, 10, 10, newStrArray(argv, "-m", "" + 1)));
  verifyExport(TOTAL_RECORDS);
  for (int i = 0; i < gens.length; i++) {
    assertColMinAndMax(forIdx(i), gens[i]);
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:33,代码来源:TestParquetExport.java

示例2: testSupportedAvroTypes

import org.apache.avro.Schema; //导入方法依赖的package包/类
public void testSupportedAvroTypes() throws IOException, SQLException {
  String[] argv = {};
  final int TOTAL_RECORDS = 1 * 10;

  byte[] b = new byte[] { (byte) 1, (byte) 2 };
  Schema fixed = Schema.createFixed("myfixed", null, null, 2);
  Schema enumeration = Schema.createEnum("myenum", null, null,
      Lists.newArrayList("a", "b"));

  ColumnGenerator[] gens = new ColumnGenerator[] {
    colGenerator(true, Schema.create(Schema.Type.BOOLEAN), true, "BIT"),
    colGenerator(100, Schema.create(Schema.Type.INT), 100, "INTEGER"),
    colGenerator(200L, Schema.create(Schema.Type.LONG), 200L, "BIGINT"),
    // HSQLDB maps REAL to double, not float:
    colGenerator(1.0f, Schema.create(Schema.Type.FLOAT), 1.0d, "REAL"),
    colGenerator(2.0d, Schema.create(Schema.Type.DOUBLE), 2.0d, "DOUBLE"),
    colGenerator("s", Schema.create(Schema.Type.STRING), "s", "VARCHAR(8)"),
    colGenerator(ByteBuffer.wrap(b), Schema.create(Schema.Type.BYTES),
        b, "VARBINARY(8)"),
    colGenerator(new GenericData.Fixed(fixed, b), fixed,
        b, "BINARY(2)"),
    colGenerator(new GenericData.EnumSymbol(enumeration, "a"), enumeration,
        "a", "VARCHAR(8)"),
  };
  createAvroFile(0, TOTAL_RECORDS, gens);
  createTable(gens);
  runExport(getArgv(true, 10, 10, newStrArray(argv, "-m", "" + 1)));
  verifyExport(TOTAL_RECORDS);
  for (int i = 0; i < gens.length; i++) {
    assertColMinAndMax(forIdx(i), gens[i]);
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:33,代码来源:TestAvroExport.java


注:本文中的org.apache.avro.Schema.createFixed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。