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
Constructors Constructor Description AsyncVariantContextWriter(VariantContextWriter out)
Creates 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(VariantContext vc)
boolean
checkError()
protected String
getThreadNamePrefix()
Returns the prefix to use when naming threads.void
setHeader(VCFHeader header)
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
synchronouslyClose()
protected void
synchronouslyWrite(VariantContext item)
void
writeHeader(VCFHeader header)
Writes the header-
Methods 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 Detail
-
AsyncVariantContextWriter
public AsyncVariantContextWriter(VariantContextWriter out)
Creates a new AsyncVariantContextWriter wrapping the provided VariantContextWriter.
-
AsyncVariantContextWriter
public AsyncVariantContextWriter(VariantContextWriter out, int queueSize)
Creates an AsyncVariantContextWriter wrapping the provided VariantContextWriter and using the specified queue size for buffer VariantContexts.
-
-
Method Detail
-
synchronouslyWrite
protected void synchronouslyWrite(VariantContext item)
- Specified by:
synchronouslyWrite
in classAbstractAsyncWriter<VariantContext>
-
synchronouslyClose
protected void synchronouslyClose()
- Specified by:
synchronouslyClose
in classAbstractAsyncWriter<VariantContext>
-
getThreadNamePrefix
protected final String getThreadNamePrefix()
Description copied from class:AbstractAsyncWriter
Returns the prefix to use when naming threads.- Specified by:
getThreadNamePrefix
in classAbstractAsyncWriter<VariantContext>
-
add
public void add(VariantContext vc)
- Specified by:
add
in interfaceVariantContextWriter
-
writeHeader
public void writeHeader(VCFHeader header)
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
public void setHeader(VCFHeader header)
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
-
-