@@ -7,6 +7,9 @@ mod segment;
77use disk:: DiskHandler ;
88use segment:: Segment ;
99
10+ // asdsa
11+ /// asdsadsa
12+
1013/// The log which can store commits in memory, and push them onto disk when needed, as well as read
1114/// from disk any valid segment. See [`Self::new`] for more information on how exactly log is
1215/// stored onto disk.
@@ -24,17 +27,17 @@ pub struct CommitLog {
2427 /// well as last segment in memory.
2528 tail : u64 ,
2629 /// Maximum size of any segment in memory.
27- max_segment_size : u64 ,
30+ max_segment_size : usize ,
2831 /// Maximum number of segments in memory, apart from the active segment.
29- max_segments : u64 ,
32+ max_segments : usize ,
3033 /// The active segment, to which incoming [`Bytes`] are appended to. Note that the bytes are
3134 /// themselves not mutable.
3235 active_segment : Segment ,
3336 /// Total size of active segment, used for enforcing the contraints.
3437 segments : VecDeque < Segment > ,
3538 /// Total size of segments in memory apart from active_segment, used for enforcing the
3639 /// contraints.
37- segments_size : u64 ,
40+ segments_size : usize ,
3841 /// A set of opened file handles to all the segments stored onto the disk. This is optional.
3942 disk_handler : Option < DiskHandler > ,
4043}
@@ -45,7 +48,7 @@ impl CommitLog {
4548 /// `self.head` will be removed. If a valid path is passed, the directory will be created if
4649 /// does not exist, and the segment at `self.head` will be stored onto disk instead of simply
4750 /// being deleted.
48- pub fn new ( max_segment_size : u64 , max_segments : u64 , dir : Option < PathBuf > ) -> io:: Result < Self > {
51+ pub fn new ( max_segment_size : usize , max_segments : usize , dir : Option < PathBuf > ) -> io:: Result < Self > {
4952 if max_segment_size < 1024 {
5053 return Err ( io:: Error :: new (
5154 io:: ErrorKind :: InvalidInput ,
@@ -116,7 +119,7 @@ impl CommitLog {
116119
117120 fn apply_retention ( & mut self ) -> io:: Result < ( ) > {
118121 if self . active_segment . size ( ) >= self . max_segment_size {
119- if self . segments . len ( ) as u64 >= self . max_segments {
122+ if self . segments . len ( ) >= self . max_segments {
120123 // TODO: unwrap might cause error if self.max_segments == 0
121124 let removed_segment = self . segments . pop_front ( ) . unwrap ( ) ;
122125 self . segments_size -= removed_segment. size ( ) ;
0 commit comments