55 void CVwNativeCacheWriter::init()
62 void CVwNativeCacheWriter::write_header()
74 char* CVwNativeCacheWriter::run_len_encode(
char *p,
vw_size_t i)
78 *(p++) = (i & 127) | 128;
86 char* CVwNativeCacheWriter::bufcache_label(
VwLabel* ld,
char* c)
89 c +=
sizeof(ld->
label);
97 void CVwNativeCacheWriter::cache_label(
VwLabel* ld)
101 c = bufcache_label(ld,c);
118 void CVwNativeCacheWriter::output_byte(
unsigned char s)
127 void CVwNativeCacheWriter::output_features(
unsigned char index,
VwFeature* begin,
VwFeature* end)
130 vw_size_t storage = (end-begin) * int_size;
131 for (
VwFeature* i = begin; i != end; i++)
132 if (i->x != 1. && i->x != -1.)
136 *(
unsigned char*)c = index;
139 char *storage_size_loc = c;
145 for (
VwFeature* i = begin; i != end; i++)
147 int32_t s_diff = (i->weight_index - last);
148 vw_size_t diff = ZigZagEncode(s_diff) << 2;
149 last = i->weight_index;
152 c = run_len_encode(c, diff);
153 else if (i->x == -1.)
154 c = run_len_encode(c, diff | neg_1);
157 c = run_len_encode(c, diff | general);
uint32_t vw_size_t
vw_size_t typedef to work across platforms
CVwCacheWriter is the base class for all VW cache creating classes.
T * end
Pointer to last set element in the array.
T * begin
Pointer to first element of the array.
Class CVwEnvironment is the environment used by VW.
virtual void use_file(int fd)
virtual void set_file(int32_t f)
CIOBuffer buf
IOBuffer used for writing.
vw_size_t num_bits
log_2 of the number of features
virtual bool close_file()
float32_t label
Label value.
v_array< vw_size_t > indices
Array of namespaces.
virtual ssize_t write_file(const void *buf, size_t nbytes)
float32_t weight
Weight of example.
Class VwLabel holds a label object used by VW.
CVwEnvironment * env
Environment.
int32_t fd
File descriptor.
void buf_write(char *&pointer, int n)
float32_t initial
Initial approximation.
all of classes and functions are contained in the shogun namespace
VwLabel * ld
Label object.
const char * vw_version
VW version.
virtual ~CVwNativeCacheWriter()
v_array< VwFeature > atomics[256]
Array of features.
virtual void cache_example(VwExample *&ex)