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
ConstructorDescriptionCreates 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 TypeMethodDescriptionvoid
add
(VariantContext vc) boolean
protected final String
Returns the prefix to use when naming threads.void
Sets 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 void
protected void
void
writeHeader
(VCFHeader header) Writes the headerMethods inherited from class htsjdk.samtools.util.AbstractAsyncWriter
close, write
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
synchronouslyWrite
in classAbstractAsyncWriter<VariantContext>
-
synchronouslyClose
protected void synchronouslyClose()- Specified by:
synchronouslyClose
in classAbstractAsyncWriter<VariantContext>
-
getThreadNamePrefix
Description copied from class:AbstractAsyncWriter
Returns the prefix to use when naming threads.- Specified by:
getThreadNamePrefix
in classAbstractAsyncWriter<VariantContext>
-
add
- Specified by:
add
in interfaceVariantContextWriter
-
writeHeader
Description copied from interface:VariantContextWriter
Writes the header- Specified by:
writeHeader
in interfaceVariantContextWriter
- Parameters:
header
- header
-
checkError
public boolean checkError()- Specified by:
checkError
in 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:VariantContextWriter
Sets 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:
setHeader
in interfaceVariantContextWriter
- Parameters:
header
- VCF header
-