chore: deny unused results (#1825)

* chore: deny unused results

* rebase
This commit is contained in:
LFC
2023-06-27 15:33:53 +08:00
committed by GitHub
parent 03057cab6c
commit fcff66e039
247 changed files with 1209 additions and 1171 deletions

View File

@@ -110,7 +110,7 @@ def entry() -> vector[i64]:
);
let source = Arc::new(source);
// execute the script in parallel for every thread in the pool
pool.broadcast(|_| {
let _ = pool.broadcast(|_| {
let source = source.clone();
let rt = get_local_runtime().unwrap();
rt.block_on(async move {
@@ -163,44 +163,44 @@ fn criterion_benchmark(c: &mut Criterion) {
// which require a local mock library
// TODO(discord9): revisit once mock library is ready
c.bench_function("fib 20 rspy", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| fibonacci(black_box(20), "rspy"))
});
c.bench_function("fib 20 pyo3", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| fibonacci(black_box(20), "pyo3"))
});
let pool = rayon::ThreadPoolBuilder::new()
.num_threads(16)
.build()
.unwrap();
c.bench_function("par fib 20 rspy", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| parallel_fibonacci(black_box(20), "rspy", &pool))
});
c.bench_function("par fib 20 pyo3", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| parallel_fibonacci(black_box(20), "pyo3", &pool))
});
c.bench_function("loop 1M rspy", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| loop_1_million(black_box("rspy")))
});
c.bench_function("loop 1M pyo3", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| loop_1_million(black_box("pyo3")))
});
c.bench_function("api heavy rspy", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| api_heavy(black_box("rspy")))
});
c.bench_function("api heavy pyo3", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| api_heavy(black_box("pyo3")))
});
let _ = c
.bench_function("fib 20 rspy", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| fibonacci(black_box(20), "rspy"))
})
.bench_function("fib 20 pyo3", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| fibonacci(black_box(20), "pyo3"))
})
.bench_function("par fib 20 rspy", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| parallel_fibonacci(black_box(20), "rspy", &pool))
})
.bench_function("par fib 20 pyo3", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| parallel_fibonacci(black_box(20), "pyo3", &pool))
})
.bench_function("loop 1M rspy", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| loop_1_million(black_box("rspy")))
})
.bench_function("loop 1M pyo3", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| loop_1_million(black_box("pyo3")))
})
.bench_function("api heavy rspy", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| api_heavy(black_box("rspy")))
})
.bench_function("api heavy pyo3", |b| {
b.to_async(tokio::runtime::Runtime::new().unwrap())
.iter(|| api_heavy(black_box("pyo3")))
});
}
criterion_group!(benches, criterion_benchmark);

View File

@@ -51,7 +51,7 @@ impl ScriptManager {
{
let mut compiled = self.compiled.write().unwrap();
compiled.insert(name.to_string(), script.clone());
let _ = compiled.insert(name.to_string(), script.clone());
}
logging::info!("Compiled and cached script: {}", name);

View File

@@ -419,9 +419,10 @@ def test(**params) -> vector[i64]:
.compile(script, CompileContext::default())
.await
.unwrap();
let mut params = HashMap::new();
params.insert("a".to_string(), "30".to_string());
params.insert("b".to_string(), "12".to_string());
let params = HashMap::from([
("a".to_string(), "30".to_string()),
("b".to_string(), "12".to_string()),
]);
let _output = script
.execute(params, EvalContext::default())
.await

View File

@@ -292,7 +292,7 @@ fn parse_keywords(keywords: &Vec<ast::Keyword<()>>) -> Result<DecoratorArgs> {
Some(kw.location),
);
} else {
visited_key.insert(s);
let _ = visited_key.insert(s);
}
match s {
"args" => ret_args.arg_names = Some(pylist_to_vec(&kw.node.value)?),

View File

@@ -96,7 +96,7 @@ async fn integrated_py_copr_test() {
let mut actual_result = HashMap::new();
for col_sch in rb.schema.column_schemas() {
let col = rb.column_by_name(&col_sch.name).unwrap();
actual_result.insert(col_sch.name.clone(), col.clone());
let _ = actual_result.insert(col_sch.name.clone(), col.clone());
}
for (name, col) in expect_result {
let actual_col = actual_result.get(&name).unwrap_or_else(|| {

View File

@@ -156,7 +156,7 @@ fn eval_pyo3(testcase: TestCase, locals: HashMap<String, PyVector>) {
fn eval_rspy(testcase: TestCase, locals: HashMap<String, PyVector>) {
vm::Interpreter::with_init(Default::default(), |vm| {
PyVector::make_class(&vm.ctx);
let _ = PyVector::make_class(&vm.ctx);
})
.enter(|vm| {
let scope = vm.new_scope_with_builtins();

View File

@@ -998,11 +998,7 @@ pub(crate) mod greptime_builtin {
let windows = {
slices
.iter()
.zip({
let mut it = slices.iter();
it.next();
it
})
.zip(slices.iter().skip(1))
.map(|(first, second)| {
let left = comparison::gt_eq_scalar(ts, *first).map_err(arrow_error)?;
let right = comparison::lt_eq_scalar(ts, *second).map_err(arrow_error)?;

View File

@@ -39,7 +39,7 @@ use crate::python::utils::format_py_error;
fn convert_scalar_to_py_obj_and_back() {
rustpython_vm::Interpreter::with_init(Default::default(), |vm| {
// this can be in `.enter()` closure, but for clearity, put it in the `with_init()`
PyVector::make_class(&vm.ctx);
let _ = PyVector::make_class(&vm.ctx);
})
.enter(|vm| {
let col = DFColValue::Scalar(ScalarValue::Float64(Some(1.0)));
@@ -311,12 +311,11 @@ fn run_builtin_fn_testcases() {
let loc = loc.to_str().expect("Fail to parse path");
let mut file = File::open(loc).expect("Fail to open file");
let mut buf = String::new();
file.read_to_string(&mut buf)
.expect("Fail to read to string");
assert!(file.read_to_string(&mut buf).is_ok());
let testcases: Vec<TestCase> = from_ron_string(&buf).expect("Fail to convert to testcases");
let cached_vm = rustpython_vm::Interpreter::with_init(Default::default(), |vm| {
vm.add_native_module("greptime", Box::new(greptime_builtin::make_module));
PyVector::make_class(&vm.ctx);
let _ = PyVector::make_class(&vm.ctx);
});
for (idx, case) in testcases.into_iter().enumerate() {
info!("Testcase {idx} ...");
@@ -423,7 +422,7 @@ fn test_vm() {
rustpython_vm::Interpreter::with_init(Default::default(), |vm| {
vm.add_native_module("udf_builtins", Box::new(greptime_builtin::make_module));
// this can be in `.enter()` closure, but for clearity, put it in the `with_init()`
PyVector::make_class(&vm.ctx);
let _ = PyVector::make_class(&vm.ctx);
})
.enter(|vm| {
let values = vec![1.0, 2.0, 3.0];

View File

@@ -215,9 +215,9 @@ pub(crate) fn init_interpreter() -> Arc<Interpreter> {
// add this line for stdlib, so rustpython can found stdlib's python part in bytecode format
vm.add_frozen(rustpython_pylib::FROZEN_STDLIB);
// add our own custom datatype and module
PyVector::make_class(&vm.ctx);
PyQueryEngine::make_class(&vm.ctx);
PyRecordBatch::make_class(&vm.ctx);
let _ = PyVector::make_class(&vm.ctx);
let _ = PyQueryEngine::make_class(&vm.ctx);
let _ = PyRecordBatch::make_class(&vm.ctx);
init_greptime_builtins("greptime", vm);
init_data_frame("data_frame", vm);
}));

View File

@@ -17,8 +17,8 @@ use rustpython_vm::{pymodule as rspymodule, VirtualMachine};
use crate::python::rspython::builtins::greptime_builtin::PyDataFrame;
pub(crate) fn init_data_frame(module_name: &str, vm: &mut VirtualMachine) {
PyDataFrame::make_class(&vm.ctx);
data_frame::PyExpr::make_class(&vm.ctx);
let _ = PyDataFrame::make_class(&vm.ctx);
let _ = data_frame::PyExpr::make_class(&vm.ctx);
vm.add_native_module(module_name.to_owned(), Box::new(data_frame::make_module));
}
/// with `register_batch`, and then wrap DataFrame API in it

View File

@@ -94,8 +94,7 @@ fn run_ron_testcases() {
let loc = loc.to_str().expect("Fail to parse path");
let mut file = File::open(loc).expect("Fail to open file");
let mut buf = String::new();
file.read_to_string(&mut buf)
.expect("Fail to read to string");
assert!(file.read_to_string(&mut buf).is_ok());
let testcases: Vec<TestCase> = from_ron_string(&buf).expect("Fail to convert to testcases");
info!("Read {} testcases from {}", testcases.len(), loc);
for testcase in testcases {

View File

@@ -183,38 +183,36 @@ impl ScriptsTable {
}
pub async fn insert(&self, schema: &str, name: &str, script: &str) -> Result<()> {
let mut columns_values: HashMap<String, VectorRef> = HashMap::with_capacity(8);
columns_values.insert(
"schema".to_string(),
Arc::new(StringVector::from(vec![schema])) as _,
);
columns_values.insert(
"name".to_string(),
Arc::new(StringVector::from(vec![name])) as _,
);
columns_values.insert(
"script".to_string(),
Arc::new(StringVector::from(vec![script])) as _,
);
// TODO(dennis): we only supports python right now.
columns_values.insert(
"engine".to_string(),
Arc::new(StringVector::from(vec!["python"])) as _,
);
// Timestamp in key part is intentionally left to 0
columns_values.insert(
"timestamp".to_string(),
Arc::new(TimestampMillisecondVector::from_slice([0])) as _,
);
let now = util::current_time_millis();
columns_values.insert(
"gmt_created".to_string(),
Arc::new(TimestampMillisecondVector::from_slice([now])) as _,
);
columns_values.insert(
"gmt_modified".to_string(),
Arc::new(TimestampMillisecondVector::from_slice([now])) as _,
);
let columns_values: HashMap<String, VectorRef> = HashMap::from([
(
"schema".to_string(),
Arc::new(StringVector::from(vec![schema])) as VectorRef,
),
("name".to_string(), Arc::new(StringVector::from(vec![name]))),
(
"script".to_string(),
Arc::new(StringVector::from(vec![script])) as VectorRef,
),
(
"engine".to_string(),
// TODO(dennis): we only supports python right now.
Arc::new(StringVector::from(vec!["python"])) as VectorRef,
),
(
"timestamp".to_string(),
// Timestamp in key part is intentionally left to 0
Arc::new(TimestampMillisecondVector::from_slice([0])) as VectorRef,
),
(
"gmt_created".to_string(),
Arc::new(TimestampMillisecondVector::from_slice([now])) as VectorRef,
),
(
"gmt_modified".to_string(),
Arc::new(TimestampMillisecondVector::from_slice([now])) as VectorRef,
),
]);
let table = self
.catalog_manager
.table(