BitMagic-C++: bvector<> serialization

BitMagic-C++

Data Structures | Enumerations | Functions
bvector<> serialization
BitMagic Library » bvector<> container

Serialization for bvector<> container. More...

Collaboration diagram for bvector<> serialization:

## Data Structures
class | bm::serializer< BV >
| Bit-vector serialization class. More...
class | bm::deseriaizer_base< DEC, BLOCK_IDX >
| Base deserialization class. More...
class | bm::deserializer< BV, DEC >
| Deserializer for bit-vector. More...
class | bm::serial_stream_iterator< DEC, BLOCK_IDX >
| Serialization stream iterator. More...
class | bm::operation_deserializer< BV >
| Deserializer, performs logical operations between bit-vector and serialized bit-vector. More...

## Enumerations
enum | bm::serialization_flags { bm::BM_NO_BYTE_ORDER = 1, bm::BM_NO_GAP_LENGTH = (1 << 1) }
| Bit mask flags for serialization algorithm. More...

## Functions
template<class BV >
size_t | bm::serialize (const BV &bv, unsigned char *buf, bm::word_t *temp_block=0, unsigned serialization_flags=0)
| Saves bitvector into memory. More...
template<class BV >
size_t | bm::serialize (BV &bv, unsigned char *buf, unsigned serialization_flags=0)
| Saves bitvector into memory. Allocates temporary memory block for bvector. More...
template<class BV >
size_t | bm::deserialize (BV &bv, const unsigned char *buf, bm::word_t *temp_block=0, const bm::bv_ref_vector< BV > *ref_vect=0)
| Bitvector deserialization from a memory BLOB. More...
template<class BV >
void | bm::deserialize_range (BV &bv, const unsigned char *buf, typename BV::size_type from, typename BV::size_type to, const bm::bv_ref_vector< BV > *ref_vect=0)
| Bitvector range deserialization from a memory BLOB. More...

## Detailed Description

Serialization for bvector<> container.

## Enumeration Type Documentation

## ◆ serialization_flags

enum bm::serialization_flags

Bit mask flags for serialization algorithm.

Enumerator
BM_NO_BYTE_ORDER | save no byte-order info (save some space)
BM_NO_GAP_LENGTH | save no GAP info (save some space)

Definition at line 2574 of file bmserial.h.

## Function Documentation

## ◆ deserialize()

template<class BV >

size_t bm::deserialize | ( | BV & | bv,
|  | const unsigned char * | buf,
|  | bm::word_t * | temp_block = `0`,
|  | const bm::bv_ref_vector< BV > * | ref_vect = `0`
| ) |  |

Bitvector deserialization from a memory BLOB.

Parameters

  bv | - target bvector
  buf | - pointer on memory which keeps serialized bvector
  temp_block | - pointer on temporary block, if NULL bvector allocates own.
  ref_vect | - [in] optional pointer to a list of reference vectors used for XOR compression.

Returns
  Number of bytes consumed by deserializer.

Function deserializes bitvector from memory block containig results of previous serialization. Function does not remove bits which are currently set. Effectively it is OR logical operation between the target bit-vector and serialized one.

See also
  deserialize_range

Examples
  sample14.cpp, sample4.cpp, and xsample01.cpp.

Definition at line 2688 of file bmserial.h.

References bm::BigEndian, BM_ASSERT, bm::BM_HM_NO_BO, bm::deserializer< BV, DEC >::deserialize(), bm::decoder_base::get_8(), bm::LittleEndian, and bm::deserializer< BV, DEC >::set_ref_vectors().

Referenced by convert_bv2bvs(), bm::compressed_collection_deserializer< CBC >::deserialize(), and main().

## ◆ deserialize_range()

template<class BV >

void bm::deserialize_range | ( | BV & | bv,
|  | const unsigned char * | buf,
|  | typename BV::size_type | from,
|  | typename BV::size_type | to,
|  | const bm::bv_ref_vector< BV > * | ref_vect = `0`
| ) |  |

Bitvector range deserialization from a memory BLOB.

Parameters

  bv | - target bvector
  buf | - pointer on memory which keeps serialized bvector
  from | - bit-vector index to deserialize from
  to | - bit-vector index to deserialize to
  ref_vect | - [in] optional pointer to a list of reference vectors used for XOR compression.

Function deserializes bitvector from memory block containig results of previous serialization. Function does not remove bits which are currently set. Effectively it is OR logical operation between the target bit-vector and serialized one.

See also
  deserialize

Examples
  sample22.cpp.

Definition at line 2751 of file bmserial.h.

References bm::BigEndian, BM_ASSERT, bm::BM_HM_NO_BO, bm::deserializer< BV, DEC >::deserialize(), bm::decoder_base::get_8(), bm::LittleEndian, bm::deserializer< BV, DEC >::set_range(), and bm::deserializer< BV, DEC >::set_ref_vectors().

Referenced by main().

## ◆ serialize() [1/2]

template<class BV >

size_t bm::serialize | ( | BV & | bv,
|  | unsigned char * | buf,
|  | unsigned | serialization_flags = `0`
| ) |  |

Saves bitvector into memory. Allocates temporary memory block for bvector.

Parameters

  bv | - source bvecor
  buf | - pointer on target memory area. No range checking in the function. It is responsibility of programmer to allocate sufficient amount of memory using information from calc_stat function.
  serialization_flags | Flags controlling serilization (bit-mask) (use OR-ed serialization flags)

Definition at line 2656 of file bmserial.h.

References bm::serialize().

Referenced by bm::serializer< bvector_type >::optimize_serialize_destroy(), and bm::serializer< bvector_type >::serialize().

## ◆ serialize() [2/2]

template<class BV >

size_t bm::serialize | ( | const BV & | bv,
|  | unsigned char * | buf,
|  | bm::word_t * | temp_block = `0`,
|  | unsigned | serialization_flags = `0`
| ) |  |

Saves bitvector into memory.

Function serializes content of the bitvector into memory. Serialization adaptively uses compression(variation of GAP encoding) when it is benefitial.

Parameters

  bv | - source bvecor
  buf | - pointer on target memory area. No range checking in the function. It is responsibility of programmer to allocate sufficient amount of memory using information from calc_stat function.
  temp_block | - pointer on temporary memory block. Cannot be 0; If you want to save memory across multiple bvectors allocate temporary block using allocate_tempblock and pass it to serialize. (Serialize does not deallocate temp_block.)
  serialization_flags | Flags controlling serilization (bit-mask) (use OR-ed serialization flags)

Returns
  Size of serialization block.

See also
  calc_stat, serialization_flags

Serialization format:

    | HEADER | BLOCKS |

    Header structure:
      BYTE : Serialization header (bit mask of BM_HM_*)
      BYTE : Byte order ( 0 - Big Endian, 1 - Little Endian)
      INT16: Reserved (0)
      INT16: Reserved Flags (0)

Definition at line 2622 of file bmserial.h.

References bm::BM_NO_BYTE_ORDER, bm::BM_NO_GAP_LENGTH, bm::serializer< BV >::byte_order_serialization(), bm::serializer< BV >::gap_length_serialization(), and bm::serializer< BV >::serialize().

Referenced by bm::serialize().