18 using namespace shogun;
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);