Skip to content

1.3: Implement TableFile Abstraction for Strong-Typed Records #11

@ArtroxGabriel

Description

@ArtroxGabriel

Description:

This issue involves creating a generic TableFile<TRecord> abstraction that provides a logical view of a table stored on disk, acting as the primary interface for managing and accessing records for a specific table type (e.g., TableFile<Grape>). This abstraction will sit above the BufferManager, requesting pages as needed and interpreting their contents as collections of TRecord instances.
 

Core Responsibilities:

  • Table-to-File Mapping: Define a clear convention for how each table (e.g., Uva, Vinho, País) maps to a specific file on disk (e.g., Uva.tbl, Vinho.tbl, Pais.tbl). [cite_start]This implementation must disregard the use of SGBDs and use only the operating system's file system.
  • Page Management: The TableFile will not directly perform file I/O but will orchestrate it by calling the BufferManager's GetPage() and UnpinPage() methods for each page it needs to access or modify.
  • Record Access: Provide methods to:
    • GetPageRecords(pageId): Retrieve a specific page via the BufferManager and deserialize all TRecord instances contained within that page.
    • AddRecord(TRecord record): Serialize a new record, find space (potentially on a new page), add it, mark the page dirty, and unpin.
    • GetAllRecords(): An iterator or method to sequentially read all pages of the table using the BufferManager and yield all TRecord instances.
  • Metadata Management: Store and retrieve table-specific metadata, such as the total number of pages currently allocated to the table, and potentially the schema information (e.g., number of columns, column types) if not implicitly handled by TRecord. This metadata might be stored in a header page or a separate metadata file for the table.
  • Record Packing/Unpacking: Leverage the serialization/deserialization logic developed in Issue 1.2 to convert between raw page data and TRecord objects.

Considerations:

Efficiently finding space for new records and handling page overflow (if a page becomes full) will be key. The TableFile should ensure proper pinning and unpinning of pages to avoid deadlocks or premature eviction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions