Skip to content

Commit 1ff48e0

Browse files
committed
remove find_segments
1 parent 8555dab commit 1ff48e0

3 files changed

Lines changed: 8 additions & 87 deletions

File tree

libsql-wal/src/storage/backend/mod.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,6 @@ pub trait Backend: Send + Sync + 'static {
8484
key: SegmentKey,
8585
) -> impl Future<Output = Result<impl FileExt>> + Send;
8686

87-
// /// Fetch a segment for `namespace` containing `frame_no`, and writes it to `dest`.
88-
async fn fetch_segment(
89-
&self,
90-
config: &Self::Config,
91-
namespace: &NamespaceName,
92-
frame_no: u64,
93-
dest_path: &Path,
94-
) -> Result<Map<Arc<[u8]>>>;
95-
9687
/// Fetch meta for `namespace`
9788
fn meta(
9889
&self,
@@ -133,18 +124,6 @@ impl<T: Backend> Backend for Arc<T> {
133124
.store(config, meta, segment_data, segment_index)
134125
}
135126

136-
async fn fetch_segment(
137-
&self,
138-
config: &Self::Config,
139-
namespace: &NamespaceName,
140-
frame_no: u64,
141-
dest_path: &Path,
142-
) -> Result<fst::Map<Arc<[u8]>>> {
143-
self.as_ref()
144-
.fetch_segment(config, namespace, frame_no, dest_path)
145-
.await
146-
}
147-
148127
async fn meta(&self, config: &Self::Config, namespace: &NamespaceName) -> Result<DbMeta> {
149128
self.as_ref().meta(config, namespace).await
150129
}

libsql-wal/src/storage/backend/s3.rs

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ pub struct S3Backend<IO> {
3838
client: Client,
3939
default_config: Arc<S3Config>,
4040
io: IO,
41-
}
42-
43-
impl S3Backend<StdIO> {
41+
} impl S3Backend<StdIO> {
4442
pub async fn from_sdk_config(
4543
aws_config: SdkConfig,
4644
bucket: String,
@@ -581,35 +579,6 @@ where
581579
Ok(())
582580
}
583581

584-
async fn fetch_segment(
585-
&self,
586-
config: &Self::Config,
587-
namespace: &NamespaceName,
588-
frame_no: u64,
589-
dest_path: &Path,
590-
) -> Result<fst::Map<Arc<[u8]>>> {
591-
let folder_key = FolderKey {
592-
cluster_id: &config.cluster_id,
593-
namespace: &namespace,
594-
};
595-
596-
let Some(segment_key) = self
597-
.find_segment_by_frame_no(config, &folder_key, frame_no)
598-
.await?
599-
else {
600-
return Err(Error::FrameNotFound(frame_no));
601-
};
602-
603-
if segment_key.includes(frame_no) {
604-
// TODO: make open async
605-
let file = self.io.open(false, false, true, dest_path)?;
606-
self.fetch_segment_from_key(config, &folder_key, &segment_key, &file)
607-
.await
608-
} else {
609-
return Err(Error::FrameNotFound(frame_no));
610-
}
611-
}
612-
613582
async fn meta(
614583
&self,
615584
config: &Self::Config,
@@ -832,7 +801,6 @@ mod tests {
832801
use fst::MapBuilder;
833802
use s3s::auth::SimpleAuth;
834803
use s3s::service::{S3ServiceBuilder, SharedS3Service};
835-
use tempfile::NamedTempFile;
836804
use uuid::Uuid;
837805

838806
use crate::io::StdIO;
@@ -902,7 +870,7 @@ mod tests {
902870
SegmentMeta {
903871
namespace: ns.clone(),
904872
segment_id: Uuid::new_v4(),
905-
start_frame_no: 0u64.into(),
873+
start_frame_no: 1u64.into(),
906874
end_frame_no: 64u64.into(),
907875
segment_timestamp: Utc::now(),
908876
},
@@ -937,30 +905,14 @@ mod tests {
937905
let db_meta = storage.meta(&s3_config, &ns).await.unwrap();
938906
assert_eq!(db_meta.max_frame_no, 128);
939907

940-
let tmp = NamedTempFile::new().unwrap();
941-
942-
let index = storage
943-
.fetch_segment(&s3_config, &ns, 1, tmp.path())
908+
let key = storage
909+
.find_segment(&s3_config, &ns, FindSegmentReq::EndFrameNoLessThan(65))
944910
.await
945911
.unwrap();
912+
assert_eq!(key.start_frame_no, 1);
913+
assert_eq!(key.end_frame_no, 64);
914+
915+
let index = storage.fetch_segment_index(&s3_config, &ns, &key).await.unwrap();
946916
assert_eq!(index.get(42u32.to_be_bytes()).unwrap(), 42);
947-
948-
let index = storage
949-
.fetch_segment(&s3_config, &ns, 63, tmp.path())
950-
.await
951-
.unwrap();
952-
assert_eq!(index.get(42u32.to_be_bytes()).unwrap(), 42);
953-
954-
let index = storage
955-
.fetch_segment(&s3_config, &ns, 64, tmp.path())
956-
.await
957-
.unwrap();
958-
assert_eq!(index.get(44u32.to_be_bytes()).unwrap(), 44);
959-
960-
let index = storage
961-
.fetch_segment(&s3_config, &ns, 65, tmp.path())
962-
.await
963-
.unwrap();
964-
assert_eq!(index.get(44u32.to_be_bytes()).unwrap(), 44);
965917
}
966918
}

libsql-wal/src/storage/job.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,6 @@ mod test {
266266
Ok(std::fs::File::open("").unwrap())
267267
}
268268

269-
async fn fetch_segment(
270-
&self,
271-
_config: &Self::Config,
272-
_namespace: &NamespaceName,
273-
_frame_no: u64,
274-
_dest_path: &std::path::Path,
275-
) -> Result<fst::Map<Arc<[u8]>>> {
276-
todo!()
277-
}
278-
279269
fn list_segments<'a>(
280270
&'a self,
281271
_config: Self::Config,

0 commit comments

Comments
 (0)