jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
jubatus::core::storage::typed_column< bit_vector > Class Template Reference

#include <abstract_column.hpp>

Inheritance diagram for jubatus::core::storage::typed_column< bit_vector >:
Inheritance graph
Collaboration diagram for jubatus::core::storage::typed_column< bit_vector >:
Collaboration graph

Public Member Functions

void clear ()
 
void dump (std::ostream &os, uint64_t target) const
 
bool insert (uint64_t target, const bit_vector &value)
 
bool insert (uint64_t target, const msgpack::object &obj)
 
bit_vector operator[] (uint64_t index)
 
bit_vector operator[] (uint64_t index) const
 
template<class Buffer >
void pack_array (msgpack::packer< Buffer > &packer) const
 
void pack_with_index (const uint64_t index, framework::packer &pk) const
 
void push_back (const bit_vector &value)
 
void push_back (const msgpack::object &obj)
 
bool remove (uint64_t target)
 
uint64_t size () const
 
 typed_column (const column_type &type)
 
void unpack_array (msgpack::object o)
 
bool update (uint64_t index, const bit_vector &value)
 
bool update (uint64_t index, const msgpack::object &obj)
 
- Public Member Functions inherited from jubatus::core::storage::detail::abstract_column_base
 abstract_column_base (const column_type &type)
 
 JUBATUS_GEN_FUNCTIONS_ (uint8_t)
 
 JUBATUS_GEN_FUNCTIONS_ (uint16_t)
 
 JUBATUS_GEN_FUNCTIONS_ (uint32_t)
 
 JUBATUS_GEN_FUNCTIONS_ (uint64_t)
 
 JUBATUS_GEN_FUNCTIONS_ (int8_t)
 
 JUBATUS_GEN_FUNCTIONS_ (int16_t)
 
 JUBATUS_GEN_FUNCTIONS_ (int32_t)
 
 JUBATUS_GEN_FUNCTIONS_ (int64_t)
 
 JUBATUS_GEN_FUNCTIONS_ (float)
 
 JUBATUS_GEN_FUNCTIONS_ (double)
 
 JUBATUS_GEN_FUNCTIONS_ (std::string)
 
 JUBATUS_GEN_FUNCTIONS_ (bit_vector)
 
 JUBATUS_GEN_FUNCTIONS_ (msgpack::object)
 
column_type type () const
 
virtual ~abstract_column_base ()
 

Private Member Functions

size_t blocks_per_value_ () const
 
size_t bytes_per_value_ () const
 
void check_bit_vector_ (const bit_vector &tested) const
 
uint64_t * get_data_at_ (size_t index)
 
const uint64_t * get_data_at_ (size_t index) const
 
void update_at_ (size_t index, const void *raw_data)
 

Private Attributes

std::vector< uint64_t > array_
 

Friends

std::ostream & operator<< (std::ostream &os, const typed_column< bit_vector > &c)
 

Detailed Description

template<>
class jubatus::core::storage::typed_column< bit_vector >

Definition at line 214 of file abstract_column.hpp.

Constructor & Destructor Documentation

Definition at line 216 of file abstract_column.hpp.

217  : detail::abstract_column_base(type) {
218  }

Member Function Documentation

size_t jubatus::core::storage::typed_column< bit_vector >::blocks_per_value_ ( ) const
inlineprivate

Definition at line 327 of file abstract_column.hpp.

327  {
328  return (bytes_per_value_() + sizeof(uint64_t) - 1) / sizeof(uint64_t);
329  }
size_t jubatus::core::storage::typed_column< bit_vector >::bytes_per_value_ ( ) const
inlineprivate

Definition at line 324 of file abstract_column.hpp.

References jubatus::core::storage::bit_vector_base< uint64_t >::memory_size(), and jubatus::core::storage::detail::abstract_column_base::type().

324  {
325  return bit_vector::memory_size(type().bit_vector_length());
326  }
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::typed_column< bit_vector >::check_bit_vector_ ( const bit_vector tested) const
inlineprivate

Definition at line 348 of file abstract_column.hpp.

References jubatus::core::storage::bit_vector_base< bit_base >::bit_num(), jubatus::core::storage::column_type::bit_vector_length(), and jubatus::core::storage::detail::abstract_column_base::type().

348  {
349  const size_t bit_num_expected = type().bit_vector_length();
350  if (tested.bit_num() > bit_num_expected) {
351  throw length_unmatch_exception(
352  "invalid length of bit_vector (" +
353  jubatus::util::lang::lexical_cast<std::string>(tested.bit_num()) + ", "
354  "expected " +
355  jubatus::util::lang::lexical_cast<std::string>(bit_num_expected) + ")");
356  }
357  }

Here is the call graph for this function:

void jubatus::core::storage::typed_column< bit_vector >::clear ( )
inlinevirtual
void jubatus::core::storage::typed_column< bit_vector >::dump ( std::ostream &  os,
uint64_t  target 
) const
inlinevirtual

Implements jubatus::core::storage::detail::abstract_column_base.

Definition at line 309 of file abstract_column.hpp.

309  {
310  os << "[" << target << "] " << (*this)[target] << std::endl;
311  }
uint64_t* jubatus::core::storage::typed_column< bit_vector >::get_data_at_ ( size_t  index)
inlineprivate

Definition at line 331 of file abstract_column.hpp.

References JUBATUS_ASSERT_LT, and jubatus::core::storage::typed_column< T >::size().

331  {
332  JUBATUS_ASSERT_LT(index, size(), "");
333  return &array_[blocks_per_value_() * index];
334  }
#define JUBATUS_ASSERT_LT(a, b, messages)
Definition: assert.hpp:69

Here is the call graph for this function:

const uint64_t* jubatus::core::storage::typed_column< bit_vector >::get_data_at_ ( size_t  index) const
inlineprivate

Definition at line 335 of file abstract_column.hpp.

References JUBATUS_ASSERT_LT, and jubatus::core::storage::typed_column< T >::size().

335  {
336  JUBATUS_ASSERT_LT(index, size(), "");
337  return &array_[blocks_per_value_() * index];
338  }
#define JUBATUS_ASSERT_LT(a, b, messages)
Definition: assert.hpp:69

Here is the call graph for this function:

bool jubatus::core::storage::typed_column< bit_vector >::insert ( uint64_t  target,
const bit_vector value 
)
inline

Definition at line 235 of file abstract_column.hpp.

References jubatus::core::storage::typed_column< T >::array_, jubatus::core::storage::bit_vector_base< bit_base >::raw_data_unsafe(), and jubatus::core::storage::typed_column< T >::size().

235  {
236  check_bit_vector_(value);
237 
238  if (size() < target) {
239  return false;
240  }
241  array_.insert(
242  array_.begin() + target * blocks_per_value_(),
243  blocks_per_value_(), 0);
244  update_at_(target, value.raw_data_unsafe());
245  return true;
246  }
void update_at_(size_t index, const void *raw_data)
void check_bit_vector_(const bit_vector &tested) const

Here is the call graph for this function:

bool jubatus::core::storage::typed_column< bit_vector >::insert ( uint64_t  target,
const msgpack::object &  obj 
)
inline

Definition at line 247 of file abstract_column.hpp.

References jubatus::core::storage::typed_column< T >::insert(), and jubatus::core::storage::detail::abstract_column_base::type().

247  {
248  bit_vector value(type().bit_vector_length());
249  obj.convert(&value);
250  return typed_column::insert(target, value);
251  }
bool insert(uint64_t target, const T &value)
bit_vector_base< uint64_t > bit_vector

Here is the call graph for this function:

bit_vector jubatus::core::storage::typed_column< bit_vector >::operator[] ( uint64_t  index)
inline

Definition at line 272 of file abstract_column.hpp.

References jubatus::core::storage::detail::abstract_column_base::type().

272  {
273  return bit_vector(get_data_at_(index), type().bit_vector_length());
274  }
bit_vector_base< uint64_t > bit_vector

Here is the call graph for this function:

bit_vector jubatus::core::storage::typed_column< bit_vector >::operator[] ( uint64_t  index) const
inline

Definition at line 275 of file abstract_column.hpp.

References jubatus::core::storage::detail::abstract_column_base::type().

275  {
276  return bit_vector(get_data_at_(index), type().bit_vector_length());
277  }
bit_vector_base< uint64_t > bit_vector

Here is the call graph for this function:

template<class Buffer >
void jubatus::core::storage::typed_column< bit_vector >::pack_array ( msgpack::packer< Buffer > &  packer) const
inline

Definition at line 314 of file abstract_column.hpp.

References jubatus::core::storage::typed_column< T >::array_.

314  {
315  packer.pack(array_);
316  }
void jubatus::core::storage::typed_column< bit_vector >::pack_with_index ( const uint64_t  index,
framework::packer pk 
) const
inlinevirtual

Reimplemented from jubatus::core::storage::detail::abstract_column_base.

Definition at line 293 of file abstract_column.hpp.

294  {
295  pk.pack((*this)[index]);
296  }
void jubatus::core::storage::typed_column< bit_vector >::push_back ( const bit_vector value)
inline
void jubatus::core::storage::typed_column< bit_vector >::push_back ( const msgpack::object &  obj)
inline

Definition at line 229 of file abstract_column.hpp.

References jubatus::core::storage::typed_column< T >::push_back(), and jubatus::core::storage::detail::abstract_column_base::type().

229  {
230  bit_vector value(type().bit_vector_length());
231  obj.convert(&value);
233  }
bit_vector_base< uint64_t > bit_vector

Here is the call graph for this function:

bool jubatus::core::storage::typed_column< bit_vector >::remove ( uint64_t  target)
inlinevirtual

Implements jubatus::core::storage::detail::abstract_column_base.

Definition at line 278 of file abstract_column.hpp.

References jubatus::core::storage::typed_column< T >::array_, JUBATUS_ASSERT_GE, and jubatus::core::storage::typed_column< T >::size().

278  {
279  if (target >= size()) {
280  return false;
281  }
282  if (target < size() - 1) {
283  const void* back = get_data_at_(size() - 1);
284  memcpy(get_data_at_(target), back, bytes_per_value_());
285  }
287  array_.resize(array_.size() - blocks_per_value_());
288  return true;
289  }
#define JUBATUS_ASSERT_GE(a, b, messages)
Definition: assert.hpp:71

Here is the call graph for this function:

uint64_t jubatus::core::storage::typed_column< bit_vector >::size ( ) const
inline

Definition at line 268 of file abstract_column.hpp.

References jubatus::core::storage::typed_column< T >::array_, and JUBATUS_ASSERT_EQ.

268  {
269  JUBATUS_ASSERT_EQ(array_.size() % blocks_per_value_(), 0u, "");
270  return array_.size() / blocks_per_value_();
271  }
#define JUBATUS_ASSERT_EQ(a, b, messages)
Definition: assert.hpp:63
void jubatus::core::storage::typed_column< bit_vector >::unpack_array ( msgpack::object  o)
inline

Definition at line 317 of file abstract_column.hpp.

References jubatus::core::storage::typed_column< T >::array_.

317  {
318  o.convert(&array_);
319  }
bool jubatus::core::storage::typed_column< bit_vector >::update ( uint64_t  index,
const bit_vector value 
)
inline

Definition at line 253 of file abstract_column.hpp.

References jubatus::core::storage::bit_vector_base< bit_base >::raw_data_unsafe(), and jubatus::core::storage::typed_column< T >::size().

253  {
254  check_bit_vector_(value);
255 
256  if (size() < index) {
257  return false;
258  }
259  update_at_(index, value.raw_data_unsafe());
260  return true;
261  }
void update_at_(size_t index, const void *raw_data)
void check_bit_vector_(const bit_vector &tested) const

Here is the call graph for this function:

bool jubatus::core::storage::typed_column< bit_vector >::update ( uint64_t  index,
const msgpack::object &  obj 
)
inline

Definition at line 262 of file abstract_column.hpp.

References jubatus::core::storage::detail::abstract_column_base::type(), and jubatus::core::storage::typed_column< T >::update().

262  {
263  bit_vector value(type().bit_vector_length());
264  obj.convert(&value);
265  return typed_column::update(index, value);
266  }
bool update(uint64_t index, const T &value)
bit_vector_base< uint64_t > bit_vector

Here is the call graph for this function:

void jubatus::core::storage::typed_column< bit_vector >::update_at_ ( size_t  index,
const void *  raw_data 
)
inlineprivate

Definition at line 340 of file abstract_column.hpp.

340  {
341  if (raw_data) {
342  memcpy(get_data_at_(index), raw_data, bytes_per_value_());
343  } else {
344  memset(get_data_at_(index), 0, bytes_per_value_());
345  }
346  }

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const typed_column< bit_vector > &  c 
)
friend

Definition at line 298 of file abstract_column.hpp.

299  {
300  os << "[column (bit_vector)"
301  << " size:" << c.size() << " {" << std::endl;
302  for (size_t i = 0; i < c.size(); ++i) {
303  c.dump(os, i);
304  }
305  os << "} ]" << std::endl;
306  return os;
307  }

Member Data Documentation

std::vector<uint64_t> jubatus::core::storage::typed_column< bit_vector >::array_
private

Definition at line 322 of file abstract_column.hpp.


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