Avro C++
Public Member Functions | List of all members
avro::DataFileReader< T > Class Template Reference

Reads the contents of data file one after another. More...

#include <DataFile.hh>

Inheritance diagram for avro::DataFileReader< T >:

Public Member Functions

 DataFileReader (const char *filename, const ValidSchema &readerSchema)
 Constructs the reader for the given file and the reader is expected to use the given schema.
 
 DataFileReader (std::unique_ptr< InputStream > inputStream, const ValidSchema &readerSchema)
 
 DataFileReader (const char *filename)
 Constructs the reader for the given file and the reader is expected to use the schema that is used with data.
 
 DataFileReader (std::unique_ptr< InputStream > inputStream)
 
 DataFileReader (std::unique_ptr< DataFileReaderBase > base)
 Constructs a reader using the reader base. More...
 
 DataFileReader (std::unique_ptr< DataFileReaderBase > base, const ValidSchema &readerSchema)
 Constructs a reader using the reader base. More...
 
bool read (T &datum)
 Reads the next entry from the data file. More...
 
const ValidSchemareaderSchema ()
 Returns the schema for this object.
 
const ValidSchemadataSchema ()
 Returns the schema stored with the data file.
 
void close ()
 Closes the reader. More...
 
void seek (int64_t position)
 Move to a specific, known synchronization point, for example one returned from previousSync().
 
void sync (int64_t position)
 Move to the next synchronization point after a position. More...
 
bool pastSync (int64_t position)
 Return true if past the next synchronization point after a position.
 
int64_t previousSync ()
 Return the last synchronization point before our current position.
 

Detailed Description

template<typename T>
class avro::DataFileReader< T >

Reads the contents of data file one after another.

Constructor & Destructor Documentation

◆ DataFileReader() [1/2]

template<typename T >
avro::DataFileReader< T >::DataFileReader ( std::unique_ptr< DataFileReaderBase base)
inlineexplicit

Constructs a reader using the reader base.

This form of constructor allows the user to examine the schema of a given file and then decide to use the right type of data to be deserialize. Without this the user must know the type of data for the template before he knows the schema within the file. The schema present in the data file will be used for reading from this reader.

◆ DataFileReader() [2/2]

template<typename T >
avro::DataFileReader< T >::DataFileReader ( std::unique_ptr< DataFileReaderBase base,
const ValidSchema readerSchema 
)
inline

Constructs a reader using the reader base.

This form of constructor allows the user to examine the schema of a given file and then decide to use the right type of data to be deserialize. Without this the user must know the type of data for the template before he knows the schema within the file. The argument readerSchema will be used for reading from this reader.

References avro::DataFileReader< T >::readerSchema().

Member Function Documentation

◆ close()

template<typename T >
void avro::DataFileReader< T >::close ( )
inline

Closes the reader.

No further operation is possible on this reader.

◆ read()

template<typename T >
bool avro::DataFileReader< T >::read ( T &  datum)
inline

Reads the next entry from the data file.

Returns
true if an object has been successfully read into datum and false if there are no more entries in the file.

References avro::decode().

◆ sync()

template<typename T >
void avro::DataFileReader< T >::sync ( int64_t  position)
inline

Move to the next synchronization point after a position.

To process a range of file entries, call this with the starting position, then check pastSync() with the end point before each call to read().


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