MCPcopy Create free account
hub / github.com/catboost/catboost / BuildBuckets

Function BuildBuckets

library/cpp/text_processing/dictionary/mmap_hash_table.h:53–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51
52 template <typename TElementRange, typename TExctractor>
53 void BuildBuckets(
54 const TElementRange& range,
55 const TExctractor& getTokenInfo,
56 TVector<TBucket>* buckets,
57 ui64* seed
58 ) {
59 const ui32 bucketCount = ComputeCorrectBucketCount(range.size());
60 *seed = 0;
61 buckets->yresize(bucketCount);
62 for (; *seed < MAX_SEED_CHOICE_COUNT; ++(*seed)) {
63 bool isBucketSearchStepLimitExceeded = false;
64 std::fill(buckets->begin(), buckets->end(), TBucket());
65 for (const auto& element : range) {
66 const auto hashAndTokenId = getTokenInfo(element, *seed);
67 ui32 bucketSearchStepCount;
68 auto index = GetBucketIndex(hashAndTokenId.first, *buckets, &bucketSearchStepCount);
69 (*buckets)[index] = {hashAndTokenId.first, hashAndTokenId.second};
70 isBucketSearchStepLimitExceeded |= bucketSearchStepCount > MAX_BUCKET_SEARCH_STEPS;
71 }
72
73 if (!isBucketSearchStepLimitExceeded) {
74 return;
75 }
76 }
77
78 Y_ENSURE(false, "Couldn't find a mapping without collisions.");
79 }
80}

Callers 3

TMMapBpeDictionaryMethod · 0.85

Calls 8

GetBucketIndexFunction · 0.85
yresizeMethod · 0.80
TBucketClass · 0.70
fillFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected