in hll/include/HllSketch-internal.hpp [245:344]
string<A> hll_sketch_alloc<A>::to_string(const bool summary,
const bool detail,
const bool aux_detail,
const bool all) const {
// Using a temporary stream for implementation here does not comply with AllocatorAwareContainer requirements.
// The stream does not support passing an allocator instance, and alternatives are complicated.
std::stringstream os;
if (summary) {
os << "### HLL sketch summary:" << std::endl
<< " Log Config K : " << std::to_string(get_lg_config_k()) << std::endl
<< " Hll Target : " << type_as_string() << std::endl
<< " Current Mode : " << mode_as_string() << std::endl
<< " LB : " << get_lower_bound(1) << std::endl
<< " Estimate : " << get_estimate() << std::endl
<< " UB : " << get_upper_bound(1) << std::endl
<< " OutOfOrder flag: " << (is_out_of_order_flag() ? "true" : "false") << std::endl;
if (get_current_mode() == HLL) {
HllArray<A>* hllArray = (HllArray<A>*) sketch_impl;
os << " CurMin : " << std::to_string(hllArray->getCurMin()) << std::endl
<< " NumAtCurMin : " << hllArray->getNumAtCurMin() << std::endl
<< " HipAccum : " << hllArray->getHipAccum() << std::endl
<< " KxQ0 : " << hllArray->getKxQ0() << std::endl
<< " KxQ1 : " << hllArray->getKxQ1() << std::endl;
if (get_target_type() == HLL_4) {
const Hll4Array<A>* hll4_ptr = static_cast<const Hll4Array<A>*>(sketch_impl);
os << " Aux table? : " << (hll4_ptr->getAuxHashMap() != nullptr ? "true" : "false") << std::endl;
}
} else {
os << " Coupon count : "
<< std::to_string(((CouponList<A>*) sketch_impl)->getCouponCount()) << std::endl;
}
os << "### End HLL sketch summary" << std::endl;
}
if (detail) {
os << "### HLL sketch data detail:" << std::endl;
if (get_current_mode() == HLL) {
const HllArray<A>* hll_ptr = static_cast<const HllArray<A>*>(sketch_impl);
os << std::left << std::setw(10) << "Slot" << std::setw(6) << "Value" << std::endl;
auto it = hll_ptr->begin(all);
while (it != hll_ptr->end()) {
os << std::setw(10) << HllUtil<A>::getLow26(*it);
os << std::setw(6) << HllUtil<A>::getValue(*it);
os << std::endl;
++it;
}
} else {
const CouponList<A>* list_ptr = static_cast<const CouponList<A>*>(sketch_impl);
os << std::left;
os << std::setw(10) << "Index";
os << std::setw(10) << "Key";
os << std::setw(10) << "Slot";
os << std::setw(6) << "Value";
os << std::endl;
auto it = list_ptr->begin(all);
int i = 0;
int mask = (1 << get_lg_config_k()) - 1;
while (it != list_ptr->end()) {
os << std::setw(10) << i;
os << std::setw(10) << HllUtil<A>::getLow26(*it);
os << std::setw(10) << (HllUtil<A>::getLow26(*it) & mask);
os << std::setw(6) << HllUtil<A>::getValue(*it);
os << std::endl;
++it;
++i;
}
}
os << "### End HLL sketch data detail" << std::endl;
}
if (aux_detail) {
if ((get_current_mode() == HLL) && (get_target_type() == HLL_4)) {
const Hll4Array<A>* hll4_ptr = static_cast<const Hll4Array<A>*>(sketch_impl);
const AuxHashMap<A>* aux_ptr = hll4_ptr->getAuxHashMap();
if (aux_ptr != nullptr) {
os << "### HLL sketch aux detail:" << std::endl;
os << std::left;
os << std::setw(10) << "Index";
os << std::setw(10) << "Key";
os << std::setw(10) << "Slot";
os << std::setw(6) << "Value";
os << std::endl;
auto it = aux_ptr->begin(all);
int i = 0;
int mask = (1 << get_lg_config_k()) - 1;
while (it != aux_ptr->end()) {
os << std::setw(10) << i;
os << std::setw(10) << HllUtil<A>::getLow26(*it);
os << std::setw(10) << (HllUtil<A>::getLow26(*it) & mask);
os << std::setw(6) << HllUtil<A>::getValue(*it);
os << std::endl;
++it;
++i;
}
os << "### End HLL sketch aux detail" << std::endl;
}
}
}
return string<A>(os.str().c_str(), sketch_impl->getAllocator());
}