]> git.proxmox.com Git - ceph.git/blame - ceph/src/arrow/cpp/src/parquet/murmur3.h
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / cpp / src / parquet / murmur3.h
CommitLineData
1d09f67e
TL
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18//-----------------------------------------------------------------------------
19// MurmurHash3 was written by Austin Appleby, and is placed in the public
20// domain. The author hereby disclaims copyright to this source code.
21
22#pragma once
23
24#include <cstdint>
25
26#include "parquet/hasher.h"
27#include "parquet/platform.h"
28#include "parquet/types.h"
29
30namespace parquet {
31
32/// Source:
33/// https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp
34/// (Modified to adapt to coding conventions and to inherit the Hasher abstract class)
35class PARQUET_EXPORT MurmurHash3 : public Hasher {
36 public:
37 MurmurHash3() : seed_(DEFAULT_SEED) {}
38 uint64_t Hash(int32_t value) const override;
39 uint64_t Hash(int64_t value) const override;
40 uint64_t Hash(float value) const override;
41 uint64_t Hash(double value) const override;
42 uint64_t Hash(const Int96* value) const override;
43 uint64_t Hash(const ByteArray* value) const override;
44 uint64_t Hash(const FLBA* val, uint32_t len) const override;
45
46 private:
47 // Default seed for hash which comes from Bloom filter in parquet-mr, it is generated
48 // by System.nanoTime() of java.
49 static constexpr int DEFAULT_SEED = 1361930890;
50
51 uint32_t seed_;
52};
53
54} // namespace parquet