Skip to content

Commit

Permalink
Migrate to GitQL 0.32.0 | Support Script mode
Browse files Browse the repository at this point in the history
  • Loading branch information
AmrDeveloper committed Nov 30, 2024
1 parent 73b4a9c commit f051b79
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 44 deletions.
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ categories = ["command-line-utilities"]
exclude = [".github/**", "docs/**", "media/**", "scripts/**"]

[dependencies]
gitql-core = "0.8.0"
gitql-std = "0.8.0"
gitql-ast = "0.28.0"
gitql-parser = "0.30.0"
gitql-engine = "0.31.0"
gitql-cli = "0.31.0"
gitql-core = "0.9.0"
gitql-std = "0.9.0"
gitql-ast = "0.29.0"
gitql-parser = "0.31.0"
gitql-engine = "0.32.0"
gitql-cli = "0.32.0"
inkwell = { version = "0.5.0", features = ["llvm16-0"] }
lineeditor = "0.4.1"
dyn-clone = "1.0.17"
Expand Down
1 change: 1 addition & 0 deletions src/ir/module_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use super::data_provider::LLVM_CONTEXT;
use super::data_provider::LLVM_MODULES;

pub fn parse_llvm_modules(paths: &[String]) -> Result<(), String> {
#[allow(static_mut_refs)]
unsafe {
LLVM_MODULES.clear();
for path in paths.iter() {
Expand Down
53 changes: 28 additions & 25 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use gitql_engine::engine;
use gitql_engine::engine::EvaluationResult::SelectedGroups;
use gitql_parser::diagnostic::Diagnostic;
use gitql_parser::parser;
use gitql_parser::tokenizer;
use gitql_parser::tokenizer::Tokenizer;
use gitql_std::aggregation::aggregation_function_signatures;
use gitql_std::aggregation::aggregation_functions;
use ir::data_provider::LLVMIRDataProvider;
Expand Down Expand Up @@ -206,7 +206,7 @@ fn execute_llql_query(
reporter: &mut DiagnosticReporter,
) {
let front_start = std::time::Instant::now();
let tokenizer_result = tokenizer::tokenize(query.clone());
let tokenizer_result = Tokenizer::tokenize(query.clone());
if tokenizer_result.is_err() {
let diagnostic = tokenizer_result.err().unwrap();
reporter.report_diagnostic(&query, *diagnostic);
Expand All @@ -232,36 +232,39 @@ fn execute_llql_query(
let evaluation_result = engine::evaluate(env, provider, query_node);
let engine_duration = engine_start.elapsed();

// Report Runtime exceptions if they exists
// Report Runtime exceptions if they exists
if evaluation_result.is_err() {
reporter.report_diagnostic(
&query,
Diagnostic::exception(&evaluation_result.err().unwrap()),
);
let exception = Diagnostic::exception(&evaluation_result.err().unwrap());
reporter.report_diagnostic(&query, exception);
return;
}

// Render the result only if they are selected groups not any other statement
let mut rows_count = 0;
let engine_result = evaluation_result.ok().unwrap();
if let SelectedGroups(mut groups) = engine_result {
rows_count += groups.len();
let printer: Box<dyn OutputPrinter> = match arguments.output_format {
OutputFormat::Render => {
Box::new(TablePrinter::new(arguments.pagination, arguments.page_size))
}
OutputFormat::JSON => Box::new(JSONPrinter),
OutputFormat::CSV => Box::new(CSVPrinter),
};
printer.print(&mut groups);
}
let printer: Box<dyn OutputPrinter> = match arguments.output_format {
OutputFormat::Render => {
Box::new(TablePrinter::new(arguments.pagination, arguments.page_size))
}
OutputFormat::JSON => Box::new(JSONPrinter {}),
OutputFormat::CSV => Box::new(CSVPrinter {}),
};

if arguments.analysis {
let total_time = front_duration + engine_duration;
println!(
"{} row in set (total: {:?}, front: {:?}, engine: {:?})",
rows_count, total_time, front_duration, engine_duration
);
// Render the result only if they are selected groups not any other statement
let evaluations_results = evaluation_result.ok().unwrap();
for evaluation_result in evaluations_results {
let mut rows_count = 0;
if let SelectedGroups(mut groups) = evaluation_result {
rows_count += groups.len();
printer.print(&mut groups);
}

if arguments.analysis {
let total_time = front_duration + engine_duration;
println!(
"{} row in set (total: {:?}, front: {:?}, engine: {:?})",
rows_count, total_time, front_duration, engine_duration
);
}
}
}

Expand Down

0 comments on commit f051b79

Please sign in to comment.