Add preliminary mock and PropertyStore modifications

This commit is contained in:
Ante Pušić 2023-12-21 13:23:14 +01:00
parent f11b3c6d9d
commit df82b05725
2 changed files with 30 additions and 1 deletions

View File

@ -105,7 +105,8 @@ enum class Type : uint8_t {
STRING = 0x50,
LIST = 0x60,
MAP = 0x70,
TEMPORAL_DATA = 0x80
TEMPORAL_DATA = 0x80,
EXTERNALLY_STORED = 0x90
};
const uint8_t kMaskType = 0xf0;

View File

@ -11,6 +11,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <json/json.hpp>
#include <limits>
@ -21,6 +22,33 @@
using testing::UnorderedElementsAre;
struct SearchResult {
std::uint64_t id;
nlohmann::json document;
double score;
};
class TantivyMock {
enum class Consistency : uint8_t { DEFAULT };
std::string INDEX = ""; // placeholder
std::map<std::string, std::map<std::uint64_t, nlohmann::json>> storage{}; // index_name: {document_id: document}
void CreateAllPropsIndex(std::string name, std::string tokenizer, Consistency consistency = Consistency::DEFAULT) {}
void DropIndex(std::string index_name) { storage.erase(index_name); }
void AddDocument(std::uint64_t id, nlohmann::json document) { storage[INDEX][id] = document; }
void DeleteDocument(std::uint64_t id) { storage[INDEX].erase(id); }
SearchResult Search(std::string index_name, std::string search_query) {
auto mock_result = storage[index_name].begin();
return SearchResult{.id = mock_result->first, .document = mock_result->second, .score = 1.0};
}
};
const memgraph::storage::PropertyValue kSampleValues[] = {
memgraph::storage::PropertyValue(),
memgraph::storage::PropertyValue(false),