Started adding hashmap instead of std::vector as QueryWithMany return

This commit is contained in:
2026-03-02 09:12:29 +02:00
parent 5112f2a3a3
commit 81ace42256

View File

@@ -10,6 +10,7 @@
#define GUARD_TOURMALINE_DUALKEYMAP_H #define GUARD_TOURMALINE_DUALKEYMAP_H
#include "../Concepts.hpp" #include "../Concepts.hpp"
#include "../Systems/Logging.hpp" #include "../Systems/Logging.hpp"
#include "Hashmap.hpp"
#include <algorithm> #include <algorithm>
#include <array> #include <array>
@@ -299,7 +300,10 @@ private:
Key *keyToCompare; Key *keyToCompare;
OppositeKey *oppositeKey; OppositeKey *oppositeKey;
std::vector<MultiQueryResult<OppositeKey, keyCount>> queryResults; std::vector<MultiQueryResult<OppositeKey, keyCount>> queryResults;
queryResults.reserve(512); queryResults.reserve(2048);
Containers::Hashmap<OppositeKey, MultiQueryResult<OppositeKey, keyCount> *,
3.0f, 2048, 0.01f> // Aggressive hashmap :o
locations;
for (DualkeyHash *hash : hashList) { for (DualkeyHash *hash : hashList) {
// Tombstone // Tombstone
@@ -322,26 +326,15 @@ 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)) {
bool doesExist = false; locations.Get(*oppositeKey)->valueQueryResults[index] =
for (auto &queryRecord : queryResults) { &hash->value;
if (*queryRecord.oppositeKey == *oppositeKey) { } else {
queryRecord.valueQueryResults[index] = &hash->value;
++queryRecord.howManyFound;
doesExist = true;
break;
}
}
if (doesExist) {
break;
}
// Since the result record is not present
// we have to make it
queryResults.emplace_back(oppositeKey); queryResults.emplace_back(oppositeKey);
auto &newRecord = queryResults.back(); auto &newRecord = queryResults.back();
newRecord.valueQueryResults[index] = &hash->value; newRecord.valueQueryResults[index] = &hash->value;
locations.Insert(*oppositeKey, &newRecord);
}
} }
} }
} }