krishvishal commented on code in PR #2916:
URL: https://github.com/apache/iggy/pull/2916#discussion_r2936495024
##########
core/journal/src/lib.rs:
##########
@@ -30,16 +34,40 @@ where
fn header(&self, idx: usize) -> Option<Self::HeaderRef<'_>>;
fn previous_header(&self, header: &Self::Header) ->
Option<Self::HeaderRef<'_>>;
- fn append(&self, entry: Self::Entry) -> impl Future<Output = ()>;
+ fn append(&self, entry: Self::Entry) -> impl Future<Output =
io::Result<()>>;
fn entry(&self, header: &Self::Header) -> impl Future<Output =
Option<Self::Entry>>;
+
+ /// Advance the snapshot watermark so entries at or below `op` may be
+ /// evicted from the journal's in-memory index. The default is a no-op
+ /// for journals that do not require this watermark.
+ fn set_snapshot_op(&self, _op: u64) {}
+
+ /// Number of entries that can be appended before the journal would need
+ /// to evict un-snapshotted slots. Returns `None` for journals that don't
persist to disk.
+ fn remaining_capacity(&self) -> Option<usize> {
+ None
+ }
+
+ /// Remove snapshotted entries from the WAL to reclaim disk space.
+ /// The default is a no-op for journals that do not persist to disk.
+ ///
+ /// # Errors
+ /// Returns an I/O error if compaction fails.
+ fn compact(&self) -> impl Future<Output = io::Result<()>> {
+ async { Ok(()) }
+ }
}
// TODO: Move to other crate.
pub trait Storage {
type Buffer;
- fn write(&self, buf: Self::Buffer) -> impl Future<Output = usize>;
- fn read(&self, offset: usize, buffer: Self::Buffer) -> impl Future<Output
= Self::Buffer>;
+ fn write(&self, buf: Self::Buffer) -> impl Future<Output =
io::Result<usize>>;
Review Comment:
Done.
##########
core/journal/src/file_storage.rs:
##########
@@ -0,0 +1,137 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::Storage;
+use compio::buf::IoBuf;
+use compio::io::{AsyncReadAtExt, AsyncWriteAtExt};
+use std::cell::{Cell, RefCell};
+use std::io;
+use std::path::{Path, PathBuf};
+
+/// File-backed storage implementing the `Storage` trait.
+pub struct FileStorage {
+ file: RefCell<compio::fs::File>,
+ write_offset: Cell<u64>,
+ path: PathBuf,
+}
+
+#[allow(clippy::future_not_send, clippy::await_holding_refcell_ref)]
Review Comment:
Done.
##########
core/journal/src/file_storage.rs:
##########
@@ -0,0 +1,137 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::Storage;
+use compio::buf::IoBuf;
+use compio::io::{AsyncReadAtExt, AsyncWriteAtExt};
+use std::cell::{Cell, RefCell};
+use std::io;
+use std::path::{Path, PathBuf};
+
+/// File-backed storage implementing the `Storage` trait.
+pub struct FileStorage {
+ file: RefCell<compio::fs::File>,
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]