Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
rust-rocksdb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangzongwu
rust-rocksdb
Commits
46cf7a08
Unverified
Commit
46cf7a08
authored
Sep 06, 2021
by
Wallace
Committed by
GitHub
Sep 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ingest L0 bug (#662)
* fix ingest L0 bug Signed-off-by:
Little-Wallace
<
bupt2013211450@gmail.com
>
parent
f0ea86d8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
+69
-0
rocksdb.rs
src/rocksdb.rs
+69
-0
No files found.
src/rocksdb.rs
View file @
46cf7a08
...
@@ -3634,4 +3634,73 @@ mod test {
...
@@ -3634,4 +3634,73 @@ mod test {
}
}
});
});
}
}
#[test]
fn
test_ingest_multiple_file
()
{
let
path_dir
=
tempdir_with_prefix
(
"_test_ingest_multiple_file"
);
let
root_path
=
path_dir
.path
();
let
db_path
=
root_path
.join
(
"db"
);
let
path_str
=
db_path
.to_str
()
.unwrap
();
let
cfs
=
[
"default"
];
let
mut
opts
=
DBOptions
::
new
();
opts
.create_if_missing
(
true
);
let
db
=
DB
::
open_cf
(
opts
,
path_str
,
cfs
.iter
()
.map
(|
cf
|
{
let
mut
opt
=
ColumnFamilyOptions
::
new
();
opt
.set_force_consistency_checks
(
true
);
(
*
cf
,
opt
)
})
.collect
(),
)
.unwrap
();
let
wb
=
WriteBatch
::
new
();
for
i
in
1000
..
5000
{
let
v
=
i
.to_string
();
wb
.put
(
v
.as_bytes
(),
v
.as_bytes
())
.unwrap
();
if
i
%
1000
==
100
{
db
.write
(
&
wb
)
.unwrap
();
wb
.clear
();
}
}
{
db
.flush
(
true
)
.unwrap
();
}
assert_eq!
(
1
,
db
.get_property_int_cf
(
db
.cf_handle
(
"default"
)
.unwrap
(),
"rocksdb.num-files-at-level0"
)
.unwrap
()
);
let
sst_path1
=
root_path
.join
(
"sst1"
);
let
p1
=
sst_path1
.to_str
()
.unwrap
();
let
sst_path2
=
root_path
.join
(
"sst2"
);
let
p2
=
sst_path2
.to_str
()
.unwrap
();
let
mut
opt
=
ColumnFamilyOptions
::
new
();
opt
.set_force_consistency_checks
(
true
);
let
mut
sst1
=
SstFileWriter
::
new
(
EnvOptions
::
new
(),
opt
.clone
());
let
mut
sst2
=
SstFileWriter
::
new
(
EnvOptions
::
new
(),
opt
.clone
());
sst1
.open
(
p1
)
.unwrap
();
sst2
.open
(
p2
)
.unwrap
();
for
i
in
1001
..
2000
{
let
v
=
i
.to_string
();
sst1
.put
(
v
.as_bytes
(),
v
.as_bytes
())
.unwrap
();
}
sst1
.finish
()
.unwrap
();
for
i
in
2001
..
3000
{
let
v
=
i
.to_string
();
sst2
.put
(
v
.as_bytes
(),
v
.as_bytes
())
.unwrap
();
}
sst2
.finish
()
.unwrap
();
let
mut
ingest_opt
=
IngestExternalFileOptions
::
new
();
ingest_opt
.move_files
(
true
);
db
.ingest_external_file_cf
(
db
.cf_handle
(
"default"
)
.unwrap
(),
&
ingest_opt
,
&
[
p1
,
p2
])
.unwrap
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment