ClickHouse/src/Common/WeakHash.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
962 B
C++
Raw Normal View History

2020-03-13 17:31:50 +00:00
#pragma once
#include <Common/PODArray.h>
namespace DB
{
2020-03-25 05:27:43 +00:00
/// It's a class which represents the result of weak and fast hash function per row in column.
/// It's usually hardware accelerated CRC32-C.
2020-03-13 17:31:50 +00:00
/// Has function result may be combined to calculate hash for tuples.
///
/// The main purpose why this class needed is to support data initialization. Initially, every bit is 1.
class WeakHash32
{
static constexpr UInt32 kDefaultInitialValue = ~UInt32(0);
2020-03-13 17:31:50 +00:00
public:
2020-03-13 17:31:50 +00:00
using Container = PaddedPODArray<UInt32>;
explicit WeakHash32(size_t size, UInt32 initial_value = kDefaultInitialValue) : data(size, initial_value) {}
WeakHash32(const WeakHash32 & other) { data.assign(other.data); }
2020-03-13 17:31:50 +00:00
void reset(size_t size, UInt32 initial_value = kDefaultInitialValue) { data.assign(size, initial_value); }
2020-04-22 13:52:07 +00:00
2020-03-13 17:31:50 +00:00
const Container & getData() const { return data; }
Container & getData() { return data; }
private:
PaddedPODArray<UInt32> data;
};
}