vg
tools for working with variation graphs
|
#include <blocked_gzip_input_stream.hpp>
Public Member Functions | |
BlockedGzipInputStream (std::istream &stream) | |
virtual | ~BlockedGzipInputStream () |
Destroy the stream. More... | |
BlockedGzipInputStream (const BlockedGzipInputStream &other)=delete | |
BlockedGzipInputStream & | operator= (const BlockedGzipInputStream &other)=delete |
BlockedGzipInputStream (BlockedGzipInputStream &&other)=delete | |
BlockedGzipInputStream & | operator= (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... | |
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.
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.
|
virtual |
Destroy the stream.
|
delete |
|
delete |
|
virtual |
|
virtual |
Get the number of bytes read since the stream was constructed.
|
virtual |
Turn on multithreaded decompression. Return true if successful and false if the BGZF could not set up its thread pool.
|
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.
|
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.
|
delete |
|
delete |
|
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.
|
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.
|
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.
|
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().
|
protected |
The counter to back ByteCount.
|
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.
|
protected |
Flag for whether our backing stream is tellable.