return batch; }) .then(new JsonSerializerTask<>(VariantStatsWrapper.class)));
@Override public List<R> drain() throws Exception { // Drain and write List<R> drain = task.drain(); writer.write(drain); return drain; }
})).then(new VariantToVcfSliceConverterTask(progressLogger));
@Override public List<R> apply(List<T> batch) throws Exception { List<R> batch2 = task.apply(batch); writer.write(batch2); return batch2; }
if (isStageParallelWrite(options)) { logger.info("Multi thread stage load... [{} readerThreads, {} writerThreads]", numReaders, loadThreads); ptr = new ParallelTaskRunner<>(variantReader, remapIdsTask.then(converterTask).then(stageLoader), null, config); } else { logger.info("Multi thread stage load... [{} readerThreads, {} tasks, {} writerThreads]", numReaders, loadThreads, 1); ptr = new ParallelTaskRunner<>(variantReader, remapIdsTask.then(converterTask), stageLoader, config);
@Override public List<O> read(int batch) { try { List<T> read = DataReader.this.read(batch); // Iterate while reader has data // Exit when reader is exhausted, or task produces data while (read != null && !read.isEmpty()) { List<O> apply = task.apply(read); if (apply != null && !apply.isEmpty()) { // Valid task apply. return apply; } else { // Empty task apply. Read more data read = DataReader.this.read(batch); } } // Reader is exhausted. Drain the task. return task.drain(); } catch (Exception e) { // TODO: Reader should throw any exception throw new RuntimeException(e); } } };
@Override public boolean post() { try { task.post(); } catch (Exception e) { throw new RuntimeException(e); } return DataReader.this.post(); }
@Override public boolean pre() { try { task.pre(); } catch (Exception e) { throw new RuntimeException(e); } return DataReader.this.pre(); }
@Override public void post() throws Exception { task.post(); if (!post.getAndSet(true)) { writer.post(); writer.close(); } } };
@Override public void pre() throws Exception { if (!pre.getAndSet(true)) { writer.open(); writer.pre(); } task.pre(); }