ream/storage/stream/index

Types

pub type Index {
  Index(offset: Int, size: Int, file_id: Int)
}

Constructors

  • Index(offset: Int, size: Int, file_id: Int)
pub type IndexFile {
  IndexFile(handler: Pid, size: Int, file_path: String)
}

Constructors

  • IndexFile(handler: Pid, size: Int, file_path: String)

Constants

pub const event_size_bits: Int = 24

event size (in bits) is storing letting us store events of 2^24 bits (16MB) of data

pub const file_id_size_bits: Int = 128

the size of the file id in bytes, it’s 16 bytes or 128 bits representing a 128 bit integer (UUID)

pub const index_size_bytes: Int = 25

the size of the index entry in bytes, it’s 25 bytes because we’re storing the offset (6 bytes), the event size (3 bytes) and the file id (16 bytes).

pub const offset_size_bits: Int = 48

the size of the offset in bytes, it’s 6 bytes or 48 bits letting us store offsets of 2^48 bytes (256TB) of data

Functions

pub fn add(index_file: IndexFile, event_size: Int, file_id: Int) -> #(
  Index,
  IndexFile,
)
pub fn close(index_file: IndexFile) -> Result(Nil, Reason)
pub fn count(index_file: IndexFile) -> Int
pub fn get(index_file: IndexFile, index: Int) -> Result(
  Index,
  Reason,
)
pub fn get_next(index_file: IndexFile) -> Result(Index, Reason)
pub fn open(path: String) -> Result(IndexFile, Reason)
pub fn set_pos(index_file: IndexFile, index: Int) -> Result(
  Int,
  Reason,
)
Search Document