Skip to content

Commit b3c37b1

Browse files
committed
Stub in sieve with initial test implementation.
1 parent 58ea831 commit b3c37b1

12 files changed

Lines changed: 1333 additions & 4 deletions

File tree

Makefile.am

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ test_libbitcoin_database_test_SOURCES = \
8181
test/primitives/hashhead.cpp \
8282
test/primitives/hashmap.cpp \
8383
test/primitives/iterator.cpp \
84+
test/primitives/keys.cpp \
8485
test/primitives/linkage.cpp \
8586
test/primitives/manager.cpp \
8687
test/primitives/nomap.cpp \
88+
test/primitives/sieve.cpp \
8789
test/query/archive.cpp \
8890
test/query/confirm.cpp \
8991
test/query/context.cpp \
@@ -164,7 +166,8 @@ include_bitcoin_database_impl_primitives_HEADERS = \
164166
include/bitcoin/database/impl/primitives/iterator.ipp \
165167
include/bitcoin/database/impl/primitives/linkage.ipp \
166168
include/bitcoin/database/impl/primitives/manager.ipp \
167-
include/bitcoin/database/impl/primitives/nomap.ipp
169+
include/bitcoin/database/impl/primitives/nomap.ipp \
170+
include/bitcoin/database/impl/primitives/sieve.ipp
168171

169172
include_bitcoin_database_impl_querydir = ${includedir}/bitcoin/database/impl/query
170173
include_bitcoin_database_impl_query_HEADERS = \
@@ -217,7 +220,8 @@ include_bitcoin_database_primitives_HEADERS = \
217220
include/bitcoin/database/primitives/linkage.hpp \
218221
include/bitcoin/database/primitives/manager.hpp \
219222
include/bitcoin/database/primitives/nomap.hpp \
220-
include/bitcoin/database/primitives/primitives.hpp
223+
include/bitcoin/database/primitives/primitives.hpp \
224+
include/bitcoin/database/primitives/sieve.hpp
221225

222226
include_bitcoin_database_tablesdir = ${includedir}/bitcoin/database/tables
223227
include_bitcoin_database_tables_HEADERS = \

builds/cmake/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ else ()
3333
set( libdir "\${exec_prefix}/lib" )
3434
set( includedir "\${exec_prefix}/include" )
3535

36-
set( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" )
37-
3836
set( PACKAGE_VERSION "4.0.0" )
3937
set( VERSION "${PACKAGE_VERSION}" )
4038
endif ()
@@ -291,9 +289,11 @@ if (with-tests)
291289
"../../test/primitives/hashhead.cpp"
292290
"../../test/primitives/hashmap.cpp"
293291
"../../test/primitives/iterator.cpp"
292+
"../../test/primitives/keys.cpp"
294293
"../../test/primitives/linkage.cpp"
295294
"../../test/primitives/manager.cpp"
296295
"../../test/primitives/nomap.cpp"
296+
"../../test/primitives/sieve.cpp"
297297
"../../test/query/archive.cpp"
298298
"../../test/query/confirm.cpp"
299299
"../../test/query/context.cpp"

builds/msvc/vs2022/libbitcoin-database-test/libbitcoin-database-test.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@
9090
<ClCompile Include="..\..\..\..\test\primitives\hashhead.cpp" />
9191
<ClCompile Include="..\..\..\..\test\primitives\hashmap.cpp" />
9292
<ClCompile Include="..\..\..\..\test\primitives\iterator.cpp" />
93+
<ClCompile Include="..\..\..\..\test\primitives\keys.cpp" />
9394
<ClCompile Include="..\..\..\..\test\primitives\linkage.cpp" />
9495
<ClCompile Include="..\..\..\..\test\primitives\manager.cpp" />
9596
<ClCompile Include="..\..\..\..\test\primitives\nomap.cpp" />
97+
<ClCompile Include="..\..\..\..\test\primitives\sieve.cpp" />
9698
<ClCompile Include="..\..\..\..\test\query\archive.cpp" />
9799
<ClCompile Include="..\..\..\..\test\query\confirm.cpp" />
98100
<ClCompile Include="..\..\..\..\test\query\context.cpp" />

builds/msvc/vs2022/libbitcoin-database-test/libbitcoin-database-test.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@
9393
<ClCompile Include="..\..\..\..\test\primitives\iterator.cpp">
9494
<Filter>src\primitives</Filter>
9595
</ClCompile>
96+
<ClCompile Include="..\..\..\..\test\primitives\keys.cpp">
97+
<Filter>src\primitives</Filter>
98+
</ClCompile>
9699
<ClCompile Include="..\..\..\..\test\primitives\linkage.cpp">
97100
<Filter>src\primitives</Filter>
98101
</ClCompile>
@@ -102,6 +105,9 @@
102105
<ClCompile Include="..\..\..\..\test\primitives\nomap.cpp">
103106
<Filter>src\primitives</Filter>
104107
</ClCompile>
108+
<ClCompile Include="..\..\..\..\test\primitives\sieve.cpp">
109+
<Filter>src\primitives</Filter>
110+
</ClCompile>
105111
<ClCompile Include="..\..\..\..\test\query\archive.cpp">
106112
<Filter>src\query</Filter>
107113
</ClCompile>

builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
<ClInclude Include="..\..\..\..\include\bitcoin\database\primitives\manager.hpp" />
122122
<ClInclude Include="..\..\..\..\include\bitcoin\database\primitives\nomap.hpp" />
123123
<ClInclude Include="..\..\..\..\include\bitcoin\database\primitives\primitives.hpp" />
124+
<ClInclude Include="..\..\..\..\include\bitcoin\database\primitives\sieve.hpp" />
124125
<ClInclude Include="..\..\..\..\include\bitcoin\database\query.hpp" />
125126
<ClInclude Include="..\..\..\..\include\bitcoin\database\settings.hpp" />
126127
<ClInclude Include="..\..\..\..\include\bitcoin\database\store.hpp" />
@@ -167,6 +168,7 @@
167168
<None Include="..\..\..\..\include\bitcoin\database\impl\primitives\linkage.ipp" />
168169
<None Include="..\..\..\..\include\bitcoin\database\impl\primitives\manager.ipp" />
169170
<None Include="..\..\..\..\include\bitcoin\database\impl\primitives\nomap.ipp" />
171+
<None Include="..\..\..\..\include\bitcoin\database\impl\primitives\sieve.ipp" />
170172
<None Include="..\..\..\..\include\bitcoin\database\impl\query\archive_read.ipp" />
171173
<None Include="..\..\..\..\include\bitcoin\database\impl\query\archive_write.ipp" />
172174
<None Include="..\..\..\..\include\bitcoin\database\impl\query\confirm.ipp" />

builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@
206206
<ClInclude Include="..\..\..\..\include\bitcoin\database\primitives\primitives.hpp">
207207
<Filter>include\bitcoin\database\primitives</Filter>
208208
</ClInclude>
209+
<ClInclude Include="..\..\..\..\include\bitcoin\database\primitives\sieve.hpp">
210+
<Filter>include\bitcoin\database\primitives</Filter>
211+
</ClInclude>
209212
<ClInclude Include="..\..\..\..\include\bitcoin\database\query.hpp">
210213
<Filter>include\bitcoin\database</Filter>
211214
</ClInclude>
@@ -340,6 +343,9 @@
340343
<None Include="..\..\..\..\include\bitcoin\database\impl\primitives\nomap.ipp">
341344
<Filter>include\bitcoin\database\impl\primitives</Filter>
342345
</None>
346+
<None Include="..\..\..\..\include\bitcoin\database\impl\primitives\sieve.ipp">
347+
<Filter>include\bitcoin\database\impl\primitives</Filter>
348+
</None>
343349
<None Include="..\..\..\..\include\bitcoin\database\impl\query\archive_read.ipp">
344350
<Filter>include\bitcoin\database\impl\query</Filter>
345351
</None>

include/bitcoin/database.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include <bitcoin/database/primitives/manager.hpp>
5151
#include <bitcoin/database/primitives/nomap.hpp>
5252
#include <bitcoin/database/primitives/primitives.hpp>
53+
#include <bitcoin/database/primitives/sieve.hpp>
5354
#include <bitcoin/database/tables/association.hpp>
5455
#include <bitcoin/database/tables/associations.hpp>
5556
#include <bitcoin/database/tables/context.hpp>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
3+
*
4+
* This file is part of libbitcoin.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
#ifndef LIBBITCOIN_DATABASE_PRIMITIVES_SIEVE_IPP
20+
#define LIBBITCOIN_DATABASE_PRIMITIVES_SIEVE_IPP
21+
22+
#include <bitcoin/system.hpp>
23+
#include <bitcoin/database/define.hpp>
24+
25+
// [-------------------screen----------][--------------link--------------]
26+
// [[selector][--------masks----------]][--------------link--------------]
27+
28+
// [[111][1111111111111111111111111111]] terminal sentinal (empty/default)
29+
// [[000][1111111111111111111111111111]] 1 screen
30+
// [[001][2222222222222211111111111111]] 2 screens
31+
// [[010][3333333333222222222111111111]] 3 screens
32+
// [[011][4444444333333322222221111111]] 4 screens
33+
// [[100][5555554444443333332222211111]] 5 screens
34+
// [[101][6666655555444443333322221111]] 6 screens
35+
// [[110][7777666655554444333322221111]] 7 screens
36+
// [[111][-777766665555444433332222111]] 8 screens (partial)
37+
// [[111][1000000000000000000000000000]] overflow sentinal
38+
39+
// To minimize masking and shifting in alignment, the sieve is defined as a two
40+
// dimensional matrix of precomputed. One dimension is determined by the
41+
// screen selector the other is used to iterate through maskes for that screen.
42+
// A single screen requires one mask, a double two, and so on. The max selector
43+
// value indicates that the first bit of the screen is a sentinel. This is set
44+
// for either terminal (all other bits set) or overflow (no other bits set).
45+
// If the sentinel is unset then the max screen is in used on remaining bits.
46+
// The seive should be terminal if and only if the link is terminal, and when
47+
// overflowed implies that the bucket is saturated, rendering it unscreened.
48+
49+
// A 28 bit sieve requires 28 bits from each hashmap key, independent of both
50+
// the hashmap hash function and each other. The mask is
51+
52+
namespace libbitcoin {
53+
namespace database {
54+
55+
TEMPLATE
56+
constexpr CLASS::sieve() NOEXCEPT
57+
{
58+
}
59+
60+
} // namespace database
61+
} // namespace libbitcoin
62+
63+
#endif

include/bitcoin/database/primitives/primitives.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@
2828
#include <bitcoin/database/primitives/linkage.hpp>
2929
#include <bitcoin/database/primitives/manager.hpp>
3030
#include <bitcoin/database/primitives/nomap.hpp>
31+
#include <bitcoin/database/primitives/sieve.hpp>
3132

3233
#endif
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
3+
*
4+
* This file is part of libbitcoin.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
#ifndef LIBBITCOIN_DATABASE_PRIMITIVES_SIEVE_HPP
20+
#define LIBBITCOIN_DATABASE_PRIMITIVES_SIEVE_HPP
21+
22+
#include <bitcoin/system.hpp>
23+
#include <bitcoin/database/define.hpp>
24+
25+
namespace libbitcoin {
26+
namespace database {
27+
28+
template <size_t Size>
29+
struct sieve
30+
{
31+
constexpr sieve() NOEXCEPT;
32+
};
33+
34+
} // namespace database
35+
} // namespace libbitcoin
36+
37+
#define TEMPLATE template <size_t Size>
38+
#define CLASS sieve<Size>
39+
40+
#include <bitcoin/database/impl/primitives/sieve.ipp>
41+
42+
#undef CLASS
43+
#undef TEMPLATE
44+
45+
#endif

0 commit comments

Comments
 (0)