Commit af522bc2 authored by Ranadeep Biswas's avatar Ranadeep Biswas
Browse files

Support to parse YAML history

parent bae237e2
......@@ -8,6 +8,10 @@ mysql = "*"
rand = "*"
clap = "*"
ansi_term = "*"
serde = "*"
serde_derive = "*"
serde_json = "*"
serde_yaml = "*"
[profile.release]
opt-level = 3
- - events:
- id: 1
write: true
variable: 0
value: 1
success: true
success: true
- - events:
- id: 2
write: false
variable: 0
value: 1
success: true
- id: 3
write: true
variable: 1
value: 3
success: true
success: true
- - events:
- id: 4
write: false
variable: 0
value: 0
success: true
- id: 5
write: false
variable: 1
value: 3
success: true
success: true
extern crate rand;
extern crate ansi_term;
extern crate rand;
pub mod consistency;
pub mod db;
pub mod verifier;
extern crate serde;
extern crate serde_json;
extern crate serde_yaml;
#[macro_use]
extern crate serde_derive;
extern crate clap;
extern crate dbcop;
extern crate serde_yaml;
use clap::{App, Arg};
use std::fs::File;
use std::io::Read;
use dbcop::db::history::Transaction;
use dbcop::verifier::transactional_history_verify;
fn main() {
let matches = App::new("dbcop")
.version("1.0")
.author("Ranadeep")
.about("verifies a history")
.arg(
Arg::with_name("yaml_file")
.long("yaml")
.short("y")
.value_name("YAML_FILE")
.takes_value(true)
.required(true)
.help("yaml file containing history"),
).get_matches();
let yaml_path = matches.value_of("yaml_file").unwrap();
let mut bytes = Vec::new();
let mut file = File::open(yaml_path).unwrap();
file.read_to_end(&mut bytes).unwrap();
let hist: Vec<Vec<Transaction>> = serde_yaml::from_slice(&bytes).unwrap();
println!("{:?}", hist);
let mut id_vec = Vec::new();
id_vec.push((0, 0, 0));
for (i_node, session) in hist.iter().enumerate() {
for (i_transaction, transaction) in session.iter().enumerate() {
for (i_event, event) in transaction.events.iter().enumerate() {
assert_eq!(event.id, id_vec.len());
id_vec.push((i_node + 1, i_transaction, i_event));
}
}
}
transactional_history_verify(&hist, &id_vec);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment