1 Commits

Author SHA1 Message Date
dependabot[bot]
e3d0bad63c Update sqlx requirement from 0.7 to 0.8
Updates the requirements on [sqlx](https://github.com/launchbadge/sqlx) to permit the latest version.
- [Changelog](https://github.com/launchbadge/sqlx/blob/main/CHANGELOG.md)
- [Commits](https://github.com/launchbadge/sqlx/compare/v0.7.0...v0.8.0)

---
updated-dependencies:
- dependency-name: sqlx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-29 10:34:27 +00:00
3 changed files with 19 additions and 13 deletions

2
schemsearch-cli/Cargo.toml Executable file → Normal file
View File

@@ -13,7 +13,7 @@ schemsearch-sql = { path = "../schemsearch-sql", optional = true }
clap = { version = "4.1.8", features = ["cargo"] } clap = { version = "4.1.8", features = ["cargo"] }
futures = { version = "0.3", optional = true } futures = { version = "0.3", optional = true }
sqlx = { version = "0.7", features = [ "runtime-async-std-native-tls" , "mysql" ], optional = true } sqlx = { version = "0.8", features = [ "runtime-async-std-native-tls" , "mysql" ], optional = true }
rayon = "1.7.0" rayon = "1.7.0"
indicatif = { version = "0.17.3", features = ["rayon"] } indicatif = { version = "0.17.3", features = ["rayon"] }
serde = "1.0.157" serde = "1.0.157"

View File

@@ -43,34 +43,40 @@ pub fn search(
let schem_height = schem.height as usize; let schem_height = schem.height as usize;
let schem_length = schem.length as usize; let schem_length = schem.length as usize;
let pattern_vec_length = pattern_schem.block_data.iter().map(|x| x * x).sum::<i32>(); let skip_amount = ceil((pattern_blocks * (1.0 - search_behavior.threshold)) as f64, 0) as i32;
for y in 0..=schem_height - pattern_height { for y in 0..=schem_height - pattern_height {
for z in 0..=schem_length - pattern_length { for z in 0..=schem_length - pattern_length {
for x in 0..=schem_width - pattern_width { for x in 0..=schem_width - pattern_width {
let mut dot_p: i32 = 0; let mut not_matching = 0;
let mut schem_vec_length = 0; 'outer:
for j in 0..pattern_height { for j in 0..pattern_height {
for k in 0..pattern_length { for k in 0..pattern_length {
'inner:
for i in 0..pattern_width { for i in 0..pattern_width {
let index = (x + i) + schem_width * ((z + k) + (y + j) * schem_length); let index = (x + i) + schem_width * ((z + k) + (y + j) * schem_length);
let pattern_index = i + pattern_width * (k + j * pattern_length); let pattern_index = i + pattern_width * (k + j * pattern_length);
let data = unsafe { *schem_data.add(index) };
dot_p += unsafe { *pattern_data.add(pattern_index) * *schem_data.add(index) }; let pattern_data = unsafe { *pattern_data.add(pattern_index) };
schem_vec_length += unsafe { *schem_data.add(index) * *schem_data.add(index) }; if (search_behavior.ignore_air && data != *air_id) || (search_behavior.air_as_any && pattern_data != *air_id) {
continue 'inner;
}
if data != pattern_data {
not_matching += 1;
if not_matching >= skip_amount {
break 'outer;
}
}
} }
} }
} }
let sim = dot_p as f32 / ((pattern_vec_length as f32).sqrt() * (schem_vec_length as f32).sqrt()); if not_matching < skip_amount {
if sim > search_behavior.threshold {
matches.push(Match { matches.push(Match {
x: x as u16, x: x as u16,
y: y as u16, y: y as u16,
z: z as u16, z: z as u16,
percent: sim, percent: (i_pattern_blocks - not_matching) as f32 / pattern_blocks,
}); });
} }
} }

View File

@@ -7,7 +7,7 @@ license = "AGPL-3.0-or-later"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
sqlx = { version = "0.7", features = [ "runtime-async-std-native-tls" , "mysql" ] } sqlx = { version = "0.8", features = [ "runtime-async-std-native-tls" , "mysql" ] }
schemsearch-lib = { path = "../schemsearch-lib" } schemsearch-lib = { path = "../schemsearch-lib" }
schemsearch-files = { path = "../schemsearch-files" } schemsearch-files = { path = "../schemsearch-files" }