BitMagic-C++: xsample05.cpp File Reference

BitMagic-C++

Typedefs | Functions | Variables
xsample05.cpp File Reference

Example: Example on how to use bit-transposed string sparse vector. More...

`#include <iostream>`
`#include <sstream>`
`#include <chrono>`
`#include <regex>`
`#include <time.h>`
`#include <stdio.h>`
`#include <vector>`
`#include <map>`
`#include <utility>`
`#include <algorithm>`
`#include <random>`
`#include "bm.h"`
`#include "bmalgo.h"`
`#include "bmserial.h"`
`#include "bmrandom.h"`
`#include "bmstrsparsevec.h"`
`#include "bmsparsevec_algo.h"`
`#include "bmsparsevec_serial.h"`
`#include "bmalgo_similarity.h"`
`#include "bmsparsevec_util.h"`
`#include "bmdbg.h"`
`#include "bmtimer.h"`
Include dependency graph for xsample05.cpp:

Go to the source code of this file.

## Typedefs
typedef bm::str_sparse_vector< char, bm::bvector<>, 64 > | str_sparse_vect
typedef vector< string > | string_vector

## Functions
static void | show_help ()
| Print help. More...
static int | parse_args (int argc, char *argv[])
static int | load_dict_report (const std::string &fname, string_vector &str_vec)
| Parse the input file and extract dictionary values. More...
static void | check_sparse (const str_sparse_vect &str_sv, const string_vector &str_vec)
| Compare STL vector with bit-transposed container to check correcness. More...
static void | pick_benchmark_set (string_vector &bench_vec, string_vector &bench_vec_not_found, const string_vector &str_vec)
| Sample a few random terms out of collection. More...
static void | run_benchmark (const str_sparse_vect &str_sv, const string_vector &str_vec)
int | main (int argc, char *argv[])

## Variables
std::string | sv_out_name
std::string | sv_in_name
std::string | i_name
bool | is_diag = false
bool | is_timing = false
bool | is_bench = false
bm::chrono_taker::duration_map_type | timing_map
const unsigned | benchmark_max = 15000

## Detailed Description

Example: Example on how to use bit-transposed string sparse vector.

Illustrates how to build a sparse vector, serialize it to disk, load back and do search or binary hybrid search.

See also
  bm::str_sparse_vector<>

Definition in file xsample05.cpp.

## Typedef Documentation

## ◆ str_sparse_vect

typedef bm::str_sparse_vector<char, bm::bvector<>, 64> str_sparse_vect

Examples
  xsample05.cpp.

Definition at line 173 of file xsample05.cpp.

## ◆ string_vector

typedef vector<string> string_vector

Examples
  xsample05.cpp.

Definition at line 174 of file xsample05.cpp.

## Function Documentation

## ◆ check_sparse()

static void check_sparse | ( | const str_sparse_vect & | str_sv,
|  | const string_vector & | str_vec
| ) |  |
| static

Compare STL vector with bit-transposed container to check correcness.

Examples
  xsample05.cpp.

Definition at line 233 of file xsample05.cpp.

References bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::get(), and bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::size().

Referenced by main().

## ◆ load_dict_report()

static int load_dict_report | ( | const std::string & | fname,
|  | string_vector & | str_vec
| ) |  |
| static

Parse the input file and extract dictionary values.

Examples
  xsample05.cpp.

Definition at line 183 of file xsample05.cpp.

References timing_map.

Referenced by main().

## ◆ main()

int main | ( | int | argc,
|  | char * | argv[]
| ) |  |

Examples
  xsample05.cpp.

Definition at line 447 of file xsample05.cpp.

References BM_DECLARE_TEMP_BLOCK, check_sparse(), bm::chrono_taker::ct_time, bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::empty(), bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::get(), i_name, is_bench, is_diag, is_timing, load_dict_report(), bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::optimize(), parse_args(), bm::chrono_taker::print_duration_map(), bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::push_back(), bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::remap_from(), run_benchmark(), show_help(), bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::size(), sv_in_name, sv_out_name, bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::swap(), and timing_map.

## ◆ parse_args()

static int parse_args | ( | int | argc,
|  | char * | argv[]
| ) |  |
| static

Examples
  xsample05.cpp.

Definition at line 93 of file xsample05.cpp.

References i_name, is_bench, is_diag, is_timing, show_help(), sv_in_name, and sv_out_name.

Referenced by main().

## ◆ pick_benchmark_set()

static void pick_benchmark_set | ( | string_vector & | bench_vec,
|  | string_vector & | bench_vec_not_found,
|  | const string_vector & | str_vec
| ) |  |
| static

Sample a few random terms out of collection.

Examples
  xsample05.cpp.

Definition at line 252 of file xsample05.cpp.

References benchmark_max, gen(), rand_dev, rand_dis(), bm::bvector< Alloc >::resize(), bm::bvector< Alloc >::set(), and bm::bvector< Alloc >::test().

Referenced by run_benchmark().

## ◆ run_benchmark()

static void run_benchmark | ( | const str_sparse_vect & | str_sv,
|  | const string_vector & | str_vec
| ) |  |
| static

Examples
  xsample05.cpp.

Definition at line 300 of file xsample05.cpp.

References bm::sparse_vector_scanner< SV >::bfind_eq_str(), bm::sparse_vector_scanner< SV >::bind(), bm::bvector< Alloc >::compare(), bm::bvector< Alloc >::count(), bm::sparse_vector_scanner< SV >::find_eq_str(), pick_benchmark_set(), bm::bvector< Alloc >::set(), bm::bvector< Alloc >::size(), and timing_map.

Referenced by main().

## ◆ show_help()

static void show_help | ( |  | ) |
| static

Print help.

Examples
  xsample05.cpp.

Definition at line 68 of file xsample05.cpp.

Referenced by main(), and parse_args().

## Variable Documentation

## ◆ benchmark_max

const unsigned benchmark_max = 15000

Examples
  xsample05.cpp.

Definition at line 248 of file xsample05.cpp.

Referenced by pick_benchmark_set().

## ◆ i_name

std::string i_name

Examples
  xsample05.cpp.

Definition at line 86 of file xsample05.cpp.

Referenced by main(), and parse_args().

## ◆ is_bench

bool is_bench = false

Examples
  xsample05.cpp.

Definition at line 89 of file xsample05.cpp.

Referenced by main(), and parse_args().

## ◆ is_diag

bool is_diag = false

Examples
  xsample05.cpp.

Definition at line 87 of file xsample05.cpp.

Referenced by main(), and parse_args().

## ◆ is_timing

bool is_timing = false

Examples
  xsample05.cpp.

Definition at line 88 of file xsample05.cpp.

Referenced by main(), and parse_args().

## ◆ sv_in_name

std::string sv_in_name

Examples
  xsample05.cpp.

Definition at line 85 of file xsample05.cpp.

Referenced by main(), and parse_args().

## ◆ sv_out_name

std::string sv_out_name

Examples
  xsample05.cpp.

Definition at line 84 of file xsample05.cpp.

Referenced by main(), and parse_args().

## ◆ timing_map

bm::chrono_taker::duration_map_type timing_map

Examples
  xsample05.cpp.

Definition at line 178 of file xsample05.cpp.

Referenced by load_dict_report(), main(), and run_benchmark().