SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VwNativeCacheWriter.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights
3  * embodied in the content of this file are licensed under the BSD
4  * (revised) open source license.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Written (W) 2011 Shashwat Lal Das
12  * Adaptation of Vowpal Wabbit v5.1.
13  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society.
14  */
15 
16 #ifndef _VW_NATIVECACHE_WRITE_H__
17 #define _VW_NATIVECACHE_WRITE_H__
18 
20 
21 namespace shogun
22 {
27 {
28 public:
33 
40  CVwNativeCacheWriter(char * fname, CVwEnvironment* env_to_use);
41 
45  virtual ~CVwNativeCacheWriter();
46 
52  virtual void set_file(int32_t f);
53 
59  virtual void cache_example(VwExample* &ex);
60 
66  virtual const char* get_name() const { return "VwNativeCacheWriter"; }
67 
68 private:
72  void init();
73 
78  void write_header();
79 
88  char* run_len_encode(char *p, vw_size_t i);
89 
97  inline uint32_t ZigZagEncode(int32_t n)
98  {
99  uint32_t ret = (n << 1) ^ (n >> 31);
100 
101  return ret;
102  }
103 
112  char* bufcache_label(VwLabel* ld, char* c);
113 
119  void cache_label(VwLabel* ld);
120 
126  void cache_tag(v_array<char> tag);
127 
133  void output_byte(unsigned char s);
134 
142  void output_features(unsigned char index, VwFeature* begin, VwFeature* end);
143 
144 protected:
147 
148 private:
150  vw_size_t neg_1;
152  vw_size_t general;
154  vw_size_t int_size;
155 };
156 
157 }
158 #endif // _VW_NATIVECACHE_WRITE_H__

SHOGUN Machine Learning Toolbox - Documentation