コード例 #1
0
 /**
  * ストリームからTSVファイルを読み出し、ジョブの入力データとして書き出す。
  *
  * @param <T> Import対象テーブルに対応するModelのクラス型
  * @param targetTableModel Import対象テーブルに対応するModelのクラス
  * @param dfsFilePath HFSF上のファイル名
  * @param inputStream FileList
  * @return 書きだした件数
  * @throws BulkLoaderSystemException 読み出しや出力に失敗した場合
  */
 protected <T> long write(Class<T> targetTableModel, URI dfsFilePath, InputStream inputStream)
     throws BulkLoaderSystemException {
   Configuration conf = new Configuration();
   TsvIoFactory<T> factory = new TsvIoFactory<>(targetTableModel);
   try (ModelInput<T> input = factory.createModelInput(inputStream)) {
     long count = 0;
     T buffer = factory.createModelObject();
     try (ModelOutput<T> output =
         TemporaryStorage.openOutput(conf, targetTableModel, new Path(dfsFilePath))) {
       while (input.readTo(buffer)) {
         count++;
         output.write(buffer);
       }
     }
     return count;
   } catch (IOException e) {
     throw new BulkLoaderSystemException(
         e, getClass(), "TG-EXTRACTOR-02001", "DFSにファイルを書き出す処理に失敗。URI:" + dfsFilePath);
   }
 }
コード例 #2
0
ファイル: CacheBuildTest.java プロジェクト: sugiii8/asakusafw
 private ModelOutput<TestDataModel> create(CacheStorage storage, Path path) throws IOException {
   return TemporaryStorage.openOutput(
       storage.getFileSystem().getConf(), TestDataModel.class, path);
 }