Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/catalog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub mod model;
pub mod query;
pub mod rules;
pub mod safe_file;
pub mod segments;
pub mod stacks;
pub mod store;
pub mod tally;
Expand Down Expand Up @@ -1504,6 +1505,8 @@ mod tests_rule_order;
#[cfg(test)]
mod tests_scale;
#[cfg(test)]
mod tests_segments;
#[cfg(test)]
mod tests_tally;
#[cfg(test)]
mod tests_torn_append;
18 changes: 18 additions & 0 deletions crates/catalog/src/segments.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//! Where the segment files of a snapshot in several files will be: in a folder of the library's
//! own, named `segments/<first id>-<seq>.json`. The stores ([`crate::store`]) know these names:
//! they make the folder, list its files and sync it. Nothing writes or reads segments yet: what
//! they hold, and how they are written and read, come with the catalog format that uses them.

/// The folder in the library that holds the segment files.
pub const SEGMENT_DIR: &str = "segments";
/// Segment files are named `segments/<first id>-<seq>.json`: every one starts with this, and
/// ends with [`SEGMENT_SUFFIX`]. (A file an interrupted write left is the same name plus `.tmp`,
/// and is listed under this prefix too.)
pub const SEGMENT_PREFIX: &str = "segments/";
/// Segments are JSON, and say so.
pub const SEGMENT_SUFFIX: &str = ".json";

/// The name of the segment file `<stem>.json` in the segments folder (`stem`: `<first id>-<seq>`).
pub fn segment_file(stem: &str) -> String {
format!("{SEGMENT_PREFIX}{stem}{SEGMENT_SUFFIX}")
}
Loading
Loading