jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
jubatus::core::storage::column_type Class Reference

#include <column_type.hpp>

Collaboration diagram for jubatus::core::storage::column_type:
Collaboration graph

Public Types

enum  type_name {
  int8_type, int16_type, int32_type, int64_type,
  uint8_type, uint16_type, uint32_type, uint64_type,
  float_type, double_type, bit_vector_type, string_type,
  array_type, invalid_type
}
 

Public Member Functions

size_t bit_vector_length () const
 
 column_type ()
 
 column_type (type_name name)
 
 column_type (type_name name, int length)
 
bool is (const type_name &type) const
 
template<class Buffer >
void msgpack_pack (msgpack::packer< Buffer > &packer) const
 
void msgpack_unpack (msgpack::object o)
 
column_typeoperator= (const column_type &orig)
 
size_t size () const
 
void swap (column_type &rhs)
 
std::string type_as_string () const
 

Private Attributes

int bit_vector_length_
 
type_name type_
 

Friends

bool operator!= (const column_type &x, const column_type &y)
 
std::ostream & operator<< (std::ostream &os, const column_type &type)
 
bool operator== (const column_type &x, const column_type &y)
 

Detailed Description

Definition at line 32 of file column_type.hpp.

Member Enumeration Documentation

Enumerator
int8_type 
int16_type 
int32_type 
int64_type 
uint8_type 
uint16_type 
uint32_type 
uint64_type 
float_type 
double_type 
bit_vector_type 
string_type 
array_type 
invalid_type 

Definition at line 34 of file column_type.hpp.

Constructor & Destructor Documentation

jubatus::core::storage::column_type::column_type ( )
inline
jubatus::core::storage::column_type::column_type ( type_name  name)
inlineexplicit

Definition at line 51 of file column_type.hpp.

References bit_vector_type.

51  : type_(name), bit_vector_length_(0) {
52  if (name == bit_vector_type) {
53  throw argument_unmatch_exception(
54  "bit_vector_type expects bit_vector's length as second argument");
55  }
56  }
jubatus::core::storage::column_type::column_type ( type_name  name,
int  length 
)
inline

Definition at line 57 of file column_type.hpp.

References bit_vector_type.

58  : type_(name),
59  bit_vector_length_(length) {
60  if (name != bit_vector_type) {
61  throw argument_unmatch_exception(
62  "unneeded second parameter, it is used only for bit_vector_type");
63  }
64  }

Member Function Documentation

size_t jubatus::core::storage::column_type::bit_vector_length ( ) const
inline

Definition at line 126 of file column_type.hpp.

References bit_vector_length_, bit_vector_type, type_, and type_as_string().

Referenced by jubatus::core::storage::typed_column< bit_vector >::check_bit_vector_(), and msgpack_unpack().

126  {
127  if (type_ != bit_vector_type) {
128  throw type_unmatch_exception(
129  "bit_vector length expected but type was" + type_as_string());
130  }
131  return bit_vector_length_;
132  }
std::string type_as_string() const
Definition: column_type.hpp:70

Here is the call graph for this function:

Here is the caller graph for this function:

bool jubatus::core::storage::column_type::is ( const type_name type) const
inline
template<class Buffer >
void jubatus::core::storage::column_type::msgpack_pack ( msgpack::packer< Buffer > &  packer) const
inline

Definition at line 163 of file column_type.hpp.

References bit_vector_length_, and type_.

163  {
164  packer.pack_array(2);
165  packer.pack(static_cast<uint8_t>(type_));
166  packer.pack(static_cast<uint64_t>(bit_vector_length_));
167  }
void jubatus::core::storage::column_type::msgpack_unpack ( msgpack::object  o)
inline

Definition at line 168 of file column_type.hpp.

References bit_vector_length(), bit_vector_length_, and type_.

168  {
169  if (o.type != msgpack::type::ARRAY || o.via.array.size != 2) {
170  throw msgpack::type_error();
171  }
172  uint8_t type;
173  o.via.array.ptr[0].convert(&type);
174  uint64_t bit_vector_length;
175  o.via.array.ptr[1].convert(&bit_vector_length);
176  type_ = static_cast<type_name>(type);
178  }

Here is the call graph for this function:

column_type& jubatus::core::storage::column_type::operator= ( const column_type orig)
inline

Definition at line 134 of file column_type.hpp.

References bit_vector_length_, and type_.

134  {
135  type_ = orig.type_;
136  bit_vector_length_ = orig.bit_vector_length_;
137  return *this;
138  }
size_t jubatus::core::storage::column_type::size ( ) const
inline

Definition at line 99 of file column_type.hpp.

References array_type, bit_vector_length_, bit_vector_type, double_type, float_type, int16_type, int32_type, int64_type, int8_type, invalid_type, jubatus::core::storage::bit_vector_base< uint64_t >::memory_size(), string_type, type_, uint16_type, uint32_type, uint64_type, and uint8_type.

99  {
100  switch (type_) {
101  case int8_type:
102  case uint8_type:
103  return 1;
104  case int16_type:
105  case uint16_type:
106  return 2;
107  case int32_type:
108  case uint32_type:
109  case float_type:
110  return 4;
111  case int64_type:
112  case uint64_type:
113  case double_type:
114  case string_type:
115  return 8;
116  case bit_vector_type:
118  case array_type:
119  case invalid_type:
120  default:
121  return 0;
122  }
123  }
static size_t memory_size(size_t bit_width)
Definition: bit_vector.hpp:319

Here is the call graph for this function:

void jubatus::core::storage::column_type::swap ( column_type rhs)
inline

Definition at line 140 of file column_type.hpp.

References bit_vector_length_, jubatus::core::clustering::swap(), and type_.

140  {
141  using std::swap;
142  swap(type_, rhs.type_);
143  swap(bit_vector_length_, rhs.bit_vector_length_);
144  }
void swap(weighted_point &p1, weighted_point &p2)
Definition: types.hpp:47

Here is the call graph for this function:

std::string jubatus::core::storage::column_type::type_as_string ( ) const
inline

Definition at line 70 of file column_type.hpp.

References bit_vector_type, double_type, float_type, int16_type, int32_type, int64_type, int8_type, string_type, type_, uint16_type, uint32_type, uint64_type, and uint8_type.

Referenced by bit_vector_length().

70  {
71  if (type_ == int8_type) {
72  return "int8";
73  } else if (type_ == int16_type) {
74  return "int16";
75  } else if (type_ == int32_type) {
76  return "int32";
77  } else if (type_ == int64_type) {
78  return "int64";
79  } else if (type_ == uint8_type) {
80  return "uint8";
81  } else if (type_ == uint16_type) {
82  return "uint16";
83  } else if (type_ == uint32_type) {
84  return "uint32";
85  } else if (type_ == uint64_type) {
86  return "uint64";
87  } else if (type_ == float_type) {
88  return "float";
89  } else if (type_ == double_type) {
90  return "double";
91  } else if (type_ == bit_vector_type) {
92  return "bit_vector";
93  } else if (type_ == string_type) {
94  return "string";
95  }
96  throw type_unmatch_exception("in type_as_string(): unknown type");
97  }

Here is the caller graph for this function:

Friends And Related Function Documentation

bool operator!= ( const column_type x,
const column_type y 
)
friend

Definition at line 158 of file column_type.hpp.

158  {
159  return !(x == y);
160  }
std::ostream& operator<< ( std::ostream &  os,
const column_type type 
)
friend

Definition at line 146 of file column_type.hpp.

146  {
147  os << "{ " << type.type_as_string();
148  if (type.type_ == bit_vector_type) {
149  os << ": " << type.bit_vector_length_;
150  }
151  os << " }";
152  return os;
153  }
bool operator== ( const column_type x,
const column_type y 
)
friend

Definition at line 155 of file column_type.hpp.

155  {
156  return x.type_ == y.type_ && x.bit_vector_length_ == y.bit_vector_length_;
157  }

Member Data Documentation

int jubatus::core::storage::column_type::bit_vector_length_
private

Definition at line 182 of file column_type.hpp.

Referenced by bit_vector_length(), msgpack_pack(), msgpack_unpack(), operator=(), size(), and swap().

type_name jubatus::core::storage::column_type::type_
private

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