Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some assertions and PHOBIC typedef #51

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/dense_partitioned_phf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ namespace pthash {
template <typename Hasher, typename Bucketer, typename Encoder, bool NeedsFreeArray,
pthash_search_type Search>
struct dense_partitioned_phf {
static_assert(std::is_base_of<dense_encoder, Encoder>::value,
"Needs a dense encoder for dense partitioned PTHash. Select another encoder.");
typedef Encoder encoder_type;
static constexpr bool needsFreeArray = NeedsFreeArray;

template <typename Iterator>
build_timings build_in_internal_memory(Iterator keys, const uint64_t num_keys,
build_configuration const& config) {
assert(Search == config.search);
assert(config.dense_partitioning == true);
assert(config.avg_partition_size < 10000); // Unlike partitioned, must use small partitions
internal_memory_builder_partitioned_phf<Hasher, Bucketer> builder;
auto timings = builder.build_from_keys(keys, num_keys, config);
timings.encoding_microseconds = build(builder, config);
Expand Down Expand Up @@ -132,4 +136,7 @@ struct dense_partitioned_phf {
ef_sequence<false> m_free_slots;
};

template <typename Hasher, typename Encoder>
using phobic = dense_partitioned_phf<Hasher, table_bucketer<opt_bucketer>,
dense_interleaved<Encoder>, false, pthash_search_type::add_displacement>;
} // namespace pthash
9 changes: 6 additions & 3 deletions include/encoders/dense_encoders.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ struct diff {
Encoder m_encoder;
};

struct dense_encoder {
};

template <typename Encoder>
struct dense_mono {
struct dense_mono : dense_encoder {
template <typename Iterator>
void encode(Iterator begin, //
const uint64_t num_partitions, //
Expand Down Expand Up @@ -89,7 +92,7 @@ struct dense_mono {
};

template <typename Encoder>
struct dense_interleaved {
struct dense_interleaved : dense_encoder {
template <typename Iterator>
void encode(Iterator begin, //
const uint64_t num_partitions, //
Expand Down Expand Up @@ -151,7 +154,7 @@ struct dense_interleaved {
};

template <typename Front, typename Back, uint64_t numerator = 1, uint64_t denominator = 3>
struct dense_dual {
struct dense_dual : dense_encoder {
template <typename Iterator>
void encode(Iterator begin, //
const uint64_t num_partitions, //
Expand Down
2 changes: 2 additions & 0 deletions include/partitioned_phf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace pthash {
template <typename Hasher, typename Bucketer, typename Encoder, bool Minimal,
pthash_search_type Search>
struct partitioned_phf {
static_assert(!std::is_base_of<dense_encoder, Encoder>::value,
"Dense encoders are only for dense PTHash. Select another encoder.");
private:
struct partition {
template <typename Visitor>
Expand Down
2 changes: 2 additions & 0 deletions include/single_phf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace pthash {
template <typename Hasher, typename Bucketer, typename Encoder, bool Minimal,
pthash_search_type Search>
struct single_phf {
static_assert(!std::is_base_of<dense_encoder, Encoder>::value,
"Dense encoders are only for dense PTHash. Select another encoder.");
typedef Encoder encoder_type;
static constexpr bool minimal = Minimal;

Expand Down