REST-Neo4p
view release on metacpan or search on metacpan
lib/REST/Neo4p/ParseStream.pm view on Meta::CPAN
}
}
else {
$current = 'DONE';
$done=1;
}
}
when (undef) {
die "j_parse: No key found";
}
default {
# why am I here?
die "j_parse: Unexpected key '$key' in stream";
}
}
if (defined $obj) {
$head = [$key => $obj];
$j->incr_text =~ s/^(?:(\s*,\s*)|(\s*}\s*))//;
$done = !!$2;
}
else {
$head = $done ? undef : [$key => $current = 'PENDING'];
}
return node($head, $done ? undef : promise { $po->() }) if $head;
return node(undef, undef);
};
return $po;
}
=head1 NAME
REST::Neo4p::ParseStream - Parse Neo4j REST responses on the fly
=head1 SYNOPSIS
Not for human consumption.
This module is ignored by the Neo4j::Driver-based agent.
=head1 DESCRIPTION
This module helps L<REST::Neo4p> exploit the L<Neo4j|http://neo4j.org>
server's chunked transfer encoding of its JSON REST responses. It is
based on the fast L<JSON::XS> incremental parser and
L<MJD|https://metacpan.org/author/MJD>'s L<Higher Order
Perl|http://hop.perl.plover.com> ideas as implemented in
L<HOP::Stream>.
The goal is to be able to pull in objects from the server stream as
soon as they are available. In practice, this means specifically
finding and incrementally processing the potentially large arrays of
objects that are returned from cypher queries, transaction queries,
and batch requests.
Because of inconsistencies among the Neo4j response formats for each
of these functions, this module does a significant amount of
"hand-parsing". Currently the code will not be very robust to changes
in those response formats. If you find your query handling is breaking
with a new server version, L<make a
ticket|https://rt.cpan.org/Public/Bug/Report.html?Queue=REST-Neo4p>. In
the meantime, you should be able to keep things going (albeit more
slowly) by turning off streaming at the agent:
use REST::Neo4p;
REST::Neo4p->agent->no_stream;
...
=head1 SEE ALSO
L<REST::Neo4p>, L<REST::Neo4p::Query>, L<REST::Neo4p::Batch>,
L<HOP::Stream>, L<JSON::XS/"INCREMENTAL PARSING">.
=head1 AUTHOR
Mark A. Jensen
CPAN ID: MAJENSEN
majensen -at- cpan -dot- org
=head1 LICENSE
Copyright (c) 2012-2022 Mark A. Jensen. This program is free software; you
can redistribute it and/or modify it under the same terms as Perl
itself.
=cut
1;
( run in 0.786 second using v1.01-cache-2.11-cpan-39bf76dae61 )