20 while (*p & 128) i = i | ((uint64_t)(*(p++) & 127) << 7 * count++);
21 i = i | ((uint64_t)(*(p++)) << 7 * count);
30 *(p++) = (i & 127) | 128;
37 inline int64_t
ZigZagDecode(uint64_t n) {
return (n >> 1) ^ -
static_cast<int64_t
>(n & 1); }
43 if (cache.
buf_read(c,
sizeof(tag_size)) <
sizeof(tag_size))
45 tag_size = *(
size_t*)c;
46 c +=
sizeof(tag_size);
48 if (cache.
buf_read(c, tag_size) < tag_size)
53 return tag_size +
sizeof(tag_size);
77 unsigned char num_indices = 0;
78 if (input->
buf_read(c,
sizeof(num_indices)) <
sizeof(num_indices))
80 num_indices = *(
unsigned char*)c;
81 c +=
sizeof(num_indices);
84 for (; num_indices > 0; num_indices--)
87 unsigned char index = 0;
88 if ((temp = input->
buf_read(c,
sizeof(index) +
sizeof(
size_t))) <
sizeof(index) +
sizeof(size_t))
94 index = *(
unsigned char*)c;
98 size_t storage = *(
size_t*)c;
102 if (input->
buf_read(c, storage) < storage)
104 all->
trace_message <<
"truncated example! wanted: " << storage <<
" bytes" << std::endl;
108 char* end = c + storage;
124 uint64_t diff = i >> 2;
140 uint64_t ret = (n << 1) ^ (n >> 63);
158 if (f != 1. && f != -1.)
161 cache.
buf_write(c,
sizeof(index) + storage +
sizeof(
size_t));
162 *
reinterpret_cast<unsigned char*
>(
c) = index;
165 char* storage_size_loc =
c;
172 int64_t s_diff = (fi - last);
178 else if (f.value() == -1.)
189 *(
size_t*)storage_size_loc = c - storage_size_loc -
sizeof(
size_t);
196 *(
size_t*)c = tag.
size();
213 if (number > UINT32_MAX)
215 THROW(
"size_t value is out of bounds of uint32_t.")
217 return static_cast<uint32_t
>(number);
v_array< namespace_index > indices
size_t read_cached_tag(io_buf &cache, example *ae)
void push_back(feature_value v, feature_index i)
constexpr size_t char_size
uint64_t ZigZagEncode(int64_t n)
constexpr size_t int_size
the core definition of a set of features.
char * run_len_decode(char *p, uint64_t &i)
void output_byte(io_buf &cache, unsigned char s)
v_array< feature_value > values
std::array< features, NUM_NAMESPACES > feature_space
void push_many(v_array< T > &v, const T *_begin, size_t num)
void output_features(io_buf &cache, unsigned char index, features &fs, uint64_t mask)
void push_back(const T &new_ele)
unsigned char namespace_index
struct one_float __attribute__((packed))
void buf_write(char *&pointer, size_t n)
iterator over values and indicies
void cache_features(io_buf &cache, example *ae, uint64_t mask)
int64_t ZigZagDecode(uint64_t n)
char * run_len_encode(char *p, uint64_t i)
int read_cached_features(vw *all, v_array< example *> &examples)
uint32_t convert(size_t number)
size_t(* read_cached_label)(shared_data *, void *, io_buf &cache)
void cache_tag(io_buf &cache, v_array< char > tag)
size_t buf_read(char *&pointer, size_t n)