projects
/
spider.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6f56661
)
speeded up search and load of dx spots (a lot)
author
djk
<djk>
Mon, 13 Jul 1998 22:04:45 +0000
(22:04 +0000)
committer
djk
<djk>
Mon, 13 Jul 1998 22:04:45 +0000
(22:04 +0000)
perl/gdx.pl
patch
|
blob
|
history
perl/spot.pm
patch
|
blob
|
history
diff --git
a/perl/gdx.pl
b/perl/gdx.pl
index 8f6f2065edd75b8395c581d8146ed1279a5ea77d..3d311e38264d4d36a5be378c331c1faba986c047 100755
(executable)
--- a/
perl/gdx.pl
+++ b/
perl/gdx.pl
@@
-1,3
+1,4
@@
+#!/usr/bin/perl
#
# grep for expressions in various fields of the dx file
#
#
# grep for expressions in various fields of the dx file
#
@@
-8,7
+9,13
@@
use DXDebug;
use spot;
# initialise spots file
use spot;
# initialise spots file
+STDOUT->autoflush(1);
+
+print "reading in spot data ..";
+$t = time;
$count = spot->init();
$count = spot->init();
+$t = time - $t;
+print "done ($t secs)\n";
dbgadd('spot');
dbgadd('spot');
@@
-18,8
+25,6
@@
$time = time;
print "$count database records read in\n";
print "$count database records read in\n";
-STDOUT->autoflush(1);
-
#loada();
for (;;) {
print "field: ";
#loada();
for (;;) {
print "field: ";
diff --git
a/perl/spot.pm
b/perl/spot.pm
index 811a708034f471070d824e7a71d95cbe31a3f736..1d0ac75331c79d53ad0a48311489134acd600018 100644
(file)
--- a/
perl/spot.pm
+++ b/
perl/spot.pm
@@
-34,11
+34,14
@@
sub init
my $ref = spot->open(@first);
if ($ref) {
my $fh = $ref->{fh};
my $ref = spot->open(@first);
if ($ref) {
my $fh = $ref->{fh};
+ my @out = ();
while (<$fh>) {
chomp;
my @ent = split /\^/;
while (<$fh>) {
chomp;
my @ent = split /\^/;
- unshift @spot::table, [ @ent ]; # stick this ref to anon list on the FRONT of the table
- ++$count;
+
+ push @spot::table, \@ent; # stick this ref to anon list on the FRONT of the table
+
+ ++$count;
}
}
@first = julian->add(@first, 1);
}
}
@first = julian->add(@first, 1);
@@
-57,7
+60,7
@@
sub new
$spot[2] = 0 + $spot[2];
# save it on the front of the list
$spot[2] = 0 + $spot[2];
# save it on the front of the list
- unshift @spot::table,
[ @spot ]
;
+ unshift @spot::table,
\@spot
;
# compare dates to see whether need to open a other save file
my @date = julian->unixtoj($spot[2]);
# compare dates to see whether need to open a other save file
my @date = julian->unixtoj($spot[2]);
@@
-91,10
+94,11
@@
sub purge
#
sub search
{
#
sub search
{
- my ($pkg, $field, $expr) = @_;
+ my ($pkg, $field, $expr
, $from, $to
) = @_;
my $eval;
my @out;
my $ref;
my $eval;
my @out;
my $ref;
+ my $i;
dbg('spot', "input expr = $expr\n");
if ($field == 0 || $field == 2) { # numeric fields
dbg('spot', "input expr = $expr\n");
if ($field == 0 || $field == 2) { # numeric fields
@@
-106,7
+110,12
@@
sub search
# build up eval to execute
$eval = qq(foreach \$ref (\@spot::table) {
# build up eval to execute
$eval = qq(foreach \$ref (\@spot::table) {
- push \@out, \$ref if $expr;
+ next if \$i < \$from;
+ if ($expr) {
+ unshift(\@out, \$ref);
+ \$i++;
+ last if \$to && \$i >= \$to;
+ }
});
dbg('spot', "eval = $eval\n");
eval $eval; # execute it
});
dbg('spot', "eval = $eval\n");
eval $eval; # execute it