mirror of
https://github.com/Chaoscaot/schemsearch.git
synced 2025-12-05 16:57:05 +01:00
Compare commits
4 Commits
v0.1.2
...
chaoscaot/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
277d833da2 | ||
|
|
00e3d6fd0f | ||
|
|
fb8f935617 | ||
|
|
2a112ac49c |
24
.github/workflows/master-build.yml
vendored
24
.github/workflows/master-build.yml
vendored
@@ -19,32 +19,36 @@ jobs:
|
|||||||
- name: Cache Cargo modules
|
- name: Cache Cargo modules
|
||||||
id: cache-cargo
|
id: cache-cargo
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
env:
|
continue-on-error: false
|
||||||
cache-name: cache-cargo-target-debug
|
|
||||||
with:
|
with:
|
||||||
path: target
|
path: |
|
||||||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-${{ env.cache-name }}-
|
${{ runner.os }}-cargo-
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make debug
|
run: make debug
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test --verbose -p schemsearch-lib
|
run: cargo test --verbose -p schemsearch-lib
|
||||||
|
|
||||||
build-release:
|
build-release:
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Cache Cargo modules
|
- name: Cache Cargo modules
|
||||||
id: cache-cargo
|
id: cache-cargo
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
env:
|
continue-on-error: false
|
||||||
cache-name: cache-cargo-target-release
|
|
||||||
with:
|
with:
|
||||||
path: target
|
path: |
|
||||||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-${{ env.cache-name }}-
|
${{ runner.os }}-cargo-
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make
|
run: make
|
||||||
- name: Upload a Build Artifact
|
- name: Upload a Build Artifact
|
||||||
|
|||||||
11
.github/workflows/release-build.yml
vendored
11
.github/workflows/release-build.yml
vendored
@@ -22,13 +22,14 @@ jobs:
|
|||||||
- name: Cache Cargo modules
|
- name: Cache Cargo modules
|
||||||
id: cache-cargo
|
id: cache-cargo
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
env:
|
continue-on-error: false
|
||||||
cache-name: cache-cargo-target-release
|
|
||||||
with:
|
with:
|
||||||
path: target
|
path: |
|
||||||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-${{ env.cache-name }}-
|
${{ runner.os }}-cargo-
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make
|
run: make
|
||||||
- name: Create Tarball
|
- name: Create Tarball
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "schemsearch-cli"
|
name = "schemsearch-cli"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
|
|
||||||
|
|||||||
@@ -150,6 +150,15 @@ fn main() {
|
|||||||
.default_value("0")
|
.default_value("0")
|
||||||
.value_parser(|s: &str| s.parse::<u16>().map_err(|e| e.to_string()))
|
.value_parser(|s: &str| s.parse::<u16>().map_err(|e| e.to_string()))
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("limit")
|
||||||
|
.help("The maximum number of matches to return [0 = Unlimited]")
|
||||||
|
.short('l')
|
||||||
|
.long("limit")
|
||||||
|
.action(ArgAction::Set)
|
||||||
|
.default_value("50")
|
||||||
|
.value_parser(|s: &str| s.parse::<usize>().map_err(|e| e.to_string())),
|
||||||
|
)
|
||||||
.about("Searches for a pattern in a schematic")
|
.about("Searches for a pattern in a schematic")
|
||||||
.bin_name("schemsearch");
|
.bin_name("schemsearch");
|
||||||
|
|
||||||
@@ -264,6 +273,8 @@ fn main() {
|
|||||||
bar.set_draw_target(ProgressDrawTarget::term_like(Box::new(MaschineStdErr { size: term_size })))
|
bar.set_draw_target(ProgressDrawTarget::term_like(Box::new(MaschineStdErr { size: term_size })))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let max_matching = *matches.get_one::<usize>("limit").expect("Could not get max-matching");
|
||||||
|
|
||||||
let matches: Vec<SearchResult> = schematics.par_iter().progress_with(bar).map(|schem| {
|
let matches: Vec<SearchResult> = schematics.par_iter().progress_with(bar).map(|schem| {
|
||||||
match schem {
|
match schem {
|
||||||
SchematicSupplierType::PATH(schem) => {
|
SchematicSupplierType::PATH(schem) => {
|
||||||
@@ -300,13 +311,19 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
for matching in matches {
|
let mut matches_count = 0;
|
||||||
|
|
||||||
|
'outer: for matching in matches {
|
||||||
let schem_name = matching.name;
|
let schem_name = matching.name;
|
||||||
let matching = matching.matches;
|
let matching = matching.matches;
|
||||||
for x in matching {
|
for x in matching {
|
||||||
for out in &mut output {
|
for out in &mut output {
|
||||||
write!(out.1, "{}", out.0.found_match(&schem_name, x)).unwrap();
|
write!(out.1, "{}", out.0.found_match(&schem_name, x)).unwrap();
|
||||||
}
|
}
|
||||||
|
matches_count += 1;
|
||||||
|
if max_matching != 0 && matches_count >= max_matching {
|
||||||
|
break 'outer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "schemsearch-files"
|
name = "schemsearch-files"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# 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
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "schemsearch-lib"
|
name = "schemsearch-lib"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
|
|
||||||
@@ -9,4 +9,5 @@ license = "AGPL-3.0-or-later"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
hematite-nbt = "0.5.2"
|
hematite-nbt = "0.5.2"
|
||||||
serde = "1.0.152"
|
serde = "1.0.152"
|
||||||
schemsearch-files = { path = "../schemsearch-files" }
|
schemsearch-files = { path = "../schemsearch-files" }
|
||||||
|
manual-avx2 = { git = "https://github.com/Chaoscaot/manual-avx2", version = "0.1.0" }
|
||||||
|
|||||||
@@ -88,6 +88,12 @@ pub fn search(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for index in (0..schem_data.len()).step_by(8) {
|
||||||
|
let pattern_data_slice = schem_data[index..index + 8];
|
||||||
|
let data = manual_avx2::vec_i::VecInteger::new_i32(&(index..index + 8).map(|i| schem_data[i]).collect::<[i32; 8]>());
|
||||||
|
}
|
||||||
|
|
||||||
let matching_percent = matching as f32 / pattern_blocks;
|
let matching_percent = matching as f32 / pattern_blocks;
|
||||||
if matching_percent >= search_behavior.threshold {
|
if matching_percent >= search_behavior.threshold {
|
||||||
matches.push(Match {
|
matches.push(Match {
|
||||||
|
|||||||
Reference in New Issue
Block a user