remove a lot of unecessary clone and ref

This commit is contained in:
Irevoire 2022-10-25 10:53:29 +02:00 committed by Clément Renault
parent 4d25c159e6
commit 7e52f1effb
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
5 changed files with 32 additions and 32 deletions

View File

@ -130,7 +130,7 @@ impl CompatV5ToV6 {
v5::Details::DocumentAddition { received_documents, indexed_documents } => {
v6::Details::DocumentAdditionOrUpdate {
received_documents: received_documents as u64,
indexed_documents: indexed_documents.map(|i| i as u64),
indexed_documents,
}
}
v5::Details::Settings { settings } => {

View File

@ -269,16 +269,16 @@ impl IndexScheduler {
must_stop_processing: self.must_stop_processing.clone(),
processing_tasks: self.processing_tasks.clone(),
file_store: self.file_store.clone(),
all_tasks: self.all_tasks.clone(),
status: self.status.clone(),
kind: self.kind.clone(),
index_tasks: self.index_tasks.clone(),
enqueued_at: self.enqueued_at.clone(),
started_at: self.started_at.clone(),
finished_at: self.finished_at.clone(),
all_tasks: self.all_tasks,
status: self.status,
kind: self.kind,
index_tasks: self.index_tasks,
enqueued_at: self.enqueued_at,
started_at: self.started_at,
finished_at: self.finished_at,
index_mapper: self.index_mapper.clone(),
wake_up: self.wake_up.clone(),
autobatching_enabled: self.autobatching_enabled.clone(),
autobatching_enabled: self.autobatching_enabled,
dumps_path: self.dumps_path.clone(),
#[cfg(test)]
test_breakpoint_sdr: self.test_breakpoint_sdr.clone(),
@ -808,7 +808,7 @@ impl IndexScheduler {
let res = {
let cloned_index_scheduler = self.private_clone();
let handle = std::thread::spawn(move || cloned_index_scheduler.process_batch(batch));
handle.join().unwrap_or_else(|_| Err(Error::ProcessBatchPanicked))
handle.join().unwrap_or(Err(Error::ProcessBatchPanicked))
};
#[cfg(test)]
@ -1223,7 +1223,7 @@ mod tests {
index_scheduler
.register(KindWithContent::TaskDeletion {
query: "test_query".to_owned(),
tasks: RoaringBitmap::from_iter(&[0, 1]),
tasks: RoaringBitmap::from_iter([0, 1]),
})
.unwrap();
index_scheduler.assert_internally_consistent();
@ -1279,7 +1279,7 @@ mod tests {
index_scheduler
.register(KindWithContent::TaskDeletion {
query: "test_query".to_owned(),
tasks: RoaringBitmap::from_iter(&[0]),
tasks: RoaringBitmap::from_iter([0]),
})
.unwrap();
index_scheduler.assert_internally_consistent();
@ -1322,7 +1322,7 @@ mod tests {
index_scheduler
.register(KindWithContent::TaskDeletion {
query: "test_query".to_owned(),
tasks: RoaringBitmap::from_iter(&[0]),
tasks: RoaringBitmap::from_iter([0]),
})
.unwrap();
index_scheduler.assert_internally_consistent();

View File

@ -436,7 +436,7 @@ impl IndexScheduler {
}
Details::Dump { dump_uid: d1 } => {
assert!(
matches!(&kind, KindWithContent::DumpExport { dump_uid: d2, keys: _, instance_uid: _ } if &d1 == d2 )
matches!(&kind, KindWithContent::DumpCreation { dump_uid: d2, keys: _, instance_uid: _ } if &d1 == d2 )
);
}
},

View File

@ -96,7 +96,7 @@ async fn error_access_expired_key() {
assert!(response["key"].is_string());
let key = response["key"].as_str().unwrap();
server.use_api_key(&key);
server.use_api_key(key);
// wait until the key is expired.
thread::sleep(time::Duration::new(1, 0));
@ -126,7 +126,7 @@ async fn error_access_unauthorized_index() {
assert!(response["key"].is_string());
let key = response["key"].as_str().unwrap();
server.use_api_key(&key);
server.use_api_key(key);
for (method, route) in AUTHORIZATIONS
.keys()
@ -160,7 +160,7 @@ async fn error_access_unauthorized_action() {
assert!(response["key"].is_string());
let key = response["key"].as_str().unwrap();
server.use_api_key(&key);
server.use_api_key(key);
let (response, code) = server.dummy_request(method, route).await;
assert_eq!(response, INVALID_RESPONSE.clone(), "on route: {:?} - {:?}", method, route);
@ -203,7 +203,7 @@ async fn access_authorized_restricted_index() {
assert!(response["key"].is_string());
let key = response["key"].as_str().unwrap();
server.use_api_key(&key);
server.use_api_key(key);
let (response, code) = server.dummy_request(method, route).await;
@ -241,7 +241,7 @@ async fn access_authorized_no_index_restriction() {
assert!(response["key"].is_string());
let key = response["key"].as_str().unwrap();
server.use_api_key(&key);
server.use_api_key(key);
let (response, code) = server.dummy_request(method, route).await;
@ -286,7 +286,7 @@ async fn access_authorized_stats_restricted_index() {
// use created key.
let key = response["key"].as_str().unwrap();
server.use_api_key(&key);
server.use_api_key(key);
let (response, code) = server.stats().await;
assert_eq!(200, code, "{:?}", &response);
@ -326,7 +326,7 @@ async fn access_authorized_stats_no_index_restriction() {
// use created key.
let key = response["key"].as_str().unwrap();
server.use_api_key(&key);
server.use_api_key(key);
let (response, code) = server.stats().await;
assert_eq!(200, code, "{:?}", &response);
@ -366,7 +366,7 @@ async fn list_authorized_indexes_restricted_index() {
// use created key.
let key = response["key"].as_str().unwrap();
server.use_api_key(&key);
server.use_api_key(key);
let (response, code) = server.list_indexes(None, None).await;
assert_eq!(200, code, "{:?}", &response);
@ -407,7 +407,7 @@ async fn list_authorized_indexes_no_index_restriction() {
// use created key.
let key = response["key"].as_str().unwrap();
server.use_api_key(&key);
server.use_api_key(key);
let (response, code) = server.list_indexes(None, None).await;
assert_eq!(200, code, "{:?}", &response);
@ -447,7 +447,7 @@ async fn list_authorized_tasks_restricted_index() {
// use created key.
let key = response["key"].as_str().unwrap();
server.use_api_key(&key);
server.use_api_key(key);
let (response, code) = server.service.get("/tasks").await;
assert_eq!(200, code, "{:?}", &response);
@ -487,7 +487,7 @@ async fn list_authorized_tasks_no_index_restriction() {
// use created key.
let key = response["key"].as_str().unwrap();
server.use_api_key(&key);
server.use_api_key(key);
let (response, code) = server.service.get("/tasks").await;
assert_eq!(200, code, "{:?}", &response);
@ -518,7 +518,7 @@ async fn error_creating_index_without_action() {
// use created key.
let key = response["key"].as_str().unwrap();
server.use_api_key(&key);
server.use_api_key(key);
let expected_error = json!({
"message": "Index `test` not found.",
@ -598,7 +598,7 @@ async fn lazy_create_index() {
// use created key.
let key = response["key"].as_str().unwrap();
server.use_api_key(&key);
server.use_api_key(key);
// try to create a index via add documents route
let index = server.index("test");
@ -665,7 +665,7 @@ async fn error_creating_index_without_index() {
// use created key.
let key = response["key"].as_str().unwrap();
server.use_api_key(&key);
server.use_api_key(key);
// try to create a index via add documents route
let index = server.index("test");

View File

@ -470,7 +470,7 @@ async fn error_access_forbidden_routes() {
"searchRules" => json!(["*"]),
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
};
let web_token = generate_tenant_token(&uid, &key, tenant_token);
let web_token = generate_tenant_token(uid, key, tenant_token);
server.use_api_key(&web_token);
for ((method, route), actions) in AUTHORIZATIONS.iter() {
@ -506,7 +506,7 @@ async fn error_access_expired_parent_key() {
"searchRules" => json!(["*"]),
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
};
let web_token = generate_tenant_token(&uid, &key, tenant_token);
let web_token = generate_tenant_token(uid, key, tenant_token);
server.use_api_key(&web_token);
// test search request while parent_key is not expired
@ -545,7 +545,7 @@ async fn error_access_modified_token() {
"searchRules" => json!(["products"]),
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
};
let web_token = generate_tenant_token(&uid, &key, tenant_token);
let web_token = generate_tenant_token(uid, key, tenant_token);
server.use_api_key(&web_token);
// test search request while web_token is valid
@ -558,7 +558,7 @@ async fn error_access_modified_token() {
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
};
let alt = generate_tenant_token(&uid, &key, tenant_token);
let alt = generate_tenant_token(uid, key, tenant_token);
let altered_token = [
web_token.split('.').next().unwrap(),
alt.split('.').nth(1).unwrap(),