From c1cfe2c2ff17bca3cafb9dea4d7a7697eeab9683 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 21 Sep 2021 07:41:59 +0000 Subject: lei q: improve --limit behavior and progress Avoid slurping gigantic (e.g. 100000) result sets into a single response if a giant limit is specified, and instead use 10000 as a window for the mset with a given offset. We'll also warn and hint towards about the --limit= switch when the estimated result set is larger than the default limit. --- lib/PublicInbox/LeiUp.pm | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'lib/PublicInbox/LeiUp.pm') diff --git a/lib/PublicInbox/LeiUp.pm b/lib/PublicInbox/LeiUp.pm index abb05d46..89cf0112 100644 --- a/lib/PublicInbox/LeiUp.pm +++ b/lib/PublicInbox/LeiUp.pm @@ -18,7 +18,6 @@ sub up1 ($$) { my $lss = PublicInbox::LeiSavedSearch->up($lei, $out) or return; my $f = $lss->{'-f'}; my $mset_opt = $lei->{mset_opt} = { relevance => -2 }; - $mset_opt->{limit} = $lei->{opt}->{limit} // 10000; my $q = $mset_opt->{q_raw} = $lss->{-cfg}->{'lei.q'} // return $lei->fail("lei.q unset in $f"); my $lse = $lei->{lse} // die 'BUG: {lse} missing'; @@ -27,24 +26,18 @@ sub up1 ($$) { } else { $lse->query_approxidate($lse->git, $mset_opt->{qstr} = $q); } - my $o = $lei->{opt}->{output} = $lss->{-cfg}->{'lei.q.output'} // - return $lei->fail("lei.q.output unset in $f"); - ref($o) and return $lei->fail("multiple values of lei.q.output in $f"); - if (defined(my $dd = $lss->{-cfg}->{'lei.q.dedupe'})) { - $lss->translate_dedupe($lei, $dd) or return; - $lei->{opt}->{dedupe} = $dd; - } - for my $k (qw(only include exclude)) { + # n.b. only a few CLI args are accepted for "up", so //= usually sets + for my $k ($lss->ARRAY_FIELDS) { my $v = $lss->{-cfg}->get_all("lei.q.$k") // next; - $lei->{opt}->{$k} = $v; + $lei->{opt}->{$k} //= $v; } - for my $k (qw(external local remote - import-remote import-before threads)) { - my $c = "lei.q.$k"; - my $v = $lss->{-cfg}->{$c} // next; - ref($v) and return $lei->fail("multiple values of $c in $f"); - $lei->{opt}->{$k} = $v; + for my $k ($lss->BOOL_FIELDS, $lss->SINGLE_FIELDS) { + my $v = $lss->{-cfg}->get_1('lei.q', $k) // next; + $lei->{opt}->{$k} //= $v; } + my $o = $lei->{opt}->{output} // ''; + return $lei->fail("lei.q.output unset in $f") if $o eq ''; + $lss->translate_dedupe($lei) or return; $lei->{lss} = $lss; # for LeiOverview->new and query_remote_mboxrd my $lxs = $lei->lxs_prepare or return; $lei->ale->refresh_externals($lxs, $lei); -- cgit v1.2.3-24-ge0c7