aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/minikql/compact_hash.cpp
blob: 17810ccacbf86b9ad2170754d3967ccf4a0db6e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "compact_hash.h"

#include <util/generic/map.h>
#include <util/stream/str.h>


namespace NKikimr {

namespace NCHash {

void TListPoolBase::FreeListPage(TListHeader* p) {
    Y_ASSERT(TAlignedPagePool::GetPageStart(p) == p);
    p->~TListHeader();
    PagePool_.ReturnPage(p);
}

size_t TListPoolBase::TUsedPages::PrintStat(const TStringBuf& header, IOutputStream& out) const {
    TMap<ui32, ui64> counts;
    size_t pages = 0;
    for (auto& p: FullPages) {
        ++pages;
        ++counts[p.As<TListHeader>()->ListSize];
    }
    for (auto& c: counts) {
        out << header << "Count of full pages<" << c.first << ">: " << c.second << Endl;
    }
    for (size_t i = 0; i < SmallPages.size(); ++i) {
        if (size_t size = SmallPages[i].Size()) {
            pages += size;
            out << header << "Count of partially free pages<" << SmallPages[i].Front()->As<TListHeader>()->ListSize << ">: " << size << Endl;
        }
    }
    for (size_t i = 0; i < MediumPages.size(); ++i) {
        if (size_t size = MediumPages[i].Size()) {
            pages += size;
            out << header << "Count of partially free pages<" << MediumPages[i].Front()->As<TListHeader>()->ListSize << ">: " << size << Endl;
        }
    }
    return pages;
}

TString TListPoolBase::TUsedPages::DebugInfo() const {
    TStringStream out;
    TMap<ui32, ui64> counts;
    for (auto& p: FullPages) {
        out << "Full page<" << p.As<TListHeader>()->ListSize << ">: " << p.As<TListHeader>()->FreeLists << Endl;
    }
    for (size_t i = 0; i < SmallPages.size(); ++i) {
        for (auto& p: SmallPages[i]) {
            out << "Partially free page<" << p.As<TListHeader>()->ListSize << ">: " << p.As<TListHeader>()->FreeLists << Endl;
        }
    }
    for (size_t i = 0; i < MediumPages.size(); ++i) {
        for (auto& p: MediumPages[i]) {
            out << "Partially free page<" << p.As<TListHeader>()->ListSize << ">: " << p.As<TListHeader>()->FreeLists << Endl;
        }
    }
    return out.Str();
}

} // NCHash

} // NKikimr