datasketches-cpp
Hll4Array.hpp
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #ifndef _HLL4ARRAY_HPP_
21 #define _HLL4ARRAY_HPP_
22 
23 #include "AuxHashMap.hpp"
24 #include "HllArray.hpp"
25 
26 namespace datasketches {
27 
28 template<typename A>
29 class Hll4Array final : public HllArray<A> {
30  public:
31  explicit Hll4Array(uint8_t lgConfigK, bool startFullSize, const A& allocator);
32  explicit Hll4Array(const Hll4Array<A>& that);
33  explicit Hll4Array(const HllArray<A>& that);
34 
35  virtual ~Hll4Array();
36  virtual std::function<void(HllSketchImpl<A>*)> get_deleter() const;
37 
38  virtual Hll4Array* copy() const;
39 
40  inline uint8_t getSlot(uint32_t slotNo) const;
41  inline void putSlot(uint32_t slotNo, uint8_t value);
42  inline uint8_t adjustRawValue(uint32_t index, uint8_t value) const;
43 
44  virtual uint32_t getUpdatableSerializationBytes() const;
45  virtual uint32_t getHllByteArrBytes() const;
46 
47  virtual HllSketchImpl<A>* couponUpdate(uint32_t coupon) final;
48 
49  virtual AuxHashMap<A>* getAuxHashMap() const;
50  // does *not* delete old map if overwriting
51  void putAuxHashMap(AuxHashMap<A>* auxHashMap);
52 
53  virtual typename HllArray<A>::const_iterator begin(bool all = false) const;
54  virtual typename HllArray<A>::const_iterator end() const;
55 
56  private:
57  void internalCouponUpdate(uint32_t coupon);
58  void internalHll4Update(uint32_t slotNo, uint8_t newVal);
59  void shiftToBiggerCurMin();
60 
61  AuxHashMap<A>* auxHashMap_;
62 };
63 
64 }
65 
66 #endif /* _HLL4ARRAY_HPP_ */
DataSketches namespace.
Definition: binomial_bounds.hpp:38