File tree Expand file tree Collapse file tree 4 files changed +54
-4
lines changed Expand file tree Collapse file tree 4 files changed +54
-4
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,4 @@ Cargo.lock
21
21
.data
22
22
23
23
/old_ *
24
+ .test
Original file line number Diff line number Diff line change 2
2
name = " fjall"
3
3
description = " LSM-based key-value storage engine"
4
4
license = " MIT OR Apache-2.0"
5
- version = " 0.6.1 "
5
+ version = " 0.6.2 "
6
6
edition = " 2021"
7
7
rust-version = " 1.74.0"
8
8
readme = " README.md"
@@ -26,11 +26,12 @@ segment_history = ["lsm-tree/segment_history"]
26
26
[dependencies ]
27
27
byteorder = " 1.5.0"
28
28
crc32fast = " 1.3.2"
29
- lsm-tree = { version = " 0.6.1 " , default-features = false }
29
+ lsm-tree = { version = " 0.6.2 " , default-features = false }
30
30
log = " 0.4.20"
31
31
std-semaphore = " 0.1.0"
32
32
tempfile = " 3.9.0"
33
33
fs_extra = " 1.3.0"
34
+ path-absolutize = " 3.1.1"
34
35
35
36
[dev-dependencies ]
36
37
criterion = { version = " 0.5.1" , features = [" html_reports" ] }
Original file line number Diff line number Diff line change 1
1
use crate :: { journal:: shard:: RecoveryMode , Keyspace } ;
2
2
use lsm_tree:: { descriptor_table:: FileDescriptorTable , BlockCache } ;
3
+ use path_absolutize:: Absolutize ;
3
4
use std:: {
4
5
path:: { Path , PathBuf } ,
5
6
sync:: Arc ,
6
7
} ;
7
8
9
+ fn absolute_path < P : AsRef < Path > > ( path : P ) -> PathBuf {
10
+ // TODO: replace with https://doc.rust-lang.org/std/path/fn.absolute.html once stable
11
+ path. as_ref ( )
12
+ . absolutize ( )
13
+ . expect ( "should be absolute path" )
14
+ . into ( )
15
+ }
16
+
8
17
/// Global keyspace configuration
9
18
#[ derive( Clone ) ]
10
19
pub struct Config {
@@ -50,7 +59,7 @@ impl Default for Config {
50
59
. max ( 1 ) ;
51
60
52
61
Self {
53
- path : ".fjall_data" . into ( ) ,
62
+ path : absolute_path ( ".fjall_data" ) ,
54
63
block_cache : Arc :: new ( BlockCache :: with_capacity_bytes ( /* 16 MiB */ 16 * 1_024 * 1_024 ) ) ,
55
64
descriptor_table : Arc :: new ( FileDescriptorTable :: new ( 960 , 4 ) ) ,
56
65
max_write_buffer_size_in_bytes : 64 * 1_024 * 1_024 ,
@@ -67,7 +76,7 @@ impl Config {
67
76
/// Creates a new configuration
68
77
pub fn new < P : AsRef < Path > > ( path : P ) -> Self {
69
78
Self {
70
- path : path . as_ref ( ) . into ( ) ,
79
+ path : absolute_path ( path ) ,
71
80
..Default :: default ( )
72
81
}
73
82
}
Original file line number Diff line number Diff line change
1
+ use fjall:: Config ;
2
+ use std:: time:: Duration ;
3
+ use test_log:: test;
4
+
5
+ #[ test]
6
+ fn recover_from_different_folder ( ) -> fjall:: Result < ( ) > {
7
+ if std:: path:: Path :: new ( ".test" ) . try_exists ( ) ? {
8
+ std:: fs:: remove_dir_all ( ".test" ) ?;
9
+ }
10
+
11
+ let folder = ".test/asd" ;
12
+
13
+ {
14
+ let keyspace = Config :: new ( folder) . open ( ) ?;
15
+ let partition = keyspace. open_partition ( "default" , Default :: default ( ) ) ?;
16
+
17
+ partition. insert ( "abc" , "def" ) ?;
18
+ partition. insert ( "wqewe" , "def" ) ?;
19
+ partition. insert ( "ewewq" , "def" ) ?;
20
+ partition. insert ( "asddas" , "def" ) ?;
21
+ partition. insert ( "ycxycx" , "def" ) ?;
22
+ partition. insert ( "asdsda" , "def" ) ?;
23
+ partition. insert ( "wewqe" , "def" ) ?;
24
+ }
25
+
26
+ let absolute_folder = std:: path:: Path :: new ( folder) . canonicalize ( ) ?;
27
+
28
+ std:: fs:: create_dir_all ( ".test/def" ) ?;
29
+ std:: env:: set_current_dir ( ".test/def" ) ?;
30
+
31
+ for _ in 0 ..10 {
32
+ let _keyspace = Config :: new ( & absolute_folder)
33
+ . max_write_buffer_size ( 1 )
34
+ . open ( ) ?;
35
+ std:: thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
36
+ }
37
+
38
+ Ok ( ( ) )
39
+ }
You can’t perform that action at this time.
0 commit comments