Skip to content

Commit

Permalink
remove const from copied primitives in method signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalkin committed Aug 16, 2024
1 parent ecc856b commit 9d53c6c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 44 deletions.
20 changes: 10 additions & 10 deletions filters/include/bit_array_ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace bit_array_ops {
* @param index the index of the bit to get
* @return the value of the bit at the given index.
*/
static inline bool get_bit(uint8_t* array, const uint64_t index) {
static inline bool get_bit(uint8_t* array, uint64_t index) {
return (array[index >> 3] & (1 << (index & 7))) != 0;
}

Expand All @@ -51,7 +51,7 @@ namespace bit_array_ops {
* @param array the array of bits
* @param index the index of the bit to set.
*/
static inline void set_bit(uint8_t* array, const uint64_t index) {
static inline void set_bit(uint8_t* array, uint64_t index) {
array[index >> 3] |= (1 << (index & 7));
}

Expand All @@ -60,7 +60,7 @@ namespace bit_array_ops {
* @param array the array of bits
* @param index the index of the bit to clear.
*/
static inline void clear_bit(uint8_t* array, const uint64_t index) {
static inline void clear_bit(uint8_t* array, uint64_t index) {
array[index >> 3] &= ~(1 << (index & 7));
}

Expand All @@ -69,7 +69,7 @@ namespace bit_array_ops {
* @param array the array of bits
* @param index the index of the bit to set.
*/
static inline void assign_bit(uint8_t* array, const uint64_t index, const bool value) {
static inline void assign_bit(uint8_t* array, uint64_t index, bool value) {
// read-only checks handled by set_bit() and clear_bit()
if (value) {
set_bit(array, index);
Expand All @@ -84,7 +84,7 @@ namespace bit_array_ops {
* @param index the index of the bit to get and set
* @return the value of the bit at the specified index
*/
static inline bool get_and_set_bit(uint8_t* array, const uint64_t index) {
static inline bool get_and_set_bit(uint8_t* array, uint64_t index) {
const uint64_t offset = index >> 3;
const uint8_t mask = 1 << (index & 7);
if ((array[offset] & mask) != 0) {
Expand All @@ -101,7 +101,7 @@ namespace bit_array_ops {
* @param length_bytes the length of the array, in bytes
* @return the number of bits set in the bit array.
*/
static inline uint64_t count_num_bits_set(uint8_t* array, const uint64_t length_bytes) {
static inline uint64_t count_num_bits_set(uint8_t* array, uint64_t length_bytes) {
uint64_t num_bits_set = 0;

// we rounded up to a multiple of 64 so we know we can use 64-bit operations
Expand All @@ -126,7 +126,7 @@ namespace bit_array_ops {
* @param length_bytes the length of the two arrays, in bytes
* @return the number of bits set in the resulting array
*/
static inline uint64_t union_with(uint8_t* tgt, const uint8_t* src, const uint64_t length_bytes) {
static inline uint64_t union_with(uint8_t* tgt, const uint8_t* src, uint64_t length_bytes) {
uint64_t num_bits_set = 0;
for (uint64_t i = 0; i < length_bytes; ++i) {
tgt[i] |= src[i];
Expand All @@ -146,7 +146,7 @@ namespace bit_array_ops {
* @param length_bytes the length of the two arrays, in bytes
* @return the number of bits set in the resulting array
*/
static inline uint64_t intersect(uint8_t* tgt, const uint8_t* src, const uint64_t length_bytes) {
static inline uint64_t intersect(uint8_t* tgt, const uint8_t* src, uint64_t length_bytes) {
uint64_t num_bits_set = 0;
for (uint64_t i = 0; i < length_bytes; ++i) {
tgt[i] &= src[i];
Expand All @@ -163,7 +163,7 @@ namespace bit_array_ops {
* @param length_bytes the length of the array, in bytes
* @return the number of bits set in the resulting array
*/
static inline uint64_t invert(uint8_t* array, const uint64_t length_bytes) {
static inline uint64_t invert(uint8_t* array, uint64_t length_bytes) {
uint64_t num_bits_set = 0;
for (uint64_t i = 0; i < length_bytes; ++i) {
array[i] = ~array[i];
Expand All @@ -177,4 +177,4 @@ namespace bit_array_ops {

} // namespace datasketches

#endif // _BIT_ARRAY_OPS_HPP_
#endif // _BIT_ARRAY_OPS_HPP_
28 changes: 14 additions & 14 deletions filters/include/bloom_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ class bloom_filter_alloc {
* @param num_bits The number of bits in the Bloom Filter for the size calculation
* @return The serialized size of a Bloom Filter with a capacity of num_bits, in bytes
*/
static size_t get_serialized_size_bytes(const uint64_t num_bits);
static size_t get_serialized_size_bytes(uint64_t num_bits);

/**
* @brief Returns a human-readable string representation of the Bloom Filter.
Expand All @@ -707,17 +707,17 @@ class bloom_filter_alloc {
static const uint8_t EMPTY_FLAG_MASK = 4;

// used by builder methods
bloom_filter_alloc(const uint64_t num_bits, const uint16_t num_hashes, const uint64_t seed, const A& allocator);
bloom_filter_alloc(uint8_t* memory, size_t length_bytes, const uint64_t num_bits, const uint16_t num_hashes, const uint64_t seed, const A& allocator);
bloom_filter_alloc(uint64_t num_bits, uint16_t num_hashes, uint64_t seed, const A& allocator);
bloom_filter_alloc(uint8_t* memory, size_t length_bytes, uint64_t num_bits, uint16_t num_hashes, uint64_t seed, const A& allocator);

// used by deserialize and wrap
bloom_filter_alloc(const uint64_t seed,
const uint16_t num_hashes,
const bool is_dirty,
const bool is_owned,
const bool is_read_only,
const uint64_t capacity_bits,
const uint64_t num_bits_set,
bloom_filter_alloc(uint64_t seed,
uint16_t num_hashes,
bool is_dirty,
bool is_owned,
bool is_read_only,
uint64_t capacity_bits,
uint64_t num_bits_set,
uint8_t* bit_array,
uint8_t* memory,
const A& allocator);
Expand All @@ -729,11 +729,11 @@ class bloom_filter_alloc {
const A& allocator);

// internal query/update methods
void internal_update(const uint64_t h0, const uint64_t h1);
bool internal_query_and_update(const uint64_t h0, const uint64_t h1);
bool internal_query(const uint64_t h0, const uint64_t h1) const;
void internal_update(uint64_t h0, uint64_t h1);
bool internal_query_and_update(uint64_t h0, uint64_t h1);
bool internal_query(uint64_t h0, uint64_t h1) const;

void update_num_bits_set(const uint64_t num_bits_set);
void update_num_bits_set(uint64_t num_bits_set);

A allocator_;
uint64_t seed_;
Expand Down
40 changes: 20 additions & 20 deletions filters/include/bloom_filter_builder_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ uint64_t bloom_filter_builder_alloc<A>::generate_random_seed() {
}

template<typename A>
uint16_t bloom_filter_builder_alloc<A>::suggest_num_hashes(const uint64_t max_distinct_items,
const uint64_t num_filter_bits) {
uint16_t bloom_filter_builder_alloc<A>::suggest_num_hashes(uint64_t max_distinct_items,
uint64_t num_filter_bits) {
if (max_distinct_items == 0) {
throw std::invalid_argument("maximum number of distinct items must be strictly positive");
}
Expand All @@ -54,22 +54,22 @@ uint16_t bloom_filter_builder_alloc<A>::suggest_num_hashes(const uint64_t max_di
}

template<typename A>
uint16_t bloom_filter_builder_alloc<A>::suggest_num_hashes(const double target_false_positive_prob) {
uint16_t bloom_filter_builder_alloc<A>::suggest_num_hashes(double target_false_positive_prob) {
validate_accuracy_inputs(100, target_false_positive_prob); // max_distinct_items is an arbitrary valid value
return static_cast<uint16_t>(std::ceil(-log(target_false_positive_prob) / log(2.0)));
}

template<typename A>
uint64_t bloom_filter_builder_alloc<A>::suggest_num_filter_bits(const uint64_t max_distinct_items,
const double target_false_positive_prob) {
uint64_t bloom_filter_builder_alloc<A>::suggest_num_filter_bits(uint64_t max_distinct_items,
double target_false_positive_prob) {
validate_accuracy_inputs(max_distinct_items, target_false_positive_prob);
return static_cast<uint64_t>(std::ceil(-static_cast<double>(max_distinct_items) * log(target_false_positive_prob) / (log(2.0) * log(2.0))));
}

template<typename A>
bloom_filter_alloc<A> bloom_filter_builder_alloc<A>::create_by_accuracy(const uint64_t max_distinct_items,
const double target_false_positive_prob,
const uint64_t seed,
bloom_filter_alloc<A> bloom_filter_builder_alloc<A>::create_by_accuracy(uint64_t max_distinct_items,
double target_false_positive_prob,
uint64_t seed,
const A& allocator) {
validate_accuracy_inputs(max_distinct_items, target_false_positive_prob);
const uint64_t num_filter_bits = bloom_filter_builder_alloc<A>::suggest_num_filter_bits(max_distinct_items, target_false_positive_prob);
Expand All @@ -78,20 +78,20 @@ bloom_filter_alloc<A> bloom_filter_builder_alloc<A>::create_by_accuracy(const ui
}

template<typename A>
bloom_filter_alloc<A> bloom_filter_builder_alloc<A>::create_by_size(const uint64_t num_bits,
const uint16_t num_hashes,
const uint64_t seed,
bloom_filter_alloc<A> bloom_filter_builder_alloc<A>::create_by_size(uint64_t num_bits,
uint16_t num_hashes,
uint64_t seed,
const A& allocator) {
validate_size_inputs(num_bits, num_hashes);
return bloom_filter_alloc<A>(num_bits, num_hashes, seed, allocator);
}

template<typename A>
bloom_filter_alloc<A> bloom_filter_builder_alloc<A>::initialize_by_accuracy(void* memory,
const size_t length_bytes,
const uint64_t max_distinct_items,
const double target_false_positive_prob,
const uint64_t seed,
size_t length_bytes,
uint64_t max_distinct_items,
double target_false_positive_prob,
uint64_t seed,
const A& allocator) {
validate_accuracy_inputs(max_distinct_items, target_false_positive_prob);
const uint64_t num_filter_bits = bloom_filter_builder_alloc<A>::suggest_num_filter_bits(max_distinct_items, target_false_positive_prob);
Expand All @@ -101,10 +101,10 @@ bloom_filter_alloc<A> bloom_filter_builder_alloc<A>::initialize_by_accuracy(void

template<typename A>
bloom_filter_alloc<A> bloom_filter_builder_alloc<A>::initialize_by_size(void* memory,
const size_t length_bytes,
const uint64_t num_bits,
const uint16_t num_hashes,
const uint64_t seed,
size_t length_bytes,
uint64_t num_bits,
uint16_t num_hashes,
uint64_t seed,
const A& allocator) {
validate_size_inputs(num_bits, num_hashes);
return bloom_filter_alloc<A>(static_cast<uint8_t*>(memory), length_bytes, num_bits, num_hashes, seed, allocator);
Expand Down Expand Up @@ -134,4 +134,4 @@ void bloom_filter_builder_alloc<A>::validate_accuracy_inputs(uint64_t max_distin

} // namespace datasketches

#endif // _BLOOM_FILTER_BUILDER_IMPL_HPP_
#endif // _BLOOM_FILTER_BUILDER_IMPL_HPP_

0 comments on commit 9d53c6c

Please sign in to comment.