1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
# -*- Mode: Perl -*- |
# -*- Mode: Perl -*- |
3 |
# $Basename$ |
# $Basename$ |
4 |
# $Revision: 1.2 $ |
# $Revision: 1.5 $ |
5 |
# Author : Ulrich Pfeifer |
# Author : Ulrich Pfeifer |
6 |
# Created On : Mon Dec 31 13:57:11 2001 |
# Created On : Mon Dec 31 13:57:11 2001 |
7 |
# Last Modified By: Ulrich Pfeifer |
# Last Modified By: Ulrich Pfeifer |
8 |
# Last Modified On: Fri Jan 4 15:47:31 2002 |
# Last Modified On: Fri Jan 4 15:59:20 2002 |
9 |
# Language : CPerl |
# Language : CPerl |
10 |
# |
# |
11 |
# (C) Copyright 2001, UUNET Deutschland GmbH, Germany |
# (C) Copyright 2001, UUNET Deutschland GmbH, Germany |
26 |
|
|
27 |
$DB_BTREE->{'cachesize'} = 200_000 ; |
$DB_BTREE->{'cachesize'} = 200_000 ; |
28 |
|
|
29 |
my %OPT = (clean => 0, |
my %OPT = ( |
30 |
database => 'DB', |
database => 'DB', |
31 |
dir => $WAIT::Config->{WAIT_home} || '/tmp', |
dir => $WAIT::Config->{WAIT_home} || '/tmp', |
32 |
table => 'ora', |
table => 'ora', |
33 |
); |
); |
34 |
|
|
35 |
GetOptions(\%OPT, |
GetOptions(\%OPT, |
|
'clean!', |
|
36 |
'database=s', |
'database=s', |
37 |
'dir=s', |
'dir=s', |
38 |
'table=s', |
'table=s', |
39 |
) || die "Usage: ...\n"; |
) || die "Usage: ...\n"; |
40 |
|
|
|
if ($OPT{clean} and -d "$OPT{dir}/$OPT{database}") { |
|
|
my $tmp = WAIT::Database->open(name => $OPT{database}, |
|
|
'directory' => $OPT{dir}) |
|
|
or die "Could not open table $OPT{table}: $@\n"; |
|
|
my $tbl = $tmp->table(name => $OPT{table}); |
|
|
$tbl->drop if $tbl; |
|
|
rmtree("$OPT{dir}/$OPT{database}/$OPT{table}", 1, 1) |
|
|
if -d "$OPT{dir}/$OPT{database}/$OPT{table}"; |
|
|
$tmp->close; |
|
|
} |
|
|
|
|
41 |
my $db; |
my $db; |
42 |
unless (-d "$OPT{dir}/$OPT{database}") { |
unless (-d "$OPT{dir}/$OPT{database}") { |
43 |
$db = WAIT::Database->create(name => $OPT{database}, |
$db = WAIT::Database->create(name => $OPT{database}, |
67 |
or die "Couldn't tie to file: $!\n"; |
or die "Couldn't tie to file: $!\n"; |
68 |
|
|
69 |
my $tb = $db->create_table(name => $OPT{table}, |
my $tb = $db->create_table(name => $OPT{table}, |
70 |
attr => ['author', 'title', |
attr => ['author', 'isbn', 'title', |
71 |
'headline', 'docid'], |
'headline', 'docid'], |
72 |
layout => $layout, |
layout => $layout, |
73 |
access => $access, |
access => $access, |
77 |
'about' => $stem, |
'about' => $stem, |
78 |
'text' => $text, |
'text' => $text, |
79 |
'author' => $text, |
'author' => $text, |
80 |
|
'colophon' => $text, |
81 |
|
'author' => $sound, |
82 |
|
'isbn' => $text, |
83 |
] |
] |
84 |
); |
); |
85 |
die "Couldn't create table $OPT{table}: $@\n" unless $tb; |
die "Couldn't create table $OPT{table}: $@\n" unless $tb; |
89 |
my $record = $layout->split($value); |
my $record = $layout->split($value); |
90 |
my $headline = $record->{title}; |
my $headline = $record->{title}; |
91 |
$headline =~ s/\s+/ /sg; |
$headline =~ s/\s+/ /sg; |
92 |
printf "%s\n", substr($headline,0,80); |
printf "%15s %s\n", $record->{isbn}, substr($headline,0,60); |
93 |
$tb->insert('docid' => $did, |
$tb->insert('docid' => $did, |
94 |
headline => $headline, |
headline => $headline, |
95 |
%{$record}); |
%{$record}); |
113 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
114 |
|
|
115 |
B<index_ora> |
B<index_ora> |
|
[B<-clean>] [B<-noclean>] |
|
116 |
[B<-database> I<dbname>] |
[B<-database> I<dbname>] |
117 |
[B<-dir> I<directory>] |
[B<-dir> I<directory>] |
118 |
[B<-table> I<table name>] |
[B<-table> I<table name>] |
124 |
|
|
125 |
=over 5 |
=over 5 |
126 |
|
|
|
=item B<-clean> / B<-noclean> |
|
|
|
|
|
Clean the table before indexing. Default is B<off>. |
|
|
|
|
127 |
=item B<-database> I<dbname> |
=item B<-database> I<dbname> |
128 |
|
|
129 |
Specify database name. Default is F<DB>. |
Specify database name. Default is F<DB>. |