Skip to content

Commit

Permalink
remove old debug feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed Jun 27, 2024
1 parent 825026f commit a73df39
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 129 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ Cargo.lock
.data
/old_*
.test*
segment_history.jsonl
.block_index_test
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "lsm-tree"
description = "A K.I.S.S. implementation of log-structured merge trees (LSM-trees/LSMTs)"
license = "MIT OR Apache-2.0"
version = "1.1.3"
version = "1.2.0"
edition = "2021"
rust-version = "1.74.0"
readme = "README.md"
Expand All @@ -19,7 +19,6 @@ path = "src/lib.rs"
[features]
default = []
bloom = ["dep:seahash"]
segment_history = ["dep:serde", "dep:serde_json"]
all = ["bloom"]

[dependencies]
Expand All @@ -33,8 +32,6 @@ path-absolutize = "3.1.1"
quick_cache = { version = "0.5.1", default-features = false, features = [] }
seahash = { version = "4.1.0", optional = true }
self_cell = "1.0.4"
serde = { version = "1.0.200", features = ["derive", "rc"], optional = true }
serde_json = { version = "1.0.116", optional = true }
tempfile = "3.10.1"

[dev-dependencies]
Expand Down
1 change: 1 addition & 0 deletions segment_history.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"event":"create_new","levels":[[],[],[],[],[],[],[]],"time_ms":1719499946451,"time_unix":1719499946}
4 changes: 0 additions & 4 deletions src/key_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ use std::{

/// A key range in the format of [min, max] (inclusive on both sides)
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(
feature = "segment_history",
derive(serde::Deserialize, serde::Serialize)
)]
pub struct KeyRange((UserKey, UserKey));

impl std::ops::Deref for KeyRange {
Expand Down
81 changes: 1 addition & 80 deletions src/levels/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
pub mod iter;
mod level;

#[cfg(feature = "segment_history")]
mod segment_history;

#[cfg(feature = "segment_history")]
use crate::time::unix_timestamp;

use self::level::Level;
use crate::{
file::rewrite_atomic,
Expand Down Expand Up @@ -41,9 +35,6 @@ pub struct LevelManifest {
/// While consuming segments (because of compaction) they will not appear in the list of segments
/// as to not cause conflicts between multiple compaction threads (compacting the same segments)
hidden_set: HiddenSet,

#[cfg(feature = "segment_history")]
segment_history_writer: segment_history::Writer,
}

impl std::fmt::Display for LevelManifest {
Expand Down Expand Up @@ -124,42 +115,12 @@ impl LevelManifest {
path: path.as_ref().to_path_buf(),
levels,
hidden_set: HashSet::with_capacity(10),

#[cfg(feature = "segment_history")]
segment_history_writer: segment_history::Writer::new()?,
};
Self::write_to_disk(path, &levels.levels)?;

#[cfg(feature = "segment_history")]
levels.write_segment_history_entry("create_new")?;

Ok(levels)
}

#[cfg(feature = "segment_history")]
fn write_segment_history_entry(&mut self, event: &str) -> crate::Result<()> {
let ts = unix_timestamp();

let line = serde_json::to_string(&serde_json::json!({
"time_unix": ts.as_secs(),
"time_ms": ts.as_millis(),
"event": event,
"levels": self.levels.iter().map(|level| {
level.segments
.iter()
.map(|segment| serde_json::json!({
"id": segment.metadata.id,
"metadata": segment.metadata.clone(),
"hidden": self.hidden_set.contains(&segment.metadata.id)
}))
.collect::<Vec<_>>()
}).collect::<Vec<_>>()
}))
.expect("Segment history write failed");

self.segment_history_writer.write(&line)
}

pub(crate) fn load_level_manifest<P: AsRef<Path>>(
path: P,
) -> crate::Result<Vec<Vec<SegmentId>>> {
Expand Down Expand Up @@ -234,20 +195,13 @@ impl LevelManifest {

let levels = Self::resolve_levels(level_manifest, &segments);

// NOTE: See segment_history feature
#[allow(unused_mut)]
let mut levels = Self {
let levels = Self {
levels,
hidden_set: HashSet::with_capacity(10),
path: path.as_ref().to_path_buf(),

#[cfg(feature = "segment_history")]
segment_history_writer: segment_history::Writer::new()?,
};

#[cfg(feature = "segment_history")]
levels.write_segment_history_entry("load_from_disk")?;

Ok(levels)
}

Expand Down Expand Up @@ -322,20 +276,8 @@ impl LevelManifest {
.expect("level should exist");

level.insert(segment);

#[cfg(feature = "segment_history")]
self.write_segment_history_entry("insert").ok();
}

/* pub(crate) fn remove(&mut self, segment_id: SegmentId) {
for level in &mut self.levels {
level.remove(segment_id);
}
#[cfg(feature = "segment_history")]
self.write_segment_history_entry("remove").ok();
} */

/// Returns `true` if there are no segments
#[must_use]
pub fn is_empty(&self) -> bool {
Expand Down Expand Up @@ -426,34 +368,16 @@ impl LevelManifest {
output
}

/* pub(crate) fn get_visible_segments(&self) -> HashMap<SegmentId, Arc<Segment>> {
let mut output = HashMap::new();
for segment in self.iter() {
if !self.hidden_set.contains(&segment.metadata.id) {
output.insert(segment.metadata.id, segment);
}
}
output
} */

pub(crate) fn show_segments(&mut self, keys: &[SegmentId]) {
for key in keys {
self.hidden_set.remove(key);
}

#[cfg(feature = "segment_history")]
self.write_segment_history_entry("show").ok();
}

pub(crate) fn hide_segments(&mut self, keys: &[SegmentId]) {
for key in keys {
self.hidden_set.insert(*key);
}

#[cfg(feature = "segment_history")]
self.write_segment_history_entry("hide").ok();
}
}

Expand Down Expand Up @@ -586,9 +510,6 @@ mod tests {
hidden_set: HashSet::default(),
levels: Vec::default(),
path: "a".into(),

#[cfg(feature = "segment_history")]
segment_history_writer: super::segment_history::Writer::new()?,
};

let mut bytes = vec![];
Expand Down
28 changes: 0 additions & 28 deletions src/levels/segment_history.rs

This file was deleted.

4 changes: 0 additions & 4 deletions src/segment/meta/compression.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(
feature = "segment_history",
derive(serde::Deserialize, serde::Serialize)
)]
#[allow(clippy::module_name_repetitions)]
pub enum CompressionType {
Lz4,
Expand Down
4 changes: 0 additions & 4 deletions src/segment/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ pub const METADATA_HEADER_MAGIC: &[u8] = &[b'F', b'J', b'L', b'L', b'S', b'M', b
pub type SegmentId = u64;

#[derive(Clone, Debug, Eq, PartialEq)]
#[cfg_attr(
feature = "segment_history",
derive(serde::Deserialize, serde::Serialize)
)]
pub struct Metadata {
/// Segment ID
pub id: SegmentId,
Expand Down
4 changes: 0 additions & 4 deletions src/segment/meta/table_type.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(
feature = "segment_history",
derive(serde::Deserialize, serde::Serialize)
)]
pub enum TableType {
Block,
}
Expand Down

0 comments on commit a73df39

Please sign in to comment.