BitMagic-C++: bm::sparse_vector_serializer< SV > Class Template Reference

BitMagic-C++

Public Types | Public Member Functions | Data Fields | Protected Types | Protected Member Functions | Protected Attributes
bm::sparse_vector_serializer< SV > Class Template Reference
BitMagic Library » Sparse and compressed vectors BitMagic Library » Sparse and compressed vectors » | Sparse vector serialization

`#include <bmsparsevec_serial.h>`

Collaboration diagram for bm::sparse_vector_serializer< SV >:
[legend]

## Public Types
typedef SV::bvector_type | bvector_type
typedef bvector_type * | bvector_type_ptr
typedef SV::value_type | value_type
typedef SV::size_type | size_type
typedef bvector_type::allocator_type::allocator_pool_type | allocator_pool_type

## Public Member Functions
| sparse_vector_serializer ()
void | set_bookmarks (bool enable, unsigned bm_interval=256)
| Add skip-markers for faster range deserialization. More...
void | set_xor_ref (bool is_enabled)
| Turn ON and OFF XOR compression of sparse vectors. More...
bool | is_xor_ref () const
| Get XOR reference compression status (enabled/disabled) More...
void | serialize (const SV &sv, sparse_vector_serial_layout< SV > &sv_layout)
| Serialize sparse vector into a memory buffer(s) structure. More...

## Data Fields
const typedef bvector_type * | bvector_type_const_ptr

## Protected Types
typedef bm::serializer< bvector_type >::bv_ref_vector_type | bv_ref_vector_type

## Protected Member Functions
void | build_xor_ref_vector (const SV &sv)

## Protected Attributes
bm::serializer< bvector_type > | bvs_
bool | is_xor_ref_
bv_ref_vector_type | bv_ref_

## Detailed Description

### template<typename SV>
class bm::sparse_vector_serializer< SV >

    \brief Serialize sparse vector into a memory buffer(s) structure

Serialization format:

| HEADER | BIT-VECTORS ... | REMAP_MATRIX

## Header structure:

BYTE+BYTE: Magic-signature 'BM' or 'BC' (c-compressed) BYTE : Byte order ( 0 - Big Endian, 1 - Little Endian) { BYTE : Number of Bit-vector plains (total) (non-zero when < 255 plains) | BYTE: zero - flag of large plain matrix INT64: Nnmber of bit-vector plains } INT64: Vector size INT64: Offset of plain 0 from the header start (value 0 means plain is empty) INT64: Offset of plain 1 from ... INT32: reserved

## Bit-vectors:

Based on current bit-vector serialization

Remap Matrix: SubHeader | Matrix BLOB

sub-header: BYTE: 'R' (remapping) or 'N' (no remapping) N - means no other info is saved on the stream INT64: remap matrix size

Examples
  rscsample02.cpp, strsvsample05.cpp, and svsample08.cpp.

Definition at line 160 of file bmsparsevec_serial.h.

## Member Typedef Documentation

## ◆ allocator_pool_type

template<typename SV >

typedef bvector_type::allocator_type::allocator_pool_type bm::sparse_vector_serializer< SV >::allocator_pool_type

Definition at line 169 of file bmsparsevec_serial.h.

## ◆ bv_ref_vector_type

template<typename SV >

typedef bm::serializer<bvector_type>::bv_ref_vector_type bm::sparse_vector_serializer< SV >::bv_ref_vector_type
| protected

Definition at line 204 of file bmsparsevec_serial.h.

## ◆ bvector_type

template<typename SV >

typedef SV::bvector_type bm::sparse_vector_serializer< SV >::bvector_type

Definition at line 163 of file bmsparsevec_serial.h.

## ◆ bvector_type_ptr

template<typename SV >

typedef bvector_type* bm::sparse_vector_serializer< SV >::bvector_type_ptr

Definition at line 165 of file bmsparsevec_serial.h.

## ◆ size_type

template<typename SV >

typedef SV::size_type bm::sparse_vector_serializer< SV >::size_type

Definition at line 167 of file bmsparsevec_serial.h.

## ◆ value_type

template<typename SV >

typedef SV::value_type bm::sparse_vector_serializer< SV >::value_type

Definition at line 166 of file bmsparsevec_serial.h.

## Constructor & Destructor Documentation

## ◆ sparse_vector_serializer()

template<typename SV >

bm::sparse_vector_serializer< SV >::sparse_vector_serializer

Definition at line 606 of file bmsparsevec_serial.h.

## Member Function Documentation

## ◆ build_xor_ref_vector()

template<typename SV >

void bm::sparse_vector_serializer< SV >::build_xor_ref_vector | ( | const SV & | sv | ) |
| protected

Definition at line 619 of file bmsparsevec_serial.h.

## ◆ is_xor_ref()

template<typename SV >

bool bm::sparse_vector_serializer< SV >::is_xor_ref | ( |  | ) | const
| inline

Get XOR reference compression status (enabled/disabled)

Definition at line 190 of file bmsparsevec_serial.h.

References bm::sparse_vector_serializer< SV >::is_xor_ref_.

## ◆ serialize()

template<typename SV >

void bm::sparse_vector_serializer< SV >::serialize | ( | const SV & | sv,
|  | sparse_vector_serial_layout< SV > & | sv_layout
| ) |  |

Serialize sparse vector into a memory buffer(s) structure.

Parameters

  sv | - sparse vector to serialize
  sv_layout | - buffer structure to keep the result as defined in bm::serialization_flags

Definition at line 628 of file bmsparsevec_serial.h.

References BM_ASSERT, bm::globals< T >::byte_order(), bm::sparse_vector_serial_layout< SV >::capacity(), bm::sparse_vector_serial_layout< SV >::get_plain(), bm::encoder::memcpy(), bm::encoder::put_64(), bm::encoder::put_8(), bm::sparse_vector_serial_layout< SV >::reserve(), bm::sparse_vector_serial_layout< SV >::resize(), bm::sparse_vector_serial_layout< SV >::set_plain(), and bm::encoder::size().

Referenced by main(), and bm::sparse_vector_serialize().

## ◆ set_bookmarks()

template<typename SV >

void bm::sparse_vector_serializer< SV >::set_bookmarks | ( | bool | enable,
|  | unsigned | bm_interval = `256`
| ) |  |
| inline

Add skip-markers for faster range deserialization.

Parameters

  enable | - TRUE searilization will add bookmark codes
  bm_interval | - bookmark interval in (number of blocks) (suggested between 4 and 512) smaller interval means more bookmarks added to the skip list thus more increasing the BLOB size

Definition at line 183 of file bmsparsevec_serial.h.

References bm::sparse_vector_serializer< SV >::bvs_, and bm::serializer< BV >::set_bookmarks().

Referenced by main().

## ◆ set_xor_ref()

template<typename SV >

void bm::sparse_vector_serializer< SV >::set_xor_ref | ( | bool | is_enabled | ) |
| inline

Turn ON and OFF XOR compression of sparse vectors.

Definition at line 187 of file bmsparsevec_serial.h.

References bm::sparse_vector_serializer< SV >::is_xor_ref_.

## Field Documentation

## ◆ bv_ref_

template<typename SV >

bv_ref_vector_type bm::sparse_vector_serializer< SV >::bv_ref_
| protected

Definition at line 215 of file bmsparsevec_serial.h.

## ◆ bvector_type_const_ptr

template<typename SV >

const typedef bvector_type* bm::sparse_vector_serializer< SV >::bvector_type_const_ptr

Definition at line 164 of file bmsparsevec_serial.h.

## ◆ bvs_

template<typename SV >

bm::serializer<bvector_type> bm::sparse_vector_serializer< SV >::bvs_
| protected

Definition at line 212 of file bmsparsevec_serial.h.

Referenced by bm::sparse_vector_serializer< SV >::set_bookmarks().

## ◆ is_xor_ref_

template<typename SV >

bool bm::sparse_vector_serializer< SV >::is_xor_ref_
| protected

Definition at line 214 of file bmsparsevec_serial.h.

Referenced by bm::sparse_vector_serializer< SV >::is_xor_ref(), and bm::sparse_vector_serializer< SV >::set_xor_ref().

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

- bmsparsevec_serial.h