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#ifndef PARQUET_HASHER_H
19#define PARQUET_HASHER_H
20
21#include <cstdint>
22#include "parquet/types.h"
23
24namespace parquet {
25// Abstract class for hash
26class Hasher {
27 public:
28 /// Compute hash for 32 bits value by using its plain encoding result.
29 ///
30 /// @param value the value to hash.
31 /// @return hash result.
32 virtual uint64_t Hash(int32_t value) const = 0;
33
34 /// Compute hash for 64 bits value by using its plain encoding result.
35 ///
36 /// @param value the value to hash.
37 /// @return hash result.
38 virtual uint64_t Hash(int64_t value) const = 0;
39
40 /// Compute hash for float value by using its plain encoding result.
41 ///
42 /// @param value the value to hash.
43 /// @return hash result.
44 virtual uint64_t Hash(float value) const = 0;
45
46 /// Compute hash for double value by using its plain encoding result.
47 ///
48 /// @param value the value to hash.
49 /// @return hash result.
50 virtual uint64_t Hash(double value) const = 0;
51
52 /// Compute hash for Int96 value by using its plain encoding result.
53 ///
54 /// @param value the value to hash.
55 /// @return hash result.
56 virtual uint64_t Hash(const Int96* value) const = 0;
57
58 /// Compute hash for ByteArray value by using its plain encoding result.
59 ///
60 /// @param value the value to hash.
61 /// @return hash result.
62 virtual uint64_t Hash(const ByteArray* value) const = 0;
63
64 /// Compute hash for fixed byte array value by using its plain encoding result.
65 ///
66 /// @param value the value address.
67 /// @param len the value length.
68 virtual uint64_t Hash(const FLBA* value, uint32_t len) const = 0;
69
70 virtual ~Hasher() = default;
71};
72
73} // namespace parquet
74
75#endif // PARQUET_HASHER_H
76