RDF-Sesame
view release on metacpan or search on metacpan
lib/RDF/Sesame/Repository.pm view on Meta::CPAN
=head2 extract ( %opts )
Extract an RDF representation of all the triples in the repository. The only
required option is L</format> which specifies the serialization format of the
resulting RDF. The minimal method invocation looks like
my $rdf = $repo->extract( format => 'turtle' )
where C<$rdf> is a reference to a scalar containing the serialization of all
the triples in the repository. The streaming results returned by Sesame are
handled appropriately so that memory usage in minimized. If the output is
sent to a file (see L</output>), only one "chunk" is held in memory at a time
(subject to caching by your OS). The serialization may also be compressed (or
otherwise processed) as it's being streamed from the server (see
L</compress>).
Error handling is done differently in this method than in other methods in
L<RDF::Sesame>. Namely, if an error occurs, an exception is thrown (rather
than returning undef and setting C<errstr()>. Eventually, I'd like all
methods to behave this way.
t/31-repository-extract.t view on Meta::CPAN
print $fh 'finish.';
},
},
);
is( $rdf, 'init.content.finish.', '"pseudo-compression" worked' );
}
# make sure the gzip compression works
SKIP: {
eval 'use Compress::Zlib';
skip 'Compress::Zlib needed to test streaming gzip compression', 2
if $@;
eval { $repo->extract( format => 'turtle', compress => 'gz' ) };
like( $@, qr/Bad file descriptor/, 'gz broken with in-memory RDF' );
my ($fh, $filename) = File::Temp::tempfile();
$repo->extract(
format => 'turtle',
compress => 'gz',
output => $fh,
( run in 0.239 second using v1.01-cache-2.11-cpan-4d50c553e7e )