Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Buffer Size Parameter to dump create #234

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions replibyte/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ pub struct DumpCreateArgs {
/// import dump from stdin
#[clap(name = "input", short, long, requires = "source_type")]
pub input: bool,
#[clap(name = "dump_chunk_size", short, long, default_value_t = 100, value_name = "dump_chunk_size", help = "Dump Chunk Size in MB")]
pub dump_chunk_size: usize,
#[clap(short, long, parse(from_os_str), value_name = "dump file")]
/// dump file
pub file: Option<PathBuf>,
Expand Down
1 change: 1 addition & 0 deletions replibyte/src/commands/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ where
skip_config: &skip_config,
database_subset: &source.database_subset,
only_tables: &only_tables_config,
dump_chunk_size: &args.dump_chunk_size,
};

match args.source_type.as_ref().map(|x| x.as_str()) {
Expand Down
1 change: 1 addition & 0 deletions replibyte/src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ pub struct SourceOptions<'a> {
pub skip_config: &'a Vec<SkipConfig>,
pub database_subset: &'a Option<DatabaseSubsetConfig>,
pub only_tables: &'a Vec<OnlyTablesConfig>,
pub dump_chunk_size: &'a usize,
}
7 changes: 7 additions & 0 deletions replibyte/src/source/mongodb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ mod tests {
)
}

fn get_default_dump_chunk_size() -> usize {
100
}

#[test]
fn connect() {
let p = get_mongodb();
Expand All @@ -368,6 +372,7 @@ mod tests {
skip_config: &vec![],
database_subset: &None,
only_tables: &vec![],
dump_chunk_size: &get_default_dump_chunk_size(),
};

assert!(p.read(source_options, |_, _| {}).is_ok());
Expand All @@ -380,6 +385,7 @@ mod tests {
skip_config: &vec![],
database_subset: &None,
only_tables: &vec![],
dump_chunk_size: &get_default_dump_chunk_size(),
};

assert!(p.read(source_options, |_, _| {}).is_err());
Expand All @@ -395,6 +401,7 @@ mod tests {
skip_config: &vec![],
database_subset: &None,
only_tables: &vec![],
dump_chunk_size: &get_default_dump_chunk_size(),
};

p.read(source_options, |original_query, query| {
Expand Down
7 changes: 7 additions & 0 deletions replibyte/src/source/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ mod tests {
Mysql::new("127.0.0.1", 3306, "world", "root", "wrong_password")
}

fn get_default_dump_chunk_size() -> usize {
100
}

#[test]
fn connect() {
let mut p = get_mysql();
Expand All @@ -456,6 +460,7 @@ mod tests {
skip_config: &vec![],
database_subset: &None,
only_tables: &vec![],
dump_chunk_size: &get_default_dump_chunk_size(),
};

assert!(p.read(source_options, |_original_query, _query| {}).is_ok());
Expand All @@ -468,6 +473,7 @@ mod tests {
skip_config: &vec![],
database_subset: &None,
only_tables: &vec![],
dump_chunk_size: &get_default_dump_chunk_size(),
};
assert!(p
.read(source_options, |_original_query, _query| {})
Expand All @@ -484,6 +490,7 @@ mod tests {
skip_config: &vec![],
database_subset: &None,
only_tables: &vec![],
dump_chunk_size: &get_default_dump_chunk_size(),
};
let _ = p.read(source_options, |original_query, query| {
assert!(original_query.data().len() > 0);
Expand Down
11 changes: 11 additions & 0 deletions replibyte/src/source/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,10 @@ mod tests {
Postgres::new("localhost", 5432, "root", "root", "wrongpassword")
}

fn get_default_dump_chunk_size() -> usize {
100
}

#[test]
fn connect() {
let p = get_postgres();
Expand All @@ -581,6 +585,7 @@ mod tests {
skip_config: &vec![],
database_subset: &None,
only_tables: &vec![],
dump_chunk_size: &get_default_dump_chunk_size(),
};

assert!(p.read(source_options, |original_query, query| {}).is_ok());
Expand All @@ -593,6 +598,7 @@ mod tests {
skip_config: &vec![],
database_subset: &None,
only_tables: &vec![],
dump_chunk_size: &get_default_dump_chunk_size(),
};

assert!(p.read(source_options, |original_query, query| {}).is_err());
Expand All @@ -608,6 +614,7 @@ mod tests {
skip_config: &vec![],
database_subset: &None,
only_tables: &vec![],
dump_chunk_size: &get_default_dump_chunk_size(),
};

let _ = p.read(source_options, |original_query, query| {
Expand Down Expand Up @@ -734,6 +741,7 @@ mod tests {
skip_config: &vec![],
database_subset: &None,
only_tables: &vec![],
dump_chunk_size: &get_default_dump_chunk_size(),
};

let _ = p.read(source_options, |original_query, query| {
Expand Down Expand Up @@ -775,6 +783,7 @@ mod tests {
skip_config: &skip_config,
database_subset: &None,
only_tables: &vec![],
dump_chunk_size: &get_default_dump_chunk_size(),
};

let _ = p.read(source_options, |_original_query, query| {
Expand Down Expand Up @@ -826,6 +835,7 @@ mod tests {
passthrough_tables: None,
}),
only_tables: &vec![],
dump_chunk_size: &get_default_dump_chunk_size(),
};

let mut rows_percent_50 = vec![];
Expand Down Expand Up @@ -863,6 +873,7 @@ mod tests {
passthrough_tables: None,
}),
only_tables: &vec![],
dump_chunk_size: &get_default_dump_chunk_size(),
};

let mut rows_percent_30 = vec![];
Expand Down
2 changes: 1 addition & 1 deletion replibyte/src/tasks/full_dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ where
});

// buffer of 100MB in memory to use and re-use to upload data into datastore
let buffer_size = 100 * 1024 * 1024;
let buffer_size = self.options.dump_chunk_size * 1024 * 1024;
let mut queries = vec![];
let mut consumed_buffer_size = 0usize;
let mut total_transferred_bytes = 0usize;
Expand Down