Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _VW_NATIVECACHE_WRITE_H__
00017 #define _VW_NATIVECACHE_WRITE_H__
00018
00019 #include <shogun/classifier/vw/cache/VwCacheWriter.h>
00020
00021 namespace shogun
00022 {
00026 class CVwNativeCacheWriter: public CVwCacheWriter
00027 {
00028 public:
00032 CVwNativeCacheWriter();
00033
00040 CVwNativeCacheWriter(char * fname, CVwEnvironment* env_to_use);
00041
00045 virtual ~CVwNativeCacheWriter();
00046
00052 virtual void set_file(int32_t f);
00053
00059 virtual void cache_example(VwExample* &ex);
00060
00066 virtual const char* get_name() const { return "VwNativeCacheWriter"; }
00067
00068 private:
00072 void init();
00073
00078 void write_header();
00079
00088 char* run_len_encode(char *p, vw_size_t i);
00089
00097 inline uint32_t ZigZagEncode(int32_t n)
00098 {
00099 uint32_t ret = (n << 1) ^ (n >> 31);
00100
00101 return ret;
00102 }
00103
00112 char* bufcache_label(VwLabel* ld, char* c);
00113
00119 void cache_label(VwLabel* ld);
00120
00126 void cache_tag(v_array<char> tag);
00127
00133 void output_byte(unsigned char s);
00134
00142 void output_features(unsigned char index, VwFeature* begin, VwFeature* end);
00143
00144 protected:
00146 CIOBuffer buf;
00147
00148 private:
00150 vw_size_t neg_1;
00152 vw_size_t general;
00154 vw_size_t int_size;
00155 };
00156
00157 }
00158 #endif // _VW_NATIVECACHE_WRITE_H__