4 |
use strict; |
use strict; |
5 |
use warnings; |
use warnings; |
6 |
|
|
7 |
our $VERSION = '0.02'; |
our $VERSION = '0.03'; |
8 |
|
|
9 |
use SWISH::API; |
use SWISH::API; |
10 |
use Text::Iconv; |
use Text::Iconv; |
97 |
=item C<swish_config> |
=item C<swish_config> |
98 |
|
|
99 |
additional parametars which will be inserted into |
additional parametars which will be inserted into |
100 |
C<swish-e> configuration file. See L<swish-config>. |
C<swish-e> configuration file. See C<swish-config>. |
101 |
|
|
102 |
=item C<memoize_to_xml> |
=item C<memoize_to_xml> |
103 |
|
|
396 |
=head2 create_slice |
=head2 create_slice |
397 |
|
|
398 |
On first run, starts C<swish-e>. On subsequent calls just return |
On first run, starts C<swish-e>. On subsequent calls just return |
399 |
it's handles using L<Memoize>. |
it's handles using C<Memoize>. |
400 |
|
|
401 |
my $s = create_slice('/path/to/document'); |
my $s = create_slice('/path/to/document'); |
402 |
|
|
417 |
my $swish_config = $self->make_config($s); |
my $swish_config = $self->make_config($s); |
418 |
|
|
419 |
my $swish = qq{| swish-e }; |
my $swish = qq{| swish-e }; |
420 |
$swish .= qq{ -u } if (-f $self->{'index'}.'/'.$s); |
if (-f $self->{'index'}.'/'.$s) { |
421 |
|
$swish .= qq{ -u }; |
422 |
|
$self->{'slice'}->{$s}->{'update_mode'}++; |
423 |
|
} |
424 |
$swish .= qq{ -S prog -c } . $swish_config; |
$swish .= qq{ -S prog -c } . $swish_config; |
425 |
|
|
426 |
$self->_debug("creating slice $s using $swish"); |
$self->_debug("creating slice $s using $swish"); |
462 |
|
|
463 |
use bytes; # as opposed to chars |
use bytes; # as opposed to chars |
464 |
my $fh = $self->{'slice'}->{$s}->{'h'} || confess "handle for slice $s undefined"; |
my $fh = $self->{'slice'}->{$s}->{'h'} || confess "handle for slice $s undefined"; |
465 |
|
|
466 |
|
my $update_header = "Update-Mode: Index\n"; |
467 |
|
$update_header = '' unless ($self->{'slice'}->{$s}->{'update_mode'}); |
468 |
|
|
469 |
print { $fh } "Path-Name: $path\n". |
print { $fh } "Path-Name: $path\n". |
470 |
"Content-Length: ".(length($xml)+1)."\n". |
"Content-Length: ".(length($xml)+1)."\n" . $update_header . |
|
"Update-Mode: Index\n". |
|
471 |
"Document-Type: XML\n\n$xml\n"; |
"Document-Type: XML\n\n$xml\n"; |
472 |
|
|
473 |
$self->slice_output($s); |
$self->slice_output($s); |
540 |
|
|
541 |
my $xml = $i->to_xml({ foo => 'bar' }); |
my $xml = $i->to_xml({ foo => 'bar' }); |
542 |
|
|
543 |
This function is extracted from L<"add"> method so that you can L<Memoize> it. |
This function is extracted from L<"add"> method so that you can C<Memoize> it. |
544 |
If your data set has a lot of repeatable data, and memory is not a problem, you |
If your data set has a lot of repeatable data, and memory is not a problem, you |
545 |
can add C<memoize_to_xml> option to L<"open_index">. |
can add C<memoize_to_xml> option to L<"open_index">. |
546 |
|
|