| 1 |
This is example to build a sorted, bit-transposed dictionary vector of names of |
| 2 |
celestial objects from NED objects directory. |
| 3 |
Example shows how to do sorted search, runs benchmarks, checks self correctness. |
| 4 |
|
| 5 |
|
| 6 |
0. How to build |
| 7 |
|
| 8 |
- go to the source directory of BitMagic |
| 9 |
>cd ../.. |
| 10 |
- setup the compile root directory |
| 11 |
as |
| 12 |
>source ./bmenv.sh |
| 13 |
or |
| 14 |
>. ./bmenv.sh |
| 15 |
- get back to the sample |
| 16 |
>cd - |
| 17 |
>make |
| 18 |
or |
| 19 |
>./build_all.sh |
| 20 |
|
| 21 |
|
| 22 |
1. Download the fragment of catalog from |
| 23 |
|
| 24 |
http://bitmagic.io/data/ned.txt.gz |
| 25 |
|
| 26 |
or use NED ADQL interface: |
| 27 |
|
| 28 |
curl -o ned.txt "https://ned.ipac.caltech.edu/tap/sync?query=SELECT+*+FROM+ned_objdir&LANG=ADQL&REQUEST=doQuery&FORMAT=text" |
| 29 |
|
| 30 |
It will produce a columnar report similar to this: |
| 31 |
|
| 32 |
bhextin | dec | gallat | gallon | prefname |pretype | |
| 33 |
-------------------|----------------------|--------------------|-------------------|--------------------------------|--------| |
| 34 |
0.0 |61.090161208000005 |55.6336642907128 |129.592988077481 |"2MASX J12201807+6105248 "|"G "| |
| 35 |
0.0 |56.1873074943 |60.7497277891121 |128.223612727992 |"2MASX J12325147+5611139 "|"G "| |
| 36 |
0.0 |58.25105334925 |58.794082336604 |126.228935296354 |"2MASS J12382714+5815046 "|"G "| |
| 37 |
0.0 |57.223830104799994 |59.8791937528706 |124.806822462432 |"2MASS J12442918+5713259 "|"* "| |
| 38 |
|
| 39 |
|
| 40 |
OVERFLOW (more rows were available but have been truncated by the TAP service) |
| 41 |
|
| 42 |
|
| 43 |
NOTE: Out of this columnar report we need only "prefname" - names of objects in the NED catalog. |
| 44 |
Example will parse out the column and create a sorted STL vector, STL map (R-B tree) and |
| 45 |
bit transposed sparse vector (BitMagic) to compare memory footprint and search performance. |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
2. Run xsampl05 to load the report and build index |
| 50 |
|
| 51 |
./xsample05 -idict ned.txt -svout astra.bm -t |
| 52 |
|
| 53 |
Expected output: |
| 54 |
|
| 55 |
Reading input file: 1000000 |
| 56 |
Loaded 380132 dictionary names. |
| 57 |
|
| 58 |
Performance: |
| 59 |
1. parse input data ; 53.74 sec |
| 60 |
2. build sparse vector; 1.276 sec |
| 61 |
7. Save sparse vector; 4.726 ms |
| 62 |
|
| 63 |
See also: |
| 64 |
./run_all_compr.sh |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
3. Run search benchmarks using the compressed sparse vector of "prefname" |
| 69 |
|
| 70 |
./xsample05 -svin astra.bm -t -b |
| 71 |
|
| 72 |
|
| 73 |
Expected output: |
| 74 |
|
| 75 |
|
| 76 |
Picked 15000 samples. Running benchmarks. |
| 77 |
|
| 78 |
Performance: |
| 79 |
3. std::lower_bound() search; 427000 ops/sec; 35.08 ms |
| 80 |
4. std::map<> search; 285000 ops/sec; 52.47 ms |
| 81 |
5. bm::sparse_vector_scanner<> search; 21000 ops/sec; 685.2 ms |
| 82 |
6. bm::sparse_vector_scanner<> binary search; 42000 ops/sec; 351 ms |
| 83 |
8. Load sparse vector; 3.951 ms |
| 84 |
|
| 85 |
See also: |
| 86 |
|
| 87 |
./run_all_bench.sh |