@@ -8,6 +8,10 @@ use serde::{Deserialize, Serialize};
88
99const MB : usize = 1024 * 1024 ;
1010
11+ // restore and graceful shutdown options
12+ const RESTORE : bool = false ;
13+ const GRACEFUL_SHUTDOWN : bool = false ;
14+
1115// defaults for hashtable
1216const HASH_POWER : u8 = 16 ;
1317const OVERFLOW_FACTOR : f64 = 1.0 ;
@@ -24,9 +28,18 @@ const COMPACT_TARGET: usize = 2;
2428const MERGE_TARGET : usize = 4 ;
2529const MERGE_MAX : usize = 8 ;
2630
27- // datapool
31+ // datapool (`Segments.data`)
2832const DATAPOOL_PATH : Option < & str > = None ;
2933
34+ // `Segments` fields
35+ const SEGMENT_FIELDS_PATH : Option < & str > = None ;
36+
37+ // ttl buckets
38+ const TTL_BUCKETS_PATH : Option < & str > = None ;
39+
40+ // hashtable
41+ const HASHTABLE_PATH : Option < & str > = None ;
42+
3043#[ derive( Copy , Clone , Debug , Serialize , Deserialize ) ]
3144pub enum Eviction {
3245 None ,
@@ -39,6 +52,14 @@ pub enum Eviction {
3952}
4053
4154// helper functions for default values
55+ fn restore ( ) -> bool {
56+ RESTORE
57+ }
58+
59+ fn graceful_shutdown ( ) -> bool {
60+ GRACEFUL_SHUTDOWN
61+ }
62+
4263fn hash_power ( ) -> u8 {
4364 HASH_POWER
4465}
@@ -75,9 +96,25 @@ fn datapool_path() -> Option<String> {
7596 DATAPOOL_PATH . map ( |v| v. to_string ( ) )
7697}
7798
99+ fn segments_fields_path ( ) -> Option < String > {
100+ SEGMENT_FIELDS_PATH . map ( |v| v. to_string ( ) )
101+ }
102+
103+ fn ttl_buckets_path ( ) -> Option < String > {
104+ TTL_BUCKETS_PATH . map ( |v| v. to_string ( ) )
105+ }
106+
107+ fn hashtable_path ( ) -> Option < String > {
108+ HASHTABLE_PATH . map ( |v| v. to_string ( ) )
109+ }
110+
78111// definitions
79112#[ derive( Serialize , Deserialize , Debug ) ]
80113pub struct Seg {
114+ #[ serde( default = "restore" ) ]
115+ restore : bool ,
116+ #[ serde( default = "graceful_shutdown" ) ]
117+ graceful_shutdown : bool ,
81118 #[ serde( default = "hash_power" ) ]
82119 hash_power : u8 ,
83120 #[ serde( default = "overflow_factor" ) ]
@@ -96,11 +133,19 @@ pub struct Seg {
96133 compact_target : usize ,
97134 #[ serde( default = "datapool_path" ) ]
98135 datapool_path : Option < String > ,
136+ #[ serde( default = "segments_fields_path" ) ]
137+ segments_fields_path : Option < String > ,
138+ #[ serde( default = "ttl_buckets_path" ) ]
139+ ttl_buckets_path : Option < String > ,
140+ #[ serde( default = "hashtable_path" ) ]
141+ hashtable_path : Option < String > ,
99142}
100143
101144impl Default for Seg {
102145 fn default ( ) -> Self {
103146 Self {
147+ restore : restore ( ) ,
148+ graceful_shutdown : graceful_shutdown ( ) ,
104149 hash_power : hash_power ( ) ,
105150 overflow_factor : overflow_factor ( ) ,
106151 heap_size : heap_size ( ) ,
@@ -110,12 +155,21 @@ impl Default for Seg {
110155 merge_max : merge_max ( ) ,
111156 compact_target : compact_target ( ) ,
112157 datapool_path : datapool_path ( ) ,
158+ segments_fields_path : segments_fields_path ( ) ,
159+ ttl_buckets_path : ttl_buckets_path ( ) ,
160+ hashtable_path : hashtable_path ( ) ,
113161 }
114162 }
115163}
116164
117165// implementation
118166impl Seg {
167+ pub fn restore ( & self ) -> bool {
168+ self . restore
169+ }
170+ pub fn graceful_shutdown ( & self ) -> bool {
171+ self . graceful_shutdown
172+ }
119173 pub fn hash_power ( & self ) -> u8 {
120174 self . hash_power
121175 }
@@ -151,6 +205,24 @@ impl Seg {
151205 pub fn datapool_path ( & self ) -> Option < PathBuf > {
152206 self . datapool_path . as_ref ( ) . map ( |v| Path :: new ( v) . to_owned ( ) )
153207 }
208+
209+ pub fn segments_fields_path ( & self ) -> Option < PathBuf > {
210+ self . segments_fields_path
211+ . as_ref ( )
212+ . map ( |v| Path :: new ( v) . to_owned ( ) )
213+ }
214+
215+ pub fn ttl_buckets_path ( & self ) -> Option < PathBuf > {
216+ self . ttl_buckets_path
217+ . as_ref ( )
218+ . map ( |v| Path :: new ( v) . to_owned ( ) )
219+ }
220+
221+ pub fn hashtable_path ( & self ) -> Option < PathBuf > {
222+ self . hashtable_path
223+ . as_ref ( )
224+ . map ( |v| Path :: new ( v) . to_owned ( ) )
225+ }
154226}
155227
156228// trait definitions
0 commit comments