Package htsjdk.variant.variantcontext.writer

# 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

Modifier and Type
Method
Description
`void`
`add(VariantContext vc)`
`boolean`
`checkError()`
`protected final 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 writer
`protected 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 Details

### 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 Details

### synchronouslyWrite

protected void synchronouslyWrite(VariantContext item)

Specified by:
  `synchronouslyWrite` in class `AbstractAsyncWriter<VariantContext>`

### synchronouslyClose

protected void synchronouslyClose()

Specified by:
  `synchronouslyClose` in class `AbstractAsyncWriter<VariantContext>`

### getThreadNamePrefix

protected final String getThreadNamePrefix()
Description copied from class: `AbstractAsyncWriter`
Returns the prefix to use when naming threads.

Specified by:
  `getThreadNamePrefix` in class `AbstractAsyncWriter<VariantContext>`

### add

public void add(VariantContext vc)

Specified by:
  `add` in interface `VariantContextWriter`

### writeHeader

public void writeHeader(VCFHeader header)
Description copied from interface: `VariantContextWriter`
Writes the header

Specified by:
  `writeHeader` in interface `VariantContextWriter`
Parameters:
  `header` - header

### checkError

public boolean checkError()

Specified by:
  `checkError` in interface `VariantContextWriter`
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 interface `VariantContextWriter`
Parameters:
  `header` - VCF header