Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 08:28:54

0001 // Licensed to the Apache Software Foundation (ASF) under one
0002 // or more contributor license agreements.  See the NOTICE file
0003 // distributed with this work for additional information
0004 // regarding copyright ownership.  The ASF licenses this file
0005 // to you under the Apache License, Version 2.0 (the
0006 // "License"); you may not use this file except in compliance
0007 // with the License.  You may obtain a copy of the License at
0008 //
0009 //   http://www.apache.org/licenses/LICENSE-2.0
0010 //
0011 // Unless required by applicable law or agreed to in writing,
0012 // software distributed under the License is distributed on an
0013 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
0014 // KIND, either express or implied.  See the License for the
0015 // specific language governing permissions and limitations
0016 // under the License.
0017 
0018 #pragma once
0019 
0020 #include <cstdint>
0021 #include "parquet/types.h"
0022 
0023 namespace parquet {
0024 // Abstract class for hash
0025 class Hasher {
0026  public:
0027   /// Compute hash for 32 bits value by using its plain encoding result.
0028   ///
0029   /// @param value the value to hash.
0030   /// @return hash result.
0031   virtual uint64_t Hash(int32_t value) const = 0;
0032 
0033   /// Compute hash for 64 bits value by using its plain encoding result.
0034   ///
0035   /// @param value the value to hash.
0036   /// @return hash result.
0037   virtual uint64_t Hash(int64_t value) const = 0;
0038 
0039   /// Compute hash for float value by using its plain encoding result.
0040   ///
0041   /// @param value the value to hash.
0042   /// @return hash result.
0043   virtual uint64_t Hash(float value) const = 0;
0044 
0045   /// Compute hash for double value by using its plain encoding result.
0046   ///
0047   /// @param value the value to hash.
0048   /// @return hash result.
0049   virtual uint64_t Hash(double value) const = 0;
0050 
0051   /// Compute hash for Int96 value by using its plain encoding result.
0052   ///
0053   /// @param value the value to hash.
0054   /// @return hash result.
0055   virtual uint64_t Hash(const Int96* value) const = 0;
0056 
0057   /// Compute hash for ByteArray value by using its plain encoding result.
0058   ///
0059   /// @param value the value to hash.
0060   /// @return hash result.
0061   virtual uint64_t Hash(const ByteArray* value) const = 0;
0062 
0063   /// Compute hash for fixed byte array value by using its plain encoding result.
0064   ///
0065   /// @param value the value address.
0066   /// @param len the value length.
0067   virtual uint64_t Hash(const FLBA* value, uint32_t len) const = 0;
0068 
0069   /// Batch compute hashes for 32 bits values by using its plain encoding result.
0070   ///
0071   /// @param values a pointer to the values to hash.
0072   /// @param num_values the number of values to hash.
0073   /// @param hashes a pointer to the output hash values, its length should be equal to
0074   /// num_values.
0075   virtual void Hashes(const int32_t* values, int num_values, uint64_t* hashes) const = 0;
0076 
0077   /// Batch compute hashes for 64 bits values by using its plain encoding result.
0078   ///
0079   /// @param values a pointer to the values to hash.
0080   /// @param num_values the number of values to hash.
0081   /// @param hashes a pointer to the output hash values, its length should be equal to
0082   /// num_values.
0083   virtual void Hashes(const int64_t* values, int num_values, uint64_t* hashes) const = 0;
0084 
0085   /// Batch compute hashes for float values by using its plain encoding result.
0086   ///
0087   /// @param values a pointer to the values to hash.
0088   /// @param num_values the number of values to hash.
0089   /// @param hashes a pointer to the output hash values, its length should be equal to
0090   /// num_values.
0091   virtual void Hashes(const float* values, int num_values, uint64_t* hashes) const = 0;
0092 
0093   /// Batch compute hashes for double values by using its plain encoding result.
0094   ///
0095   /// @param values a pointer to the values to hash.
0096   /// @param num_values the number of values to hash.
0097   /// @param hashes a pointer to the output hash values, its length should be equal to
0098   /// num_values.
0099   virtual void Hashes(const double* values, int num_values, uint64_t* hashes) const = 0;
0100 
0101   /// Batch compute hashes for Int96 values by using its plain encoding result.
0102   ///
0103   /// @param values a pointer to the values to hash.
0104   /// @param num_values the number of values to hash.
0105   /// @param hashes a pointer to the output hash values, its length should be equal to
0106   /// num_values.
0107   virtual void Hashes(const Int96* values, int num_values, uint64_t* hashes) const = 0;
0108 
0109   /// Batch compute hashes for ByteArray values by using its plain encoding result.
0110   ///
0111   /// @param values a pointer to the values to hash.
0112   /// @param num_values the number of values to hash.
0113   /// @param hashes a pointer to the output hash values, its length should be equal to
0114   /// num_values.
0115   virtual void Hashes(const ByteArray* values, int num_values,
0116                       uint64_t* hashes) const = 0;
0117 
0118   /// Batch compute hashes for fixed byte array values by using its plain encoding result.
0119   ///
0120   /// @param values the value address.
0121   /// @param type_len the value length.
0122   /// @param num_values the number of values to hash.
0123   /// @param hashes a pointer to the output hash values, its length should be equal to
0124   /// num_values.
0125   virtual void Hashes(const FLBA* values, uint32_t type_len, int num_values,
0126                       uint64_t* hashes) const = 0;
0127 
0128   virtual ~Hasher() = default;
0129 };
0130 
0131 }  // namespace parquet