vg
tools for working with variation graphs
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
vg::io::BlockedGzipInputStream Class Reference

#include <blocked_gzip_input_stream.hpp>

Inheritance diagram for vg::io::BlockedGzipInputStream:

Public Member Functions

 BlockedGzipInputStream (std::istream &stream)
 
virtual ~BlockedGzipInputStream ()
 Destroy the stream. More...
 
 BlockedGzipInputStream (const BlockedGzipInputStream &other)=delete
 
BlockedGzipInputStreamoperator= (const BlockedGzipInputStream &other)=delete
 
 BlockedGzipInputStream (BlockedGzipInputStream &&other)=delete
 
BlockedGzipInputStreamoperator= (BlockedGzipInputStream &&other)=delete
 
virtual bool Next (const void **data, int *size)
 
virtual void BackUp (int count)
 
virtual bool Skip (int count)
 
virtual int64_t ByteCount () const
 Get the number of bytes read since the stream was constructed. More...
 
virtual int64_t Tell () const
 
virtual bool Seek (int64_t virtual_offset)
 
virtual bool IsBGZF () const
 
virtual bool EnableMultiThreading (size_t thread_count)
 

Static Public Member Functions

static bool SmellsLikeGzip (std::istream &in)
 

Protected Attributes

BGZF * handle
 
size_t byte_count
 The counter to back ByteCount. More...
 
bool know_offset
 Flag for whether our backing stream is tellable. More...
 

Detailed Description

Protobuf-style ZeroCopyInputStream that reads data from blocked gzip format, and allows interacting with virtual offsets. Cannot be moved or copied, because the base class can't be moved or copied.

Constructor & Destructor Documentation

◆ BlockedGzipInputStream() [1/3]

vg::io::BlockedGzipInputStream::BlockedGzipInputStream ( std::istream &  stream)

Make a new stream reading from the given C++ std::istream, wrapping it in a BGZF. The stream must be at a BGZF block header, since the header info is peeked.

◆ ~BlockedGzipInputStream()

vg::io::BlockedGzipInputStream::~BlockedGzipInputStream ( )
virtual

Destroy the stream.

◆ BlockedGzipInputStream() [2/3]

vg::io::BlockedGzipInputStream::BlockedGzipInputStream ( const BlockedGzipInputStream other)
delete

◆ BlockedGzipInputStream() [3/3]

vg::io::BlockedGzipInputStream::BlockedGzipInputStream ( BlockedGzipInputStream &&  other)
delete

Member Function Documentation

◆ BackUp()

void vg::io::BlockedGzipInputStream::BackUp ( int  count)
virtual

When called after Next(), mark the last count bytes of the buffer that Next() produced as not having been read.

◆ ByteCount()

int64_t vg::io::BlockedGzipInputStream::ByteCount ( ) const
virtual

Get the number of bytes read since the stream was constructed.

◆ EnableMultiThreading()

bool vg::io::BlockedGzipInputStream::EnableMultiThreading ( size_t  thread_count)
virtual

Turn on multithreaded decompression. Return true if successful and false if the BGZF could not set up its thread pool.

◆ IsBGZF()

bool vg::io::BlockedGzipInputStream::IsBGZF ( ) const
virtual

Return true if the stream being read really is BGZF, and false if we are operating on a non-blocked GZIP or uncompressed file.

◆ Next()

bool vg::io::BlockedGzipInputStream::Next ( const void **  data,
int *  size 
)
virtual

Get a buffer to read from. Saves the address of the buffer where data points, and the size of the buffer where size points. Returns false on an unrecoverable error or EOF, and true if a buffer was gotten. The data pointer must be valid until the next read call or until the stream is destroyed.

◆ operator=() [1/2]

BlockedGzipInputStream& vg::io::BlockedGzipInputStream::operator= ( BlockedGzipInputStream &&  other)
delete

◆ operator=() [2/2]

BlockedGzipInputStream& vg::io::BlockedGzipInputStream::operator= ( const BlockedGzipInputStream other)
delete

◆ Seek()

bool vg::io::BlockedGzipInputStream::Seek ( int64_t  virtual_offset)
virtual

Seek to the given virtual offset. Return true if successful, or false if the backing stream is unseekable, or not blocked. Note that this will cause problems if something reading from this stream is still operating on outstanding buffers; Any CodedInputStreams reading from this stream must be destroyed before this function is called.

◆ Skip()

bool vg::io::BlockedGzipInputStream::Skip ( int  count)
virtual

Skip ahead the given number of bytes. Return false if the end of the stream is reached, or an error occurs. If the end of the stream is hit, advances to the end of the stream.

◆ SmellsLikeGzip()

bool vg::io::BlockedGzipInputStream::SmellsLikeGzip ( std::istream &  in)
static

Return true if the given istream looks like GZIP-compressed data (i.e. has the GZIP magic number as its first two bytes). Replicates some of the sniffing logic that htslib does, but puts back the sniffed characters so the stream can be read fine either way after sniffing.

◆ Tell()

int64_t vg::io::BlockedGzipInputStream::Tell ( ) const
virtual

Return the blocked gzip virtual offset at which the next fresh buffer returned by Next() will start, or -1 if operating on an untellable stream like standard input or on a non-blocked file. Note that this will only get you the position of the next read if anything you are reading through is fully backed up to the next actually-unread byte. See Protobuf's CodedInputStream::Trim().

Member Data Documentation

◆ byte_count

size_t vg::io::BlockedGzipInputStream::byte_count
protected

The counter to back ByteCount.

◆ handle

BGZF* vg::io::BlockedGzipInputStream::handle
protected

The open BGZF handle being read from. We use the BGZF's buffer as our buffer, and its block_offset for our seeks and back-ups.

◆ know_offset

bool vg::io::BlockedGzipInputStream::know_offset
protected

Flag for whether our backing stream is tellable.


The documentation for this class was generated from the following files: