From c375b1c69665ae7c16ffa3f17264386dfc257d8e Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Sat, 9 May 2026 23:03:00 -0300 Subject: FOL VM with cursor mocked storage --- include/CursorManager.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'include/CursorManager.h') diff --git a/include/CursorManager.h b/include/CursorManager.h index 7e1ebe0..78ea24c 100644 --- a/include/CursorManager.h +++ b/include/CursorManager.h @@ -1,6 +1,12 @@ #pragma once #include "Api.h" +#include "HandlerManager.h" +#include "Types.h" + +#include +#include +#include /** * @file CursorManager.h @@ -35,5 +41,53 @@ namespace nt */ class NT_API CursorManager { + public: + /** @brief Active scan state for a single relation. */ + struct cursor { + /** Handle that authorized this cursor. */ + HandlerManager::handle* handle; + // TODO: Replace with a lazy iterator into the physical storage backend. + // Pre-loading all tuples on Open() is a mock simplification. + std::vector tuples; + size_t position = 0; + }; + + /** + * @brief Opens a cursor on the relation referenced by the handle. + * @param handle Authorized handle to a RELATION object. + * @return A new cursor, or nullptr if the object is not a RELATION. + */ + cursor* Open(HandlerManager::handle* handle); + + /** + * @brief Pulls the next tuple from the cursor. + * + * The returned pointer is valid until the next Next() or Close() call. + * + * @param cursor Active cursor. + * @return Pointer to the next tuple, or nullptr when exhausted. + */ + Tuple* Next(cursor* cursor); + + /** + * @brief Closes the cursor and releases its resources. + * @param cursor Cursor to close. + */ + void Close(cursor* cursor); + + /** + * @brief Inserts one tuple into the mock store for a given relation path. + * + * TODO: Replace with physical storage writes when the backend is wired up. + * + * @param path Logical path of the relation. + * @param tuple Attribute values for the tuple to insert. + */ + void MockInsert(std::vector path, std::vector tuple); + + private: + // TODO: Replace with physical storage backend access. + // Keyed by the relation path joined as "seg/seg/...". + std::unordered_map>> mock_store_; }; } -- cgit v1.2.3