diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-04-26 12:27:11 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-04-26 12:27:28 +1000 |
| commit | 083f4011aa740d492d9a9ceb07c7228003f5ad39 (patch) | |
| tree | 29a9fc9bcaec0ba24c27067f65772270d0273a72 /src/database/include/table.hpp | |
| parent | 2be4d4204c6cb3a591be070e5d6a15a54070fc6c (diff) | |
| download | tangara-fw-083f4011aa740d492d9a9ceb07c7228003f5ad39.tar.gz | |
removed unused raw db stuff
Diffstat (limited to 'src/database/include/table.hpp')
| -rw-r--r-- | src/database/include/table.hpp | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/src/database/include/table.hpp b/src/database/include/table.hpp deleted file mode 100644 index 438c23b6..00000000 --- a/src/database/include/table.hpp +++ /dev/null @@ -1,87 +0,0 @@ -#pragma once - -#include <cstddef> -#include <cstdint> -#include <memory> -#include <optional> -#include <string> -#include <utility> - -#include "esp32/himem.h" -#include "ff.h" -#include "span.hpp" -#include "sys/_stdint.h" - -namespace database { - -// Types used for indexing into files on disk. These should, at minimum, match -// the size of the types that the underlying filesystem uses to address within -// files. FAT32 uses 32 bit address. If we drop this and just support exFAT, we -// can change these to 64 bit types. -typedef uint32_t Index_t; -typedef Index_t IndexOffset_t; - -// The amount of memory that will be used to page database columns in from disk. -// Currently we only use a single 'page' in PSRAM per column, but with some -// refactoring we could easily page more. -// Keep this value 32KiB-aligned for himem compatibility. -extern const std::size_t kRamBlockSize; - -struct DatabaseHeader { - uint32_t magic_number; - uint16_t db_version; - Index_t num_indices; -}; - -struct DatabaseEntry { - uint8_t type; - std::string path; - - std::string title; - std::string album; - std::string artist; - std::string album_artist; -}; - -struct IndexEntry { - uint8_t type; - IndexOffset_t path; - - IndexOffset_t title; - IndexOffset_t album; - IndexOffset_t artist; - IndexOffset_t album_artist; -}; - -struct RowData { - std::unique_ptr<std::byte[]> arr; - std::size_t length; -}; - -// Representation of a single column of data. Each column is simply a tightly -// packed list of [size, [bytes, ...]] pairs. Callers are responsible for -// parsing and encoding the actual bytes themselves. -class Column { - public: - static auto Open(std::string) -> std::optional<Column>; - - Column(FIL file, std::size_t file_size); - ~Column(); - - auto ReadDataAtOffset(esp_himem_rangehandle_t, IndexOffset_t) -> RowData; - auto AppendRow(cpp::span<std::byte> row) -> bool; - auto FlushChanges() -> void; - - private: - FIL file_; - IndexOffset_t length_; - - esp_himem_handle_t block_; - std::pair<IndexOffset_t, IndexOffset_t> loaded_range_; - - auto IsOffsetLoaded(IndexOffset_t offset) -> bool; - auto LoadOffsetFromDisk(cpp::span<std::byte> dest, IndexOffset_t offset) - -> bool; -}; - -} // namespace database |
