NAME

RDF::Trine::Iterator::Graph - Stream (iterator) class for graph query results.

SYNOPSIS

use RDF::Trine::Iterator;

my $iterator = RDF::Trine::Iterator::Graph->new( \&data );
while (my $statement = $iterator->next) {
	# do something with $statement
}

METHODS

new ( \@results, %args )
new ( \&results, %args )

Returns a new SPARQL Result interator object. Results must be either an reference to an array containing results or a CODE reference that acts as an iterator, returning successive items when called, and returning undef when the iterator is exhausted.

$type should be one of: bindings, boolean, graph.

as_bindings ( $s, $p, $o )

Returns the iterator as a Bindings iterator, using the supplied triple nodes to determine the variable bindings.

materialize

Returns a materialized version of the current graph iterator.

unique

Returns a Graph iterator that ensures the returned statements are unique. While the underlying RDF graph is the same regardless of uniqueness, the iterator's serialization methods assume the results are unique, and so use this method before serialization.

Uniqueness is opt-in for efficiency concerns -- this method requires O(n) memory, and so may have noticable effects on large graphs.

is_graph

Returns true if the underlying result is an RDF graph.

as_xml ( $max_size )

Returns an XML serialization of the stream data.

Prints an XML serialization of the stream data to the filehandle $fh.

as_json ( $max_size )

Returns a JSON serialization of the stream data.

construct_args

Returns the arguments necessary to pass to the stream constructor _new to re-create this stream (assuming the same closure as the first

DEPENDENCIES

JSON

Scalar::Util

AUTHOR

Gregory Todd Williams <greg@evilfunhouse.com>

LICENCE AND COPYRIGHT

Copyright (c) 2007, Gregory Todd Williams <gwilliams@cpan.org>. All rights reserved.

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