Class StreamingVwCacheFile to read vector-by-vector from VW cache files.
The cache file is usually generated either by VW or by enabling the cache writing option in a CStreamingVwFile object.
This class reads the example and label into one object of VwExample type.
Definition at line 30 of file StreamingVwCacheFile.h.
Public Member Functions | |
CStreamingVwCacheFile () | |
CStreamingVwCacheFile (EVwCacheType cache_type) | |
CStreamingVwCacheFile (char *fname, char rw='r', EVwCacheType cache_type=C_NATIVE) | |
virtual | ~CStreamingVwCacheFile () |
virtual void | get_vector (VwExample *&ex, int32_t &len) |
virtual void | get_vector_and_label (VwExample *&ex, int32_t &len, float64_t &label) |
virtual const char * | get_name () const |
void | set_env (CVwEnvironment *env_to_use) |
CVwEnvironment * | get_env () |
bool | is_seekable () |
void | reset_stream () |
Protected Attributes | |
CVwCacheReader * | cache_reader |
Cache reader. | |
CVwEnvironment * | env |
Environment used for vw. | |
EVwCacheType | cache_format |
Cache type. |
Default constructor. Assumes cache file is of type C_NATIVE
Definition at line 14 of file StreamingVwCacheFile.cpp.
CStreamingVwCacheFile | ( | EVwCacheType | cache_type | ) |
Constructor taking cache type as an argument.
cache_type | cache type - C_NATIVE or C_PROTOBUF |
Definition at line 20 of file StreamingVwCacheFile.cpp.
CStreamingVwCacheFile | ( | char * | fname, | |
char | rw = 'r' , |
|||
EVwCacheType | cache_type = C_NATIVE | |||
) |
Constructor taking file name and cache type as arguments
fname | file name | |
rw | read/write mode | |
cache_type | type of cache - C_NATIVE or C_PROTOBUF |
Definition at line 26 of file StreamingVwCacheFile.cpp.
~CStreamingVwCacheFile | ( | ) | [virtual] |
Destructor
Definition at line 32 of file StreamingVwCacheFile.cpp.
CVwEnvironment* get_env | ( | ) |
Return the environment
Definition at line 102 of file StreamingVwCacheFile.h.
virtual const char* get_name | ( | void | ) | const [virtual] |
Reimplemented from CStreamingFile.
Definition at line 85 of file StreamingVwCacheFile.h.
void get_vector | ( | VwExample *& | ex, | |
int32_t & | len | |||
) | [virtual] |
Returns the parsed example.
The example contains the label if available, and also contains length of the feature vector. These parameters, passed separately are redundant.
ex | examples as VwExample*, set by reference | |
len | length of vector, untouched |
Reimplemented from CStreamingFile.
Definition at line 38 of file StreamingVwCacheFile.cpp.
Returns the parsed example.
TODO: Make this fail if examples are found to be unlabelled.
ex | example as VwExample*, set by reference | |
len | length of vector, untouched | |
label | label, untouched |
Reimplemented from CStreamingFile.
Definition at line 46 of file StreamingVwCacheFile.cpp.
bool is_seekable | ( | ) | [virtual] |
Whether this stream is seekable
Reimplemented from CStreamingFile.
Definition at line 113 of file StreamingVwCacheFile.h.
void reset_stream | ( | ) | [virtual] |
Reset cache file back to first example.
Used when multiple passes are to be performed
Reimplemented from CStreamingFile.
Definition at line 76 of file StreamingVwCacheFile.cpp.
void set_env | ( | CVwEnvironment * | env_to_use | ) |
Set environment for vw
env_to_use | CVwEnvironment* environment |
Definition at line 54 of file StreamingVwCacheFile.cpp.
EVwCacheType cache_format [protected] |
Cache type.
Definition at line 138 of file StreamingVwCacheFile.h.
CVwCacheReader* cache_reader [protected] |
Cache reader.
Definition at line 132 of file StreamingVwCacheFile.h.
CVwEnvironment* env [protected] |
Environment used for vw.
Definition at line 135 of file StreamingVwCacheFile.h.