Source

p5-rdf-trinex-store-tardis /

Filename Size Date modified Message
lib/RDF/TrineX/Store
t
546 B
2.3 KB
3.2 KB
153 B
1005 B
1.2 KB
4.0 KB
26 B
2.0 KB
NAME
    RDF::Trine::Store::Tardis - time travelling triple store

SYNOPSIS
     use DateTime;
     use RDF::Trine qw[iri statement];
     use RDF::Trine::Store::Tardis;
 
     my $S = iri('http://example.com/s');
     my $P = iri('http://example.com/p');
     my $O = iri('http://example.com/o');
 
     my $store = RDF::Trine::Store::Tardis->new;
 
     $store->add(statement($S, $P, $O));
     sleep 5;
 
     $store->remove(statement($S, $P, $O));
     sleep 1;
 
     my $then     = DateTime->now->subtract(seconds => 3);
     my $then_iri = $store->tardis_make_iri($then);
     my $results  = $store->get_statements(undef, undef, undef, $then_iri);
     while (my $result = $results->next)
     {
       print $result->as_string . "\n";
     }

DESCRIPTION
    Tempus is a triple store (not a quad store!) that keeps track of when
    triples were added and removed from the graph.

  Constructor
    "new([$name])"
        Constructs a temporary store.

    "new($name, $dbh)"
        Uses an existing DBI database connection.

    "new($name, $dsn, $username, $password)"
        Opens a DBI database connection using supplied DSN, username and
        password.

    Note that while it's not especially feasible to share the same database
    and model name between Tardis and RDF::Trine::Store::DBI, the latter
    should be able to safely *read* a Tardis store.

  Methods
    Tempus inherits from RDF::Trine::Store so provides all the methods of an
    RDF::Trine::Store. The following additional methods and differences are
    noteworthy:

    "add_statement($statement)"
    "remove_statement($statement)"
    "remove_statements($subj, $pred, $obj)"
        Can only be handle a triple, not a quad. If passed a quad, a warning
        is given and the context is ignored.

    "get_statements($subj, $pred, $obj)"
        Ignores historic and futuristic triples, only returning triples that
        are valid at the current time.

    "get_statements($subj, $pred, $obj, $context)"
        $context must be an IRI if the form <tempus:2003-02-01T12:00:00Z> or
        a DateTime object. Returns triples valid at that time.

    "get_statements($subj, $pred, $obj, undef)"
        Returns current, historic and future triples.

    "tardis_add_statement($triple, $datetime)"
    "tardis_remove_statement($triple, $datetime)"
        Add or remove a statement at a time other than now. $datetime can be
        a special tempus URI, or a "DateTime" object.

    "tardis_add_statement($quad)"
    "tardis_remove_statement($quad)"
        Quads are supported for these methods, provided that the context is
        a special tempus URI.

    "tardis_make_iri($datetime)"
        Given a "DateTime" object, returns an RDF::Trine::Node::Resource for
        a special tempus URI representing that time.

    "tardis_parse_iri_to_datetime($resource)"
        Does the inverse of "tardis_make_iri".

  Tempus URIs
    Here is the EBNF notation for tempus URIs:

     tempusURI = 'tempus:', ('now' | date | dateTime);
     dateTime  = date, 'T', time;
     date      = year, '-', month, '-', day;
     time      = hour, ':', minute, [':', second,] [timezone];
     year      = digit, digit, digit, digit;
     month     = digit, digit;
     day       = digit, digit;
     hour      = digit, digit;
     minute    = digit, digit;
     second    = digit, digit;
     timezone  = 'Z' | numTZ
     numTZ     = ( '+' | '-' ), digit, digit, digit, digit;
     digit     = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';

BUGS
    I imagine there are many.

    Please report any bugs to <http://rt.cpan.org/>.

SEE ALSO
    RDF::Trine, DateTime.

    RDF::Trine::Store::Tardis::SQLite, RDF::Trine::Store::Tardis::mysql,
    RDF::Trine::Store::Tardis::Pg.

    <http://www.perlrdf.org/>.

    <http://en.wikipedia.org/wiki/TARDIS>.

AUTHOR
    Toby Inkster <tobyink@cpan.org>.

COPYRIGHT
    Copyright 2011 Toby Inkster

    This library is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.