org.apache.avro.file.FileReader.close()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中org.apache.avro.file.FileReader.close()方法的一些代码示例,展示了FileReader.close()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileReader.close()方法的具体详情如下:
包路径:org.apache.avro.file.FileReader
类名称:FileReader
方法名:close

FileReader.close介绍

暂无

代码示例

代码示例来源:origin: apache/hive

@Override
public void close() throws IOException {
 if (isEmptyInput == false)
  reader.close();
}

代码示例来源:origin: apache/avro

public void close() throws IOException { reader.close(); }

代码示例来源:origin: apache/avro

public void close() throws IOException { reader.close(); }

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
  * Close the stream.
  */
 @Override
 public void close() throws IOException {
  fileReader.close();
  output.close();
  super.close();
 }
}

代码示例来源:origin: apache/avro

private <D> List<D> read(DatumReader<D> reader, File file) throws IOException {
 List<D> data = new ArrayList<>();
 FileReader<D> fileReader = null;
 try {
  fileReader = new DataFileReader<>(file, reader);
  for (D datum : fileReader) {
   data.add(datum);
  }
 } finally {
  if (fileReader != null) {
   fileReader.close();
  }
 }
 return data;
}

代码示例来源:origin: apache/incubator-gobblin

public static List<GenericRecord> getRecordFromFile(String path)
  throws IOException {
 Configuration config = new Configuration();
 SeekableInput input = new FsInput(new Path(path), config);
 DatumReader<GenericRecord> reader1 = new GenericDatumReader<>();
 FileReader<GenericRecord> fileReader = DataFileReader.openReader(input, reader1);
 List<GenericRecord> records = new ArrayList<>();
 for (GenericRecord datum : fileReader) {
  records.add(datum);
 }
 fileReader.close();
 return records;
}

代码示例来源:origin: apache/avro

private static <D> List<D> read(DatumReader<D> reader, File file) throws IOException {
 List<D> data = new ArrayList<>();
 FileReader<D> fileReader = null;
 try {
  fileReader = new DataFileReader<>(file, reader);
  for (D datum : fileReader) {
   data.add(datum);
  }
 } finally {
  if (fileReader != null) {
   fileReader.close();
  }
 }
 return data;
}

代码示例来源:origin: apache/incubator-gobblin

public static List<GenericRecord> getRecordFromFile(String path)
  throws IOException {
 Configuration config = new Configuration();
 SeekableInput input = new FsInput(new Path(path), config);
 DatumReader<GenericRecord> reader1 = new GenericDatumReader<>();
 FileReader<GenericRecord> fileReader = DataFileReader.openReader(input, reader1);
 List<GenericRecord> records = new ArrayList<>();
 for (GenericRecord datum : fileReader) {
  records.add(datum);
 }
 fileReader.close();
 return records;
}

代码示例来源:origin: apache/avro

private <D> List<D> read(GenericData model, Schema schema, File file) throws IOException {
 DatumReader<D> reader = newReader(model, schema);
 List<D> data = new ArrayList<>();
 FileReader<D> fileReader = null;
 try {
  fileReader = new DataFileReader<>(file, reader);
  for (D datum : fileReader) {
   data.add(datum);
  }
 } finally {
  if (fileReader != null) {
   fileReader.close();
  }
 }
 return data;
}

代码示例来源:origin: apache/avro

public void checkFile(FileReader<Pair<Long,CharSequence>> reader) throws Exception {
 long i = 0;
 for (Pair<Long,CharSequence> p : reader) {
  assertEquals((Long)i, p.key());
  assertEquals(Long.toString(i), p.value().toString());
  i++;
 }
 assertEquals(COUNT, i);
 reader.close();
}

代码示例来源:origin: apache/avro

@Test
  public void testSerialization() throws Exception {
    Schema testSchema = getTestSchema();
    GenericRecord message = new Record(testSchema);
    message.put("name", "testValue");

    byte[] data = getSerializedMessage(message, testSchema);

    GenericDatumReader<IndexedRecord> reader = new GenericDatumReader<>(testSchema);

    SeekableInput in = new SeekableByteArrayInput(data);
    FileReader<IndexedRecord> dfr = null;
    IndexedRecord result = null;
    try {
      dfr = DataFileReader.openReader(in, reader);
      result = dfr.next();
    } finally {
      if (dfr != null) {
        dfr.close();
      }
    }
    Assert.assertNotNull(result);
    Assert.assertTrue(result instanceof GenericRecord);
    Assert.assertEquals(new Utf8("testValue"), ((GenericRecord) result).get("name"));
  }
}

代码示例来源:origin: apache/avro

indexFileReader.close();

代码示例来源:origin: cloudera/crunch

@Override
  public void close() throws IOException {
    reader.close();
  }
}

代码示例来源:origin: org.apache.crunch/crunch

@Override
 public void close() throws IOException {
  reader.close();
 }
}

代码示例来源:origin: Netflix/iceberg

@Override
 public void close() throws IOException {
  reader.close();
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

/**
  * Close the stream.
  */
 @Override
 public void close() throws IOException {
  fileReader.close();
  output.close();
  super.close();
 }
}

代码示例来源:origin: io.hops/hadoop-common

/**
  * Close the stream.
  */
 @Override
 public void close() throws IOException {
  fileReader.close();
  output.close();
  super.close();
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

/**
  * Close the stream.
  */
 @Override
 public void close() throws IOException {
  fileReader.close();
  output.close();
  super.close();
 }
}

代码示例来源:origin: qubole/streamx

@Override
 public Collection<Object> readData(Configuration conf, Path path) throws IOException {
  ArrayList<Object> collection = new ArrayList<>();
  SeekableInput input = new FsInput(path, conf);
  DatumReader<Object> reader = new GenericDatumReader<>();
  FileReader<Object> fileReader = DataFileReader.openReader(input, reader);
  for (Object object: fileReader) {
   collection.add(object);
  }
  fileReader.close();
  return collection;
 }
}

代码示例来源:origin: qubole/streamx

@Override
public Schema getSchema(Configuration conf, Path path) throws IOException {
 SeekableInput input = new FsInput(path, conf);
 DatumReader<Object> reader = new GenericDatumReader<>();
 FileReader<Object> fileReader = DataFileReader.openReader(input, reader);
 org.apache.avro.Schema schema = fileReader.getSchema();
 fileReader.close();
 return avroData.toConnectSchema(schema);
}

相关文章