
interchange-cvs at icdevgroup
Nov 16, 2009, 4:11 PM
Post #1 of 1
(366 views)
Permalink
|
|
[SCM] Interchange branch, master, updated. REL_5_7_3-22-g72809c4
|
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Interchange". The branch, master has been updated via 72809c4b84bc71dbfc5478d03fce97a81f8d3ece (commit) via dee1f77cbc66f3e6232cb50f9b9c6153e09a849e (commit) via a419785a3c0c60b93462fcb29288884800cfc0f0 (commit) from f6146256f7220658642bbbac0d12a5d8c41730a2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 72809c4b84bc71dbfc5478d03fce97a81f8d3ece Author: Jon Jensen <jon [at] endpoint> Date: Mon Nov 16 17:00:18 2009 -0700 Give mv_max_matches (aka mm) some real teeth * Make mv_max_matches stop all further searching once the limit is hit, rather than loading the entire result set into memory and then truncating it. In my tests with a 700,000+ row products table, this is dramatically faster when limiting results to 1000, but surprisingly it adds little overhead even when still fetching the entire table. * Add pragma max_matches, which takes precedence over user-supplied mv_max_matches unless the user-supplied argument is more restrictive. Please note that e.g. [pragma max_matches 1000] on a search landing page will be processed too late to affect the search, because searches are done in an ActionMap that runs before the page is seen. You can use a catalog Pragma directive like this: Pragma max_matches=1000 Which will affect everything in the catalog, including the admin. If you want to make exceptions to the mv_max_matches limit based on URL, you can instead use an Autoload that calls a GlobalSub, like this: interchange.cfg: GlobalSub <<EOR sub set_pragma_max_matches { $::Pragma->{max_matches} = 1000 unless $Vend::FinalPath =~ m{^/admin/}; return; } EOR catalog.cfg: Autoload set_pragma_max_matches commit dee1f77cbc66f3e6232cb50f9b9c6153e09a849e Author: Jon Jensen <jon [at] endpoint> Date: Mon Nov 16 16:55:24 2009 -0700 Make [tag pragma name value] work like [pragma name value] does commit a419785a3c0c60b93462fcb29288884800cfc0f0 Author: Jon Jensen <jon [at] endpoint> Date: Mon Nov 16 16:54:11 2009 -0700 Remove nonfunctional pragma that would break the admin if it did work This: [tag pragma no_image_rewrite 0][/tag] was setting $::Pragma->{no_image_rewrite0} which was of course never used, do to a misunderstanding of the [tag pragma] syntax. But fixing that bug actually breaks the admin because of this, so I'm removing it before the fix. ----------------------------------------------------------------------- Summary of changes and diff: dist/lib/UI/vars/UI_STD_HEAD | 1 - lib/Vend/DbSearch.pm | 22 ++++++++++++++++++---- lib/Vend/Interpolate.pm | 11 +++++++++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/dist/lib/UI/vars/UI_STD_HEAD b/dist/lib/UI/vars/UI_STD_HEAD index ddd5e87..fe05ff8 100644 --- a/dist/lib/UI/vars/UI_STD_HEAD +++ b/dist/lib/UI/vars/UI_STD_HEAD @@ -37,7 +37,6 @@ EOV Variable UI_STD_HEAD <<EOV [tag pragma strip_white][/tag] -[tag pragma no_image_rewrite 0][/tag] @_UI_STD_INIT_@ [if-mm !logged_in] [set ui_checklist][/set] diff --git a/lib/Vend/DbSearch.pm b/lib/Vend/DbSearch.pm index 79917af..0e54845 100644 --- a/lib/Vend/DbSearch.pm +++ b/lib/Vend/DbSearch.pm @@ -232,7 +232,20 @@ sub search { } $s->save_specs(); - foreach $searchfile (@searchfiles) { + + # set max_matches based on the lower of the pragma & the search parameter + # (so end-users can further restrict the size of the result set, but not increase it) + my $max_matches; + { + no warnings 'uninitialized'; + $max_matches = $::Pragma->{max_matches}; + undef $max_matches if $max_matches < 1; + my $search_mm = $s->{mv_max_matches}; + $max_matches = $search_mm + if $search_mm > 0 and (!$max_matches or $search_mm < $max_matches); + } + + SEARCHFILE: for $searchfile (@searchfiles) { my $lqual = $qual || ''; $searchfile =~ s/\..*//; my $db; @@ -276,6 +289,7 @@ sub search { while($ref = $dbref->each_nokey($lqual) ) { next unless $limit_sub->($ref); push @out, $return_sub->($ref); + last SEARCHFILE if $max_matches and @out >= $max_matches; } } elsif(defined $limit_sub) { @@ -287,6 +301,7 @@ sub search { next unless &$f(); next unless $limit_sub->($ref); push @out, $return_sub->($ref); + last SEARCHFILE if $max_matches and @out >= $max_matches; } } elsif (!defined $f) { @@ -301,6 +316,7 @@ sub search { $_ = join "\t", @$ref; next unless &$f(); push @out, $return_sub->($ref); + last SEARCHFILE if $max_matches and @out >= $max_matches; } } $s->restore_specs(); @@ -329,9 +345,7 @@ sub search { @out = grep ! $seen{$_->[0]}++, @out; } - if($s->{mv_max_matches} and $s->{mv_max_matches} > 0) { - splice @out, $s->{mv_max_matches}; - } + splice @out, $max_matches if $max_matches; $s->{matches} = scalar(@out); diff --git a/lib/Vend/Interpolate.pm b/lib/Vend/Interpolate.pm index 993236a..50dd129 100644 --- a/lib/Vend/Interpolate.pm +++ b/lib/Vend/Interpolate.pm @@ -1759,9 +1759,16 @@ sub show_tags { sub pragma { my($pragma, $opt, $text) = @_; - $pragma =~ s/\W+//g; + my $value; - my $value = defined $opt->{value} ? $opt->{value} : 1; + # pragma value may come in attached to the pragma name from [tag pragma name value][/tag] + $pragma =~ s/^(\w+)(?:\s+(\w+))?.*/$1/ and $value = $2; + + # or as a specified option [tag op=pragma arg="name" value="value"][/tag] + $value = defined $opt->{value} ? $opt->{value} : 1 + unless defined $value; + + # or as a tag body like [tag pragma name]value[/pragma] if(! defined $opt->{value} and $text =~ /\S/) { $value = $text; } hooks/post-receive -- Interchange _______________________________________________ interchange-cvs mailing list interchange-cvs [at] icdevgroup http://www.icdevgroup.org/mailman/listinfo/interchange-cvs
|