diff --git a/.github/workflows/release_capi.yml b/.github/workflows/release_capi.yml index 75f3218cd..1fee936b6 100644 --- a/.github/workflows/release_capi.yml +++ b/.github/workflows/release_capi.yml @@ -70,7 +70,7 @@ jobs: omitPrereleaseDuringUpdate: true deploy_macos_binaries: if: ${{ github.event.action == 'completed' || github.event.label.name == 'test-release-process' || (github.event_name == 'release' && github.event.action == 'published') }} - runs-on: macos-12 + runs-on: macos-14 steps: - id: latest-release uses: pozetroninc/github-action-get-latest-release@v0.7.0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 898fe6808..6e0ee7b2e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: RUST_LOG: debug test_mac: name: Execute automated tests on OSX - runs-on: macos-12 + runs-on: macos-14 steps: - uses: actions/checkout@v2 - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 90747bab1..8a7890e08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- `UpdateEvent` now implements `PartialEq` to make possible to compare changes. + +### Fixed + +- Deserializing a write-ahead log failed because it was located at the wrong + sub-directory and the deserialization routine for the map had a bug. + ## [3.5.1] - 2024-09-25 ### Fixed diff --git a/capi/src/cerror.rs b/capi/src/cerror.rs index 73372fbb2..11bc5b11b 100644 --- a/capi/src/cerror.rs +++ b/capi/src/cerror.rs @@ -20,7 +20,7 @@ struct CauseIterator<'a> { current: Option<&'a dyn StdError>, } -impl<'a> std::iter::Iterator for CauseIterator<'a> { +impl std::iter::Iterator for CauseIterator<'_> { type Item = Error; fn next(&mut self) -> std::option::Option { diff --git a/core/Cargo.toml b/core/Cargo.toml index 15883c295..970e3bdf5 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -16,34 +16,36 @@ bincode = "1.2" clru = "0.6.1" itertools = "0.10" lazy_static = "1.4" -toml = "0.8" log = "0.4" memmap2 = "0.9" normpath = "1.1.1" num-traits = "0.2" percent-encoding = "2.1" quick-xml = "0.28" -rand = { version = "0.8", features = ["small_rng"] } -rayon = { version = "1.3", default-features = false } +rand = {version = "0.8", features = ["small_rng"]} +rayon = {version = "1.3", default-features = false} regex = "1" regex-syntax = "0.8" rustc-hash = "1.0" -serde = { version = "1.0", features = ["rc"] } +serde = {version = "1.0", features = ["rc"]} serde_bytes = "0.11" serde_derive = "1.0" smallvec = "1.6" -smartstring = { version = "1", features = ["serde"] } +smartstring = {version = "1", features = ["serde"]} sstable = "0.11" strum = "0.21" strum_macros = "0.21" tempfile = "3.1" thiserror = "1" +toml = "0.8" transient-btree-index = "0.5" [target.'cfg(windows)'.dependencies] -winapi = { version = "0.3", features = ["heapapi"] } +winapi = {version = "0.3", features = ["heapapi"]} [dev-dependencies] env_logger = "0.9" fake = "2.2" +insta = {version = "1.38.0", features = ["json"]} pretty_assertions = "1.3" +serde_json = "1.0" diff --git a/core/src/dfs.rs b/core/src/dfs.rs index 113e098e2..b849a60b2 100644 --- a/core/src/dfs.rs +++ b/core/src/dfs.rs @@ -121,7 +121,7 @@ impl<'a> CycleSafeDFS<'a> { } } -impl<'a> Iterator for CycleSafeDFS<'a> { +impl Iterator for CycleSafeDFS<'_> { type Item = Result; fn next(&mut self) -> Option { diff --git a/core/src/graph/mod.rs b/core/src/graph/mod.rs index 806a941c7..a00cdfeaa 100644 --- a/core/src/graph/mod.rs +++ b/core/src/graph/mod.rs @@ -626,7 +626,7 @@ impl Graph { std::fs::create_dir_all(¤t_path)?; // If successfull write log - let log_path = location.join("update_log.bin"); + let log_path = current_path.join("update_log.bin"); // Create a temporary directory in the same file system as the output let temporary_dir = tempfile::tempdir_in(¤t_path)?; @@ -1155,4 +1155,62 @@ mod tests { db.ensure_loaded_parallel(&[component]).unwrap(); assert_eq!(0, db.components.len()); } + + #[test] + fn load_with_wal_file() { + let mut db = Graph::::new(false).unwrap(); + let example_node = 0; + db.node_annos + .insert( + example_node, + Annotation { + key: NODE_TYPE_KEY.as_ref().clone(), + val: "corpus".into(), + }, + ) + .unwrap(); + db.node_annos + .insert( + example_node, + Annotation { + key: NODE_NAME_KEY.as_ref().clone(), + val: "root".into(), + }, + ) + .unwrap(); + + let tmp = tempfile::tempdir().unwrap(); + // Save and remember the location, so that updates are recorded in a WAL + // file + db.persist_to(tmp.path()).unwrap(); + + // Add an node annotation with apply_update + let mut u = GraphUpdate::new(); + u.add_event(UpdateEvent::AddNodeLabel { + node_name: "root".into(), + anno_ns: "example".into(), + anno_name: "anno-name".into(), + anno_value: "anno-value".into(), + }) + .unwrap(); + db.apply_update(&mut u, |_| {}).unwrap(); + + std::mem::drop(db); + + // Check that loading the database again contains the changes + let mut db = Graph::::new(false).unwrap(); + db.load_from(tmp.path(), true).unwrap(); + let anno_value = db + .node_annos + .get_value_for_item( + &example_node, + &AnnoKey { + name: "anno-name".into(), + ns: "example".into(), + }, + ) + .unwrap() + .unwrap(); + assert_eq!("anno-value", anno_value); + } } diff --git a/core/src/graph/storage/union.rs b/core/src/graph/storage/union.rs index ad5433e8b..89bc9f3bf 100644 --- a/core/src/graph/storage/union.rs +++ b/core/src/graph/storage/union.rs @@ -15,7 +15,7 @@ impl<'a> UnionEdgeContainer<'a> { } } -impl<'a> EdgeContainer for UnionEdgeContainer<'a> { +impl EdgeContainer for UnionEdgeContainer<'_> { fn get_outgoing_edges<'b>( &'b self, node: NodeID, diff --git a/core/src/graph/update.rs b/core/src/graph/update.rs index 8c55dfbf9..9eb365a46 100644 --- a/core/src/graph/update.rs +++ b/core/src/graph/update.rs @@ -15,7 +15,7 @@ use sstable::{SSIterator, Table, TableBuilder, TableIterator}; use tempfile::NamedTempFile; /// Describes a single update on the graph. -#[derive(Serialize, Deserialize, Clone, Debug)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] pub enum UpdateEvent { /// Add a node with a name and type. AddNode { @@ -304,10 +304,7 @@ impl<'de> Visitor<'de> for GraphUpdateVisitor { let mut event_counter = 0; - while let Some((id, event)) = access - .next_entry::() - .map_err(M::Error::custom)? - { + while let Some((id, event)) = access.next_entry::()? { event_counter = id; let key = id.create_key(); let value = serialization.serialize(&event).map_err(M::Error::custom)?; @@ -338,3 +335,6 @@ impl<'de> Deserialize<'de> for GraphUpdate { deserializer.deserialize_map(GraphUpdateVisitor {}) } } + +#[cfg(test)] +mod tests; diff --git a/core/src/graph/update/snapshots/graphannis_core__graph__update__tests__serialize_json.snap b/core/src/graph/update/snapshots/graphannis_core__graph__update__tests__serialize_json.snap new file mode 100644 index 000000000..f6957cd9f --- /dev/null +++ b/core/src/graph/update/snapshots/graphannis_core__graph__update__tests__serialize_json.snap @@ -0,0 +1,27 @@ +--- +source: core/src/graph/update/tests.rs +expression: seralized_string +--- +{ + "1": { + "AddNode": { + "node_name": "parent", + "node_type": "corpus" + } + }, + "2": { + "AddNode": { + "node_name": "child", + "node_type": "corpus" + } + }, + "3": { + "AddEdge": { + "source_node": "child", + "target_node": "parent", + "layer": "annis", + "component_type": "PartOf", + "component_name": "" + } + } +} diff --git a/core/src/graph/update/tests.rs b/core/src/graph/update/tests.rs new file mode 100644 index 000000000..03015fbf1 --- /dev/null +++ b/core/src/graph/update/tests.rs @@ -0,0 +1,122 @@ +use insta::assert_snapshot; + +use super::*; + +#[test] +fn serialize_deserialize_bincode() { + let example_updates = vec![ + UpdateEvent::AddNode { + node_name: "parent".into(), + node_type: "corpus".into(), + }, + UpdateEvent::AddNode { + node_name: "child".into(), + node_type: "corpus".into(), + }, + UpdateEvent::AddEdge { + source_node: "child".into(), + target_node: "parent".into(), + layer: "annis".into(), + component_type: "PartOf".into(), + component_name: "".into(), + }, + ]; + + let mut updates = GraphUpdate::new(); + for e in example_updates.iter() { + updates.add_event(e.clone()).unwrap(); + } + + let seralized_bytes: Vec = bincode::serialize(&updates).unwrap(); + let deseralized_update: GraphUpdate = bincode::deserialize(&seralized_bytes).unwrap(); + + assert_eq!(3, deseralized_update.len().unwrap()); + let deseralized_events: Vec = deseralized_update + .iter() + .unwrap() + .map(|e| e.unwrap().1) + .collect(); + assert_eq!(example_updates, deseralized_events); +} + +#[test] +fn serialize_deserialize_bincode_empty() { + let example_updates: Vec = Vec::new(); + + let mut updates = GraphUpdate::new(); + for e in example_updates.iter() { + updates.add_event(e.clone()).unwrap(); + } + + let seralized_bytes: Vec = bincode::serialize(&updates).unwrap(); + let deseralized_update: GraphUpdate = bincode::deserialize(&seralized_bytes).unwrap(); + + assert_eq!(0, deseralized_update.len().unwrap()); + assert_eq!(true, deseralized_update.is_empty().unwrap()); +} + +#[test] +fn serialize_json() { + let example_updates = vec![ + UpdateEvent::AddNode { + node_name: "parent".into(), + node_type: "corpus".into(), + }, + UpdateEvent::AddNode { + node_name: "child".into(), + node_type: "corpus".into(), + }, + UpdateEvent::AddEdge { + source_node: "child".into(), + target_node: "parent".into(), + layer: "annis".into(), + component_type: "PartOf".into(), + component_name: "".into(), + }, + ]; + + let mut updates = GraphUpdate::new(); + for e in example_updates.iter() { + updates.add_event(e.clone()).unwrap(); + } + + let seralized_string = serde_json::to_string_pretty(&updates).unwrap(); + assert_snapshot!(seralized_string); +} + +#[test] +fn serialize_deserialize_json() { + let example_updates = vec![ + UpdateEvent::AddNode { + node_name: "parent".into(), + node_type: "corpus".into(), + }, + UpdateEvent::AddNode { + node_name: "child".into(), + node_type: "corpus".into(), + }, + UpdateEvent::AddEdge { + source_node: "child".into(), + target_node: "parent".into(), + layer: "annis".into(), + component_type: "PartOf".into(), + component_name: "".into(), + }, + ]; + + let mut updates = GraphUpdate::new(); + for e in example_updates.iter() { + updates.add_event(e.clone()).unwrap(); + } + + let seralized_string = serde_json::to_string_pretty(&updates).unwrap(); + let deseralized_update: GraphUpdate = serde_json::from_str(&seralized_string).unwrap(); + + assert_eq!(3, deseralized_update.len().unwrap()); + let deseralized_events: Vec = deseralized_update + .iter() + .unwrap() + .map(|e| e.unwrap().1) + .collect(); + assert_eq!(example_updates, deseralized_events); +} diff --git a/core/src/util/disk_collections.rs b/core/src/util/disk_collections.rs index f6795d1d5..36beb371d 100644 --- a/core/src/util/disk_collections.rs +++ b/core/src/util/disk_collections.rs @@ -471,7 +471,7 @@ where } } -impl<'a, K, V> Iterator for CombinedRange<'a, K, V> +impl Iterator for CombinedRange<'_, K, V> where K: Ord, for<'de> K: 'static + Clone + KeySerializer + Send, @@ -556,7 +556,7 @@ where } } -impl<'a, K, V> FusedIterator for CombinedRange<'a, K, V> +impl FusedIterator for CombinedRange<'_, K, V> where K: 'static + Ord + Clone + KeySerializer + Serialize + DeserializeOwned + Send, for<'de> V: 'static + Clone + Serialize + Deserialize<'de> + Send, diff --git a/graphannis/src/annis/db/aql/operators/equal_value.rs b/graphannis/src/annis/db/aql/operators/equal_value.rs index d4b0308b9..445144d85 100644 --- a/graphannis/src/annis/db/aql/operators/equal_value.rs +++ b/graphannis/src/annis/db/aql/operators/equal_value.rs @@ -65,7 +65,7 @@ pub struct EqualValue<'a> { negated: bool, } -impl<'a> std::fmt::Display for EqualValue<'a> { +impl std::fmt::Display for EqualValue<'_> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { if self.negated { write!(f, "!=") @@ -75,7 +75,7 @@ impl<'a> std::fmt::Display for EqualValue<'a> { } } -impl<'a> EqualValue<'a> { +impl EqualValue<'_> { fn value_for_match(&self, m: &Match, spec: &NodeSearchSpec) -> Result>> { match spec { NodeSearchSpec::ExactValue { .. } @@ -119,7 +119,7 @@ impl<'a> EqualValue<'a> { } } -impl<'a> BinaryOperatorBase for EqualValue<'a> { +impl BinaryOperatorBase for EqualValue<'_> { fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result { let lhs_val = self.value_for_match(lhs, &self.spec_left)?; let rhs_val = self.value_for_match(rhs, &self.spec_right)?; @@ -177,7 +177,7 @@ impl<'a> BinaryOperatorBase for EqualValue<'a> { } } -impl<'a> BinaryOperatorIndex for EqualValue<'a> { +impl BinaryOperatorIndex for EqualValue<'_> { fn retrieve_matches<'b>(&'b self, lhs: &Match) -> Box> + 'b> { let lhs = lhs.clone(); let lhs_val = try_as_boxed_iter!(self.value_for_match(&lhs, &self.spec_left)); diff --git a/graphannis/src/annis/db/aql/operators/identical_cov.rs b/graphannis/src/annis/db/aql/operators/identical_cov.rs index 166bbac93..7e49c1c9e 100644 --- a/graphannis/src/annis/db/aql/operators/identical_cov.rs +++ b/graphannis/src/annis/db/aql/operators/identical_cov.rs @@ -98,13 +98,13 @@ impl<'a> IdenticalCoverage<'a> { } } -impl<'a> std::fmt::Display for IdenticalCoverage<'a> { +impl std::fmt::Display for IdenticalCoverage<'_> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "_=_") } } -impl<'a> BinaryOperatorBase for IdenticalCoverage<'a> { +impl BinaryOperatorBase for IdenticalCoverage<'_> { fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result { let start_lhs = self.tok_helper.left_token_for(lhs.node)?; let end_lhs = self.tok_helper.right_token_for(lhs.node)?; @@ -155,7 +155,7 @@ impl<'a> BinaryOperatorBase for IdenticalCoverage<'a> { } } -impl<'a> BinaryOperatorIndex for IdenticalCoverage<'a> { +impl BinaryOperatorIndex for IdenticalCoverage<'_> { fn retrieve_matches(&self, lhs: &Match) -> Box>> { let n_left = try_as_boxed_iter!(self.tok_helper.left_token_for(lhs.node)); let n_right = try_as_boxed_iter!(self.tok_helper.right_token_for(lhs.node)); diff --git a/graphannis/src/annis/db/aql/operators/inclusion.rs b/graphannis/src/annis/db/aql/operators/inclusion.rs index fd8c2476f..31fd13d1f 100644 --- a/graphannis/src/annis/db/aql/operators/inclusion.rs +++ b/graphannis/src/annis/db/aql/operators/inclusion.rs @@ -86,13 +86,13 @@ impl<'a> Inclusion<'a> { } } -impl<'a> std::fmt::Display for Inclusion<'a> { +impl std::fmt::Display for Inclusion<'_> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "_i_") } } -impl<'a> BinaryOperatorBase for Inclusion<'a> { +impl BinaryOperatorBase for Inclusion<'_> { fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result { let left_right_lhs = self.tok_helper.left_right_token_for(lhs.node)?; let left_right_rhs = self.tok_helper.left_right_token_for(rhs.node)?; @@ -160,7 +160,7 @@ enum NodeType { Other(NodeID), } -impl<'a> BinaryOperatorIndex for Inclusion<'a> { +impl BinaryOperatorIndex for Inclusion<'_> { fn retrieve_matches<'b>(&'b self, lhs: &Match) -> Box> + 'b> { let left_right_token = try_as_boxed_iter!(self.tok_helper.left_right_token_for(lhs.node)); if let (Some(start_lhs), Some(end_lhs)) = left_right_token { diff --git a/graphannis/src/annis/db/aql/operators/leftalignment.rs b/graphannis/src/annis/db/aql/operators/leftalignment.rs index 96af88dfa..92b2f832d 100644 --- a/graphannis/src/annis/db/aql/operators/leftalignment.rs +++ b/graphannis/src/annis/db/aql/operators/leftalignment.rs @@ -56,13 +56,13 @@ impl<'a> LeftAlignment<'a> { } } -impl<'a> std::fmt::Display for LeftAlignment<'a> { +impl std::fmt::Display for LeftAlignment<'_> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "_l_") } } -impl<'a> BinaryOperatorBase for LeftAlignment<'a> { +impl BinaryOperatorBase for LeftAlignment<'_> { fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result { if let (Some(lhs_token), Some(rhs_token)) = ( self.tok_helper.left_token_for(lhs.node)?, @@ -101,7 +101,7 @@ impl<'a> BinaryOperatorBase for LeftAlignment<'a> { } } -impl<'a> BinaryOperatorIndex for LeftAlignment<'a> { +impl BinaryOperatorIndex for LeftAlignment<'_> { fn retrieve_matches(&self, lhs: &Match) -> Box>> { let mut aligned = Vec::default(); diff --git a/graphannis/src/annis/db/aql/operators/near.rs b/graphannis/src/annis/db/aql/operators/near.rs index 0e65c4f63..eab7f0661 100644 --- a/graphannis/src/annis/db/aql/operators/near.rs +++ b/graphannis/src/annis/db/aql/operators/near.rs @@ -118,13 +118,13 @@ impl<'a> Near<'a> { } } -impl<'a> std::fmt::Display for Near<'a> { +impl std::fmt::Display for Near<'_> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "^{}", self.spec) } } -impl<'a> BinaryOperatorBase for Near<'a> { +impl BinaryOperatorBase for Near<'_> { fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result { let start_end_forward = if self.spec.segmentation.is_some() { (lhs.node, rhs.node) @@ -195,7 +195,7 @@ impl<'a> BinaryOperatorBase for Near<'a> { } } -impl<'a> BinaryOperatorIndex for Near<'a> { +impl BinaryOperatorIndex for Near<'_> { fn retrieve_matches(&self, lhs: &Match) -> Box>> { let start_forward = if self.spec.segmentation.is_some() { Some(lhs.node) diff --git a/graphannis/src/annis/db/aql/operators/negated_op.rs b/graphannis/src/annis/db/aql/operators/negated_op.rs index c2fd3472e..23a091c41 100644 --- a/graphannis/src/annis/db/aql/operators/negated_op.rs +++ b/graphannis/src/annis/db/aql/operators/negated_op.rs @@ -54,7 +54,7 @@ pub struct NegatedOp<'a> { negated_op: BinaryOperator<'a>, } -impl<'a> Display for NegatedOp<'a> { +impl Display for NegatedOp<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "!",)?; self.negated_op.fmt(f)?; @@ -62,7 +62,7 @@ impl<'a> Display for NegatedOp<'a> { } } -impl<'a> BinaryOperatorBase for NegatedOp<'a> { +impl BinaryOperatorBase for NegatedOp<'_> { fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result { // Invert the filtered logic by the actual operator let orig = self.negated_op.filter_match(lhs, rhs)?; diff --git a/graphannis/src/annis/db/aql/operators/non_existing.rs b/graphannis/src/annis/db/aql/operators/non_existing.rs index f9b6e8cec..d03552fbc 100644 --- a/graphannis/src/annis/db/aql/operators/non_existing.rs +++ b/graphannis/src/annis/db/aql/operators/non_existing.rs @@ -130,14 +130,14 @@ struct NonExistingUnaryOperatorIndex<'a> { op_estimation: EstimationType, } -impl<'a> Display for NonExistingUnaryOperatorIndex<'a> { +impl Display for NonExistingUnaryOperatorIndex<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, " !{} {}", self.negated_op, self.target)?; Ok(()) } } -impl<'a> UnaryOperator for NonExistingUnaryOperatorIndex<'a> { +impl UnaryOperator for NonExistingUnaryOperatorIndex<'_> { fn filter_match(&self, m: &graphannis_core::annostorage::Match) -> Result { // Extract the annotation keys for the matches let it = self.negated_op.retrieve_matches(m).fuse().map(|m| match m { @@ -200,7 +200,7 @@ struct NonExistingUnaryOperatorFilter<'a> { op_estimation: EstimationType, } -impl<'a> Display for NonExistingUnaryOperatorFilter<'a> { +impl Display for NonExistingUnaryOperatorFilter<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if self.target_left { write!(f, " !({} {} x)", self.target, self.negated_op)?; @@ -211,7 +211,7 @@ impl<'a> Display for NonExistingUnaryOperatorFilter<'a> { } } -impl<'a> UnaryOperator for NonExistingUnaryOperatorFilter<'a> { +impl UnaryOperator for NonExistingUnaryOperatorFilter<'_> { fn filter_match(&self, m: &graphannis_core::annostorage::Match) -> Result { // The candidate match is on one side and we need to get an iterator of all possible matches for the other side if let Ok(node_search) = NodeSearch::from_spec( diff --git a/graphannis/src/annis/db/aql/operators/overlap.rs b/graphannis/src/annis/db/aql/operators/overlap.rs index 9e2fc0db7..3a6064d5a 100644 --- a/graphannis/src/annis/db/aql/operators/overlap.rs +++ b/graphannis/src/annis/db/aql/operators/overlap.rs @@ -87,7 +87,7 @@ impl<'a> Overlap<'a> { } } -impl<'a> std::fmt::Display for Overlap<'a> { +impl std::fmt::Display for Overlap<'_> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { if self.reflexive { write!(f, "_o_reflexive_") @@ -97,7 +97,7 @@ impl<'a> std::fmt::Display for Overlap<'a> { } } -impl<'a> BinaryOperatorBase for Overlap<'a> { +impl BinaryOperatorBase for Overlap<'_> { fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result { if self.reflexive && lhs == rhs { return Ok(true); @@ -173,7 +173,7 @@ impl<'a> BinaryOperatorBase for Overlap<'a> { } } -impl<'a> BinaryOperatorIndex for Overlap<'a> { +impl BinaryOperatorIndex for Overlap<'_> { fn retrieve_matches(&self, lhs: &Match) -> Box>> { // use set to filter out duplicates let mut result = FxHashSet::default(); diff --git a/graphannis/src/annis/db/aql/operators/precedence.rs b/graphannis/src/annis/db/aql/operators/precedence.rs index 40eae0143..b01e5384f 100644 --- a/graphannis/src/annis/db/aql/operators/precedence.rs +++ b/graphannis/src/annis/db/aql/operators/precedence.rs @@ -140,13 +140,13 @@ impl<'a> Precedence<'a> { } } -impl<'a> std::fmt::Display for Precedence<'a> { +impl std::fmt::Display for Precedence<'_> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, ".{}", self.spec) } } -impl<'a> BinaryOperatorBase for Precedence<'a> { +impl BinaryOperatorBase for Precedence<'_> { fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result { let start_end = if self.spec.segmentation.is_some() { (lhs.node, rhs.node) @@ -210,7 +210,7 @@ impl<'a> BinaryOperatorBase for Precedence<'a> { } } -impl<'a> BinaryOperatorIndex for Precedence<'a> { +impl BinaryOperatorIndex for Precedence<'_> { fn retrieve_matches<'b>(&'b self, lhs: &Match) -> Box> + 'b> { let start = if self.spec.segmentation.is_some() { Some(lhs.node) @@ -265,13 +265,13 @@ pub struct InversePrecedence<'a> { spec: PrecedenceSpec, } -impl<'a> std::fmt::Display for InversePrecedence<'a> { +impl std::fmt::Display for InversePrecedence<'_> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, ".\u{20D6}{}", self.spec) } } -impl<'a> BinaryOperatorBase for InversePrecedence<'a> { +impl BinaryOperatorBase for InversePrecedence<'_> { fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result { let start_end = if self.spec.segmentation.is_some() { (lhs.node, rhs.node) @@ -328,7 +328,7 @@ impl<'a> BinaryOperatorBase for InversePrecedence<'a> { } } -impl<'a> BinaryOperatorIndex for InversePrecedence<'a> { +impl BinaryOperatorIndex for InversePrecedence<'_> { fn retrieve_matches<'b>(&'b self, lhs: &Match) -> Box> + 'b> { let start = if self.spec.segmentation.is_some() { Some(lhs.node) diff --git a/graphannis/src/annis/db/aql/operators/rightalignment.rs b/graphannis/src/annis/db/aql/operators/rightalignment.rs index 60190515f..0425a668d 100644 --- a/graphannis/src/annis/db/aql/operators/rightalignment.rs +++ b/graphannis/src/annis/db/aql/operators/rightalignment.rs @@ -58,13 +58,13 @@ impl<'a> RightAlignment<'a> { } } -impl<'a> std::fmt::Display for RightAlignment<'a> { +impl std::fmt::Display for RightAlignment<'_> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "_r_") } } -impl<'a> BinaryOperatorBase for RightAlignment<'a> { +impl BinaryOperatorBase for RightAlignment<'_> { fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result { if let (Some(lhs_token), Some(rhs_token)) = ( self.tok_helper.right_token_for(lhs.node)?, @@ -101,7 +101,7 @@ impl<'a> BinaryOperatorBase for RightAlignment<'a> { } } -impl<'a> BinaryOperatorIndex for RightAlignment<'a> { +impl BinaryOperatorIndex for RightAlignment<'_> { fn retrieve_matches(&self, lhs: &Match) -> Box>> { let mut aligned = Vec::default(); diff --git a/graphannis/src/annis/db/corpusstorage.rs b/graphannis/src/annis/db/corpusstorage.rs index 515b07e76..b453287a6 100644 --- a/graphannis/src/annis/db/corpusstorage.rs +++ b/graphannis/src/annis/db/corpusstorage.rs @@ -2079,7 +2079,6 @@ impl CorpusStorage { /// the datasource, an edge in the special `Ordering/annis/datasource-gap` /// component is added between the last token of each context region and the /// first token of the next one. - pub fn subgraph( &self, corpus_name: &str, diff --git a/graphannis/src/annis/db/corpusstorage/subgraph.rs b/graphannis/src/annis/db/corpusstorage/subgraph.rs index 73896eda8..105a51830 100644 --- a/graphannis/src/annis/db/corpusstorage/subgraph.rs +++ b/graphannis/src/annis/db/corpusstorage/subgraph.rs @@ -27,7 +27,7 @@ struct TokenIterator<'a> { ordering_edges: Arc, } -impl<'a> TokenIterator<'a> { +impl TokenIterator<'_> { fn calculate_covering_nodes(&mut self) -> Result<()> { let mut covering_nodes = HashSet::new(); @@ -46,7 +46,7 @@ impl<'a> TokenIterator<'a> { } } -impl<'a> Iterator for TokenIterator<'a> { +impl Iterator for TokenIterator<'_> { type Item = Result; fn next(&mut self) -> Option { diff --git a/graphannis/src/annis/db/exec/filter.rs b/graphannis/src/annis/db/exec/filter.rs index d84945691..f828eb329 100644 --- a/graphannis/src/annis/db/exec/filter.rs +++ b/graphannis/src/annis/db/exec/filter.rs @@ -134,13 +134,13 @@ impl<'a> Filter<'a> { } } -impl<'a> ExecutionNode for Filter<'a> { +impl ExecutionNode for Filter<'_> { fn get_desc(&self) -> Option<&ExecutionNodeDesc> { self.desc.as_ref() } } -impl<'a> Iterator for Filter<'a> { +impl Iterator for Filter<'_> { type Item = Result; fn next(&mut self) -> Option { diff --git a/graphannis/src/annis/db/exec/indexjoin.rs b/graphannis/src/annis/db/exec/indexjoin.rs index af54ff8cb..f9d9e4f04 100644 --- a/graphannis/src/annis/db/exec/indexjoin.rs +++ b/graphannis/src/annis/db/exec/indexjoin.rs @@ -115,13 +115,13 @@ impl<'a> IndexJoin<'a> { } } -impl<'a> ExecutionNode for IndexJoin<'a> { +impl ExecutionNode for IndexJoin<'_> { fn get_desc(&self) -> Option<&ExecutionNodeDesc> { Some(&self.desc) } } -impl<'a> Iterator for IndexJoin<'a> { +impl Iterator for IndexJoin<'_> { type Item = Result; fn next(&mut self) -> Option { diff --git a/graphannis/src/annis/db/exec/nestedloop.rs b/graphannis/src/annis/db/exec/nestedloop.rs index dfb503926..3d4d360ca 100644 --- a/graphannis/src/annis/db/exec/nestedloop.rs +++ b/graphannis/src/annis/db/exec/nestedloop.rs @@ -103,13 +103,13 @@ impl<'a> NestedLoop<'a> { } } -impl<'a> ExecutionNode for NestedLoop<'a> { +impl ExecutionNode for NestedLoop<'_> { fn get_desc(&self) -> Option<&ExecutionNodeDesc> { Some(&self.desc) } } -impl<'a> Iterator for NestedLoop<'a> { +impl Iterator for NestedLoop<'_> { type Item = Result; fn next(&mut self) -> Option { diff --git a/graphannis/src/annis/db/exec/nodesearch.rs b/graphannis/src/annis/db/exec/nodesearch.rs index a221b57ee..189184f6d 100644 --- a/graphannis/src/annis/db/exec/nodesearch.rs +++ b/graphannis/src/annis/db/exec/nodesearch.rs @@ -1092,7 +1092,7 @@ impl<'a> NodeSearch<'a> { } } -impl<'a> ExecutionNode for NodeSearch<'a> { +impl ExecutionNode for NodeSearch<'_> { fn get_desc(&self) -> Option<&ExecutionNodeDesc> { self.desc.as_ref() } @@ -1106,7 +1106,7 @@ impl<'a> ExecutionNode for NodeSearch<'a> { } } -impl<'a> Iterator for NodeSearch<'a> { +impl Iterator for NodeSearch<'_> { type Item = Result; fn next(&mut self) -> Option { diff --git a/graphannis/src/annis/db/exec/parallel/indexjoin.rs b/graphannis/src/annis/db/exec/parallel/indexjoin.rs index 3650c4996..23a7d1aff 100644 --- a/graphannis/src/annis/db/exec/parallel/indexjoin.rs +++ b/graphannis/src/annis/db/exec/parallel/indexjoin.rs @@ -231,13 +231,13 @@ fn next_candidates( Ok(result) } -impl<'a> ExecutionNode for IndexJoin<'a> { +impl ExecutionNode for IndexJoin<'_> { fn get_desc(&self) -> Option<&ExecutionNodeDesc> { Some(&self.desc) } } -impl<'a> Iterator for IndexJoin<'a> { +impl Iterator for IndexJoin<'_> { type Item = Result; fn next(&mut self) -> Option { diff --git a/graphannis/src/annis/db/exec/parallel/nestedloop.rs b/graphannis/src/annis/db/exec/parallel/nestedloop.rs index 23834221c..05706ad40 100644 --- a/graphannis/src/annis/db/exec/parallel/nestedloop.rs +++ b/graphannis/src/annis/db/exec/parallel/nestedloop.rs @@ -273,13 +273,13 @@ impl<'a> NestedLoop<'a> { } } -impl<'a> ExecutionNode for NestedLoop<'a> { +impl ExecutionNode for NestedLoop<'_> { fn get_desc(&self) -> Option<&ExecutionNodeDesc> { Some(&self.desc) } } -impl<'a> Iterator for NestedLoop<'a> { +impl Iterator for NestedLoop<'_> { type Item = Result; fn next(&mut self) -> Option { diff --git a/graphannis/src/annis/db/exec/tokensearch.rs b/graphannis/src/annis/db/exec/tokensearch.rs index 5860ef6e6..f0e2d3e67 100644 --- a/graphannis/src/annis/db/exec/tokensearch.rs +++ b/graphannis/src/annis/db/exec/tokensearch.rs @@ -169,19 +169,19 @@ impl<'a> AnyTokenSearch<'a> { } } -impl<'a> fmt::Display for AnyTokenSearch<'a> { +impl fmt::Display for AnyTokenSearch<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "tok") } } -impl<'a> ExecutionNode for AnyTokenSearch<'a> { +impl ExecutionNode for AnyTokenSearch<'_> { fn get_desc(&self) -> Option<&ExecutionNodeDesc> { self.desc.as_ref() } } -impl<'a> Iterator for AnyTokenSearch<'a> { +impl Iterator for AnyTokenSearch<'_> { type Item = Result; fn next(&mut self) -> Option> { diff --git a/graphannis/src/annis/db/plan.rs b/graphannis/src/annis/db/plan.rs index ccb2b9175..7fbf6f6cd 100644 --- a/graphannis/src/annis/db/plan.rs +++ b/graphannis/src/annis/db/plan.rs @@ -147,7 +147,7 @@ impl<'a> ExecutionPlan<'a> { } } -impl<'a> std::fmt::Display for ExecutionPlan<'a> { +impl std::fmt::Display for ExecutionPlan<'_> { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { for (i, d) in self.descriptions.iter().enumerate() { if i > 0 { @@ -163,7 +163,7 @@ impl<'a> std::fmt::Display for ExecutionPlan<'a> { } } -impl<'a> Iterator for ExecutionPlan<'a> { +impl Iterator for ExecutionPlan<'_> { type Item = Result; fn next(&mut self) -> Option { diff --git a/graphannis/src/annis/operator.rs b/graphannis/src/annis/operator.rs index 827c85d82..d3955055c 100644 --- a/graphannis/src/annis/operator.rs +++ b/graphannis/src/annis/operator.rs @@ -192,7 +192,7 @@ pub enum BinaryOperator<'a> { Index(Box), } -impl<'a> Display for BinaryOperator<'a> { +impl Display for BinaryOperator<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { BinaryOperator::Base(op) => op.fmt(f), @@ -201,7 +201,7 @@ impl<'a> Display for BinaryOperator<'a> { } } -impl<'a> BinaryOperatorBase for BinaryOperator<'a> { +impl BinaryOperatorBase for BinaryOperator<'_> { fn filter_match( &self, lhs: &graphannis_core::annostorage::Match,