├── README ├── build └── Jamfile.v2 ├── doc ├── Proposed-B-tree-library.pdf ├── Proposed-B-tree-library.ppt ├── bayer_index.png ├── bounds_test_map.dot ├── bounds_test_multimap.dot ├── btree.dot ├── design.html ├── faq.html ├── index.html ├── minimal.css ├── preliminary_timings.html ├── reference.html ├── src │ ├── build.bat │ ├── bulk_load_map.cpp.extract │ ├── endian_map.cpp.extract │ ├── hetero_set.cpp.extract │ ├── htmlize.bat │ ├── int_map.cpp.extract │ ├── int_map_first_try.cpp.extract │ ├── int_set.cpp.extract │ ├── int_set_read.cpp.extract │ ├── int_set_read_first_try.cpp.extract │ ├── pack_map.cpp.extract │ ├── string_index_map.cpp.extract │ ├── string_index_set.cpp.extract │ ├── string_map.cpp.extract │ ├── string_set.cpp.extract │ ├── string_set_first_try.cpp.extract │ ├── tune_int_map.cpp.extract │ ├── tutorial_source.html │ ├── udt.hpp.extract │ ├── udt_3_index_set.cpp.extract │ └── udt_index_set.cpp.extract ├── tutorial.html └── two-layer-design.html ├── example ├── Jamfile.v2 ├── bulk_load_map.cpp ├── endian_map.cpp ├── hetero_set.cpp ├── int_map.cpp ├── int_map_first_try.cpp ├── int_set.cpp ├── int_set_read.cpp ├── int_set_read_first_try.cpp ├── msvc2013 │ ├── btree-examples.sln │ ├── btree_dll │ │ ├── btree_dll.vcxproj │ │ └── btree_dll.vcxproj.filters │ ├── bulk_load_map │ │ ├── bulk_load_map.vcxproj │ │ └── bulk_load_map.vcxproj.filters │ ├── endian_map │ │ ├── endian_map.vcxproj │ │ └── endian_map.vcxproj.filters │ ├── hetero_set │ │ ├── hetero_set.vcxproj │ │ └── hetero_set.vcxproj.filters │ ├── int_map │ │ ├── int_map.vcxproj │ │ └── int_map.vcxproj.filters │ ├── int_map_first_try │ │ ├── int_map_first_try.vcxproj │ │ └── int_map_first_try.vcxproj.filters │ ├── int_set │ │ └── int_set.vcxproj │ ├── int_set_read │ │ ├── int_set.btr │ │ ├── int_set_read.vcxproj │ │ └── int_set_read.vcxproj.filters │ ├── int_set_read_first_try │ │ ├── int_set_read_first_try.vcxproj │ │ └── int_set_read_first_try.vcxproj.filters │ ├── pack_map │ │ ├── int_map.btr │ │ ├── pack_map.vcxproj │ │ └── pack_map.vcxproj.filters │ ├── string_index_map │ │ ├── string_index_map.vcxproj │ │ └── string_index_map.vcxproj.filters │ ├── string_index_set │ │ ├── string_index_set.vcxproj │ │ └── string_index_set.vcxproj.filters │ ├── string_map │ │ ├── string_map.vcxproj │ │ └── string_map.vcxproj.filters │ ├── string_set │ │ ├── string_set.vcxproj │ │ └── string_set.vcxproj.filters │ ├── string_set_first_try │ │ ├── string_set_first_try.vcxproj │ │ └── string_set_first_try.vcxproj.filters │ ├── tune_int_map │ │ ├── tune_int_map.vcxproj │ │ └── tune_int_map.vcxproj.filters │ ├── udt_3_index_set │ │ ├── udt_3_index_set.vcxproj │ │ └── udt_3_index_set.vcxproj.filters │ └── udt_index_set │ │ ├── udt_index_set.vcxproj │ │ └── udt_index_set.vcxproj.filters ├── pack_map.cpp ├── string_index_map.cpp ├── string_index_set.cpp ├── string_map.cpp ├── string_set.cpp ├── string_set_first_try.cpp ├── tune_int_map.cpp ├── udt.hpp ├── udt_3_index_set.cpp └── udt_index_set.cpp ├── include └── boost │ └── btree │ ├── btree_index_map.hpp │ ├── btree_index_set.hpp │ ├── btree_map.hpp │ ├── btree_set.hpp │ ├── bulk_load.hpp │ ├── detail │ ├── binary_file.hpp │ ├── btree_bases.hpp │ ├── buffer_manager.hpp │ ├── config.hpp │ ├── index_bases.hpp │ └── test_traits.hpp │ ├── header.hpp │ ├── helpers.hpp │ ├── index_helpers.hpp │ ├── mmff.hpp │ └── support │ ├── random_string.hpp │ ├── size_t_codec.hpp │ ├── string_holder.hpp │ └── string_view.hpp ├── index.html ├── src └── detail │ ├── binary_file.cpp │ └── buffer_manager.cpp ├── test ├── Jamfile.v2 ├── binary_file_test.cpp ├── bt_time_all.bat ├── btree_unit_test.cpp ├── buffer_manager_test.cpp ├── bulk_load_test.cpp ├── index_unit_test.cpp ├── large_file_test.cpp ├── mmf_experiment.cpp ├── mmff_unit_test.cpp ├── msvc2012 │ ├── binary_file_test │ │ └── binary_file_test.vcxproj │ ├── bt_str_time │ │ └── bt_str_time.vcxproj │ ├── bt_time │ │ └── bt_time.vcxproj │ ├── btree.sln │ ├── btree_dll │ │ └── btree_dll.vcxproj │ ├── btree_unit_test │ │ └── btree_unit_test.vcxproj │ ├── buffer_manager_test │ │ └── buffer_manager_test.vcxproj │ ├── bulk_loader_test │ │ └── bulk_loader_test.vcxproj │ ├── common.props │ ├── index_unit_test │ │ └── index_unit_test.vcxproj │ ├── large_file_test │ │ └── large_file_test.vcxproj │ ├── mmf_experiment │ │ └── mmf_experiment.vcxproj │ ├── mmff_unit_test │ │ └── mmff_unit_test.vcxproj │ ├── stl_test │ │ └── stl_test.vcxproj │ ├── string_holder_test │ │ └── string_box_test.vcxproj │ └── volume_create_data │ │ └── volume_create_data.vcxproj ├── stl_restart_test.bat ├── stl_test.cpp ├── string_holder_test.cpp ├── test.dat └── timer_test.cpp └── tools ├── Jamfile.v2 ├── bt_time.cpp ├── build.bat ├── create_data.cpp ├── data.hpp ├── install.bat ├── stl_bounds_demo.cpp └── time_table.bat /README: -------------------------------------------------------------------------------- 1 | B-tree library for eventual proposal to Boost 2 | 3 | THIS IS AN BETA LIBRARY STILL UNDER DEVELOPMENT. 4 | IT IS SHOULD ONLY BE USED BY THOSE WILLING TO TAKE THE RISKS 5 | INHERENT WITH BETA LEVEL SOFTWARE. 6 | 7 | To experiment with the library, various other boost libraries must be 8 | available. Below is one way to create such a setup. 9 | 10 | Note: If you don't want use SSL to connect to GitHub, 11 | replace "git@github.com:" with "https://github.com/". 12 | 13 | Note: Install Subversion, Git, and a C++ compiler first if you haven't 14 | already done so. Be sure there is a "user-config.jam" file in your 15 | home directory and it is set up for your compiler (or compilers). 16 | 17 | Windows: 18 | cd where-you-want-stuff-to-go 19 | svn export http://svn.boost.org/svn/boost/trunk boost-trunk trunk-ex 20 | cd trunk-ex\libs 21 | git clone git@github.com:Beman/endian.git endian 22 | git clone git@github.com:Beman/btree.git btree 23 | cd ..\boost 24 | mklink /d endian ..\libs\btree\include\boost\endian 25 | mklink /d btree ..\libs\btree\include\boost\btree 26 | 27 | POSIX-like systems: 28 | sudo apt-get install libbz2-dev 29 | cd where-you-want-stuff-to-go 30 | svn export http://svn.boost.org/svn/boost/trunk boost-trunk trunk-ex 31 | cd trunk-ex/libs 32 | git clone git@github.com:Beman/endian.git endian 33 | git clone git@github.com:Beman/btree.git btree 34 | cd ../boost 35 | ln -s ../libs/endian/include/boost/endian endian 36 | ln -s ../libs/btree/include/boost/btree btree 37 | 38 | As a confidence test, the following should build b2, build various 39 | libraries and then run the btree regression tests, which should all 40 | report "**passed**". 41 | 42 | Windows: 43 | cd trunk-ex 44 | .\bootstrap 45 | .\b2 46 | cd libs\btree\test 47 | ..\..\..\b2 48 | 49 | POSIX-like systems: 50 | cd trunk-ex 51 | ./bootstrap.sh 52 | ./b2 53 | cd libs/btree/test 54 | ../../../b2 55 | 56 | ---------------------------------------------------------------------- 57 | 58 | Notes for using Visual Studio 59 | 60 | A Windows Visual Studio solution is included: btree\test\msvc2012\btree.sln 61 | Be sure to do the following setup before starting Visual Studio. 62 | 63 | IMPORTANT: If Preprocessor macros are supplied via a common property page, 64 | must be set for each project! 65 | 66 | Setup Windows to use the solution: 67 | 68 | set BOOST_TRUNK=boost-root-path 69 | path %path%;%BOOST_TRUNK%\stage\lib 70 | cd %BOOST_TRUNK% 71 | .\bootstrap 72 | .\b2 --with-system --with-chrono --with-timer --with-filesystem --with-iostreams link=shared address-model=64 variant=debug toolset=msvc-11.0express 73 | To find out more about builds: 74 | 75 | cd boost-root 76 | .\b2 --help 77 | 78 | ------------------------------------------------------------------------------------------ 79 | Copyright Beman Dawes, 2013 80 | Distributed under the Boost Software License, Version 1.0. 81 | See http://www.boost.org/LICENSE_1_0.txt 82 | -------------------------------------------------------------------------------- /build/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # Boost Btree Library Build Jamfile 2 | 3 | # (C) Copyright Beman Dawes 2010 4 | # Distributed under the Boost Software License, Version 1.0. 5 | # See www.boost.org/LICENSE_1_0.txt 6 | 7 | project boost/btree 8 | : source-location ../src/detail 9 | : usage-requirements # pass these requirement to dependents (i.e. users) 10 | shared:BOOST_BTREE_DYN_LINK=1 11 | static:BOOST_BTREE_STATIC_LINK=1 12 | ; 13 | 14 | SOURCES = 15 | binary_file buffer_manager ; 16 | 17 | lib boost_btree 18 | : 19 | $(SOURCES).cpp 20 | ../../system/build//boost_system 21 | ../../filesystem/build//boost_filesystem 22 | ../../timer/build//boost_timer 23 | ../../chrono/build//boost_chrono 24 | ../../iostreams/build//boost_iostreams 25 | : 26 | shared:BOOST_ALL_DYN_LINK=1 # tell source we're building dll's 27 | static:BOOST_All_STATIC_LINK=1 # tell source we're building static lib's 28 | : 29 | : 30 | ; 31 | 32 | boost-install boost_btree ; -------------------------------------------------------------------------------- /doc/Proposed-B-tree-library.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Beman/btree/ef7f7ddc058344262c318fc0c3705e8e113c426c/doc/Proposed-B-tree-library.pdf -------------------------------------------------------------------------------- /doc/Proposed-B-tree-library.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Beman/btree/ef7f7ddc058344262c318fc0c3705e8e113c426c/doc/Proposed-B-tree-library.ppt -------------------------------------------------------------------------------- /doc/bayer_index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Beman/btree/ef7f7ddc058344262c318fc0c3705e8e113c426c/doc/bayer_index.png -------------------------------------------------------------------------------- /doc/bounds_test_map.dot: -------------------------------------------------------------------------------- 1 | digraph btree { 2 | fontname=Courier; 3 | node [shape = record,margin=.1,width=.1,height=.5,fontname=Courier,style="filled"]; 4 | page1[label = " 1,100|3,300|empty",fillcolor="palegreen"]; 5 | page2[label = "|7||13|",fillcolor="lightblue"]; 6 | "page2":f0 -> "page1":f0; 7 | "page2":f1 -> "page3":f0; 8 | "page2":f2 -> "page4":f0; 9 | page3[label = " 7,700|9,900|11,1100",fillcolor="palegreen"]; 10 | page4[label = " 13,1300|empty|empty",fillcolor="palegreen"]; 11 | } -------------------------------------------------------------------------------- /doc/bounds_test_multimap.dot: -------------------------------------------------------------------------------- 1 | digraph btree { 2 | rankdir=LR; 3 | fontname=Courier; 4 | node [shape = record,margin=.1,width=.1,height=.1,fontname=Courier,style="filled"]; 5 | page1[label = " 1,100|3,300|3,300",fillcolor="palegreen"]; 6 | page2[label = "|5||empty||empty|",fillcolor="lightblue"]; 7 | "page2":f0 -> "page1":f0; 8 | "page2":f1 -> "page5":f0; 9 | page3[label = " 7,700|7,700|7,700",fillcolor="palegreen"]; 10 | page4[label = " 13,1300|15,1500|empty",fillcolor="palegreen"]; 11 | page5[label = " 5,500|empty|empty",fillcolor="palegreen"]; 12 | page6[label = " 11,1100|empty|empty",fillcolor="palegreen"]; 13 | page7[label = "|7||empty||empty|",fillcolor="lightblue"]; 14 | "page7":f0 -> "page2":f0; 15 | "page7":f1 -> "page8":f0; 16 | page8[label = "|9||empty||empty|",fillcolor="lightblue"]; 17 | "page8":f0 -> "page3":f0; 18 | "page8":f1 -> "page9":f0; 19 | page9[label = " 9,900|empty|empty",fillcolor="palegreen"]; 20 | page10[label = " 17,1700|empty|empty",fillcolor="palegreen"]; 21 | page11[label = "|13||empty||empty|",fillcolor="lightblue"]; 22 | "page11":f0 -> "page6":f0; 23 | "page11":f1 -> "page4":f0; 24 | page12[label = " 15,1500|15,1500|empty",fillcolor="palegreen"]; 25 | page13[label = " 15,1500|15,1500|empty",fillcolor="palegreen"]; 26 | page14[label = "|15||empty||empty|",fillcolor="lightblue"]; 27 | "page14":f0 -> "page12":f0; 28 | "page14":f1 -> "page13":f0; 29 | page15[label = " 15,1500|15,1500|empty",fillcolor="palegreen"]; 30 | page16[label = " 15,1500|15,1500|empty",fillcolor="palegreen"]; 31 | page17[label = "|15||15||17|",fillcolor="lightblue"]; 32 | "page17":f0 -> "page15":f0; 33 | "page17":f1 -> "page16":f0; 34 | "page17":f2 -> "page20":f0; 35 | "page17":f3 -> "page10":f0; 36 | page18[label = "|11||empty||empty|",fillcolor="lightblue"]; 37 | "page18":f0 -> "page7":f0; 38 | "page18":f1 -> "page19":f0; 39 | page19[label = "|15||15||empty|",fillcolor="lightblue"]; 40 | "page19":f0 -> "page11":f0; 41 | "page19":f1 -> "page14":f0; 42 | "page19":f2 -> "page17":f0; 43 | page20[label = " 15,1500|15,1500|empty",fillcolor="palegreen"]; 44 | } 45 | -------------------------------------------------------------------------------- /doc/btree.dot: -------------------------------------------------------------------------------- 1 | digraph g { 2 | aspect = 3.0; 3 | node [shape = record,height=.1,style="filled",fontname=Arial,fontsize=20]; 4 | node0[label = " | LHR ||empty| |empty|",fillcolor="lightblue"]; 5 | node1[label = "| DFW | |HND|| empty|",fillcolor="lightblue"]; 6 | node2[label = " ATL,1|CDG,2|DEN,10",fillcolor="palegreen"]; 7 | node3[label = " DFW,7|FRA,9|empty",fillcolor="palegreen"]; 8 | node4[label = " |empty | |empty| |empty|",fillcolor="lightblue"]; 9 | node5[label = " HND,4|LAX,5|empty",fillcolor="palegreen"]; 10 | node6[label = " LHR,3|ORD,2|PEK,8",fillcolor="palegreen"]; 11 | "node0":f0 -> "node1":f0; 12 | "node0":f1 -> "node4":f0; 13 | "node1":f0 -> "node2":f0; 14 | "node1":f1 -> "node3":f0; 15 | "node1":f2 -> "node5":f0; 16 | "node4":f0 -> "node6":f0; 17 | } 18 | -------------------------------------------------------------------------------- /doc/design.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Beman/btree/ef7f7ddc058344262c318fc0c3705e8e113c426c/doc/design.html -------------------------------------------------------------------------------- /doc/faq.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | B-tree FAQ 8 | 9 | 10 | 11 | 12 | 14 | 15 | 18 | 19 | 20 | 21 |
boost.png (6897 bytes)B-Tree Library FAQ
22 | 23 | 26 | 27 | 32 | 33 |
Boost Home 28 |    Library Home 29 |    Reference 30 |    Tutorial 31 |    FAQ
34 | 35 |

Why do non-const functions 36 | return const_iterator instead of iterator? The 37 | implementation needs to know when an element is modified so it can write the 38 | node back to the external file. If non-const iterator was 39 | returned, the implementation would have to assume that a write back was 40 | required even when none is actually need. That would be very inefficient.

41 | 42 |

Why are there no unordered B-tree associative containers? It 43 | wouldn't be a B-tree any more. A B-tree achieves its 44 | speed by grouping many ordered elements on nodes, and that minimizes disk 45 | access and maximizes the benefit of both hardware and software caches. A 46 | hashed approach would in effect just replace one ordering with another.

47 |

What is the difference between a node and a page? In computer 48 | science, node is the 49 | name for the basic unit used to build data structures. 50 | Page is 51 | the name for the smallest unit of data for transfers between main memory and 52 | any other auxiliary store, such as a 53 | 54 | hard disk drive. In a B-tree, performance is often optimal if node size is 55 | the same as (or a small multiple of) the system's page size.

56 | 57 |

How to make B-tree files portable between big and little endian systems? 58 | Use endian data types. See the 59 | tutorial for an example.

60 | 61 |

Where does the idea of an index come from? 62 | Bayer and McCreight's original 1970 Boeing Labs paper:

63 | 64 |

65 | 66 |
67 | 68 |

Revised 69 | 10 September 2013

70 | 71 |

© Copyright Beman Dawes, 2013

72 | 73 |

Distributed under the Boost Software License, Version 1.0. See 74 | www.boost.org/LICENSE_1_0.txt

76 | 77 | 78 | -------------------------------------------------------------------------------- /doc/minimal.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Beman/btree/ef7f7ddc058344262c318fc0c3705e8e113c426c/doc/minimal.css -------------------------------------------------------------------------------- /doc/src/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Copyright Beman Dawes 2013 3 | rem Distributed under the Boost Software License, Version 1.0. 4 | 5 | echo Extracting code snippets from example .cpp files 6 | 7 | mmp int_set.cpp.extract int_set.cpp.html 8 | call htmlize int_set.cpp.html 9 | 10 | mmp bulk_load_map.cpp.extract bulk_load_map.cpp.html 11 | call htmlize bulk_load_map.cpp.html 12 | 13 | mmp endian_map.cpp.extract endian_map.cpp.html 14 | call htmlize endian_map.cpp.html 15 | 16 | mmp hetero_set.cpp.extract hetero_set.cpp.html 17 | call htmlize hetero_set.cpp.html 18 | 19 | mmp int_map.cpp.extract int_map.cpp.html 20 | call htmlize int_map.cpp.html 21 | 22 | mmp int_map_first_try.cpp.extract int_map_first_try.cpp.html 23 | call htmlize int_map_first_try.cpp.html 24 | 25 | mmp int_set_read.cpp.extract int_set_read.cpp.html 26 | call htmlize int_set_read.cpp.html 27 | 28 | mmp int_set_read_first_try.cpp.extract int_set_read_first_try.cpp.html 29 | call htmlize int_set_read_first_try.cpp.html 30 | 31 | mmp pack_map.cpp.extract pack_map.cpp.html 32 | call htmlize pack_map.cpp.html 33 | 34 | mmp string_index_map.cpp.extract string_index_map.cpp.html 35 | call htmlize string_index_map.cpp.html 36 | 37 | mmp string_index_set.cpp.extract string_index_set.cpp.html 38 | call htmlize string_index_set.cpp.html 39 | 40 | mmp string_map.cpp.extract string_map.cpp.html 41 | call htmlize string_map.cpp.html 42 | 43 | mmp string_set.cpp.extract string_set.cpp.html 44 | call htmlize string_set.cpp.html 45 | 46 | mmp string_set_first_try.cpp.extract string_set_first_try.cpp.html 47 | call htmlize string_set_first_try.cpp.html 48 | 49 | mmp udt_3_index_set.cpp.extract udt_3_index_set.cpp.html 50 | call htmlize udt_3_index_set.cpp.html 51 | 52 | mmp udt_index_set.cpp.extract udt_index_set.cpp.html 53 | call htmlize udt_index_set.cpp.html 54 | 55 | mmp udt.hpp.extract udt.hpp.html 56 | call htmlize udt.hpp.html 57 | 58 | mmp tune_int_map.cpp.extract tune_int_map.cpp.html 59 | call htmlize tune_int_map.cpp.html 60 | 61 | echo Generating tutorial.html... 62 | del tutorial.html 2>nul 63 | 64 | rem ' dir="ltr"' is an artifact of editing mistakes. 65 | chg tutorial_source.html " dir=\qltr\q" "" 66 | 67 | mmp tutorial_source.html ..\tutorial.html 68 | ..\tutorial.html 69 | -------------------------------------------------------------------------------- /doc/src/bulk_load_map.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/bulk_load_map.cpp" -------------------------------------------------------------------------------- /doc/src/endian_map.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/endian_map.cpp" -------------------------------------------------------------------------------- /doc/src/hetero_set.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/hetero_set.cpp" -------------------------------------------------------------------------------- /doc/src/htmlize.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Copyright Beman Dawes 2013 3 | rem Distributed under the Boost Software License, Version 1.0. 4 | chg %1 "<" "<" 5 | chg %1 ">" ">" 6 | chg %1 "\q" """ 7 | chg %1 "'" "'" 8 | chg %1 "\r\n///" "" 9 | -------------------------------------------------------------------------------- /doc/src/int_map.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/int_map.cpp" -------------------------------------------------------------------------------- /doc/src/int_map_first_try.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/int_map_first_try.cpp" -------------------------------------------------------------------------------- /doc/src/int_set.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/int_set.cpp" -------------------------------------------------------------------------------- /doc/src/int_set_read.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/int_set_read.cpp" -------------------------------------------------------------------------------- /doc/src/int_set_read_first_try.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/int_set_read_first_try.cpp" -------------------------------------------------------------------------------- /doc/src/pack_map.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/pack_map.cpp" -------------------------------------------------------------------------------- /doc/src/string_index_map.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/string_index_map.cpp" -------------------------------------------------------------------------------- /doc/src/string_index_set.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/string_index_set.cpp" -------------------------------------------------------------------------------- /doc/src/string_map.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/string_map.cpp" -------------------------------------------------------------------------------- /doc/src/string_set.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/string_set.cpp" -------------------------------------------------------------------------------- /doc/src/string_set_first_try.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/string_set_first_try.cpp" -------------------------------------------------------------------------------- /doc/src/tune_int_map.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/tune_int_map.cpp" -------------------------------------------------------------------------------- /doc/src/udt.hpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/udt.hpp" -------------------------------------------------------------------------------- /doc/src/udt_3_index_set.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/udt_3_index_set.cpp" -------------------------------------------------------------------------------- /doc/src/udt_index_set.cpp.extract: -------------------------------------------------------------------------------- 1 | $snippet code "../../example/udt_index_set.cpp" -------------------------------------------------------------------------------- /doc/two-layer-design.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Btree Two Layer Design 9 | 10 | 11 | 12 | 13 |

Boost Btree Two Layer Design

14 |

Problem: Every attempt at implementing C++ variable length btree (VLBTR) 15 | has been either an outright failure or has sub-optimal performance.  16 | Abstracting away the difference between fixed-length and variable-length makes 17 | the code difficult to understand and difficult to reason about.

18 |
19 |

Solution: Btrees are fixed-length, period. Anything else should be 20 | layered on top of the unmodified fixed-length btree (FLBTR) implementation so 21 | that FLBTRs do what they do best, and don't become degraded by trying to do 22 | things they aren't suited for. The effect of a VLBTR is achieved by adding a 23 | level of indirection; a FLBTR acts as an index (i.e. a set of file offsets) 24 | into a separate flat file.

25 |
26 |

Problem: Btrees tend to become sub-optimal when the length of the 27 | value type is large in relation to the optimal node size. The optimal node size 28 | is closely related to the operating system's disk page size, and is not 29 | something the btree library can alter.

30 |
31 |

Solution: Add a layer of indirection; a FLBTR acts as an index (i.e. 32 | a set of file offsets) into a separate flat file. This has been the approach 33 | to the problem since the earliest days of Btrees and was described by Bayer 34 | himself.

35 |
36 |

Additional thoughts

37 |

1) There is so little difference between the two proposed solutions 38 | that it may be possible for a single implementation to solve both problems.

39 |

2) A memory-mapped file might be the ideal implementation technique 40 | for the flat file.

41 |

3) A experimental prototype can be built on top of the current 42 | implementation, without any changes to it. Removal of the current VLBTR code 43 | isn't necessary to prove the concept.

44 |

4) If the offset (i.e. an id.) into the flat file is exposed, users 45 | could access flat file elements directly. Such a feature was previously 46 | implemented and found useful in another context.

47 |

5) Multiple indexes into a single flat file would be a possible future 48 | extention.

49 |
50 |

Last revised: 51 | July 12, 2013

52 |

© Beman Dawes 2013

53 |

Distributed under the Boost Software License, Version 1.0. See 54 | 55 | www.boost.org/ LICENSE_1_0.txt

56 | 57 |

 

58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /example/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # Boost Btree Library examples Jamfile 2 | 3 | # (C) Copyright Beman Dawes 2013 4 | # Distributed under the Boost Software License, Version 1.0. 5 | # See www.boost.org/LICENSE_1_0.txt 6 | 7 | project 8 | : requirements 9 | /boost/btree//boost_btree 10 | /boost/filesystem//boost_filesystem 11 | /boost/system//boost_system 12 | /boost/timer//boost_timer 13 | /boost/chrono//boost_chrono 14 | msvc:on 15 | ; 16 | 17 | exe bulk_load_map : bulk_load_map.cpp : static ; 18 | exe endian_map : endian_map.cpp : static ; 19 | exe hetero_set : hetero_set.cpp : static ; 20 | exe int_map : int_map.cpp : static ; 21 | exe int_set : int_set.cpp : static ; 22 | exe int_set_read : int_set_read.cpp : static ; 23 | exe pack_map : pack_map.cpp : static ; 24 | exe string_index_map : string_index_map.cpp : static ; 25 | exe string_index_set : string_index_set.cpp : static ; 26 | exe string_map : string_map.cpp : static ; 27 | exe string_set : string_set.cpp : static ; 28 | exe tune_int_map : tune_int_map.cpp : static release ; 29 | exe udt_3_index_set : udt_3_index_set.cpp : static ; 30 | exe udt_index_set : udt_index_set.cpp : static ; 31 | 32 | 33 | alias install : bin ; 34 | install bin : 35 | bulk_load_map 36 | endian_map 37 | hetero_set 38 | int_map 39 | int_set 40 | int_set_read 41 | pack_map 42 | string_index_map 43 | string_index_set 44 | string_map 45 | string_set 46 | tune_int_map 47 | udt_3_index_set 48 | udt_index_set ; 49 | explicit install bin ; 50 | -------------------------------------------------------------------------------- /example/bulk_load_map.cpp: -------------------------------------------------------------------------------- 1 | // example/bulk_load_map.cpp 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using std::cout; 15 | using namespace boost::btree; 16 | 17 | int cpp_main(int, char *[]) 18 | { 19 | typedef btree_set BT; 20 | BT bt("bulk_load_map.btr", flags::truncate); 21 | 22 | 23 | for (BT::iterator itr = bt.begin(); itr != bt.end(); ++itr) 24 | cout << *itr << '\n'; 25 | 26 | return 0; 27 | } 28 | ///$endid 29 | -------------------------------------------------------------------------------- /example/endian_map.cpp: -------------------------------------------------------------------------------- 1 | // example/endian_map.cpp 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using std::cout; 15 | using namespace boost::btree; 16 | using namespace boost::endian; 17 | 18 | int cpp_main(int, char *[]) 19 | { 20 | typedef btree_map BT; // note the sizes! 21 | BT bt("endian_map.btr", flags::truncate); 22 | 23 | bt.emplace(38759234875LL, 1); 24 | bt.emplace(82352345, 2); 25 | bt.emplace(1242423462, 3); 26 | 27 | cout << "sizeof(BT::value_type) is " << sizeof(BT::value_type) << '\n'; 28 | 29 | for (BT::const_iterator itr = bt.begin(); 30 | itr != bt.end(); ++itr) 31 | cout << itr->first << ", " << itr->second << '\n'; 32 | 33 | return 0; 34 | } 35 | ///$endid 36 | -------------------------------------------------------------------------------- /example/hetero_set.cpp: -------------------------------------------------------------------------------- 1 | // example/hetero_set.cpp 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include 11 | #include 12 | 13 | using std::cout; 14 | using namespace boost::btree; 15 | 16 | namespace 17 | { 18 | struct UDT 19 | { 20 | int x; 21 | int y; 22 | 23 | UDT() {} 24 | UDT(int x_, int y_) : x(x_), y(y_) {} 25 | bool operator<(const UDT& rhs) const { return x < rhs.x; } 26 | bool operator<(int rhs) const { return x < rhs; } // note rhs type 27 | }; 28 | bool operator<(int lhs, const UDT& rhs) { return lhs < rhs.x; } // note lhs type 29 | } 30 | 31 | 32 | int cpp_main(int, char *[]) 33 | { 34 | typedef btree_set BT; 35 | BT bt("hetero_set.btr", flags::truncate); 36 | 37 | bt.insert(UDT(2, 222)); 38 | bt.insert(UDT(1, 111)); 39 | bt.insert(UDT(3, 333)); 40 | 41 | for (BT::iterator itr = bt.begin(); itr != bt.end(); ++itr) 42 | cout << itr->x << ',' << itr->y << '\n'; 43 | 44 | BT::iterator itr = bt.find(2); // note find(2) argument type 45 | cout << "find(2) found " << itr->x << ',' << itr->y << '\n'; 46 | 47 | return 0; 48 | } 49 | ///$endid 50 | -------------------------------------------------------------------------------- /example/int_map.cpp: -------------------------------------------------------------------------------- 1 | // example/int_map.cpp 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include 11 | #include 12 | 13 | using std::cout; 14 | using namespace boost::btree; 15 | 16 | int cpp_main(int, char *[]) 17 | { 18 | typedef btree_map BT; 19 | BT bt("int_map.btr", flags::truncate); 20 | 21 | bt.emplace(2, 222); 22 | bt.emplace(1, 111); 23 | bt.emplace(3, 333); 24 | 25 | for (BT::const_iterator itr = bt.begin(); // note well: const_iterator 26 | itr != bt.end(); ++itr) 27 | cout << itr->first << ", " << itr->second << '\n'; 28 | 29 | return 0; 30 | } 31 | ///$endid 32 | -------------------------------------------------------------------------------- /example/int_map_first_try.cpp: -------------------------------------------------------------------------------- 1 | // example/int_map.cpp 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include 11 | #include 12 | 13 | using std::cout; 14 | using namespace boost::btree; 15 | 16 | int cpp_main(int, char *[]) 17 | { 18 | typedef btree_map BT; 19 | BT bt("int_map.btr", flags::truncate); 20 | 21 | bt.emplace(2, 222); 22 | bt.emplace(1, 111); 23 | bt.emplace(3, 333); 24 | 25 | for (BT::iterator itr = bt.begin(); // Error! 26 | itr != bt.end(); ++itr) 27 | cout << itr->first << ", " << itr->second << '\n'; 28 | 29 | return 0; 30 | } 31 | ///$endid 32 | -------------------------------------------------------------------------------- /example/int_set.cpp: -------------------------------------------------------------------------------- 1 | // example/int_set.cpp 2 | 3 | // Copyright Beman Dawes 2011 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include 11 | 12 | using std::cout; 13 | using namespace boost::btree; 14 | 15 | int main() 16 | { 17 | typedef btree_set BT; 18 | BT bt("int_set.btr", flags::truncate); // ctor with path, open flags 19 | 20 | bt.insert(5); 21 | bt.insert(3); 22 | bt.insert(1); 23 | 24 | for (BT::iterator itr = bt.begin(); itr != bt.end(); ++itr) 25 | cout << *itr << '\n'; 26 | 27 | cout << "lower_bound(3) is " << *bt.lower_bound(3) << '\n'; 28 | cout << "upper_bound(3) is " << *bt.upper_bound(3) << '\n'; 29 | } 30 | ///$endid 31 | -------------------------------------------------------------------------------- /example/int_set_read.cpp: -------------------------------------------------------------------------------- 1 | // example/int_set_read.cpp 2 | 3 | // Copyright Beman Dawes 2011 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include 11 | #include // supplies main, does try cpp_main, 12 | // catches, reports any exceptions 13 | 14 | using std::cout; 15 | using namespace boost::btree; 16 | 17 | int cpp_main(int, char *[]) // note the name and required formal parameters 18 | { 19 | typedef btree_set BT; 20 | BT bt("int_set.btr"); 21 | 22 | for (BT::iterator itr = bt.begin(); itr != bt.end(); ++itr) 23 | cout << *itr << '\n'; 24 | 25 | cout << "lower_bound(3) is " << *bt.lower_bound(3) << '\n'; 26 | cout << "upper_bound(3) is " << *bt.upper_bound(3) << '\n'; 27 | 28 | return 0; // required 29 | } 30 | ///$endid 31 | -------------------------------------------------------------------------------- /example/int_set_read_first_try.cpp: -------------------------------------------------------------------------------- 1 | // example/int_set_read_first_try.cpp 2 | 3 | // Copyright Beman Dawes 2011 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include 11 | 12 | using std::cout; 13 | using namespace boost::btree; 14 | 15 | int main() 16 | { 17 | typedef btree_set BT; 18 | BT bt("int_set.btr"); 19 | 20 | for (BT::iterator itr = bt.begin(); itr != bt.end(); ++itr) 21 | cout << *itr << '\n'; 22 | 23 | cout << "lower_bound(3) is " << *bt.lower_bound(3) << '\n'; 24 | cout << "upper_bound(3) is " << *bt.upper_bound(3) << '\n'; 25 | } 26 | ///$endid 27 | -------------------------------------------------------------------------------- /example/msvc2013/btree_dll/btree_dll.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {461DEAAB-1CD8-4CDB-8158-04AF110B32A9} 15 | Win32Proj 16 | btree_dll 17 | 18 | 19 | 20 | DynamicLibrary 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | DynamicLibrary 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Windows 60 | true 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | Level3 69 | 70 | 71 | MaxSpeed 72 | true 73 | true 74 | true 75 | 76 | 77 | Windows 78 | true 79 | true 80 | true 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /example/msvc2013/btree_dll/btree_dll.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/msvc2013/bulk_load_map/bulk_load_map.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {784E9235-D752-4ABA-9D2D-D12C14BD1CFB} 15 | Win32Proj 16 | bulk_load_map 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/bulk_load_map/bulk_load_map.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/endian_map/endian_map.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {595805F6-9BBE-4AB1-9F7A-3B638FE372CD} 15 | Win32Proj 16 | endian_map 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/endian_map/endian_map.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/hetero_set/hetero_set.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {E087BCD8-67D0-41C3-AFB8-9C6C81A58D32} 15 | Win32Proj 16 | hetero_set 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/hetero_set/hetero_set.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/int_map/int_map.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {DE146F03-8C59-44FE-976F-7689D25000E0} 15 | Win32Proj 16 | int_map 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/int_map/int_map.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/int_map_first_try/int_map_first_try.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {AE192C4C-733D-440A-95B1-EA6253D05BF0} 15 | Win32Proj 16 | int_map_first_try 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/int_map_first_try/int_map_first_try.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/int_set/int_set.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {7DA3ADCF-7277-41A5-8533-0DF38A9E1DFF} 15 | Win32Proj 16 | int_set 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | "$(TargetDir)\$(TargetName).exe" 64 | 65 | 66 | 67 | 68 | Level3 69 | 70 | 71 | MaxSpeed 72 | true 73 | true 74 | true 75 | 76 | 77 | Console 78 | true 79 | true 80 | true 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /example/msvc2013/int_set_read/int_set.btr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Beman/btree/ef7f7ddc058344262c318fc0c3705e8e113c426c/example/msvc2013/int_set_read/int_set.btr -------------------------------------------------------------------------------- /example/msvc2013/int_set_read/int_set_read.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {E0602D6D-A0B6-4C9A-803C-6CBF971E1C58} 15 | Win32Proj 16 | int_set_read 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/int_set_read/int_set_read.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/int_set_read_first_try/int_set_read_first_try.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {F39AEEB2-DC4B-43AB-A902-55E8B73B0B81} 15 | Win32Proj 16 | int_set_read_first_try 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/int_set_read_first_try/int_set_read_first_try.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/pack_map/int_map.btr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Beman/btree/ef7f7ddc058344262c318fc0c3705e8e113c426c/example/msvc2013/pack_map/int_map.btr -------------------------------------------------------------------------------- /example/msvc2013/pack_map/pack_map.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {B8A6DD9B-E09C-4DDF-B61A-D0B12117313C} 15 | Win32Proj 16 | pack_map 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/pack_map/pack_map.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/string_index_map/string_index_map.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {C9D44866-2CFD-4BDD-99E1-E5EAF3EDA0CB} 15 | Win32Proj 16 | string_index_map 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/string_index_map/string_index_map.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/string_index_set/string_index_set.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {FE1648F7-EF44-4C67-A4A5-FDA3A0B7EFA6} 15 | Win32Proj 16 | string_index_set 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/string_index_set/string_index_set.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/string_map/string_map.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {65E26356-EA6C-43AE-A76B-44F7EC1DC6AA} 15 | Win32Proj 16 | string_map 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/string_map/string_map.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/string_set/string_set.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {60793851-7C74-4007-9408-32CF02FBAC64} 15 | Win32Proj 16 | string_set 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/string_set/string_set.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/string_set_first_try/string_set_first_try.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {7B36CD23-737A-4D73-9B9F-DF0CAD255314} 15 | Win32Proj 16 | string_set_first_try 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/string_set_first_try/string_set_first_try.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/tune_int_map/tune_int_map.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {C327AC77-4073-408E-90D3-9A9994D0E57F} 15 | Win32Proj 16 | tune_int_map 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | "$(TargetDir)\$(TargetName).exe" 10000000 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /example/msvc2013/tune_int_map/tune_int_map.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/udt_3_index_set/udt_3_index_set.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {014CE0EF-CE58-4136-B065-22899F762A4C} 15 | Win32Proj 16 | udt_3_index_set 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/udt_3_index_set/udt_3_index_set.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/msvc2013/udt_index_set/udt_index_set.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {0EFC52E6-601F-4C59-B34A-6383C4764DF9} 15 | Win32Proj 16 | udt_index_set 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | true 57 | 58 | 59 | Console 60 | true 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {461deaab-1cd8-4cdb-8158-04af110b32a9} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /example/msvc2013/udt_index_set/udt_index_set.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/pack_map.cpp: -------------------------------------------------------------------------------- 1 | // example/pack_map.cpp 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using std::cout; 15 | using namespace boost::btree; 16 | 17 | int cpp_main(int, char *[]) 18 | { 19 | typedef btree_map BT; 20 | 21 | BT old_bt("int_map.btr", flags::read_only); 22 | BT new_bt(old_bt.begin(), old_bt.end(), "packed_int_map.btr", flags::truncate); 23 | 24 | BOOST_ASSERT(old_bt == new_bt); 25 | 26 | return 0; 27 | } 28 | ///$endid 29 | -------------------------------------------------------------------------------- /example/string_index_map.cpp: -------------------------------------------------------------------------------- 1 | // example/string_index_map.cpp 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using std::cout; 15 | using namespace boost::btree; 16 | 17 | int cpp_main(int, char *[]) 18 | { 19 | typedef btree_index_map BT; 20 | BT bt("string_index_map", flags::truncate); 21 | 22 | bt.emplace("eat", "comer"); 23 | bt.emplace("drink", "beber"); 24 | bt.emplace("be merry", "ser feliz"); 25 | bt.emplace("be exceptionally merry", "ser feliz excepcionalmente"); 26 | 27 | for (BT::const_iterator itr = bt.begin(); itr != bt.end(); ++itr) 28 | cout << itr->first << ", " << itr->second << '\n'; 29 | 30 | return 0; 31 | } 32 | ///$endid 33 | -------------------------------------------------------------------------------- /example/string_index_set.cpp: -------------------------------------------------------------------------------- 1 | // example/string_index_set.cpp 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using std::cout; 15 | using namespace boost::btree; 16 | 17 | int cpp_main(int, char *[]) 18 | { 19 | typedef btree_index_set BT; 20 | BT bt("string_index_set", flags::truncate); // creates .ndx and .dat files 21 | 22 | bt.insert("eat"); 23 | bt.insert("drink"); 24 | bt.insert("be merry"); 25 | bt.insert("be exceptionally merry"); 26 | 27 | for (BT::iterator itr = bt.begin(); itr != bt.end(); ++itr) 28 | cout << *itr << '\n'; 29 | 30 | return 0; 31 | } 32 | /// $endid 33 | -------------------------------------------------------------------------------- /example/string_map.cpp: -------------------------------------------------------------------------------- 1 | // example/string_map.cpp 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using std::cout; 15 | using namespace boost::btree; 16 | 17 | int cpp_main(int, char *[]) 18 | { 19 | typedef btree_map, string_holder<32> > BT; 20 | BT bt("string_map.btr", flags::truncate); 21 | 22 | bt.emplace("eat", "comer"); 23 | bt.emplace("drink", "beber"); 24 | bt.emplace("be merry", "ser feliz"); 25 | bt.emplace("be exceptionally merry", "ser feliz excepcionalmente"); 26 | 27 | for (BT::const_iterator itr = bt.begin(); itr != bt.end(); ++itr) 28 | cout << itr->first << ", " << itr->second << '\n'; 29 | 30 | return 0; 31 | } 32 | ///$endid 33 | -------------------------------------------------------------------------------- /example/string_set.cpp: -------------------------------------------------------------------------------- 1 | // example/string_set 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include // fixed length string 11 | #include 12 | #include 13 | 14 | using std::cout; 15 | using namespace boost::btree; 16 | 17 | int cpp_main(int, char *[]) 18 | { 19 | typedef btree_set > BT; // note maximum length 20 | BT bt("string_set.btr", flags::truncate); 21 | 22 | bt.insert("eat"); 23 | bt.insert("drink"); 24 | bt.insert("be merry"); 25 | bt.insert("be exceptionally merry"); // will truncate 26 | 27 | for (BT::iterator it = bt.begin(); it != bt.end(); ++it) 28 | cout << *it << '\n'; 29 | 30 | return 0; // required 31 | } 32 | ///$endid 33 | -------------------------------------------------------------------------------- /example/string_set_first_try.cpp: -------------------------------------------------------------------------------- 1 | // example/string_set_first_try.cpp --------------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using std::cout; 15 | using namespace boost::btree; 16 | 17 | int cpp_main(int, char *[]) 18 | { 19 | typedef btree_set BT; 20 | BT bt("string_set.btr", flags::truncate); 21 | 22 | bt.insert("eat"); 23 | bt.insert("drink"); 24 | bt.insert("be merry"); 25 | 26 | for (BT::iterator itr = bt.begin(); itr != bt.end(); ++itr) 27 | cout << *itr << '\n'; 28 | 29 | return 0 30 | } 31 | ///$endid 32 | -------------------------------------------------------------------------------- /example/tune_int_map.cpp: -------------------------------------------------------------------------------- 1 | // example/tune_int_map.cpp 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include // for rand() 14 | #include 15 | 16 | using std::cout; 17 | using namespace boost::btree; 18 | 19 | int cpp_main(int argc, char *argv[]) 20 | { 21 | long n = 10000; 22 | flags::bitmask hint = flags::fastest; 23 | 24 | if (argc > 1) 25 | { n = std::atol(*++argv); --argc; } 26 | if (argc > 1) 27 | { 28 | std::string s(*++argv); 29 | if (s == "least_memory") hint = flags::least_memory; 30 | else if (s == "low_memory") hint = flags::low_memory; 31 | else if (s == "balanced") hint = flags::balanced; 32 | else if (s == "fast") hint = flags::fast; 33 | else if (s == "fastest") hint = flags::fastest; 34 | else 35 | { 36 | cout << 37 | "invoke: tune_int_map [#] least_memory|low_memory|balanced|fast|fastest\n" 38 | " where # is the number of elements to test\n" 39 | " example: tune_int_map 1000000 fast\n"; 40 | return 1; 41 | } 42 | } 43 | 44 | typedef btree_map BT; 45 | BT bt; // unopened btree_map 46 | bt.open("tune_int_map.btr", flags::truncate | hint); // open it 47 | 48 | cout << "test with " << n << " elements" << std::endl; 49 | boost::timer::auto_cpu_timer t(2); 50 | 51 | // emplace n elements 52 | for (int i = 1; i <= n; ++i) 53 | bt.emplace(std::rand(), i); 54 | 55 | bt.close(); // include close() cost in timings 56 | t.stop(); 57 | cout << "emplace() complete"<< std::endl; 58 | t.report(); 59 | 60 | std::srand(1); 61 | t.start(); 62 | bt.open("tune_int_map.btr", hint); 63 | 64 | // find n elements 65 | for (int i = 1; i <= n; ++i) 66 | bt.find(std::rand()); 67 | 68 | bt.close(); 69 | t.stop(); 70 | cout << "find() complete\n"; 71 | t.report(); 72 | 73 | return 0; 74 | } 75 | ///$endid 76 | -------------------------------------------------------------------------------- /example/udt.hpp: -------------------------------------------------------------------------------- 1 | // example/udt.hpp 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #ifndef BOOST_BTREE_UDT_EXAMPLE_HPP 10 | #define BOOST_BTREE_UDT_EXAMPLE_HPP 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | using std::cout; 17 | using namespace boost::btree; 18 | using boost::string_view; 19 | 20 | // The actual UDT ----------------------------------------------------------// 21 | 22 | struct UDT 23 | { 24 | typedef int id_type; 25 | 26 | id_type id; 27 | string_view english; 28 | string_view spanish; 29 | 30 | UDT() {} 31 | UDT(id_type n, string_view en, string_view sp) 32 | : id(n), english(en), spanish(sp) 33 | {} 34 | 35 | bool operator < (const UDT& rhs) const { return english < rhs.english; } 36 | }; 37 | 38 | // stream inserter ---------------------------------------------------------// 39 | 40 | inline std::ostream& operator<<(std::ostream& os, const UDT& x) 41 | { 42 | os << x.id << " \"" << x.english << "\" \"" << x.spanish << "\""; 43 | return os; 44 | } 45 | 46 | // function objects for different orderings --------------------------------// 47 | 48 | struct id_ordering 49 | { 50 | bool operator()(const UDT& x, const UDT& y) const 51 | {return x.id < y.id;} 52 | }; 53 | 54 | struct spanish_ordering 55 | { 56 | bool operator()(const UDT& x, const UDT& y) const 57 | {return x.spanish < y.spanish;} 58 | }; 59 | 60 | // specializations to support btree indexes --------------------------------// 61 | 62 | namespace boost 63 | { 64 | namespace btree 65 | { 66 | template <> struct index_reference { typedef const UDT type; }; 67 | 68 | template <> 69 | inline void index_serialize(const UDT& udt, flat_file_type& file) 70 | { 71 | index_serialize(udt.id, file); 72 | index_serialize(udt.english, file); 73 | index_serialize(udt.spanish, file); 74 | } 75 | 76 | template <> 77 | inline index_reference::type index_deserialize(const char** flat) 78 | { 79 | UDT udt; 80 | udt.id = index_deserialize(flat); 81 | udt.english = index_deserialize(flat); 82 | udt.spanish = index_deserialize(flat); 83 | return udt; 84 | } 85 | }} // namespaces 86 | 87 | #endif 88 | ///$endid 89 | -------------------------------------------------------------------------------- /example/udt_3_index_set.cpp: -------------------------------------------------------------------------------- 1 | // example/udt_3_index_set.cpp 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include "udt.hpp" 11 | #include 12 | #include 13 | #include 14 | 15 | using std::cout; 16 | using namespace boost::btree; 17 | 18 | int cpp_main(int, char *[]) 19 | { 20 | typedef btree_index_set IDX1; 21 | typedef btree_index_set IDX2; 22 | typedef btree_index_set IDX3; 23 | 24 | IDX1 idx1("udt_3_index_set.idx1", "udt_3_index_set.dat", flags::truncate); 25 | IDX2 idx2("udt_3_index_set.idx2", idx1.file(), flags::truncate, -1, 26 | id_ordering()); 27 | IDX3 idx3("udt_3_index_set.idx3", idx1.file(), flags::truncate, -1, 28 | spanish_ordering()); 29 | 30 | IDX1::file_position pos; 31 | 32 | pos = idx1.push_back(UDT(1, "eat", "comer")); 33 | idx1.insert_file_position(pos); 34 | idx2.insert_file_position(pos); 35 | idx3.insert_file_position(pos); 36 | 37 | pos = idx1.push_back(UDT(2, "drink", "beber")); 38 | idx1.insert_file_position(pos); 39 | idx2.insert_file_position(pos); 40 | idx3.insert_file_position(pos); 41 | 42 | pos = idx1.push_back(UDT(3, "be merry", "ser feliz")); 43 | idx1.insert_file_position(pos); 44 | idx2.insert_file_position(pos); 45 | idx3.insert_file_position(pos); 46 | 47 | cout << "\ninx1 - English ordering:\n\n"; 48 | for (IDX1::iterator itr = idx1.begin(); itr != idx1.end(); ++itr) 49 | cout << " " << *itr << '\n'; 50 | 51 | cout << "\ninx2 - ID ordering:\n\n"; 52 | for (IDX2::iterator itr = idx2.begin(); itr != idx2.end(); ++itr) 53 | cout << " " << *itr << '\n'; 54 | 55 | cout << "\ninx3 - Spanish ordering:\n\n"; 56 | for (IDX3::iterator itr = idx3.begin(); itr != idx3.end(); ++itr) 57 | cout << " " << *itr << '\n'; 58 | 59 | return 0; 60 | } 61 | ///$endid 62 | -------------------------------------------------------------------------------- /example/udt_index_set.cpp: -------------------------------------------------------------------------------- 1 | // example/udt_index_set.cpp 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | ///$id code= 9 | #include 10 | #include "udt.hpp" 11 | #include 12 | #include 13 | #include 14 | 15 | using std::cout; 16 | using namespace boost::btree; 17 | 18 | int cpp_main(int, char *[]) 19 | { 20 | typedef btree_index_set BT; 21 | BT bt("UDT_index_set", flags::truncate); 22 | 23 | bt.insert(UDT(1, "eat", "comer")); 24 | bt.insert(UDT(2, "drink", "beber")); 25 | bt.insert(UDT(3, "be merry", "ser feliz")); 26 | 27 | for (BT::iterator itr = bt.begin(); itr != bt.end(); ++itr) 28 | cout << *itr << '\n'; 29 | 30 | return 0; 31 | } 32 | ///$endid 33 | -------------------------------------------------------------------------------- /include/boost/btree/detail/config.hpp: -------------------------------------------------------------------------------- 1 | // boost/btree/detail/config.hpp -----------------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2003, 2010 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | // Library home page: http://www.boost.org/libs/btree 9 | 10 | //--------------------------------------------------------------------------------------// 11 | 12 | #ifndef BOOST_BTREE_CONFIG_HPP 13 | #define BOOST_BTREE_CONFIG_HPP 14 | 15 | // This header implements separate compilation features as described in 16 | // http://www.boost.org/more/separate_compilation.html 17 | 18 | #include 19 | #include // for BOOST_POSIX_API or BOOST_WINDOWS_API 20 | 21 | // throw an exception ----------------------------------------------------------------// 22 | // 23 | // Exceptions were originally thrown via boost::throw_exception(). 24 | // As throw_exception() became more complex, it caused user error reporting 25 | // to be harder to interpret, since the exception reported became much more complex. 26 | // The immediate fix was to throw directly, wrapped in a macro to make any later change 27 | // easier. 28 | 29 | #define BOOST_BTREE_THROW(EX) throw EX 30 | 31 | // enable dynamic linking -------------------------------------------------------------// 32 | 33 | #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_BTREE_DYN_LINK) 34 | # if defined(BOOST_BTREE_SOURCE) 35 | # define BOOST_BTREE_DECL BOOST_SYMBOL_EXPORT 36 | # else 37 | # define BOOST_BTREE_DECL BOOST_SYMBOL_IMPORT 38 | # endif 39 | #else 40 | # define BOOST_BTREE_DECL 41 | #endif 42 | 43 | // enable automatic library variant selection ----------------------------------------// 44 | 45 | #if !defined(BOOST_BTREE_SOURCE) && !defined(BOOST_ALL_NO_LIB) \ 46 | && !defined(BOOST_BTREE_NO_LIB) 47 | // 48 | // Set the name of our library, this will get undef'ed by auto_link.hpp 49 | // once it's done with it: 50 | // 51 | #define BOOST_LIB_NAME boost_btree 52 | // 53 | // If we're importing code from a dll, then tell auto_link.hpp about it: 54 | // 55 | #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_BTREE_DYN_LINK) 56 | # define BOOST_DYN_LINK 57 | #endif 58 | // 59 | // And include the header that does the work: 60 | // 61 | #include 62 | #endif // auto-linking disabled 63 | 64 | #endif // BOOST_BTREE_CONFIG_HPP 65 | -------------------------------------------------------------------------------- /include/boost/btree/detail/test_traits.hpp: -------------------------------------------------------------------------------- 1 | // boost/btree/detail/test_traits.hpp ------------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | #ifndef BOOST_BTREE_DETAIL_TEST_TRAITS_HPP 9 | #define BOOST_BTREE_DETAIL_TEST_TRAITS_HPP 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | 23 | namespace boost { namespace btree { namespace detail { 24 | 25 | //------------------------------------------------------------------------------------// 26 | // // 27 | // Abstract away differences between btree and std types, between sets and maps, // 28 | // between trees and indexes, and between generator types. // 29 | // // 30 | //------------------------------------------------------------------------------------// 31 | 32 | class map_64_64 33 | { 34 | mt19937_64 m_rng; 35 | uniform_int m_dist; 36 | variate_generator > m_key; 37 | public: 38 | typedef boost::btree::btree_map btree_type; 39 | typedef btree_type::key_type btree_key_type; 40 | typedef btree_type::value_type btree_value_type; 41 | typedef std::map stl_type; 42 | typedef stl_type::key_type stl_key_type; 43 | typedef stl_type::value_type stl_value_type; 44 | 45 | map_64_64(int64_t n) : m_dist(0, n-1), m_key(m_rng, m_dist) {} 46 | 47 | void seed(int64_t seed_) {m_rng.seed(seed_);} 48 | btree_key_type key() {return m_key();} 49 | btree_value_type value(int64_t mapped_value) {return std::make_pair(m_key(), 50 | mapped_value);} 51 | 52 | stl_key_type stl_key(const btree_value_type& v) {return v.first;} 53 | stl_value_type stl_value(const btree_value_type& v) {return v;} 54 | }; 55 | 56 | //class set_64_generator 57 | //{ 58 | // mt19937_64 m_rng; 59 | // uniform_int m_dist; 60 | // variate_generator > m_key; 61 | //public: 62 | // typedef std::set stl_type; 63 | 64 | // set_64_generator(int64_t n) : m_dist(0, n-1), m_key(m_rng, m_dist) {} 65 | 66 | // void seed(int64_t seed_) {m_rng.seed(seed_);} 67 | // int64_t key() {return m_key();} 68 | // int64_t value(int64_t) {return m_key();} 69 | 70 | // static int64_t stl_key(int64_t vt) {return vt;} 71 | // static stl_type::value_type stl_value(int64_t vt) {return vt;} 72 | //}; 73 | 74 | //class set_index_64_generator 75 | //{ 76 | // mt19937_64 m_rng; 77 | // uniform_int m_dist; 78 | // variate_generator > m_key; 79 | //public: 80 | // typedef std::set stl_type; 81 | 82 | // set_index_64_generator(int64_t n) : m_dist(0, n-1), m_key(m_rng, m_dist) {} 83 | 84 | // void seed(int64_t seed_) {m_rng.seed(seed_);} 85 | // int64_t key() {return m_key();} 86 | // int64_t value(int64_t) {return m_key();} 87 | 88 | // static int64_t stl_key(int64_t vt) {return vt;} 89 | // static stl_type::value_type stl_value(int64_t vt) {return vt;} 90 | //}; 91 | 92 | class set_index_string_view 93 | { 94 | boost::random_string m_rsg; 95 | std::string m_string; 96 | public: 97 | typedef boost::btree:: 98 | btree_index_set btree_type; 99 | typedef std::set stl_type; 100 | 101 | typedef btree_type::key_type btree_key_type; 102 | typedef btree_type::value_type btree_value_type; 103 | typedef btree_type::value_type btree_mapped_type; 104 | typedef stl_type::key_type stl_key_type; 105 | typedef stl_type::value_type stl_value_type; 106 | typedef stl_type::value_type stl_mapped_type; 107 | 108 | set_index_string_view(int64_t) 109 | : m_rsg(0, 512, 'a', 'z') {} 110 | 111 | void seed(int64_t seed_) {m_rsg.seed(static_cast(seed_));} 112 | 113 | btree_key_type generate_btree_key() {m_string = m_rsg(); 114 | return boost::string_view(m_string);} 115 | btree_value_type generate_btree_value(int64_t) {return generate_btree_key();} 116 | 117 | btree_key_type btree_key(const btree_value_type& v) const 118 | {return v;} 119 | btree_key_type btree_mapped(const btree_value_type& v) const 120 | {return v;} 121 | 122 | stl_value_type stl_value(const btree_value_type& v) const 123 | {return stl_value_type(v.data(), v.size());} 124 | stl_key_type stl_key(const stl_value_type& v) const 125 | {return v;} 126 | stl_mapped_type stl_mapped(const stl_value_type& v) const 127 | {return v;} 128 | }; 129 | 130 | }}} // namespaces 131 | 132 | #endif // BOOST_BTREE_DETAIL_TEST_TRAITS_HPP 133 | -------------------------------------------------------------------------------- /include/boost/btree/index_helpers.hpp: -------------------------------------------------------------------------------- 1 | // boost/btree/index_helpers.hpp -----------------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // http://www.boost.org/LICENSE_1_0.txt 7 | 8 | #ifndef BOOST_BTREE_INDEX_HELPERS_HPP 9 | #define BOOST_BTREE_INDEX_HELPERS_HPP 10 | 11 | #ifdef _MSC_VER 12 | # pragma warning(push) 13 | # pragma warning(disable : 4996) // equivalent to -D_SCL_SECURE_NO_WARNINGS 14 | #endif 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace boost 27 | { 28 | namespace btree 29 | { 30 | 31 | typedef boost::btree::extendible_mapped_file flat_file_type; 32 | 33 | //--------------------------------------------------------------------------------------// 34 | // index traits // 35 | //--------------------------------------------------------------------------------------// 36 | 37 | // index_serialize should be customized for variable length UDTs by specialization 38 | // rather than by overload to eliminate the silent error of a user writing 39 | // index_serialize(...) by mistake and getting the primary template instead 40 | // of a MyType specialization. 41 | 42 | //------------------ defaults for all fixed length data types ------------------------// 43 | 44 | template 45 | struct index_reference { typedef const T& type; }; 46 | 47 | template 48 | inline void index_serialize(const T& x, flat_file_type& file) 49 | { 50 | flat_file_type::position_type pos = file.file_size(); 51 | file.increment_file_size(sizeof(T)); // will resize if needed 52 | std::memcpy(file.template data() + pos, 53 | reinterpret_cast(&x), sizeof(T)); 54 | } 55 | 56 | template 57 | inline typename index_reference::type index_deserialize(const char** flat) 58 | { 59 | BOOST_ASSERT(flat); 60 | BOOST_ASSERT(*flat); 61 | const char* p = *flat; 62 | *flat += sizeof(T); 63 | return *reinterpret_cast(p); 64 | } 65 | 66 | //------------------ string_view (i.e. C++ style string) traits --------------------// 67 | 68 | template <> 69 | struct index_reference 70 | { typedef const boost::string_view type; }; 71 | 72 | template <> 73 | inline void index_serialize(const boost::string_view& sv, 74 | flat_file_type& file) 75 | { 76 | typedef btree::support::size_t_codec codec; 77 | std::size_t size_sz = codec::encoded_size(sv.size()); 78 | flat_file_type::position_type pos = file.file_size(); 79 | file.increment_file_size(size_sz + sv.size()); // will resize if needed 80 | codec::encode(sv.size(), file.data() + pos, size_sz); 81 | pos += size_sz; 82 | std::memcpy(file.data() + pos, sv.data(), sv.size()); 83 | } 84 | 85 | template <> 86 | inline index_reference::type 87 | index_deserialize(const char** flat) 88 | { 89 | typedef btree::support::size_t_codec codec; 90 | BOOST_ASSERT(flat); 91 | BOOST_ASSERT(*flat); 92 | std::pair dec = codec::decode(*flat); 93 | *flat += dec.second; // size of the size prefix 94 | const char* p = *flat; 95 | *flat += dec.first; // size of the string 96 | return boost::string_view(p, dec.first); 97 | } 98 | 99 | } // namespace btree 100 | } // namespace boost 101 | 102 | #ifdef _MSC_VER 103 | # pragma warning(pop) 104 | #endif 105 | 106 | #endif // BOOST_BTREE_INDEX_HELPERS_HPP 107 | -------------------------------------------------------------------------------- /include/boost/btree/support/random_string.hpp: -------------------------------------------------------------------------------- 1 | // random_string.hpp -----------------------------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2011 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | #ifndef BOOST_RANDOM_STRING_HPP 9 | #define BOOST_RANDOM_STRING_HPP 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace boost 17 | { 18 | class random_string 19 | { 20 | public: 21 | random_string(int min_len, int max_len, 22 | int min_char = ' ', int max_char = '~') 23 | { 24 | m_char_dist.reset(new uniform_int<> (min_char, max_char)); 25 | m_char.reset(new variate_generator > 26 | (m_char_rng, *m_char_dist)); 27 | 28 | m_len_dist.reset(new uniform_int<> (min_len, max_len)); 29 | m_len.reset(new variate_generator > 30 | (m_len_rng, *m_len_dist)); 31 | } 32 | std::string operator()(); 33 | 34 | void seed(int x) 35 | { 36 | m_len_rng.seed(x); 37 | m_char_rng.seed(x); 38 | } 39 | 40 | private: 41 | 42 | rand48 m_char_rng; 43 | shared_ptr > m_char_dist; 44 | shared_ptr > > m_char; 45 | 46 | rand48 m_len_rng; 47 | shared_ptr > m_len_dist; 48 | shared_ptr > > m_len; 49 | }; 50 | 51 | std::string random_string::operator()() 52 | { 53 | std::string s; 54 | for (int len = m_len->operator()(); len > 0; --len) 55 | s += m_char->operator()(); 56 | //std::cout << s << '\n'; 57 | return s; 58 | } 59 | 60 | } // namespace boost 61 | 62 | #endif // BOOST_RANDOM_STRING_HPP 63 | -------------------------------------------------------------------------------- /include/boost/btree/support/size_t_codec.hpp: -------------------------------------------------------------------------------- 1 | // boost/btree/support/size_t_codec.hpp ----------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | #ifndef BOOST_BTREE_SIZE_T_CODEC_HPP 9 | #define BOOST_BTREE_SIZE_T_CODEC_HPP 10 | 11 | #include 12 | #include 13 | #include // for std::pair<> 14 | 15 | namespace boost 16 | { 17 | namespace btree 18 | { 19 | namespace support 20 | { 21 | 22 | //--------------------------------------------------------------------------------------// 23 | // // 24 | // coder/decoder for std::size_t // 25 | // // 26 | // Encodes and decodes a size_t value as a variable length byte string. The // 27 | // high-order bit of the last (i.e. low-order) byte is not set. The high-order bit of // 28 | // all other bytes is set. Thus there are 7 significant bits per byte, so it takes 1 // 29 | // to (sizeof(size_t) * 8) / 7 + 1 bytes to hold a size_t value. That works out to 5 // 30 | // bytes for 32-bit size_t, and 10 bytes for 64-bit size_t. // 31 | // // 32 | // A use case would be to encode the length of strings. Since typical strings are // 33 | // short, the encode length is often only one or two bytes, and that is a significant // 34 | // savings for applications like B-trees that are very sensitive to data sizes. // 35 | // // 36 | // The technique obviously generalizes to types other than size_t, but size_t is the // 37 | // only current concern. // 38 | // // 39 | // See size_t_codec_test() in index_unit_test.cpp for tests. // 40 | // // 41 | //--------------------------------------------------------------------------------------// 42 | 43 | BOOST_STATIC_ASSERT_MSG(sizeof(std::size_t) == 4 || sizeof(std::size_t) == 8, 44 | "Only 32 and 64-bit size_t currently supported"); 45 | 46 | BOOST_STATIC_ASSERT_MSG(CHAR_BIT == 8, "Only CHAR_BIT == 8 currently supported"); 47 | 48 | struct size_t_codec 49 | { 50 | static const std::size_t max_size = (sizeof(std::size_t)*8)/7+1; 51 | 52 | static std::size_t encoded_size(std::size_t x); 53 | // Returns: The encoded size of x. 54 | 55 | static void encode(std::size_t x, char* dest, std::size_t encoded_sz); 56 | // Requires: encoded_sz == encoded_size(x) 57 | // Effects: The encoded value of x is placed in the array beginning at dest. 58 | 59 | static std::pair decode(const char* x); 60 | // Requires: x is encoded using the encode function. 61 | // Returns: A pair containing the value of the encoded byte string beginning at s 62 | // and the size of that byte string. 63 | }; 64 | 65 | inline std::size_t size_t_codec::encoded_size(std::size_t x) 66 | { 67 | // hopefully this code is very fast for the common use cases of smallish values 68 | if (x <= 0x7fu) return 1; 69 | if (x <= 0x3fffu) return 2; 70 | if (x <= 0x1fffffu) return 3; 71 | 72 | // this code will work for either 32 or 64-bit size_t 73 | x >>= 21; 74 | std::size_t r = 3; 75 | for (; x; ++r, x >>= 7) {} 76 | return r; 77 | } 78 | 79 | inline void size_t_codec::encode(std::size_t x, char* dest, std::size_t encoded_sz) 80 | { 81 | BOOST_ASSERT(encoded_sz == encoded_size(x)); 82 | char* p = dest + encoded_sz - 1; 83 | *p = static_cast(x & 0x7f); 84 | x >>= 7; 85 | while (x) 86 | { 87 | *--p = static_cast((x & 0x7f) | 0x80); 88 | x >>= 7; 89 | }; 90 | } 91 | 92 | inline std::pair 93 | size_t_codec::decode(const char* x) 94 | { 95 | std::pair tmp; 96 | tmp.first = 0; 97 | tmp.second = 0; 98 | while (*x & 0x80) 99 | { 100 | BOOST_ASSERT(tmp.second < max_size); 101 | tmp.first |= static_cast(*x & 0x7f); 102 | tmp.first <<= 7; 103 | ++x; 104 | ++tmp.second; 105 | } 106 | tmp.first |= *x & 0x7f; 107 | ++tmp.second; 108 | return tmp; 109 | } 110 | 111 | } // namespace support 112 | } // namespace btree 113 | } // namespace boost 114 | 115 | #endif //BOOST_BTREE_SIZE_T_CODEC_HPP 116 | -------------------------------------------------------------------------------- /include/boost/btree/support/string_view.hpp: -------------------------------------------------------------------------------- 1 | // boost/btree/index_helpers.hpp -----------------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // http://www.boost.org/LICENSE_1_0.txt 7 | 8 | #ifndef BOOST_BTREE_STRING_VIEW_HPP 9 | #define BOOST_BTREE_STRING_VIEW_HPP 10 | #include 11 | 12 | namespace boost 13 | { 14 | 15 | //--------------------------------------------------------------------------------------// 16 | // // 17 | // string_view // 18 | // // 19 | // Thanks to Marshall Clow, Boost has an early version of string_view, dating from // 20 | // when it was named string_ref. So the only thing needed is a typedef. // 21 | // // 22 | // See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3685.html // 23 | // // 24 | //--------------------------------------------------------------------------------------// 25 | 26 | // . So typedef the name. 27 | 28 | typedef string_ref string_view; 29 | 30 | } // namespace boost 31 | 32 | #endif // BOOST_BTREE_STRING_VIEW_HPP 33 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Automatic redirection failed, please go to 7 | doc/index.html. 8 |
9 |

© Copyright Beman Dawes, 2013

10 |

Distributed under the Boost Software License, Version 1.0. 11 | See http://www.boost.org/LICENSE_1_0.txt

12 | 13 | -------------------------------------------------------------------------------- /test/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # Boost Btree Library test Jamfile 2 | 3 | # (C) Copyright Beman Dawes 2010 4 | # Distributed under the Boost Software License, Version 1.0. 5 | # See www.boost.org/LICENSE_1_0.txt 6 | 7 | project 8 | : requirements 9 | /boost/btree//boost_btree 10 | /boost/filesystem//boost_filesystem 11 | /boost/system//boost_system 12 | /boost/timer//boost_timer 13 | /boost/chrono//boost_chrono 14 | /boost/iostreams//boost_iostreams 15 | msvc:on 16 | ; 17 | 18 | test-suite "btree" : 19 | [ run 20 | btree_unit_test.cpp # sources 21 | : # command line arguments 22 | : # input files 23 | : # requirements 24 | : # target name 25 | ] 26 | [ run binary_file_test.cpp : : : : ] 27 | [ run ../tools/bt_time.cpp : 100 -stl -pack : : : ] 28 | [ run index_unit_test.cpp : : : : ] 29 | [ run buffer_manager_test.cpp : : : : ] 30 | [ run stl_test.cpp : : : : ] 31 | ; 32 | -------------------------------------------------------------------------------- /test/binary_file_test.cpp: -------------------------------------------------------------------------------- 1 | // Boost binary_file_test.cpp --------------------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2006, 2010 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | // See library home page http://www.boost.org/libs/filesystem 9 | 10 | //--------------------------------------------------------------------------------------// 11 | 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace fs = boost::filesystem; 21 | namespace bt = boost::btree; 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #ifdef BOOST_WINDOWS_API 28 | # include 29 | # define BOOST_BAD_SEEK ERROR_NEGATIVE_SEEK 30 | #else 31 | # include 32 | # define BOOST_BAD_SEEK EINVAL 33 | #endif 34 | 35 | namespace 36 | { 37 | void open_flag_tests() 38 | { 39 | std::cout << "open flag tests..." << std::endl; 40 | 41 | fs::path p("test.txt"); 42 | fs::remove(p); 43 | BOOST_TEST(!fs::exists(p)); 44 | 45 | boost::system::error_code ec; 46 | 47 | { 48 | std::cout << " oflag::in test, file doesn't exist..." << std::endl; 49 | bt::binary_file f(p, bt::oflag::in, ec); 50 | BOOST_TEST(ec); 51 | } 52 | { 53 | std::cout << " oflag::out test, file doesn't exist..." << std::endl; 54 | bt::binary_file f(p, bt::oflag::out, ec); 55 | BOOST_TEST(!ec); 56 | BOOST_TEST(fs::exists(p)); 57 | BOOST_TEST_EQ(fs::file_size(p), 0U); 58 | f.write("foo", 3, ec); 59 | BOOST_TEST(!ec); 60 | BOOST_TEST_EQ(fs::file_size(p), 3U); 61 | } 62 | { 63 | std::cout << " oflag::in test, file exists..." << std::endl; 64 | BOOST_TEST(fs::exists(p)); 65 | bt::binary_file f(p, bt::oflag::in); 66 | std::cout << " handle() returns " << f.handle() << std::endl; 67 | BOOST_TEST_EQ(fs::file_size(p), 3U); 68 | } 69 | { 70 | std::cout << " oflag::in test | bt::oflag::out, file exists..." << std::endl; 71 | BOOST_TEST(fs::exists(p)); 72 | bt::binary_file f(p, bt::oflag::in | bt::oflag::out); 73 | BOOST_TEST_EQ(fs::file_size(p), 3U); 74 | } 75 | { 76 | std::cout << " oflag::in test bt::oflag::in | bt::oflag::out | bt::oflag::truncate\n" 77 | ", file exists..." << std::endl; 78 | BOOST_TEST(fs::exists(p)); 79 | bt::binary_file f(p, bt::oflag::in | bt::oflag::out | bt::oflag::truncate); 80 | BOOST_TEST_EQ(fs::file_size(p), 0U); 81 | } 82 | 83 | fs::remove(p); 84 | std::cout << " completed open flag tests" << std::endl; 85 | } 86 | } 87 | 88 | // cpp_main --------------------------------------------------------------------------// 89 | 90 | int cpp_main(int argc, char * argv[]) 91 | { 92 | bt::binary_file::offset_type gap(32); 93 | 94 | if (argc > 1) gap = 95 | static_cast(std::atol(argv[1])) * 1024; 96 | 97 | open_flag_tests(); 98 | 99 | char buf[128] = "0123456789abcdef"; 100 | 101 | std::string filename("file_with_gap"); 102 | bt::binary_file f(filename, bt::oflag::in |bt::oflag::out | bt::oflag::truncate); 103 | BOOST_TEST(f.path() == filename); 104 | BOOST_TEST(fs::exists(filename)); 105 | 106 | 107 | boost::system::error_code ec; 108 | f.seek(-1, bt::seekdir::begin, ec); 109 | BOOST_TEST(ec); 110 | BOOST_TEST_EQ(ec.value(), BOOST_BAD_SEEK); 111 | 112 | bool error_thrown(false); 113 | try 114 | { 115 | f.seek(-1, bt::seekdir::begin); 116 | } 117 | catch (const fs::filesystem_error & ex) 118 | { 119 | error_thrown = true; 120 | BOOST_TEST_EQ(ec.value(), BOOST_BAD_SEEK); 121 | BOOST_TEST_EQ(ex.path1().string(), filename); 122 | } 123 | BOOST_TEST(error_thrown); 124 | 125 | char beginning[] = "beginning"; 126 | f.write(beginning, 10); 127 | BOOST_TEST(fs::file_size(filename) == 10); 128 | BOOST_TEST(f.seek(0, bt::seekdir::end) == 10); 129 | BOOST_TEST(f.seek(gap, bt::seekdir::current) == gap + 10); 130 | 131 | char ending[] = "ending"; 132 | f.write(ending, 7); 133 | BOOST_TEST(f.seek(0, bt::seekdir::current) == gap + 17); 134 | BOOST_TEST(f.seek(0, bt::seekdir::end) == gap + 17); 135 | 136 | int i = 12345; 137 | f.write(i); 138 | BOOST_TEST(f.seek(0, bt::seekdir::current) == gap + 17 + int(sizeof(i))); 139 | BOOST_TEST(f.seek(0, bt::seekdir::end) == gap + 17 + int(sizeof(i))); 140 | 141 | BOOST_TEST(f.seek(0, bt::seekdir::begin) == 0); 142 | 143 | BOOST_TEST(f.read(buf, 10)); 144 | BOOST_TEST(std::strcmp(buf, beginning) == 0); 145 | BOOST_TEST(std::memcmp(&buf[10], "abcdef", 6) == 0); 146 | 147 | BOOST_TEST(f.seek(gap + 10, bt::seekdir::begin) == gap + 10); 148 | BOOST_TEST(f.read(buf, 7)); 149 | BOOST_TEST(std::strcmp(buf, ending) == 0); 150 | 151 | int j; 152 | f.read(j); 153 | BOOST_TEST_EQ(i, j); 154 | 155 | BOOST_TEST(!f.read(buf, 1)); 156 | 157 | BOOST_TEST(f.is_open()); 158 | f.close(); 159 | BOOST_TEST(!f.is_open()); 160 | 161 | BOOST_TEST_EQ(fs::file_size(filename), 162 | static_cast(gap + 17 + sizeof(i))); 163 | 164 | return boost::report_errors(); 165 | } 166 | -------------------------------------------------------------------------------- /test/bt_time_all.bat: -------------------------------------------------------------------------------- 1 | bt_time 5000000 -stl -p4096 -c32 -native -html 2>times.html 2 | bt_time 5000000 -stl -p4096 -c2100 -native -html 2>>times.html 3 | bt_time 5000000 -stl -p4096 -c4200 -native -html 2>>times.html 4 | bt_time 5000000 -stl -p4096 -c8400 -native -html 2>>times.html 5 | bt_time 5000000 -stl -p4096 -c8400 -little -html 2>>times.html 6 | bt_time 5000000 -stl -p4096 -c8400 -big -html 2>>times.html 7 | type times.html 8 | -------------------------------------------------------------------------------- /test/bulk_load_test.cpp: -------------------------------------------------------------------------------- 1 | // btree/test/bulk_load_test.cpp -----------------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | #include "../tools/data.hpp" 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include // for atoll() or Microsoft equivalent 17 | #include // for isdigit() 18 | #ifndef _MSC_VER 19 | # define BOOST_BTREE_ATOLL std::atoll 20 | #else 21 | # define BOOST_BTREE_ATOLL _atoi64 22 | #endif 23 | 24 | using namespace boost::btree; 25 | using std::cout; using std::endl; 26 | 27 | /* 28 | TODO: 29 | 30 | * need to specify directory for temporary files 31 | 32 | * add tests for multimaps, sets, multisets 33 | 34 | */ 35 | 36 | namespace 37 | { 38 | boost::filesystem::path source_path; 39 | boost::filesystem::path btree_path; 40 | boost::filesystem::path temp_path(boost::filesystem::temp_directory_path()); 41 | std::size_t max_memory_megabytes = 1000U; 42 | const std::size_t one_megabyte = 1000000U; 43 | std::size_t max_memory = max_memory_megabytes * one_megabyte; 44 | 45 | std::string command_args; 46 | bulk_opts::bitmask opts = bulk_opts::none; 47 | int64_t log_point = 0; // if != 0, log_point every lg iterations 48 | 49 | char thou_separator = ','; 50 | bool verbose (false); 51 | const int places = 2; 52 | std::string path("data.dat"); 53 | 54 | std::ofstream out; 55 | 56 | const double sec = 1000000000.0; 57 | 58 | struct thousands_separator : std::numpunct { 59 | char do_thousands_sep() const { return thou_separator; } 60 | std::string do_grouping() const { return "\3"; } 61 | }; 62 | } 63 | 64 | int cpp_main(int argc, char* argv[]) 65 | { 66 | for (int a = 0; a < argc; ++a) 67 | { 68 | command_args += argv[a]; 69 | if (a != argc-1) 70 | command_args += ' '; 71 | } 72 | cout << command_args << '\n'; 73 | const int req = 3; 74 | 75 | if (argc >= req) 76 | { 77 | source_path = argv[1]; 78 | btree_path = argv[2]; 79 | 80 | for (; argc > req; ++argv, --argc) 81 | { 82 | if (*argv[req] != '-') 83 | temp_path = argv[req]; 84 | else 85 | { 86 | if ( *(argv[req]+1) == 'm' && std::isdigit(*(argv[req]+2)) ) 87 | { 88 | max_memory_megabytes = static_cast(BOOST_BTREE_ATOLL(argv[req]+2)); 89 | max_memory = max_memory_megabytes * one_megabyte; 90 | } 91 | else if ( *(argv[req]+1) == 'k' && std::isdigit(*(argv[req]+2)) ) 92 | { 93 | std::size_t tmp = static_cast(BOOST_BTREE_ATOLL(argv[req]+2)); 94 | max_memory = tmp * 1024U; 95 | } 96 | else if ( *(argv[req]+1) == 'l' && std::isdigit(*(argv[req]+2)) ) 97 | log_point = BOOST_BTREE_ATOLL( argv[req]+2 ); 98 | else if ( *(argv[req]+1) == 'x' && *(argv[req]+2) == 'd' 99 | && *(argv[req]+3) == '\0') 100 | opts |= bulk_opts::skip_distribution; 101 | else if ( std::strncmp( argv[req]+1, "sep", 3 )==0 102 | && (std::ispunct(*(argv[req]+4)) || *(argv[req]+4)== '\0') ) 103 | thou_separator = *(argv[req]+4) ? *(argv[req]+4) : ' '; 104 | else 105 | { 106 | cout << "Error - unknown option: " << argv[req] << "\n\n"; 107 | argc = -1; 108 | break; 109 | } 110 | } 111 | } 112 | } 113 | 114 | if (argc < 3) 115 | { 116 | cout << "Usage: bulk_load_test source-path target-path [Options]\n" 117 | " source-path File of binary key/mapped data pairs; must exist\n" 118 | " target-path BTree file the source data pairs will be inserted\n" 119 | " into; error if already exists\n" 120 | " Options:\n" 121 | " temp-path Directory for temporary files; default: " << temp_path << "\n" 122 | " -m# Maximum memory # megabytes; default: " << 123 | max_memory_megabytes << "\n" 124 | " Note well: The number of temporary files will be\n" 125 | " source file size / maximum memory. Ensure this is reasonable!\n" 126 | " -x Skip distribution phase; use existing temporary files;\n" 127 | " default: do not skip" 128 | " -l# Log progress every # actions; default: no action logging\n" 129 | " -sep[punct] Thousands separator; space if punct omitted, default -sep,\n" 130 | " -k# Maximum memory # kilobytes; default: see -m#. Note: for testing only\n" 131 | // TODO: " -v Verbose output statistics\n" 132 | ; 133 | return 1; 134 | } 135 | 136 | cout.imbue(std::locale(std::locale(), new thousands_separator)); 137 | boost::timer::auto_cpu_timer t(1); 138 | 139 | //bulk_load_map map; // KISS 140 | bulk_load_map loader; 141 | loader(source_path, btree_path, temp_path, cout, max_memory, opts, 142 | log_point, flags::truncate); 143 | //bulk_load_set loader; 144 | //loader(source_path, btree_path, temp_path, cout, max_memory, opts, 145 | log_point, flags::truncate); 146 | 147 | t.stop(); 148 | t.report(); 149 | 150 | return 0; 151 | } 152 | -------------------------------------------------------------------------------- /test/large_file_test.cpp: -------------------------------------------------------------------------------- 1 | // large_file_test.cpp ---------------------------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2010 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace boost::filesystem; 16 | using std::cout; 17 | using std::endl; 18 | 19 | int cpp_main(int argc, char* argv[]) 20 | { 21 | if (argc < 2) 22 | { 23 | cout << "Usage large_file_test [size-in-megabytes]\n"; 24 | return 1; 25 | } 26 | 27 | boost::btree::binary_file::offset_type sz = 5000000000LL; 28 | 29 | if (argc > 2) 30 | { 31 | sz = atol(argv[2]); 32 | sz *= 1000000; 33 | } 34 | 35 | cout << "sizeof(boost::btree::binary_file::offset_type) is " 36 | << sizeof(boost::btree::binary_file::offset_type) << endl; 37 | 38 | path p(argv[1]); 39 | 40 | cout << "opening " << p << endl; 41 | boost::btree::binary_file lft(p, boost::btree::oflag::out 42 | | boost::btree::oflag::truncate); 43 | 44 | boost::btree::binary_file::offset_type result; 45 | 46 | cout << "seeking" << endl; 47 | result = lft.seek(sz); 48 | 49 | cout << "seek(" << sz << ") returned " << result << endl; 50 | 51 | cout << "writing 1 byte" << endl; 52 | lft.write(" ", 1); 53 | 54 | cout << "closing " << p << endl; 55 | lft.close(); 56 | 57 | cout << "file_size(" << p << ") is " << file_size(p) << endl; 58 | 59 | cout << "removing " << p << endl; 60 | remove(p); 61 | 62 | cout << "tests complete" << endl; 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /test/mmf_experiment.cpp: -------------------------------------------------------------------------------- 1 | // mmf_experiment.cpp - memory mapped file experiments -----------------------------// 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace boost::btree; 17 | 18 | int cpp_main(int argc, char* argv[]) 19 | { 20 | std::string p("test.mmf"); 21 | 22 | // Test 1: Extend the file before opening as a mapped_file 23 | { 24 | { 25 | binary_file fi(p, oflag::in | oflag::out | oflag::truncate | oflag::random); 26 | fi.seek(12); 27 | fi.write(0); 28 | } 29 | 30 | boost::iostreams::mapped_file mmf(p, 31 | boost::iostreams::mapped_file::readwrite, 1000); 32 | 33 | std::memset(mmf.data(), 0x22, 100); 34 | mmf.close(); 35 | std::cout << p << " size is " << boost::filesystem::file_size(p) << std::endl; 36 | // output: test.mmf size is 16 37 | } 38 | 39 | // Test 2: Extend the file while also open as a mapped_file 40 | // The mmf constructor throws with the message: 41 | // "failed opening file: The process cannot access the file because it is 42 | // being used by another process." 43 | if (false) 44 | { 45 | binary_file fi(p, oflag::in | oflag::out | oflag::truncate | oflag::random); 46 | fi.write(0); // mapped_file open will fail if file is 0 length 47 | 48 | boost::iostreams::mapped_file mmf(p, 49 | boost::iostreams::mapped_file::readwrite, 1000); 50 | 51 | fi.seek(12); 52 | fi.write(0); 53 | 54 | std::memset(mmf.data(), 0x22, 100); 55 | mmf.close(); 56 | std::cout << p << " size is " << boost::filesystem::file_size(p) << std::endl; 57 | } 58 | 59 | // Test 3: Extend the file before opening as a mapped_file, then resize 60 | // after mapped_file is closed 61 | { 62 | { 63 | binary_file fi(p, oflag::in | oflag::out | oflag::truncate | oflag::random); 64 | fi.seek(50); 65 | fi.write(0); 66 | } 67 | 68 | boost::iostreams::mapped_file mmf(p, 69 | boost::iostreams::mapped_file::readwrite, 1000); 70 | 71 | std::memset(mmf.data(), 0x22, 100); 72 | mmf.close(); 73 | 74 | boost::filesystem::resize_file(p, 32); 75 | 76 | std::cout << p << " size is " << boost::filesystem::file_size(p) << std::endl; 77 | // output: test.mmf size is 32 78 | } 79 | 80 | // Test 4: Resize the file before opening as a mapped_file, then resize 81 | // after mapped_file is closed 82 | { 83 | 84 | boost::filesystem::resize_file(p, 75); 85 | 86 | std::cout << p << " size is " << boost::filesystem::file_size(p) << std::endl; 87 | // output: test.mmf size is 75 88 | 89 | boost::iostreams::mapped_file mmf(p, 90 | boost::iostreams::mapped_file::readwrite, 1000); 91 | 92 | std::memset(mmf.data(), 0x22, 100); 93 | mmf.close(); 94 | 95 | boost::filesystem::resize_file(p, 32); 96 | 97 | std::cout << p << " size is " << boost::filesystem::file_size(p) << std::endl; 98 | // output: test.mmf size is 32 99 | } 100 | 101 | return 0; 102 | } 103 | -------------------------------------------------------------------------------- /test/msvc2012/common.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <_ProjectFileVersion>10.0.30319.1 5 | $(SolutionDir)$(Configuration)\ 6 | $(Configuration)\ 7 | 8 | 9 | 10 | ../../../include;$(BOOST_TRUNK);..\..\..\..\endian\include;%(AdditionalIncludeDirectories) 11 | BOOST_SYSTEM_NO_DEPRECATED;BOOST_BTREE_NO_LIB;BOOST_ALL_DYN_LINK;BOOST_LIGHTWEIGHT_TEST_OSTREAM=std::cout;BOOST_ASSERT_MSG_OSTREAM=std::cout;%(PreprocessorDefinitions) 12 | Level4 13 | 14 | 15 | 16 | 17 | $(BOOST_TRUNK)\stage\lib;%(AdditionalLibraryDirectories) 18 | 19 | 20 | "$(TargetDir)\$(TargetName).exe" 21 | 22 | 23 | -------------------------------------------------------------------------------- /test/msvc2012/large_file_test/large_file_test.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {188F048F-5414-4D2C-81F4-2D6CBFC284DA} 23 | Win32Proj 24 | large_file_test 25 | 26 | 27 | 28 | Application 29 | true 30 | Unicode 31 | v110 32 | 33 | 34 | Application 35 | true 36 | Unicode 37 | v110 38 | 39 | 40 | Application 41 | false 42 | true 43 | Unicode 44 | v110 45 | 46 | 47 | Application 48 | false 49 | true 50 | Unicode 51 | v110 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | true 78 | 79 | 80 | false 81 | 82 | 83 | false 84 | 85 | 86 | 87 | 88 | 89 | Level3 90 | Disabled 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | 100 | 101 | Level3 102 | Disabled 103 | 104 | 105 | Console 106 | true 107 | 108 | 109 | 110 | 111 | Level3 112 | 113 | 114 | MaxSpeed 115 | true 116 | true 117 | 118 | 119 | Console 120 | true 121 | true 122 | true 123 | 124 | 125 | 126 | 127 | Level3 128 | 129 | 130 | MaxSpeed 131 | true 132 | true 133 | 134 | 135 | Console 136 | true 137 | true 138 | true 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | {61954631-3857-4c20-9e7c-1da7baaff426} 147 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /test/msvc2012/mmf_experiment/mmf_experiment.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {BB526282-6BDC-4D34-BC43-E939FA69A508} 23 | Win32Proj 24 | mmf_experiment 25 | 26 | 27 | 28 | Application 29 | true 30 | v110 31 | Unicode 32 | 33 | 34 | Application 35 | true 36 | v110 37 | Unicode 38 | 39 | 40 | Application 41 | false 42 | v110 43 | true 44 | Unicode 45 | 46 | 47 | Application 48 | false 49 | v110 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | true 78 | 79 | 80 | false 81 | 82 | 83 | false 84 | 85 | 86 | 87 | 88 | 89 | Level3 90 | Disabled 91 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | 93 | 94 | Console 95 | true 96 | 97 | 98 | 99 | 100 | 101 | 102 | Level3 103 | Disabled 104 | 105 | 106 | Console 107 | true 108 | 109 | 110 | 111 | 112 | Level3 113 | 114 | 115 | MaxSpeed 116 | true 117 | true 118 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 119 | 120 | 121 | Console 122 | true 123 | true 124 | true 125 | 126 | 127 | 128 | 129 | Level3 130 | 131 | 132 | MaxSpeed 133 | true 134 | true 135 | 136 | 137 | Console 138 | true 139 | true 140 | true 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | {61954631-3857-4c20-9e7c-1da7baaff426} 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /test/stl_restart_test.bat: -------------------------------------------------------------------------------- 1 | stl_test -max=10 -min=5 -cycles=3 -dump=2 -v 2 | copy /y restart.* restart2.* 3 | stl_test -max=10 -min=5 -cycles=1 -dump=-1 -v 4 | stl_test -restart -cycles=1 -v 5 | bc3 stl.btr restart2.btr 6 | -------------------------------------------------------------------------------- /test/string_holder_test.cpp: -------------------------------------------------------------------------------- 1 | // string_holder_test.cpp ------------------------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2010, 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // http://www.boost.org/LICENSE_1_0.txt 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | namespace 17 | { 18 | void default_construct() 19 | { 20 | boost::btree::string_holder<5> x; 21 | 22 | BOOST_TEST_EQ(x.size(), 0U); 23 | BOOST_TEST_EQ(x.max_size(), 5U); 24 | BOOST_TEST(x.empty()); 25 | } 26 | 27 | void construct_from_c_str() 28 | { 29 | boost::btree::string_holder<5> x0(""); 30 | BOOST_TEST_EQ(x0.size(), 0U); 31 | BOOST_TEST(x0.empty()); 32 | 33 | boost::btree::string_holder<5> x3("abc"); 34 | BOOST_TEST_EQ(x3.size(), 3U); 35 | BOOST_TEST(!x3.empty()); 36 | BOOST_TEST(x3 == "abc"); 37 | 38 | boost::btree::string_holder<5> x5("abcdef"); 39 | BOOST_TEST_EQ(x5.size(), 5U); 40 | BOOST_TEST(!x5.empty()); 41 | BOOST_TEST(x5 == "abcde"); 42 | } 43 | 44 | // size(), empty(), and c_str() have now been well tested, so test contents only 45 | // from here on. 46 | 47 | void construct_from_string() 48 | { 49 | boost::btree::string_holder<5> x0(std::string("")); 50 | BOOST_TEST_EQ(x0.size(), 0U); 51 | BOOST_TEST(x0.empty()); 52 | 53 | boost::btree::string_holder<5> x3(std::string("abc")); 54 | BOOST_TEST(x3 == "abc"); 55 | 56 | boost::btree::string_holder<5> x5(std::string("abcdef")); 57 | BOOST_TEST(x5 == "abcde"); 58 | } 59 | 60 | void copy_construct() 61 | { 62 | boost::btree::string_holder<5> y0(""); 63 | boost::btree::string_holder<5> x0(y0); 64 | BOOST_TEST(x0 == ""); 65 | 66 | boost::btree::string_holder<5> y3("abc"); 67 | boost::btree::string_holder<5> x3(y3); 68 | BOOST_TEST(x3 == "abc"); 69 | 70 | boost::btree::string_holder<5> y5("abcdef"); 71 | boost::btree::string_holder<5> x5(y5); 72 | BOOST_TEST(x5 == "abcde"); 73 | } 74 | 75 | void copy_assign() 76 | { 77 | boost::btree::string_holder<5> y0(""); 78 | boost::btree::string_holder<5> x0 = y0; 79 | BOOST_TEST(x0 == ""); 80 | 81 | boost::btree::string_holder<5> y3("abc"); 82 | boost::btree::string_holder<5> x3 = y3; 83 | BOOST_TEST(x3 == "abc"); 84 | 85 | boost::btree::string_holder<5> y5("abcdef"); 86 | boost::btree::string_holder<5> x5 = y5; 87 | BOOST_TEST(x5 == "abcde"); 88 | } 89 | 90 | void copy_from_c_str() 91 | { 92 | boost::btree::string_holder<5> x0("xxx"); 93 | x0 = ""; 94 | BOOST_TEST(x0 == ""); 95 | 96 | boost::btree::string_holder<5> x3("xxxxx"); 97 | x3 = "abc"; 98 | BOOST_TEST(x3 == "abc"); 99 | 100 | boost::btree::string_holder<5> x5("xxx"); 101 | x5 = "abcdef"; 102 | BOOST_TEST(x5 == "abcde"); 103 | } 104 | 105 | void copy_from_string() 106 | { 107 | boost::btree::string_holder<5> x0("xxx"); 108 | x0 = std::string(""); 109 | BOOST_TEST(x0 == ""); 110 | 111 | boost::btree::string_holder<5> x3("xxxxx"); 112 | x3 = std::string("abc"); 113 | BOOST_TEST(x3 == "abc"); 114 | 115 | boost::btree::string_holder<5> x5("xxx"); 116 | x5 = std::string("abcdef"); 117 | BOOST_TEST(x5 == "abcde"); 118 | } 119 | 120 | void clear() 121 | { 122 | boost::btree::string_holder<5> x0(""); 123 | x0.clear(); 124 | BOOST_TEST(x0 == ""); 125 | 126 | boost::btree::string_holder<5> x3("abc"); 127 | x3.clear(); 128 | BOOST_TEST(x3 == ""); 129 | 130 | boost::btree::string_holder<5> x5("abcdef"); 131 | x5.clear(); 132 | BOOST_TEST(x5 == ""); 133 | } 134 | 135 | void operator_square_brackets_const() 136 | { 137 | const boost::btree::string_holder<5> x3("abc"); 138 | BOOST_TEST_EQ(x3[0], 'a'); 139 | BOOST_TEST_EQ(x3[1], 'b'); 140 | BOOST_TEST_EQ(x3[2], 'c'); 141 | } 142 | 143 | void several_flavors_of_find() 144 | { 145 | typedef boost::btree::string_holder<20> T; 146 | const T x("abcdefbca"); 147 | BOOST_TEST(x.find("xyz") == T::npos); 148 | BOOST_TEST(x.find("def") == 3); 149 | BOOST_TEST(x.find_first_of("xyz") == T::npos); 150 | BOOST_TEST(x.find_first_of("xbz") == 1); 151 | BOOST_TEST(x.find_first_not_of("fedcba") == T::npos); 152 | BOOST_TEST(x.find_first_not_of("fdcba") == 4); 153 | BOOST_TEST(x.find_last_of("xyz") == T::npos); 154 | BOOST_TEST(x.find_last_of("xbz") == 6); 155 | } 156 | 157 | void string() 158 | { 159 | boost::btree::string_holder<5> x0(""); 160 | BOOST_TEST(x0 == std::string("")); 161 | 162 | boost::btree::string_holder<5> x3("abc"); 163 | BOOST_TEST(x3 == std::string("abc")); 164 | 165 | boost::btree::string_holder<5> x5("abcdef"); 166 | BOOST_TEST(x5 == std::string("abcde")); 167 | } 168 | 169 | void relationals() 170 | { 171 | boost::btree::string_holder<5> nul(""); 172 | boost::btree::string_holder<5> a("a"); 173 | boost::btree::string_holder<5> aa("aa"); 174 | boost::btree::string_holder<5> b("b"); 175 | 176 | BOOST_TEST(nul == nul); 177 | BOOST_TEST(!(nul != nul)); 178 | BOOST_TEST(!(nul < nul)); 179 | BOOST_TEST(nul <= nul); 180 | BOOST_TEST(!(nul > nul)); 181 | BOOST_TEST(nul >= nul); 182 | 183 | BOOST_TEST(!(a == nul)); 184 | BOOST_TEST(a != nul); 185 | BOOST_TEST(!(a < nul)); 186 | BOOST_TEST(!(a <= nul)); 187 | BOOST_TEST(a > nul); 188 | BOOST_TEST(a >= nul); 189 | 190 | BOOST_TEST(!(nul == a)); 191 | BOOST_TEST(nul != a); 192 | BOOST_TEST(nul < a); 193 | BOOST_TEST(nul <= a); 194 | BOOST_TEST(!(nul > a)); 195 | BOOST_TEST(!(nul >= a)); 196 | 197 | BOOST_TEST(a == a); 198 | BOOST_TEST(!(a != a)); 199 | BOOST_TEST(!(a < a)); 200 | BOOST_TEST(a <= a); 201 | BOOST_TEST(!(a > a)); 202 | BOOST_TEST(a >= a); 203 | 204 | BOOST_TEST(!(a == aa)); 205 | BOOST_TEST(a != aa); 206 | BOOST_TEST(a < aa); 207 | BOOST_TEST(a <= aa); 208 | BOOST_TEST(!(a > aa)); 209 | BOOST_TEST(!(a >= aa)); 210 | 211 | BOOST_TEST(!(aa == a)); 212 | BOOST_TEST(aa != a); 213 | BOOST_TEST(!(aa < a)); 214 | BOOST_TEST(!(aa <= a)); 215 | BOOST_TEST(aa > a); 216 | BOOST_TEST(aa >= a); 217 | 218 | BOOST_TEST(!(a == b)); 219 | BOOST_TEST(a != b); 220 | BOOST_TEST(a < b); 221 | BOOST_TEST(a <= b); 222 | BOOST_TEST(!(a > b)); 223 | BOOST_TEST(!(a >= b)); 224 | 225 | BOOST_TEST(!(b == a)); 226 | BOOST_TEST(b != a); 227 | BOOST_TEST(!(b < a)); 228 | BOOST_TEST(!(b <= a)); 229 | BOOST_TEST(b > a); 230 | BOOST_TEST(b >= a); 231 | } 232 | } 233 | 234 | void inserter_test() 235 | { 236 | boost::btree::string_holder<10> x("Bingo!"); 237 | std::cout << '"' << x << '"' << std::endl; 238 | } 239 | 240 | int cpp_main(int, char *[]) 241 | { 242 | default_construct(); 243 | construct_from_c_str(); 244 | construct_from_string(); 245 | copy_construct(); 246 | copy_assign(); 247 | copy_from_c_str(); 248 | copy_from_string(); 249 | clear(); 250 | operator_square_brackets_const(); 251 | several_flavors_of_find(); 252 | string(); 253 | relationals(); 254 | 255 | inserter_test(); 256 | 257 | return ::boost::report_errors(); 258 | } 259 | -------------------------------------------------------------------------------- /test/test.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Beman/btree/ef7f7ddc058344262c318fc0c3705e8e113c426c/test/test.dat -------------------------------------------------------------------------------- /test/timer_test.cpp: -------------------------------------------------------------------------------- 1 | // boost timer_test.cpp ----------------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2006 4 | 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | // See http://www.boost.org/libs/system for documentation. 9 | 10 | #include 11 | #include // for atol() 12 | #include 13 | #include 14 | 15 | using boost::system::microsecond_t; 16 | using boost::system::times_t; 17 | using boost::system::timer; 18 | using boost::system::run_timer; 19 | 20 | int main(int argc, char * argv[]) 21 | { 22 | std::locale loc(""); 23 | std::cout.imbue(loc); 24 | 25 | run_timer timer(6); 26 | run_timer timer2("\nwall %w s, utilization %p%\n"); 27 | run_timer timer3("\nwall %w s, total cpu %t s, utilization %p%\n", 3); 28 | 29 | long long count = 0; 30 | times_t times; 31 | times.wall = 0; 32 | microsecond_t timeout 33 | = microsecond_t(500000); // default .5 seconds 34 | 35 | if (argc > 1) timeout = microsecond_t(std::atol(argv[1])); 36 | 37 | while (times.wall < timeout) 38 | { 39 | // The point of this code is to burn both kernal and user cpu time, 40 | // with the total less than wall clock time. 41 | ++count; 42 | timer.elapsed(times); 43 | // sleep(1); 44 | //std::cout << "iteration " << count << ", " 45 | // << times.wall << " wall, " 46 | // << times.user << " user, " 47 | // << times.system << " system microsecs" 48 | // << std::endl; 49 | } 50 | std::cout << "\niteration count= " << count 51 | << " wall= "<< times.wall 52 | << " user= "<< times.user 53 | << " system= "<< times.system 54 | << " user+system= "<< times.user+times.system 55 | << std::endl; 56 | 57 | std::cout << count << " iterations\n"; 58 | return 0; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /tools/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # Boost Btree Library tools Jamfile 2 | 3 | # (C) Copyright Beman Dawes 2010 4 | # Distributed under the Boost Software License, Version 1.0. 5 | # See www.boost.org/LICENSE_1_0.txt 6 | 7 | # For debugging, build with bjam variant=debug 8 | 9 | project 10 | : requirements 11 | /boost/btree//boost_btree 12 | /boost/filesystem//boost_filesystem 13 | /boost/system//boost_system 14 | msvc:on 15 | ; 16 | 17 | exe bt_time : bt_time.cpp : release static ; 18 | exe large_file_test : ../test/large_file_test.cpp : release static ; 19 | exe stl_test : ../test/stl_test.cpp : release static ; 20 | #exe bulk_load_test : ../test/bulk_load_test.cpp : release static ; 21 | exe create_data : create_data.cpp : release static ; 22 | 23 | alias install : bin ; 24 | install bin : bt_time large_file_test stl_test create_data ; 25 | explicit install bin ; 26 | -------------------------------------------------------------------------------- /tools/build.bat: -------------------------------------------------------------------------------- 1 | b2 address-model=64 install 2 | -------------------------------------------------------------------------------- /tools/create_data.cpp: -------------------------------------------------------------------------------- 1 | // create_data.cpp -------------------------------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | #include "data.hpp" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include // for atoll() or Microsoft equivalent 25 | #include // for isdigit() 26 | #ifndef _MSC_VER 27 | # define BOOST_BTREE_ATOLL std::atoll 28 | #else 29 | # define BOOST_BTREE_ATOLL _atoi64 30 | #endif 31 | 32 | using namespace boost; 33 | namespace fs = boost::filesystem; 34 | using std::cout; 35 | using std::cerr; 36 | using std::endl; 37 | 38 | namespace 39 | { 40 | std::string command_args; 41 | int64_t n; // number of test cases 42 | int64_t seed = 1; // random number generator seed 43 | int64_t lg = 0; // if != 0, log every lg iterations 44 | char thou_separator = ','; 45 | bool verbose (false); 46 | const int places = 2; 47 | std::string path("data.dat"); 48 | 49 | std::ofstream out; 50 | 51 | const double sec = 1000000000.0; 52 | 53 | struct thousands_separator : std::numpunct { 54 | char do_thousands_sep() const { return thou_separator; } 55 | std::string do_grouping() const { return "\3"; } 56 | }; 57 | 58 | void log(timer::auto_cpu_timer& t, timer::cpu_times& then, int64_t i) 59 | { 60 | t.stop(); 61 | timer::cpu_times now = t.elapsed(); 62 | cout << i << ", " << (now.wall-then.wall)/sec << " sec, " 63 | << lg / ((now.wall-then.wall)/sec) << " per sec" 64 | << endl; 65 | then = now; 66 | t.resume(); 67 | } 68 | 69 | void generate_data() 70 | { 71 | timer::auto_cpu_timer t(3); 72 | mt19937_64 rng; 73 | uniform_int n_dist(0, std::numeric_limits::max()); 74 | variate_generator > key(rng, n_dist); 75 | 76 | cout << "creating " << n << " data elements in " << path << endl; 77 | rng.seed(seed); 78 | t.start(); 79 | timer::cpu_times then = t.elapsed(); 80 | 81 | volume::data dat; 82 | 83 | for (int64_t i = 1; i <= n; ++i) 84 | { 85 | if (lg && i % lg == 0) 86 | log(t, then, i); 87 | dat.key.assign(key(), key()); 88 | dat.mapped = i; 89 | out.write(reinterpret_cast(&dat), sizeof(dat)); 90 | } 91 | t.stop(); 92 | t.report(); 93 | cout << " data element creation complete" << endl; 94 | } 95 | } 96 | 97 | //-------------------------------------- main() ---------------------------------------// 98 | 99 | int cpp_main(int argc, char * argv[]) 100 | { 101 | for (int a = 0; a < argc; ++a) 102 | { 103 | command_args += argv[a]; 104 | if (a != argc-1) 105 | command_args += ' '; 106 | } 107 | 108 | cout << command_args << '\n';; 109 | 110 | if (argc >=2) 111 | n = BOOST_BTREE_ATOLL(argv[1]); 112 | 113 | for (; argc > 2; ++argv, --argc) 114 | { 115 | if (*argv[2] != '-') 116 | path = argv[2]; 117 | else 118 | { 119 | if ( *(argv[2]+1) == 's' && std::isdigit(*(argv[2]+2)) ) 120 | seed = BOOST_BTREE_ATOLL( argv[2]+2 ); 121 | else if ( *(argv[2]+1) == 'l' && std::isdigit(*(argv[2]+2)) ) 122 | lg = BOOST_BTREE_ATOLL( argv[2]+2 ); 123 | else if ( std::strncmp( argv[2]+1, "sep", 3 )==0 124 | && (std::ispunct(*(argv[2]+4)) || *(argv[2]+4)== '\0') ) 125 | thou_separator = *(argv[2]+4) ? *(argv[2]+4) : ' '; 126 | else if ( std::strcmp( argv[2]+1, "v" )==0 ) 127 | verbose = true; 128 | else 129 | { 130 | cout << "Error - unknown option: " << argv[2] << "\n\n"; 131 | argc = -1; 132 | break; 133 | } 134 | } 135 | } 136 | 137 | if (argc < 2) 138 | { 139 | cout << "Usage: create_data n [Options]\n" 140 | " The argument n specifies the number of test cases to run\n" 141 | " Options:\n" 142 | " path Specifies the test file path; default " << path << "\n" 143 | " -s# Seed for random number generator; default 1\n" 144 | " -l# log progress every # actions; default is to not log\n" 145 | " -sep[punct] cout thousands separator; space if punct omitted, default -sep,\n" 146 | // TODO: " -v Verbose output statistics\n" 147 | ; 148 | return 1; 149 | } 150 | 151 | cout.imbue(std::locale(std::locale(), new thousands_separator)); 152 | 153 | out.open(path.c_str(), std::ios_base::out | std::ios_base::binary); 154 | 155 | if (!out) 156 | { 157 | cout << "failed to open " << path << endl; 158 | return 1; 159 | } 160 | 161 | generate_data(); 162 | out.close(); 163 | 164 | return 0; 165 | } 166 | -------------------------------------------------------------------------------- /tools/data.hpp: -------------------------------------------------------------------------------- 1 | // volume/data.hpp -----------------------------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2013 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | #ifndef BOOST_BTREE_VOLUME_DATA_HPP 9 | #define BOOST_BTREE_VOLUME_DATA_HPP 10 | 11 | #include 12 | #include 13 | 14 | namespace volume 15 | { 16 | class u128_t 17 | { 18 | boost::uint64_t m_hi; 19 | boost::uint64_t m_lo; 20 | public: 21 | u128_t() {} 22 | u128_t(const u128_t& x) : m_hi(x.m_hi), m_lo(x.m_lo) {} 23 | u128_t(const boost::uint64_t hi, const boost::uint64_t lo) : m_hi(hi), m_lo(lo) {} 24 | 25 | u128_t& operator=(const u128_t& x) {m_hi = x.m_hi; m_lo = x.m_lo; return *this;} 26 | u128_t& assign(const boost::uint64_t hi, const boost::uint64_t lo) 27 | {m_hi = hi; m_lo = lo; return *this;} 28 | 29 | bool operator<(const u128_t& x) const 30 | { 31 | return m_hi < x.m_hi 32 | || (m_hi == x.m_hi && m_lo < x.m_lo); 33 | } 34 | 35 | }; 36 | 37 | class data 38 | { 39 | public: 40 | u128_t key; 41 | boost::uint64_t mapped; 42 | }; 43 | 44 | // 45 | 46 | } // namespace volume 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /tools/install.bat: -------------------------------------------------------------------------------- 1 | rem Copyright Beman Dawes 2011 2 | rem Distributed under the Boost Software License, Version 1.0. See http://www.boost.org/LICENSE_1_0.txt 3 | git clone git://github.com/Beman/Boost-Btree.git btree 4 | svn export --force http://svn.boost.org/svn/boost/trunk btree 5 | -------------------------------------------------------------------------------- /tools/stl_bounds_demo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | namespace 10 | { 11 | typedef vector vec; 12 | vec v; 13 | 14 | void bounds(int k) 15 | { 16 | vec::iterator lb = lower_bound(v.begin(), v.end(), k); 17 | cout << "lower_bound " << k << " is " << (lb != v.end() ? *lb : -1) 18 | << ", index " << distance(v.begin(), lb) << '\n'; 19 | vec::iterator ub = upper_bound(v.begin(), v.end(), k); 20 | cout << "upper_bound " << k << " is " << (ub != v.end() ? *ub : -1) 21 | << ", index " << distance(v.begin(), ub) << '\n'; 22 | } 23 | } 24 | 25 | int main() 26 | { 27 | for (int i = 1; i <= 5; i += 2) 28 | { 29 | v.push_back(i); 30 | cout << i << " "; 31 | if (i == 3) 32 | { 33 | v.push_back(i); 34 | cout << i << " "; 35 | v.push_back(i); 36 | cout << i << " "; 37 | } 38 | } 39 | cout << '\n'; 40 | for (int j = 0; j <= 6; ++j) 41 | bounds(j); 42 | return 0; 43 | } 44 | 45 | /* Output: 46 | 1 3 3 3 5 47 | lower_bound 0 is 1, index 0 48 | upper_bound 0 is 1, index 0 49 | lower_bound 1 is 1, index 0 50 | upper_bound 1 is 3, index 1 51 | lower_bound 2 is 3, index 1 52 | upper_bound 2 is 3, index 1 53 | lower_bound 3 is 3, index 1 54 | upper_bound 3 is 5, index 4 55 | lower_bound 4 is 5, index 4 56 | upper_bound 4 is 5, index 4 57 | lower_bound 5 is 5, index 4 58 | upper_bound 5 is -1, index 5 59 | lower_bound 6 is -1, index 5 60 | upper_bound 6 is -1, index 5 61 | */ 62 | -------------------------------------------------------------------------------- /tools/time_table.bat: -------------------------------------------------------------------------------- 1 | bjam --toolset=gcc-4.5 2 | echo "GCC/MinGW 4.5" >c:\temp\time_table.html 3 | bin\bt_time 5000000 -stl -p4096 -c32 -native -html 2>>c:\temp\time_table.html 4 | bin\bt_time 5000000 -stl -p4096 -c1000 -native -html 2>>c:\temp\time_table.html 5 | bin\bt_time 5000000 -stl -p4096 -c10000 -native -html 2>>c:\temp\time_table.html 6 | bin\bt_time 5000000 -stl -p4096 -c10000 -big -html 2>>c:\temp\time_table.html 7 | bin\bt_time 5000000 -stl -p4096 -c10000 -little -html 2>>c:\temp\time_table.html 8 | bjam --toolset=msvc-10.0express 9 | echo "VC++ 10.0 Express" >>c:\temp\time_table.html 10 | bin\bt_time 5000000 -stl -p4096 -c32 -native -html 2>>c:\temp\time_table.html 11 | bin\bt_time 5000000 -stl -p4096 -c1000 -native -html 2>>c:\temp\time_table.html 12 | bin\bt_time 5000000 -stl -p4096 -c10000 -native -html 2>>c:\temp\time_table.html 13 | bin\bt_time 5000000 -stl -p4096 -c10000 -big -html 2>>c:\temp\time_table.html 14 | bin\bt_time 5000000 -stl -p4096 -c10000 -little -html 2>>c:\temp\time_table.html 15 | type c:\temp\time_table.html 16 | 17 | --------------------------------------------------------------------------------