Skip to content

Commit 017ca6f

Browse files
committed
refactor: search --preview-match option forces sequential search
1 parent 3cc88f7 commit 017ca6f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/cmd/search.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Returns exitcode 1 when no match is found, unless the '--not-one' flag is used.
1313
When --quick is enabled, no output is produced and exitcode 0 is returned on
1414
the first match.
1515
16+
When the CSV is indexed, a faster parallel search is used.
17+
1618
For examples, see https://github.com/dathere/qsv/blob/master/tests/test_search.rs.
1719
1820
Usage:
@@ -53,7 +55,7 @@ search options:
5355
N milliseconds, whichever occurs first. Returns the preview to
5456
stderr. Output is still written to stdout or --output as usual.
5557
Only applicable when CSV is NOT indexed, as it's read sequentially.
56-
If the CSV is indexed, the --preview-match option is not supported.
58+
Forces a sequential search, even if the CSV is indexed.
5759
-c, --count Return number of matches to stderr.
5860
--size-limit <mb> Set the approximate size limit (MB) of the compiled
5961
regular expression. If the compiled expression exceeds this
@@ -168,9 +170,11 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
168170
.no_headers(args.flag_no_headers)
169171
.select(args.flag_select.clone());
170172

171-
// Route to parallel or sequential search based on index availability
173+
// Route to parallel or sequential search
174+
// based on index availability, number of jobs, and --preview-match option
172175
if let Some(idx) = rconfig.indexed()?
173176
&& util::njobs(args.flag_jobs) > 1
177+
&& !args.flag_preview_match.is_some()
174178
{
175179
args.parallel_search(&idx, pattern, &rconfig)
176180
} else {

0 commit comments

Comments
 (0)