Skip to content

Commit 7043ee6

Browse files
authored
Merge pull request #333 from korpling/feature/facet-for-update-event
Feature/facet for update event
2 parents b50710b + d6ae21a commit 7043ee6

File tree

8 files changed

+54
-17
lines changed

8 files changed

+54
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55

66
## [Unreleased]
77

8+
### Added
9+
10+
- Added [Facet](https://facet.rs/) support to `UpdateEvent`
11+
812
## [4.0.1] - 2025-10-09
913

1014
### Fixed

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ toml = "0.5"
2626
tikv-jemallocator = "0.5"
2727

2828
[dev-dependencies]
29-
assert_cmd = "2.0.12"
29+
assert_cmd = "2.1"
3030
insta = { version = "1.34.0", features = ["filters"] }
3131
insta-cmd = "0.5"
3232
serial_test = "2"

cli/tests/cli.rs

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use assert_cmd::prelude::*;
1+
use assert_cmd::cargo;
22
use insta::Settings;
3-
use insta_cmd::assert_cmd_snapshot;
3+
use insta::assert_snapshot;
44
use serial_test::serial;
5-
use std::{path::Path, process::Command};
5+
use std::path::Path;
66

77
fn standard_filter() -> Settings {
88
let mut settings = insta::Settings::clone_current();
@@ -19,10 +19,29 @@ fn standard_filter() -> Settings {
1919
settings
2020
}
2121

22+
fn mimic_insta_snapshot(
23+
output: std::process::Output,
24+
) -> Result<String, Box<dyn std::error::Error>> {
25+
let success = output.status.success();
26+
let exit_code = output.status.code().unwrap();
27+
let stdout = str::from_utf8(&output.stdout)?;
28+
let stderr = str::from_utf8(&output.stderr)?;
29+
Ok(format!(
30+
r#"
31+
success: {success}
32+
exit_code: {exit_code}
33+
----- stdout -----
34+
{stdout}
35+
----- stderr -----
36+
{stderr}
37+
"#
38+
))
39+
}
40+
2241
#[test]
2342
#[serial]
2443
fn show_corpus_info() -> Result<(), Box<dyn std::error::Error>> {
25-
let mut cmd = Command::cargo_bin("annis")?;
44+
let mut cmd = cargo::cargo_bin_cmd!("annis");
2645

2746
cmd.arg("../graphannis/tests/data/")
2847
.arg("-c")
@@ -32,29 +51,33 @@ fn show_corpus_info() -> Result<(), Box<dyn std::error::Error>> {
3251
.arg("-c")
3352
.arg("info");
3453

54+
let output = cmd.output().unwrap();
55+
let actual = mimic_insta_snapshot(output)?;
3556
let settings = standard_filter();
36-
settings.bind(|| assert_cmd_snapshot!(cmd));
57+
settings.bind(|| assert_snapshot!(actual));
3758

3859
Ok(())
3960
}
4061

4162
#[test]
4263
#[serial]
4364
fn list_corpora_not_loaded() -> Result<(), Box<dyn std::error::Error>> {
44-
let mut cmd = Command::cargo_bin("annis")?;
65+
let mut cmd = cargo::cargo_bin_cmd!("annis");
4566

4667
cmd.arg("../graphannis/tests/data/").arg("-c").arg("list");
4768

69+
let output = cmd.output().unwrap();
70+
let actual = mimic_insta_snapshot(output)?;
4871
let settings = standard_filter();
49-
settings.bind(|| assert_cmd_snapshot!(cmd));
72+
settings.bind(|| assert_snapshot!(actual));
5073

5174
Ok(())
5275
}
5376

5477
#[test]
5578
#[serial]
5679
fn list_corpora_fully_loaded() -> Result<(), Box<dyn std::error::Error>> {
57-
let mut cmd = Command::cargo_bin("annis")?;
80+
let mut cmd = cargo::cargo_bin_cmd!("annis");
5881

5982
cmd.arg("../graphannis/tests/data/")
6083
.arg("-c")
@@ -64,16 +87,18 @@ fn list_corpora_fully_loaded() -> Result<(), Box<dyn std::error::Error>> {
6487
.arg("-c")
6588
.arg("list");
6689

90+
let output = cmd.output().unwrap();
91+
let actual = mimic_insta_snapshot(output)?;
6792
let settings = standard_filter();
68-
settings.bind(|| assert_cmd_snapshot!(cmd));
93+
settings.bind(|| assert_snapshot!(actual));
6994

7095
Ok(())
7196
}
7297

7398
#[test]
7499
#[serial]
75100
fn list_corpora_partially_loaded() -> Result<(), Box<dyn std::error::Error>> {
76-
let mut cmd = Command::cargo_bin("annis")?;
101+
let mut cmd = cargo::cargo_bin_cmd!("annis");
77102

78103
cmd.arg("../graphannis/tests/data/")
79104
.arg("-c")
@@ -83,25 +108,29 @@ fn list_corpora_partially_loaded() -> Result<(), Box<dyn std::error::Error>> {
83108
.arg("-c")
84109
.arg("list");
85110

111+
let output = cmd.output().unwrap();
112+
let actual = mimic_insta_snapshot(output)?;
86113
let settings = standard_filter();
87-
settings.bind(|| assert_cmd_snapshot!(cmd));
114+
settings.bind(|| assert_snapshot!(actual));
88115

89116
Ok(())
90117
}
91118

92119
#[test]
93120
#[serial]
94121
fn export_to_zip_file() -> Result<(), Box<dyn std::error::Error>> {
95-
let mut cmd = Command::cargo_bin("annis")?;
122+
let mut cmd = cargo::cargo_bin_cmd!("annis");
96123

97124
cmd.arg("../graphannis/tests/data/")
98125
.arg("-c")
99126
.arg("corpus sample-disk-based-3.3")
100127
.arg("-c")
101128
.arg("export sample-disk-based-3.3.zip");
102129

130+
let output = cmd.output().unwrap();
131+
let actual = mimic_insta_snapshot(output)?;
103132
let settings = standard_filter();
104-
settings.bind(|| assert_cmd_snapshot!(cmd));
133+
settings.bind(|| assert_snapshot!(actual));
105134

106135
// Check that the file has been created
107136
let p = Path::new("sample-disk-based-3.3.zip");

core/src/graph/update.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::sync::Mutex;
77
use crate::errors::{GraphAnnisCoreError, Result};
88
use crate::serializer::KeySerializer;
99
use bincode::Options;
10+
use facet::Facet;
1011
use serde::de::Error as DeserializeError;
1112
use serde::de::{MapAccess, Visitor};
1213
use serde::ser::{Error as SerializeError, SerializeMap};
@@ -15,7 +16,8 @@ use sstable::{SSIterator, Table, TableBuilder, TableIterator};
1516
use tempfile::NamedTempFile;
1617

1718
/// Describes a single update on the graph.
18-
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
19+
#[derive(Serialize, Deserialize, Clone, Debug, Facet, PartialEq)]
20+
#[repr(u8)]
1921
pub enum UpdateEvent {
2022
/// Add a node with a name and type.
2123
AddNode {

graphannis/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ strum_macros = "0.21"
5050
sys-info = "0.9"
5151
tempfile = "3"
5252
thiserror = "1"
53+
time = "0.3.44"
5354
toml = "0.8"
5455
transient-btree-index = "0.5"
5556
zip = "0.6.4"

graphannis/src/annis/db/aql/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use boolean_expression::Expr;
88
use graphannis_core::annostorage::MatchGroup;
99
use itertools::Itertools;
1010
lalrpop_mod!(
11-
#[allow(clippy::all)]
11+
#[allow(clippy::all, clippy::pedantic, clippy::restriction, clippy::nursery)]
1212
#[allow(clippy::panic)]
1313
parser,
1414
"/annis/db/aql/parser.rs"

graphannis/src/annis/db/corpusstorage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2726,7 +2726,7 @@ fn extract_subgraph_by_query(
27262726
) -> Result<AnnotationGraph> {
27272727
let t_before = std::time::SystemTime::now();
27282728
// acquire read-only lock and create query that finds the context nodes
2729-
let lock = db_entry.read().unwrap();
2729+
let lock = db_entry.read()?;
27302730
let orig_db = get_read_or_error(&lock)?;
27312731

27322732
let plan = ExecutionPlan::from_disjunction(query, orig_db, query_config, timeout)?;

webservice/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ serde_derive = "1.0"
3434
simplelog = "0.12"
3535
tempfile = "3"
3636
thiserror = "1"
37+
time = "0.3.44"
3738
uuid = { version = "0.8", features = ["v4"] }
3839
walkdir = "2"
3940
zip = "0.6.4"

0 commit comments

Comments
 (0)