Class AsyncVariantContextWriter
java.lang.Object
htsjdk.samtools.util.AbstractAsyncWriter<VariantContext>
htsjdk.variant.variantcontext.writer.AsyncVariantContextWriter
- All Implemented Interfaces:
VariantContextWriter,Closeable,AutoCloseable
public class AsyncVariantContextWriter
extends AbstractAsyncWriter<VariantContext>
implements VariantContextWriter
AsyncVariantContextWriter that can be wrapped around an underlying AsyncVariantContextWriter to provide asynchronous output. Records
added are placed into a queue, the queue is then drained into the underlying VariantContextWriter by a thread owned
by the instance.
Exceptions experienced by the writer thread will be emitted back to the caller in subsequent calls to either
add() or close().
-
Field Summary
Fields inherited from class htsjdk.samtools.util.AbstractAsyncWriter
DEFAULT_QUEUE_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new AsyncVariantContextWriter wrapping the provided VariantContextWriter.AsyncVariantContextWriter(VariantContextWriter out, int queueSize) Creates an AsyncVariantContextWriter wrapping the provided VariantContextWriter and using the specified queue size for buffer VariantContexts. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(VariantContext vc) booleanprotected final StringReturns the prefix to use when naming threads.voidSets the VCF header so that data blocks can be written without writing the header Exactly one of writeHeader() or setHeader() should be called when using a writerprotected voidprotected voidvoidwriteHeader(VCFHeader header) Writes the headerMethods inherited from class htsjdk.samtools.util.AbstractAsyncWriter
close, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface htsjdk.variant.variantcontext.writer.VariantContextWriter
close
-
Constructor Details
-
AsyncVariantContextWriter
Creates a new AsyncVariantContextWriter wrapping the provided VariantContextWriter. -
AsyncVariantContextWriter
Creates an AsyncVariantContextWriter wrapping the provided VariantContextWriter and using the specified queue size for buffer VariantContexts.
-
-
Method Details
-
synchronouslyWrite
- Specified by:
synchronouslyWritein classAbstractAsyncWriter<VariantContext>
-
synchronouslyClose
protected void synchronouslyClose()- Specified by:
synchronouslyClosein classAbstractAsyncWriter<VariantContext>
-
getThreadNamePrefix
Description copied from class:AbstractAsyncWriterReturns the prefix to use when naming threads.- Specified by:
getThreadNamePrefixin classAbstractAsyncWriter<VariantContext>
-
add
- Specified by:
addin interfaceVariantContextWriter
-
writeHeader
Description copied from interface:VariantContextWriterWrites the header- Specified by:
writeHeaderin interfaceVariantContextWriter- Parameters:
header- header
-
checkError
public boolean checkError()- Specified by:
checkErrorin interfaceVariantContextWriter- Returns:
- true if the underlying stream is a java.io.PrintStream and its checkError returned true, used for pipelines
-
setHeader
Description copied from interface:VariantContextWriterSets the VCF header so that data blocks can be written without writing the header Exactly one of writeHeader() or setHeader() should be called when using a writer- Specified by:
setHeaderin interfaceVariantContextWriter- Parameters:
header- VCF header
-