Fixed DualKeyMap MultiQuery not recording how many found properly
This commit is contained in:
@@ -300,12 +300,9 @@ private:
|
|||||||
Key *keyToCompare;
|
Key *keyToCompare;
|
||||||
OppositeKey *oppositeKey;
|
OppositeKey *oppositeKey;
|
||||||
|
|
||||||
// TO DO, merge std::vector with Containers::Hashmap!!
|
Containers::Hashmap<OppositeKey, MultiQueryResult<OppositeKey, keyCount>,
|
||||||
std::vector<MultiQueryResult<OppositeKey, keyCount>> queryResults;
|
|
||||||
queryResults.reserve(2048);
|
|
||||||
Containers::Hashmap<OppositeKey, MultiQueryResult<OppositeKey, keyCount> *,
|
|
||||||
8.0f, 2048, 0.01f> // Aggressive hashmap :o
|
8.0f, 2048, 0.01f> // Aggressive hashmap :o
|
||||||
locations;
|
queryResults;
|
||||||
|
|
||||||
for (DualkeyHash *hash : hashList) {
|
for (DualkeyHash *hash : hashList) {
|
||||||
// Tombstone
|
// Tombstone
|
||||||
@@ -328,20 +325,22 @@ private:
|
|||||||
// The code above was done to make this code more uniform
|
// The code above was done to make this code more uniform
|
||||||
for (uint64_t index = 0; index < keyCount; index++) {
|
for (uint64_t index = 0; index < keyCount; index++) {
|
||||||
if (keyHashes[index] == hashToCompare && keys[index] == *keyToCompare) {
|
if (keyHashes[index] == hashToCompare && keys[index] == *keyToCompare) {
|
||||||
if (locations.Has(*oppositeKey)) {
|
if (queryResults.Has(*oppositeKey)) {
|
||||||
locations.Get(*oppositeKey)->valueQueryResults[index] =
|
auto &entry = queryResults.Get(*oppositeKey);
|
||||||
&hash->value;
|
entry.valueQueryResults[index] = &hash->value;
|
||||||
} else {
|
++entry.howManyFound;
|
||||||
queryResults.emplace_back(oppositeKey);
|
break;
|
||||||
auto &newRecord = queryResults.back();
|
|
||||||
newRecord.valueQueryResults[index] = &hash->value;
|
|
||||||
locations.Insert(*oppositeKey, &newRecord);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
queryResults
|
||||||
|
.Insert(*oppositeKey,
|
||||||
|
MultiQueryResult<OppositeKey, keyCount>(oppositeKey))
|
||||||
|
.valueQueryResults[index] = &hash->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryResults;
|
return queryResults.ExtractValuesToArray();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace Tourmaline::Containers
|
} // namespace Tourmaline::Containers
|
||||||
|
|||||||
@@ -100,6 +100,25 @@ public:
|
|||||||
"Hashmap", Systems::Logging::LogLevel::Error);
|
"Hashmap", Systems::Logging::LogLevel::Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard("Discarding an expensive operation!")]]
|
||||||
|
std::vector<Value> ExtractValuesToArray() {
|
||||||
|
std::vector<Value> result;
|
||||||
|
result.reserve(count);
|
||||||
|
|
||||||
|
for (bucket &entry : storage) {
|
||||||
|
for (hashStorage &hash : entry) {
|
||||||
|
result.emplace_back(std::move(hash.value));
|
||||||
|
}
|
||||||
|
entry.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
bucketCount = minimumBucketCount;
|
||||||
|
std::vector<bucket> newStorage;
|
||||||
|
storage.swap(newStorage);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void Clear() noexcept {
|
void Clear() noexcept {
|
||||||
storage.clear();
|
storage.clear();
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user