SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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__
An I/O buffer class.
Definition: IOBuffer.h:41
uint32_t vw_size_t
vw_size_t typedef to work across platforms
Definition: vw_constants.h:26
CVwCacheWriter is the base class for all VW cache creating classes.
Definition: VwCacheWriter.h:35
Class CVwEnvironment is the environment used by VW.
Definition: VwEnvironment.h:41
virtual void set_file(int32_t f)
CIOBuffer buf
IOBuffer used for writing.
Example class for VW.
Definition: vw_example.h:58
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual const char * get_name() const
Class CVwNativeCacheWriter writes a cache exactly as that which would be produced by VW's default cac...
virtual void cache_example(VwExample *&ex)

SHOGUN Machine Learning Toolbox - Documentation