Vowpal Wabbit
Public Member Functions | List of all members
MultiState< audit > Struct Template Reference

#include <parse_example_json.h>

Inheritance diagram for MultiState< audit >:
BaseState< audit >

Public Member Functions

 MultiState ()
 
BaseState< audit > * StartArray (Context< audit > &ctx) override
 
BaseState< audit > * StartObject (Context< audit > &ctx) override
 
BaseState< audit > * EndArray (Context< audit > &ctx, rapidjson::SizeType) override
 
- Public Member Functions inherited from BaseState< audit >
 BaseState (const char *pname)
 
virtual BaseState< audit > * Null (Context< audit > &ctx)
 
virtual BaseState< audit > * Bool (Context< audit > &ctx, bool b)
 
virtual BaseState< audit > * Float (Context< audit > &ctx, float v)
 
virtual BaseState< audit > * Uint (Context< audit > &ctx, unsigned v)
 
virtual BaseState< audit > * String (Context< audit > &ctx, const char *str, rapidjson::SizeType len, bool)
 
virtual BaseState< audit > * Key (Context< audit > &ctx, const char *str, rapidjson::SizeType len, bool)
 
virtual BaseState< audit > * EndObject (Context< audit > &ctx, rapidjson::SizeType)
 

Additional Inherited Members

- Public Attributes inherited from BaseState< audit >
const char * name
 

Detailed Description

template<bool audit>
struct MultiState< audit >

Definition at line 429 of file parse_example_json.h.

Constructor & Destructor Documentation

◆ MultiState()

template<bool audit>
MultiState< audit >::MultiState ( )
inline

Definition at line 431 of file parse_example_json.h.

431 : BaseState<audit>("Multi") {}

Member Function Documentation

◆ EndArray()

template<bool audit>
BaseState<audit>* MultiState< audit >::EndArray ( Context< audit > &  ctx,
rapidjson::SizeType   
)
inlineoverridevirtual

Reimplemented from BaseState< audit >.

Definition at line 477 of file parse_example_json.h.

References Context< audit >::default_state, Context< audit >::ex, and Context< audit >::examples.

478  {
479  // return to shared example
480  ctx.ex = (*ctx.examples)[0];
481 
482  return &ctx.default_state;
483  }
example * ex
v_array< example * > * examples
DefaultState< audit > default_state

◆ StartArray()

template<bool audit>
BaseState<audit>* MultiState< audit >::StartArray ( Context< audit > &  ctx)
inlineoverridevirtual

Reimplemented from BaseState< audit >.

Definition at line 433 of file parse_example_json.h.

References CB::cb_class::action, Context< audit >::all, polylabel::cb, label_type::cb, label_type::ccb, polylabel::conditional_contextual_bandit, CB::cb_class::cost, CB::label::costs, Context< audit >::ex, f, example::l, vw::label_type, CB::cb_class::partial_prediction, CB::cb_class::probability, CCB::shared, THROW, CCB::label::type, and uniform_hash().

434  {
435  // mark shared example
436  if (ctx.all->label_type == label_type::cb)
437  {
438  CB::label* ld = &ctx.ex->l.cb;
439  CB::cb_class f;
440 
441  f.partial_prediction = 0.;
442  f.action = (uint32_t)uniform_hash("shared", 6, 0);
443  f.cost = FLT_MAX;
444  f.probability = -1.f;
445 
446  ld->costs.push_back(f);
447  }
448  else if (ctx.all->label_type == label_type::ccb)
449  {
452  }
453  else
454  THROW("label type is not CB or CCB")
455 
456  return this;
457  }
CB::label cb
Definition: example.h:31
label_type::label_type_t label_type
Definition: global_data.h:550
example * ex
v_array< cb_class > costs
Definition: cb.h:27
VW_STD14_CONSTEXPR uint64_t uniform_hash(const void *key, size_t len, uint64_t seed)
Definition: hash.h:67
uint32_t action
Definition: cb.h:18
float partial_prediction
Definition: cb.h:21
float probability
Definition: cb.h:19
example_type type
Definition: ccb_label.h:32
polylabel l
Definition: example.h:57
Definition: cb.h:25
float cost
Definition: cb.h:17
CCB::label conditional_contextual_bandit
Definition: example.h:32
#define THROW(args)
Definition: vw_exception.h:181
float f
Definition: cache.cc:40

◆ StartObject()

template<bool audit>
BaseState<audit>* MultiState< audit >::StartObject ( Context< audit > &  ctx)
inlineoverridevirtual

Reimplemented from BaseState< audit >.

Definition at line 459 of file parse_example_json.h.

References Context< audit >::all, label_type::ccb, polylabel::conditional_contextual_bandit, label_parser::default_label, Context< audit >::default_state, Context< audit >::ex, Context< audit >::example_factory, Context< audit >::example_factory_context, Context< audit >::examples, example::l, vw::label_type, parser::lp, vw::p, v_array< T >::push_back(), Context< audit >::PushNamespace(), and CCB::label::type.

460  {
461  // allocate new example
462  ctx.ex = &(*ctx.example_factory)(ctx.example_factory_context);
463  ctx.all->p->lp.default_label(&ctx.ex->l);
464  if (ctx.all->label_type == label_type::ccb)
465  {
467  }
468 
469  ctx.examples->push_back(ctx.ex);
470 
471  // setup default namespace
472  ctx.PushNamespace(" ", this);
473 
474  return &ctx.default_state;
475  }
void(* default_label)(void *)
Definition: label_parser.h:12
label_type::label_type_t label_type
Definition: global_data.h:550
example * ex
uint32_t action
Definition: search.h:19
void * example_factory_context
parser * p
Definition: global_data.h:377
VW::example_factory_t example_factory
void push_back(const T &new_ele)
Definition: v_array.h:107
v_array< example * > * examples
DefaultState< audit > default_state
example_type type
Definition: ccb_label.h:32
polylabel l
Definition: example.h:57
CCB::label conditional_contextual_bandit
Definition: example.h:32
label_parser lp
Definition: parser.h:102
void PushNamespace(const char *ns, BaseState< audit > *return_state)

The documentation for this struct was generated from the following file: