4 Commits

Author SHA1 Message Date
Chaoscaot
277d833da2 Add AVX2 Dependency 2023-04-05 22:39:59 +02:00
Chaoscaot
00e3d6fd0f Fix Cache 2023-04-05 13:07:14 +02:00
Chaoscaot
fb8f935617 Fix Cache and Bump Version 2023-04-05 13:05:15 +02:00
Chaoscaot
2a112ac49c Add Output Limit 2023-04-05 02:43:28 +02:00
7 changed files with 49 additions and 20 deletions

View File

@@ -19,32 +19,36 @@ jobs:
- name: Cache Cargo modules
id: cache-cargo
uses: actions/cache@v3
env:
cache-name: cache-cargo-target-debug
continue-on-error: false
with:
path: target
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-cargo-
- name: Build
run: make debug
- name: Run tests
run: cargo test --verbose -p schemsearch-lib
build-release:
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache Cargo modules
id: cache-cargo
uses: actions/cache@v3
env:
cache-name: cache-cargo-target-release
continue-on-error: false
with:
path: target
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-cargo-
- name: Build
run: make
- name: Upload a Build Artifact

View File

@@ -22,13 +22,14 @@ jobs:
- name: Cache Cargo modules
id: cache-cargo
uses: actions/cache@v3
env:
cache-name: cache-cargo-target-release
continue-on-error: false
with:
path: target
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-cargo-
- name: Build
run: make
- name: Create Tarball

View File

@@ -1,6 +1,6 @@
[package]
name = "schemsearch-cli"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
license = "AGPL-3.0-or-later"

View File

@@ -150,6 +150,15 @@ fn main() {
.default_value("0")
.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")
.bin_name("schemsearch");
@@ -264,6 +273,8 @@ fn main() {
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| {
match schem {
SchematicSupplierType::PATH(schem) => {
@@ -300,13 +311,19 @@ fn main() {
}
}).collect();
for matching in matches {
let mut matches_count = 0;
'outer: for matching in matches {
let schem_name = matching.name;
let matching = matching.matches;
for x in matching {
for out in &mut output {
write!(out.1, "{}", out.0.found_match(&schem_name, x)).unwrap();
}
matches_count += 1;
if max_matching != 0 && matches_count >= max_matching {
break 'outer;
}
}
}

View File

@@ -1,6 +1,6 @@
[package]
name = "schemsearch-files"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -1,6 +1,6 @@
[package]
name = "schemsearch-lib"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
license = "AGPL-3.0-or-later"
@@ -9,4 +9,5 @@ license = "AGPL-3.0-or-later"
[dependencies]
hematite-nbt = "0.5.2"
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" }

View File

@@ -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;
if matching_percent >= search_behavior.threshold {
matches.push(Match {