StreamingVwCacheFile.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 2011 Shashwat Lal Das
00008  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
00009  */
00010 #ifndef __STREAMING_VWCACHEFILE_H__
00011 #define __STREAMING_VWCACHEFILE_H__
00012 
00013 #include <shogun/io/StreamingFile.h>
00014 #include <shogun/classifier/vw/vw_common.h>
00015 #include <shogun/classifier/vw/cache/VwCacheReader.h>
00016 #include <shogun/classifier/vw/cache/VwNativeCacheReader.h>
00017 
00018 namespace shogun
00019 {
00030 class CStreamingVwCacheFile: public CStreamingFile
00031 {
00032 public:
00037     CStreamingVwCacheFile();
00038 
00045     CStreamingVwCacheFile(EVwCacheType cache_type);
00046 
00054     CStreamingVwCacheFile(char* fname, char rw='r', EVwCacheType cache_type = C_NATIVE);
00055 
00059     virtual ~CStreamingVwCacheFile();
00060 
00071     virtual void get_vector(VwExample* &ex, int32_t &len);
00072 
00082     virtual void get_vector_and_label(VwExample* &ex, int32_t &len, float64_t &label);
00083 
00085     inline virtual const char* get_name() const
00086     {
00087         return "StreamingVwCacheFile";
00088     }
00089 
00095     void set_env(CVwEnvironment* env_to_use);
00096 
00102     CVwEnvironment* get_env()
00103     {
00104         SG_REF(env);
00105         return env;
00106     }
00107 
00113     bool is_seekable() { return true; }
00114 
00120     void reset_stream();
00121 
00122 private:
00128     virtual void init(EVwCacheType cache_type);
00129 
00130 protected:
00132     CVwCacheReader* cache_reader;
00133 
00135     CVwEnvironment* env;
00136 
00138     EVwCacheType cache_format;
00139 };
00140 }
00141 #endif //__STREAMING_VWCACHEFILE_H__
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation