our
(
$VERSION
);
BEGIN {
$VERSION
=
'2.919'
;
}
sub
new {
my
$class
=
shift
;
my
$iter
=
shift
;
my
$cb
=
shift
;
my
$self
=
$class
->SUPER::new(
$iter
,
$cb
);
$self
->[0]{referenced_variables} = [];
return
$self
;
}
sub
execute ($) {
my
$self
=
shift
;
my
$context
=
shift
;
$self
->[0]{delegate} =
$context
->delegate;
if
(
$self
->state ==
$self
->OPEN) {
throw RDF::Query::Error::ExecutionError
-text
=>
"ITERATOR plan can't be executed while already open"
;
}
if
(
ref
(
$self
->[2])) {
$self
->[2]->(
$context
);
}
if
(reftype(
$self
->[1]) eq
'CODE'
and not(blessed(
$self
->[1]) and
$self
->[1]->isa(
'RDF::Trine::Iterator'
))) {
$self
->[1] =
$self
->[1]->(
$context
);
}
$self
->state(
$self
->OPEN );
$self
;
}
sub
next
{
my
$self
=
shift
;
unless
(
$self
->state ==
$self
->OPEN) {
throw RDF::Query::Error::ExecutionError
-text
=>
"next() cannot be called on an un-open ITERATOR"
;
}
my
$iter
=
$self
->[1];
my
$bindings
=
$iter
->
next
;
if
(
my
$d
=
$self
->delegate) {
$d
->log_result(
$self
,
$bindings
);
}
return
$bindings
;
}
sub
close
{
my
$self
=
shift
;
unless
(
$self
->state ==
$self
->OPEN) {
throw RDF::Query::Error::ExecutionError
-text
=>
"close() cannot be called on an un-open ITERATOR"
;
}
my
$iter
=
$self
->[1];
$iter
->
close
;
$self
->SUPER::
close
();
}
sub
distinct {
return
0;
}
sub
ordered {
return
[];
}
sub
plan_node_name {
return
'optimized-iterator'
;
}
sub
plan_prototype {
my
$self
=
shift
;
return
qw()
;
}
sub
plan_node_data {
my
$self
=
shift
;
return
;
}
1;