當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。