NAME
RDF::Trine::Store::File - Using a file with N-Triples as triplestore
VERSION
Version 0.01_02
SYNOPSIS
To be used as a normal triple store.
my $store = RDF::Trine::Store::File->new($filename);
$store->add_statement(RDF::Trine::Statement->new(
RDF::Trine::Node::Resource->new('http://example.org/a'),
RDF::Trine::Node::Resource->new('http://example.org/b'),
RDF::Trine::Node::Resource->new('http://example.org/c')
));
...
METHODS
new($filename)
A constructor, takes a filename as parameter. If the file doesn't exist, it will be created.
temporary_store
Constructor that creates a temporary file to work on.
add_statement($statement)
Adds the specified $statement
to the underlying model.
get_statements($subject, $predicate, $object)
Returns a stream object of all statements matching the specified subject, predicate and objects. Any of the arguments may be undef to match any value.
count_statements($subject, $predicate, $object)
Returns a count of all the statements matching the specified subject, predicate and objects. Any of the arguments may be undef to match any value.
remove_statement($statement)
Removes the specified $statement
from the underlying model.
remove_statements($subject, $predicate, $object)
Removes all statement matching the specified subject, predicate and objects. Any of the arguments may be undef to match any value.
get_contexts
Contexts are not supported for this store.
size
Returns the number of statements in the store. Breaks if there are comments or empty lines in the file.
etag
Returns an etag based on the last modification time of the file. Note: This has resolution of one second, so it cannot be relied on for data that changes fast.
nuke
Permanently removes the store file and its data.
DISCUSSION
This module is intended mostly as a simple backend to dump data to a file and do as little as possible in memory. Thus, it is mostly suitable in cases where a lot of data is written to file. It should be possible to use it as a SPARQL store with RDF::Query, but the performance is likely to be somewhere between terrible and abyssmal, so don't do that unless you are prepared to be waiting around.
On the good side, adding statements should be pretty fast, as it just appends to a file. The size
method should be pretty fast too, as it just counts the lines in that file. Finally, it supports the etag
method, not perfectly, but that's still pretty good!
It uses a lot of heuristics tied to the format chosen, i.e. N-Triples. That's a line-based format, with predictable amounts of whitespace, allowing us to create relatively simple regular expressions as search patterns in the file. This is likely to be somewhat fragile (it is making assumptions about the file that is true in the RDF::Trine::Serializer::Ntriples case, but not in the format), but it kinda works.
I've decided to use File::Data to actually do the work with the file. Locking and that kind of stuff is done there and is thus Not My Problem. If it is yours, then File::Data is probably the right place to go and fix it.
TODO
This is alpha-quality software and there are some important things to do before it is ready for general use:
Use the Test::RDF::Trine::Store test suite (without it, this module is arguably not well tested).
Support more constructors (e.g.
new_with_config
)Support bulk operations (somewhat less important)
AUTHOR
Kjetil Kjernsmo, <kjetilk at cpan.org>
BUGS
Please report any bugs or feature requests to bug-rdf-trine-store-file at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=RDF-Trine-Store-File. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc RDF::Trine::Store::File
The perlrdf mailing list is the right place to seek help and discuss this module:
http://lists.perlrdf.org/listinfo/dev
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=RDF-Trine-Store-File
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
LICENSE AND COPYRIGHT
Copyright 2011 Kjetil Kjernsmo.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.