summaryrefslogtreecommitdiffstats
path: root/blog/builddb.pl
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-06-25 16:00:32 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-06-25 16:00:32 +0800
commitd5c1e17d4914c8409a7a741570e94e0ade6ec017 (patch)
tree3c1b5d165e5321365cf9e14b874c2bd745ec7d9b /blog/builddb.pl
parent8b95b780207789b0b5531429ee07027ab9ea85e2 (diff)
downloadpttbbs-d5c1e17d4914c8409a7a741570e94e0ade6ec017.tar
pttbbs-d5c1e17d4914c8409a7a741570e94e0ade6ec017.tar.gz
pttbbs-d5c1e17d4914c8409a7a741570e94e0ade6ec017.tar.bz2
pttbbs-d5c1e17d4914c8409a7a741570e94e0ade6ec017.tar.lz
pttbbs-d5c1e17d4914c8409a7a741570e94e0ade6ec017.tar.xz
pttbbs-d5c1e17d4914c8409a7a741570e94e0ade6ec017.tar.zst
pttbbs-d5c1e17d4914c8409a7a741570e94e0ade6ec017.zip
FuzzyIndex
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@966 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'blog/builddb.pl')
-rwxr-xr-xblog/builddb.pl16
1 files changed, 14 insertions, 2 deletions
diff --git a/blog/builddb.pl b/blog/builddb.pl
index b519587b..1cec2615 100755
--- a/blog/builddb.pl
+++ b/blog/builddb.pl
@@ -7,6 +7,7 @@ use IO::Handle;
use Data::Dumper;
use BBSFileHeader;
use DB_File;
+use OurNet::FuzzyIndex;
sub main
{
@@ -99,12 +100,17 @@ sub buildconfigure($$)
sub builddata($$$$$$)
{
my($board, $rbh, $rebuild, $contentonly, $number, $force) = @_;
- my(%dat, $dbfn, $y, $m, $d, $t, $currid);
+ my(%dat, $dbfn, $idxfn, $y, $m, $d, $t, $currid, $idx);
$dbfn = "$BLOGROOT/$board.db";
- unlink $dbfn if( $rebuild );
+ $idxfn = "$BLOGROOT/$board.idx";
+ if( $rebuild ){
+ unlink $dbfn;
+ unlink $idxfn;
+ }
tie %dat, 'DB_File', $dbfn, O_CREAT | O_RDWR, 0666, $DB_HASH;
+ $idx = OurNet::FuzzyIndex->new($idxfn);
foreach( $number ? $number : (1..($rbh->{num} - 1)) ){
if( !(($y, $m, $d, $t) =
$rbh->{"$_.title"} =~ /(\d+)\.(\d+).(\d+),(.*)/) ){
@@ -127,6 +133,9 @@ sub builddata($$$$$$)
$dat{"$currid.content"} = $rbh->{"$_.content"});
$dat{"$currid.short"} = ("$c[0]\n$c[1]\n$c[2]\n$c[3]\n");
+ $idx->delete($currid) if( $idx->findkey($currid) );
+ $idx->insert($currid, $rbh->{"$_.content"});
+
if( !$contentonly ){
debugmsg("\tbuilding $currid linking... ");
if( $dat{$currid} ){
@@ -163,6 +172,9 @@ sub builddata($$$$$$)
}
}
untie %dat;
+ $idx->sync();
+ undef $idx;
+ chmod 0666, $idxfn;
}
sub getdir($$$$$)