dlvhex  2.5.0
bm::serializer< BV > Class Template Reference

Bit-vector serialization class. More...

#include <vs10/bm/bmserial.h>

Public Types

typedef BV::allocator_type allocator_type
typedef BV::blocks_manager_type blocks_manager_type
typedef BV::allocator_type allocator_type
typedef BV::blocks_manager_type blocks_manager_type

Public Member Functions

 serializer (const allocator_type &alloc=allocator_type())
 ~serializer ()
void set_compression_level (unsigned clevel)
 Set compression level.
unsigned get_compression_level () const
 Get compression level.
unsigned serialize (const BV &bv, unsigned char *buf, unsigned buf_size)
 Bitvector serilization into memory block.
void gap_length_serialization (bool value)
 Set GAP length serialization (serializes GAP levels of the original vector)
void byte_order_serialization (bool value)
 Set byte-order serialization (for cross platform compatibility)
 serializer (const allocator_type &alloc=allocator_type())
 ~serializer ()
void set_compression_level (unsigned clevel)
 Set compression level.
unsigned get_compression_level () const
 Get compression level.
unsigned serialize (const BV &bv, unsigned char *buf, unsigned buf_size)
 Bitvector serilization into memory block.
void gap_length_serialization (bool value)
 Set GAP length serialization (serializes GAP levels of the original vector)
void byte_order_serialization (bool value)
 Set byte-order serialization (for cross platform compatibility)

Protected Member Functions

void encode_header (const BV &bv, bm::encoder &enc)
 Encode serialization header information.
void encode_gap_block (bm::gap_word_t *gap_block, bm::encoder &enc)
 Encode GAP block.
void gamma_gap_block (bm::gap_word_t *gap_block, bm::encoder &enc)
 Encode GAP block with Elias Gamma coder.
void gamma_gap_array (const bm::gap_word_t *gap_block, unsigned arr_len, bm::encoder &enc, bool inverted=false)
 Encode GAP block as delta-array with Elias Gamma coder.
void encode_bit_interval (const bm::word_t *blk, bm::encoder &enc, unsigned size_control)
 Encode BIT block with repeatable runs of zeroes.
void encode_header (const BV &bv, bm::encoder &enc)
 Encode serialization header information.
void encode_gap_block (bm::gap_word_t *gap_block, bm::encoder &enc)
 Encode GAP block.
void gamma_gap_block (bm::gap_word_t *gap_block, bm::encoder &enc)
 Encode GAP block with Elias Gamma coder.
void gamma_gap_array (const bm::gap_word_t *gap_block, unsigned arr_len, bm::encoder &enc, bool inverted=false)
 Encode GAP block as delta-array with Elias Gamma coder.
void encode_bit_interval (const bm::word_t *blk, bm::encoder &enc, unsigned size_control)
 Encode BIT block with repeatable runs of zeroes.

Private Types

typedef bm::bit_out< bm::encoderbit_out_type
typedef bm::gamma_encoder
< bm::gap_word_t, bit_out_type
gamma_encoder_func
typedef bm::bit_out< bm::encoderbit_out_type
typedef bm::gamma_encoder
< bm::gap_word_t, bit_out_type
gamma_encoder_func

Private Member Functions

 serializer (const serializer &)
serializeroperator= (const serializer &)
 serializer (const serializer &)
serializeroperator= (const serializer &)

Private Attributes

allocator_type alloc_
bool gap_serial_
bool byte_order_serial_
bm::word_ttemp_block_
unsigned compression_level_

Detailed Description

template<class BV>
class bm::serializer< BV >

Bit-vector serialization class.

Class designed to convert sparse bit-vector into a block of memory ready for file or database storage or network transfer.

Definition at line 146 of file bmserial.h.


Member Typedef Documentation

template<class BV>
typedef BV::allocator_type bm::serializer< BV >::allocator_type

Definition at line 149 of file bmserial.h.

template<class BV>
typedef BV::allocator_type bm::serializer< BV >::allocator_type

Definition at line 149 of file bmserial.h.

template<class BV>
typedef bm::bit_out<bm::encoder> bm::serializer< BV >::bit_out_type [private]

Definition at line 235 of file bmserial.h.

template<class BV>
typedef bm::bit_out<bm::encoder> bm::serializer< BV >::bit_out_type [private]

Definition at line 235 of file bmserial.h.

template<class BV>
typedef BV::blocks_manager_type bm::serializer< BV >::blocks_manager_type

Definition at line 150 of file bmserial.h.

template<class BV>
typedef BV::blocks_manager_type bm::serializer< BV >::blocks_manager_type

Definition at line 150 of file bmserial.h.

template<class BV>
typedef bm::gamma_encoder<bm::gap_word_t, bit_out_type> bm::serializer< BV >::gamma_encoder_func [private]

Definition at line 236 of file bmserial.h.

template<class BV>
typedef bm::gamma_encoder<bm::gap_word_t, bit_out_type> bm::serializer< BV >::gamma_encoder_func [private]

Definition at line 236 of file bmserial.h.


Constructor & Destructor Documentation

template<class BV >
bm::serializer< BV >::serializer ( const allocator_type alloc = allocator_type())

Definition at line 544 of file bmserial.h.

References bm::serializer< BV >::alloc_, and bm::serializer< BV >::temp_block_.

template<class BV >
bm::serializer< BV >::~serializer ( )

Definition at line 567 of file bmserial.h.

template<class BV>
bm::serializer< BV >::serializer ( const serializer< BV > &  ) [private]
template<class BV>
bm::serializer< BV >::serializer ( const allocator_type alloc = allocator_type())
template<class BV>
bm::serializer< BV >::~serializer ( )
template<class BV>
bm::serializer< BV >::serializer ( const serializer< BV > &  ) [private]

Member Function Documentation

template<class BV >
void bm::serializer< BV >::byte_order_serialization ( bool  value)

Set byte-order serialization (for cross platform compatibility)

Parameters:
value- TRUE serialization format includes byte-order marker

Definition at line 580 of file bmserial.h.

Referenced by bm::serialize().

template<class BV>
void bm::serializer< BV >::byte_order_serialization ( bool  value)

Set byte-order serialization (for cross platform compatibility)

Parameters:
value- TRUE serialization format includes byte-order marker
template<class BV >
void bm::serializer< BV >::encode_bit_interval ( const bm::word_t blk,
bm::encoder enc,
unsigned  size_control 
) [protected]

Encode BIT block with repeatable runs of zeroes.

Definition at line 762 of file bmserial.h.

References bm::encoder::put_16(), bm::encoder::put_32(), bm::encoder::put_8(), bm::set_block_bit_0runs, and bm::set_block_size.

template<class BV>
void bm::serializer< BV >::encode_bit_interval ( const bm::word_t blk,
bm::encoder enc,
unsigned  size_control 
) [protected]

Encode BIT block with repeatable runs of zeroes.

template<class BV>
void bm::serializer< BV >::encode_gap_block ( bm::gap_word_t gap_block,
bm::encoder enc 
) [protected]

Encode GAP block.

template<class BV >
void bm::serializer< BV >::encode_gap_block ( bm::gap_word_t gap_block,
bm::encoder enc 
) [protected]
template<class BV>
void bm::serializer< BV >::encode_header ( const BV &  bv,
bm::encoder enc 
) [protected]

Encode serialization header information.

template<class BV >
void bm::serializer< BV >::encode_header ( const BV &  bv,
bm::encoder enc 
) [protected]
template<class BV>
void bm::serializer< BV >::gamma_gap_array ( const bm::gap_word_t gap_block,
unsigned  arr_len,
bm::encoder enc,
bool  inverted = false 
) [protected]

Encode GAP block as delta-array with Elias Gamma coder.

template<class BV >
void bm::serializer< BV >::gamma_gap_array ( const bm::gap_word_t gap_block,
unsigned  arr_len,
bm::encoder enc,
bool  inverted = false 
) [protected]
template<class BV >
void bm::serializer< BV >::gamma_gap_block ( bm::gap_word_t gap_block,
bm::encoder enc 
) [protected]
template<class BV>
void bm::serializer< BV >::gamma_gap_block ( bm::gap_word_t gap_block,
bm::encoder enc 
) [protected]

Encode GAP block with Elias Gamma coder.

template<class BV >
void bm::serializer< BV >::gap_length_serialization ( bool  value)

Set GAP length serialization (serializes GAP levels of the original vector)

Parameters:
value- when TRUE serialized vector includes GAP levels parameters

Definition at line 574 of file bmserial.h.

Referenced by bm::serialize().

template<class BV>
void bm::serializer< BV >::gap_length_serialization ( bool  value)

Set GAP length serialization (serializes GAP levels of the original vector)

Parameters:
value- when TRUE serialized vector includes GAP levels parameters
template<class BV >
unsigned bm::serializer< BV >::get_compression_level ( ) const

Get compression level.

Definition at line 561 of file bmserial.h.

template<class BV>
unsigned bm::serializer< BV >::get_compression_level ( ) const

Get compression level.

template<class BV>
serializer& bm::serializer< BV >::operator= ( const serializer< BV > &  ) [private]
template<class BV>
serializer& bm::serializer< BV >::operator= ( const serializer< BV > &  ) [private]
template<class BV>
unsigned bm::serializer< BV >::serialize ( const BV &  bv,
unsigned char *  buf,
unsigned  buf_size 
)

Bitvector serilization into memory block.

Parameters:
bv- input bitvector
buf- out buffer (pre-allocated) No range checking is done in this method. It is responsibility of caller to allocate sufficient amount of memory using information from calc_stat() function.
buf_size- size of the output buffer
Returns:
Size of serialization block.
See also:
calc_stat
template<class BV >
unsigned bm::serializer< BV >::serialize ( const BV &  bv,
unsigned char *  buf,
unsigned  buf_size 
)

Bitvector serilization into memory block.

Parameters:
bv- input bitvector
buf- out buffer (pre-allocated) No range checking is done in this method. It is responsibility of caller to allocate sufficient amount of memory using information from calc_stat() function.
buf_size- size of the output buffer
Returns:
Size of serialization block.
See also:
calc_stat

Definition at line 814 of file bmserial.h.

References bm::bit_block_calc_count_change(), bm::bit_convert_to_arr(), bm::bit_convert_to_gap(), bm::bit_count_nonzero_size(), bm::bit_find_in_block(), BM_IS_GAP, BMGAP_PTR, bm::gap_equiv_len, bm::gap_max_bits, bm::encoder::put_16(), bm::encoder::put_8(), bm::encoder::put_prefixed_array_32(), SER_NEXT_GRP, bm::set_block_16one, bm::set_block_16zero, bm::set_block_1one, bm::set_block_1zero, bm::set_block_32one, bm::set_block_32zero, bm::set_block_8one, bm::set_block_8zero, bm::set_block_aone, bm::set_block_azero, bm::set_block_bit, bm::set_block_bit_1bit, bm::set_block_end, bm::set_block_size, bm::set_total_blocks, and bm::encoder::size().

Referenced by bm::serialize().

template<class BV >
void bm::serializer< BV >::set_compression_level ( unsigned  clevel)

Set compression level.

Higher compression takes more time to process.

Parameters:
clevel- compression level (0-4)

Definition at line 555 of file bmserial.h.

Referenced by bm::serialize().

template<class BV>
void bm::serializer< BV >::set_compression_level ( unsigned  clevel)

Set compression level.

Higher compression takes more time to process.

Parameters:
clevel- compression level (0-4)

Field Documentation

template<class BV>
allocator_type bm::serializer< BV >::alloc_ [private]

Definition at line 239 of file bmserial.h.

Referenced by bm::serializer< BV >::serializer().

template<class BV>
bool bm::serializer< BV >::byte_order_serial_ [private]

Definition at line 241 of file bmserial.h.

template<class BV>
unsigned bm::serializer< BV >::compression_level_ [private]

Definition at line 243 of file bmserial.h.

template<class BV>
bool bm::serializer< BV >::gap_serial_ [private]

Definition at line 240 of file bmserial.h.

template<class BV>
bm::word_t * bm::serializer< BV >::temp_block_ [private]

Definition at line 242 of file bmserial.h.

Referenced by bm::serializer< BV >::serializer().


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