Vowpal Wabbit
example_predict_builder.cc
Go to the documentation of this file.
2 #include "hash.h"
3 #include "hashstring.h"
4 
5 namespace vw_slim
6 {
8  example_predict* ex, char* namespace_name, uint32_t feature_index_num_bits)
9  : _ex(ex)
10 {
11  _feature_index_bit_mask = ((uint64_t)1 << feature_index_num_bits) - 1;
12  add_namespace(namespace_name[0]);
13  _namespace_hash = hashstring({namespace_name, namespace_name + (strlen(namespace_name))}, 0);
14 }
15 
17  example_predict* ex, namespace_index namespace_idx, uint32_t feature_index_num_bits)
18  : _ex(ex), _namespace_hash(namespace_idx)
19 {
20  _feature_index_bit_mask = ((uint64_t)1 << feature_index_num_bits) - 1;
21  add_namespace(namespace_idx);
22 }
23 
25 {
26  _namespace_idx = feature_group;
27  _ex->indices.unique_add_sorted(feature_group);
28 }
29 
31 {
32  feature_index feature_hash =
33  _feature_index_bit_mask & hashstring({feature_name, feature_name + (strlen(feature_name))}, _namespace_hash);
34  _ex->feature_space[_namespace_idx].push_back(value, feature_hash);
35 }
36 
38 {
39  _ex->feature_space[_namespace_idx].push_back(value, _namespace_hash + feature_idx);
40 }
41 }; // namespace vw_slim
void push_feature(feature_index feature_idx, feature_value value)
v_array< namespace_index > indices
void add_namespace(namespace_index feature_group)
float feature_value
Definition: feature_group.h:20
example_predict_builder(example_predict *ex, char *namespace_name, uint32_t feature_index_num_bits=18)
std::array< features, NUM_NAMESPACES > feature_space
unsigned char namespace_index
uint64_t feature_index
Definition: feature_group.h:21
void push_feature_string(char *feature_idx, feature_value value)
VW_STD14_CONSTEXPR uint64_t hashstring(substring s, uint64_t h)
Definition: hashstring.h:18
size_t unique_add_sorted(const T &new_ele)
Definition: v_array.h:140