| RDF-Trine documentation | view source | Contained in the RDF-Trine distribution. |
new ( \@results, $type, \@names, %args )new ( \&results, $type, \@names, %args )typeis_booleanis_bindingsis_graphto_string ( $format )from_string ( $xml )from_json ( $json )next_resultnextpeekcurrentendfinishedopencloseconcat ( $stream )countseen_countget_booleanget_allconstruct_argseach ( \&callback )add_extra_result_data ( $tag, \%data )extra_result_data
RDF::Trine::Iterator - Stream (iterator) class for SPARQL query results
This document describes RDF::Trine::Iterator version 0.135.
use RDF::Trine::Iterator;
my $iterator = RDF::Trine::Iterator->new( \&data, 'bindings', \@names );
while (my $row = $iterator->next) {
my @vars = keys %$row;
# do something with @vars
}
new ( \@results, $type, \@names, %args )new ( \&results, $type, \@names, %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.
typeReturns the underlying result type (boolean, graph, bindings).
is_booleanReturns true if the underlying result is a boolean value.
is_bindingsReturns true if the underlying result is a set of variable bindings.
is_graphReturns true if the underlying result is an RDF graph.
to_string ( $format )Returns a string representation of the stream data in the specified
$format. If $format is missing, defaults to XML serialization.
Other options are:
http://www.w3.org/2001/sw/DataAccess/json-sparql/
from_string ( $xml )Returns a new iterator using the supplied XML in the SPARQL XML Results format.
from_json ( $json )next_resultnextReturns the next item in the stream.
peekReturns the next value from the iterator without consuming it. The value will
remain in queue until the next call to next.
currentReturns the current item in the stream.
endfinishedReturns true if the end of the stream has been reached, false otherwise.
openReturns true if the first element of the stream has been retrieved, false otherwise.
closeCloses the stream. Future attempts to retrieve data from the stream will act as if the stream had been exhausted.
concat ( $stream )Returns a new stream resulting from the concatenation of the referant and the
argument streams. The new stream uses the stream type, and optional binding
names and <%args> from the referant stream.
countDEPRECATED. Returns the number of objects returned from this iterator.
This method is deprecated. The length method from either
RDF::Trine::Iterator::Bindings::Materialized or
RDF::Trine::Iterator::Graph::Materialized should be used instead.
seen_countReturns the count of elements that have been returned by this iterator at the point of invocation.
get_booleanReturns the boolean value of the first item in the stream.
get_allReturns an array containing all the items in the stream.
construct_argsReturns the arguments necessary to pass to a stream constructor to re-create this stream (assuming the same closure as the first argument).
each ( \&callback )Calls the callback function once for each item in the iterator, passing the
item as an argument to the function. Any arguments to each beyond the
callback function will be passed as supplemental arguments to the callback
function.
add_extra_result_data ( $tag, \%data )extra_result_datasgrep { COND } $streamsmap { EXPR } $streamswatch { EXPR } $streamGregory Todd Williams <gwilliams@cpan.org>
Copyright (c) 2006-2010 Gregory Todd Williams. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| RDF-Trine documentation | view source | Contained in the RDF-Trine distribution. |