18 using namespace shogun;
57 void CVwNativeCacheReader::init()
71 SG_SERROR(
"Cache version too long, cache file is probably invalid.\n");
75 if (strcmp(t,vw_version) != 0)
78 SG_SERROR(
"Cache has possibly incompatible version!\n");
86 if (cache_numbits != numbits)
87 SG_SERROR(
"Bug encountered in caching! Bits used for weight in cache: %d.\n", cache_numbits);
90 char* CVwNativeCacheReader::run_len_decode(
char *p,
vw_size_t& i)
95 i = i | ((*(p++) & 127) << 7*count++);
96 i = i | (*(p++) << 7*count);
100 char* CVwNativeCacheReader::bufread_label(
VwLabel*
const ld,
char* c)
103 c +=
sizeof(ld->
label);
120 c = bufread_label(ld,c);
129 if (
buf.
buf_read(c,
sizeof(tag_size)) <
sizeof(tag_size))
132 c +=
sizeof(tag_size);
140 return tag_size+
sizeof(tag_size);
149 if (read_cached_tag(ae) == 0)
153 unsigned char num_indices = 0;
154 if (
buf.
buf_read(c,
sizeof(num_indices)) <
sizeof(num_indices))
156 num_indices = *(
unsigned char*)c;
157 c +=
sizeof(num_indices);
161 for (; num_indices > 0; num_indices--)
164 unsigned char index = 0;
167 if (temp <
sizeof(index) +
sizeof(
vw_size_t))
168 SG_SERROR(
"Truncated example! %d < %d bytes expected.\n",
171 index = *(
unsigned char*) c;
183 SG_SERROR(
"Truncated example! Wanted %d bytes!\n", storage);
185 char *end = c + storage;
193 c = run_len_decode(c, temp);
200 f.
x = ((one_float*)c)->f;
204 *our_sum_feat_sq += f.
x*f.
x;
207 int32_t s_diff = ZigZagDecode(diff);