Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hll/include/AuxHashMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AuxHashMap final {
int getAuxCount() const;
int* getAuxIntArr();
int getLgAuxArrInts() const;
PairIterator_with_deleter<A> getIterator() const;
pair_iterator_with_deleter<A> getIterator() const;

void mustAdd(int slotNo, int value);
int mustFindValueFor(int slotNo);
Expand Down
20 changes: 10 additions & 10 deletions hll/include/CouponHashSet-internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ template<typename A>
static int find(const int* array, const int lgArrInts, const int coupon);

template<typename A>
CouponHashSet<A>::CouponHashSet(const int lgConfigK, const TgtHllType tgtHllType)
: CouponList<A>(lgConfigK, tgtHllType, CurMode::SET)
CouponHashSet<A>::CouponHashSet(const int lgConfigK, const target_hll_type tgtHllType)
: CouponList<A>(lgConfigK, tgtHllType, hll_mode::SET)
{
if (lgConfigK <= 7) {
throw std::invalid_argument("CouponHashSet must be initialized with lgConfigK > 7. Found: "
Expand All @@ -46,7 +46,7 @@ CouponHashSet<A>::CouponHashSet(const CouponHashSet<A>& that)
: CouponList<A>(that) {}

template<typename A>
CouponHashSet<A>::CouponHashSet(const CouponHashSet<A>& that, const TgtHllType tgtHllType)
CouponHashSet<A>::CouponHashSet(const CouponHashSet<A>& that, const target_hll_type tgtHllType)
: CouponList<A>(that, tgtHllType) {}

template<typename A>
Expand Down Expand Up @@ -78,12 +78,12 @@ CouponHashSet<A>* CouponHashSet<A>::newSet(const void* bytes, size_t len) {
throw std::invalid_argument("Input stream is not an HLL sketch");
}

const CurMode curMode = HllSketchImpl<A>::extractCurMode(data[HllUtil<A>::MODE_BYTE]);
if (curMode != SET) {
const hll_mode mode = HllSketchImpl<A>::extractCurMode(data[HllUtil<A>::MODE_BYTE]);
if (mode != SET) {
throw std::invalid_argument("Calling set construtor with non-set mode data");
}

const TgtHllType tgtHllType = HllSketchImpl<A>::extractTgtHllType(data[HllUtil<A>::MODE_BYTE]);
const target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(data[HllUtil<A>::MODE_BYTE]);

const int lgK = data[HllUtil<A>::LG_K_BYTE];
if (lgK <= 7) {
Expand Down Expand Up @@ -149,12 +149,12 @@ CouponHashSet<A>* CouponHashSet<A>::newSet(std::istream& is) {
throw std::invalid_argument("Input stream is not an HLL sketch");
}

CurMode curMode = HllSketchImpl<A>::extractCurMode(listHeader[HllUtil<A>::MODE_BYTE]);
if (curMode != SET) {
hll_mode mode = HllSketchImpl<A>::extractCurMode(listHeader[HllUtil<A>::MODE_BYTE]);
if (mode != SET) {
throw std::invalid_argument("Calling set construtor with non-set mode data");
}

TgtHllType tgtHllType = HllSketchImpl<A>::extractTgtHllType(listHeader[HllUtil<A>::MODE_BYTE]);
target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(listHeader[HllUtil<A>::MODE_BYTE]);

const int lgK = listHeader[HllUtil<A>::LG_K_BYTE];
if (lgK <= 7) {
Expand Down Expand Up @@ -202,7 +202,7 @@ CouponHashSet<A>* CouponHashSet<A>::copy() const {
}

template<typename A>
CouponHashSet<A>* CouponHashSet<A>::copyAs(const TgtHllType tgtHllType) const {
CouponHashSet<A>* CouponHashSet<A>::copyAs(const target_hll_type tgtHllType) const {
return new (chsAlloc().allocate(1)) CouponHashSet<A>(*this, tgtHllType);
}

Expand Down
6 changes: 3 additions & 3 deletions hll/include/CouponHashSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class CouponHashSet : public CouponList<A> {
public:
static CouponHashSet* newSet(const void* bytes, size_t len);
static CouponHashSet* newSet(std::istream& is);
explicit CouponHashSet(int lgConfigK, TgtHllType tgtHllType);
explicit CouponHashSet(const CouponHashSet& that, TgtHllType tgtHllType);
explicit CouponHashSet(int lgConfigK, target_hll_type tgtHllType);
explicit CouponHashSet(const CouponHashSet& that, target_hll_type tgtHllType);
explicit CouponHashSet(const CouponHashSet& that);

virtual ~CouponHashSet();
Expand All @@ -39,7 +39,7 @@ class CouponHashSet : public CouponList<A> {
protected:

virtual CouponHashSet* copy() const;
virtual CouponHashSet* copyAs(TgtHllType tgtHllType) const;
virtual CouponHashSet* copyAs(target_hll_type tgtHllType) const;

virtual HllSketchImpl<A>* couponUpdate(int coupon);

Expand Down
50 changes: 25 additions & 25 deletions hll/include/CouponList-internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
namespace datasketches {

template<typename A>
CouponList<A>::CouponList(const int lgConfigK, const TgtHllType tgtHllType, const CurMode curMode)
: HllSketchImpl<A>(lgConfigK, tgtHllType, curMode, false) {
if (curMode == CurMode::LIST) {
CouponList<A>::CouponList(const int lgConfigK, const target_hll_type tgtHllType, const hll_mode mode)
: HllSketchImpl<A>(lgConfigK, tgtHllType, mode, false) {
if (mode == hll_mode::LIST) {
lgCouponArrInts = HllUtil<A>::LG_INIT_LIST_SIZE;
oooFlag = false;
} else { // curMode == SET
} else { // mode == SET
lgCouponArrInts = HllUtil<A>::LG_INIT_SET_SIZE;
oooFlag = true;
}
Expand All @@ -51,7 +51,7 @@ CouponList<A>::CouponList(const int lgConfigK, const TgtHllType tgtHllType, cons

template<typename A>
CouponList<A>::CouponList(const CouponList& that)
: HllSketchImpl<A>(that.lgConfigK, that.tgtHllType, that.curMode, false),
: HllSketchImpl<A>(that.lgConfigK, that.tgtHllType, that.mode, false),
lgCouponArrInts(that.lgCouponArrInts),
couponCount(that.couponCount),
oooFlag(that.oooFlag) {
Expand All @@ -63,8 +63,8 @@ CouponList<A>::CouponList(const CouponList& that)
}

template<typename A>
CouponList<A>::CouponList(const CouponList& that, const TgtHllType tgtHllType)
: HllSketchImpl<A>(that.lgConfigK, tgtHllType, that.curMode, false),
CouponList<A>::CouponList(const CouponList& that, const target_hll_type tgtHllType)
: HllSketchImpl<A>(that.lgConfigK, tgtHllType, that.mode, false),
lgCouponArrInts(that.lgCouponArrInts),
couponCount(that.couponCount),
oooFlag(that.oooFlag) {
Expand Down Expand Up @@ -96,7 +96,7 @@ CouponList<A>* CouponList<A>::copy() const {
}

template<typename A>
CouponList<A>* CouponList<A>::copyAs(const TgtHllType tgtHllType) const {
CouponList<A>* CouponList<A>::copyAs(target_hll_type tgtHllType) const {
return new (clAlloc().allocate(1)) CouponList<A>(*this, tgtHllType);
}

Expand All @@ -117,12 +117,12 @@ CouponList<A>* CouponList<A>::newList(const void* bytes, size_t len) {
throw std::invalid_argument("Input stream is not an HLL sketch");
}

CurMode curMode = HllSketchImpl<A>::extractCurMode(data[HllUtil<A>::MODE_BYTE]);
if (curMode != LIST) {
hll_mode mode = HllSketchImpl<A>::extractCurMode(data[HllUtil<A>::MODE_BYTE]);
if (mode != LIST) {
throw std::invalid_argument("Calling set construtor with non-list mode data");
}

TgtHllType tgtHllType = HllSketchImpl<A>::extractTgtHllType(data[HllUtil<A>::MODE_BYTE]);
target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(data[HllUtil<A>::MODE_BYTE]);

const int lgK = data[HllUtil<A>::LG_K_BYTE];
const bool compact = ((data[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::COMPACT_FLAG_MASK) ? true : false);
Expand All @@ -137,7 +137,7 @@ CouponList<A>* CouponList<A>::newList(const void* bytes, size_t len) {
+ ", found: " + std::to_string(len));
}

CouponList<A>* sketch = new (clAlloc().allocate(1)) CouponList<A>(lgK, tgtHllType, curMode);
CouponList<A>* sketch = new (clAlloc().allocate(1)) CouponList<A>(lgK, tgtHllType, mode);
sketch->couponCount = couponCount;
sketch->putOutOfOrderFlag(oooFlag); // should always be false for LIST

Expand All @@ -164,19 +164,19 @@ CouponList<A>* CouponList<A>::newList(std::istream& is) {
throw std::invalid_argument("Input stream is not an HLL sketch");
}

CurMode curMode = HllSketchImpl<A>::extractCurMode(listHeader[HllUtil<A>::MODE_BYTE]);
if (curMode != LIST) {
hll_mode mode = HllSketchImpl<A>::extractCurMode(listHeader[HllUtil<A>::MODE_BYTE]);
if (mode != LIST) {
throw std::invalid_argument("Calling list construtor with non-list mode data");
}

const TgtHllType tgtHllType = HllSketchImpl<A>::extractTgtHllType(listHeader[HllUtil<A>::MODE_BYTE]);
const target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(listHeader[HllUtil<A>::MODE_BYTE]);

const int lgK = (int) listHeader[HllUtil<A>::LG_K_BYTE];
const bool compact = ((listHeader[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::COMPACT_FLAG_MASK) ? true : false);
const bool oooFlag = ((listHeader[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::OUT_OF_ORDER_FLAG_MASK) ? true : false);
const bool emptyFlag = ((listHeader[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::EMPTY_FLAG_MASK) ? true : false);

CouponList<A>* sketch = new (clAlloc().allocate(1)) CouponList<A>(lgK, tgtHllType, curMode);
CouponList<A>* sketch = new (clAlloc().allocate(1)) CouponList<A>(lgK, tgtHllType, mode);
const int couponCount = listHeader[HllUtil<A>::LIST_COUNT_BYTE];
sketch->couponCount = couponCount;
sketch->putOutOfOrderFlag(oooFlag); // should always be false for LIST
Expand Down Expand Up @@ -209,10 +209,10 @@ std::pair<std::unique_ptr<uint8_t, std::function<void(uint8_t*)>>, const size_t>
bytes[HllUtil<A>::LG_K_BYTE] = static_cast<uint8_t>(this->lgConfigK);
bytes[HllUtil<A>::LG_ARR_BYTE] = static_cast<uint8_t>(lgCouponArrInts);
bytes[HllUtil<A>::FLAGS_BYTE] = this->makeFlagsByte(compact);
bytes[HllUtil<A>::LIST_COUNT_BYTE] = static_cast<uint8_t>(this->curMode == LIST ? couponCount : 0);
bytes[HllUtil<A>::LIST_COUNT_BYTE] = static_cast<uint8_t>(this->mode == LIST ? couponCount : 0);
bytes[HllUtil<A>::MODE_BYTE] = this->makeModeByte();

if (this->curMode == SET) {
if (this->mode == SET) {
std::memcpy(bytes + HllUtil<A>::HASH_SET_COUNT_INT, &couponCount, sizeof(couponCount));
}

Expand All @@ -225,7 +225,7 @@ std::pair<std::unique_ptr<uint8_t, std::function<void(uint8_t*)>>, const size_t>
break;
}
case 1: { // src updatable, dst compact
PairIterator_with_deleter<A> itr = getIterator();
pair_iterator_with_deleter<A> itr = getIterator();
bytes += getMemDataStart(); // reusing ponter for incremental writes
while (itr->nextValid()) {
const int pairValue = itr->getPair();
Expand Down Expand Up @@ -258,18 +258,18 @@ void CouponList<A>::serialize(std::ostream& os, const bool compact) const {
const uint8_t flagsByte(this->makeFlagsByte(compact));
os.write((char*)&flagsByte, sizeof(flagsByte));

if (this->curMode == LIST) {
if (this->mode == LIST) {
const uint8_t listCount((uint8_t) couponCount);
os.write((char*)&listCount, sizeof(listCount));
} else { // curMode == SET
} else { // mode == SET
const uint8_t unused(0);
os.write((char*)&unused, sizeof(unused));
}

const uint8_t modeByte(this->makeModeByte());
os.write((char*)&modeByte, sizeof(modeByte));

if (this->curMode == SET) {
if (this->mode == SET) {
// writing as int, already stored as int
os.write((char*)&couponCount, sizeof(couponCount));
}
Expand All @@ -283,7 +283,7 @@ void CouponList<A>::serialize(std::ostream& os, const bool compact) const {
break;
}
case 1: { // src updatable, dst compact
PairIterator_with_deleter<A> itr = getIterator();
pair_iterator_with_deleter<A> itr = getIterator();
while (itr->nextValid()) {
const int pairValue = itr->getPair();
os.write((char*)&pairValue, sizeof(pairValue));
Expand Down Expand Up @@ -401,10 +401,10 @@ int* CouponList<A>::getCouponIntArr() const {
}

template<typename A>
PairIterator_with_deleter<A> CouponList<A>::getIterator() const {
pair_iterator_with_deleter<A> CouponList<A>::getIterator() const {
typedef typename std::allocator_traits<A>::template rebind_alloc<IntArrayPairIterator<A>> iapiAlloc;
IntArrayPairIterator<A>* itr = new (iapiAlloc().allocate(1)) IntArrayPairIterator<A>(couponIntArr, 1 << lgCouponArrInts, this->lgConfigK);
return PairIterator_with_deleter<A>(
return pair_iterator_with_deleter<A>(
itr,
[](PairIterator<A>* ptr) {
IntArrayPairIterator<A>* iapi = static_cast<IntArrayPairIterator<A>*>(ptr);
Expand Down
8 changes: 4 additions & 4 deletions hll/include/CouponList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class HllSketchImplFactory;
template<typename A = std::allocator<char>>
class CouponList : public HllSketchImpl<A> {
public:
explicit CouponList(int lgConfigK, TgtHllType tgtHllType, CurMode curMode);
explicit CouponList(int lgConfigK, target_hll_type tgtHllType, hll_mode mode);
explicit CouponList(const CouponList& that);
explicit CouponList(const CouponList& that, TgtHllType tgtHllType);
explicit CouponList(const CouponList& that, target_hll_type tgtHllType);

static CouponList* newList(const void* bytes, size_t len);
static CouponList* newList(std::istream& is);
Expand All @@ -44,7 +44,7 @@ class CouponList : public HllSketchImpl<A> {
virtual std::function<void(HllSketchImpl<A>*)> get_deleter() const;

virtual CouponList* copy() const;
virtual CouponList* copyAs(TgtHllType tgtHllType) const;
virtual CouponList* copyAs(target_hll_type tgtHllType) const;

virtual HllSketchImpl<A>* couponUpdate(int coupon);

Expand All @@ -55,7 +55,7 @@ class CouponList : public HllSketchImpl<A> {

virtual bool isEmpty() const;
virtual int getCouponCount() const;
virtual PairIterator_with_deleter<A> getIterator() const;
virtual pair_iterator_with_deleter<A> getIterator() const;

protected:
typedef typename std::allocator_traits<A>::template rebind_alloc<CouponList<A>> clAlloc;
Expand Down
10 changes: 5 additions & 5 deletions hll/include/Hll4Array-internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int Hll4Iterator<A>::value() {

template<typename A>
Hll4Array<A>::Hll4Array(const int lgConfigK, const bool startFullSize) :
HllArray<A>(lgConfigK, TgtHllType::HLL_4, startFullSize) {
HllArray<A>(lgConfigK, target_hll_type::HLL_4, startFullSize) {
const int numBytes = this->hll4ArrBytes(lgConfigK);
typedef typename std::allocator_traits<A>::template rebind_alloc<uint8_t> uint8Alloc;
this->hllByteArr = uint8Alloc().allocate(numBytes);
Expand Down Expand Up @@ -97,10 +97,10 @@ Hll4Array<A>* Hll4Array<A>::copy() const {
}

template<typename A>
PairIterator_with_deleter<A> Hll4Array<A>::getIterator() const {
pair_iterator_with_deleter<A> Hll4Array<A>::getIterator() const {
typedef typename std::allocator_traits<A>::template rebind_alloc<Hll4Iterator<A>> itrAlloc;
Hll4Iterator<A>* itr = new (itrAlloc().allocate(1)) Hll4Iterator<A>(*this, 1 << this->lgConfigK);
return PairIterator_with_deleter<A>(
return pair_iterator_with_deleter<A>(
itr,
[](PairIterator<A>* ptr) {
Hll4Iterator<A>* hll = static_cast<Hll4Iterator<A>*>(ptr);
Expand All @@ -111,7 +111,7 @@ PairIterator_with_deleter<A> Hll4Array<A>::getIterator() const {
}

template<typename A>
PairIterator_with_deleter<A> Hll4Array<A>::getAuxIterator() const {
pair_iterator_with_deleter<A> Hll4Array<A>::getAuxIterator() const {
if (auxHashMap != nullptr) {
return auxHashMap->getIterator();
}
Expand Down Expand Up @@ -312,7 +312,7 @@ void Hll4Array<A>::shiftToBiggerCurMin() {
int oldActualVal;
int newShiftedVal;

PairIterator_with_deleter<A> itr = auxHashMap->getIterator();
pair_iterator_with_deleter<A> itr = auxHashMap->getIterator();
while (itr->nextValid()) {
slotNum = itr->getKey() & configKmask;
oldActualVal = itr->getValue();
Expand Down
4 changes: 2 additions & 2 deletions hll/include/Hll4Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class Hll4Array final : public HllArray<A> {

virtual Hll4Array* copy() const;

virtual PairIterator_with_deleter<A> getIterator() const;
virtual PairIterator_with_deleter<A> getAuxIterator() const;
virtual pair_iterator_with_deleter<A> getIterator() const;
virtual pair_iterator_with_deleter<A> getAuxIterator() const;

virtual int getSlot(int slotNo) const final;
virtual void putSlot(int slotNo, int value) final;
Expand Down
6 changes: 3 additions & 3 deletions hll/include/Hll6Array-internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int Hll6Iterator<A>::value() {

template<typename A>
Hll6Array<A>::Hll6Array(const int lgConfigK, const bool startFullSize) :
HllArray<A>(lgConfigK, TgtHllType::HLL_6, startFullSize) {
HllArray<A>(lgConfigK, target_hll_type::HLL_6, startFullSize) {
const int numBytes = this->hll6ArrBytes(lgConfigK);
typedef typename std::allocator_traits<A>::template rebind_alloc<uint8_t> uint8Alloc;
this->hllByteArr = uint8Alloc().allocate(numBytes);
Expand Down Expand Up @@ -84,10 +84,10 @@ Hll6Array<A>* Hll6Array<A>::copy() const {
}

template<typename A>
PairIterator_with_deleter<A> Hll6Array<A>::getIterator() const {
pair_iterator_with_deleter<A> Hll6Array<A>::getIterator() const {
typedef typename std::allocator_traits<A>::template rebind_alloc<Hll6Iterator<A>> itrAlloc;
Hll6Iterator<A>* itr = new (itrAlloc().allocate(1)) Hll6Iterator<A>(*this, 1 << this->lgConfigK);
return PairIterator_with_deleter<A>(
return pair_iterator_with_deleter<A>(
itr,
[](PairIterator<A>* ptr) {
Hll6Iterator<A>* hll = static_cast<Hll6Iterator<A>*>(ptr);
Expand Down
2 changes: 1 addition & 1 deletion hll/include/Hll6Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Hll6Array final : public HllArray<A> {

virtual Hll6Array* copy() const;

virtual PairIterator_with_deleter<A> getIterator() const;
virtual pair_iterator_with_deleter<A> getIterator() const;

virtual int getSlot(int slotNo) const final;
virtual void putSlot(int slotNo, int value) final;
Expand Down
6 changes: 3 additions & 3 deletions hll/include/Hll8Array-internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int Hll8Iterator<A>::value() {

template<typename A>
Hll8Array<A>::Hll8Array(const int lgConfigK, const bool startFullSize) :
HllArray<A>(lgConfigK, TgtHllType::HLL_8, startFullSize) {
HllArray<A>(lgConfigK, target_hll_type::HLL_8, startFullSize) {
const int numBytes = this->hll8ArrBytes(lgConfigK);
typedef typename std::allocator_traits<A>::template rebind_alloc<uint8_t> uint8Alloc;
this->hllByteArr = uint8Alloc().allocate(numBytes);
Expand Down Expand Up @@ -78,10 +78,10 @@ Hll8Array<A>* Hll8Array<A>::copy() const {
}

template<typename A>
PairIterator_with_deleter<A> Hll8Array<A>::getIterator() const {
pair_iterator_with_deleter<A> Hll8Array<A>::getIterator() const {
typedef typename std::allocator_traits<A>::template rebind_alloc<Hll8Iterator<A>> itrAlloc;
Hll8Iterator<A>* itr = new (itrAlloc().allocate(1)) Hll8Iterator<A>(*this, 1 << this->lgConfigK);
return PairIterator_with_deleter<A>(
return pair_iterator_with_deleter<A>(
itr,
[](PairIterator<A>* ptr) {
Hll8Iterator<A>* hll = static_cast<Hll8Iterator<A>*>(ptr);
Expand Down
2 changes: 1 addition & 1 deletion hll/include/Hll8Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Hll8Array final : public HllArray<A> {

virtual Hll8Array<A>* copy() const;

virtual PairIterator_with_deleter<A> getIterator() const;
virtual pair_iterator_with_deleter<A> getIterator() const;

virtual int getSlot(int slotNo) const final;
virtual void putSlot(int slotNo, int value) final;
Expand Down
Loading