Mark Allen Jensen > REST-Neo4p-0.128 > REST::Neo4p::Batch

Download:
REST-Neo4p-0.128.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  4
Stalled  1
View/Report Bugs
Module Version: 0.1   Source   Latest Release: REST-Neo4p-0.3004

NAME ^

REST::Neo4p::Batch - Mixin for batch processing

SYNOPSIS ^

 use REST::Neo4p;
 use REST::Neo4p::Batch;
 use List::MoreUtils qw(pairwise);

 my @bunch = map { "new_node_$_" } (1..100);
 my @nodes;
 batch {
  my $idx = REST::Neo4p::Index->new('node','bunch');
  @nodes = map { REST::Neo4p::Node->new({name => $_}) } @bunch;
  pairwise { $idx->add_entry($a, name => $b) } @nodes, @bunch;
  $nodes[$_]->relate_to($nodes[$_+1],'next_node') for (0..$#nodes-1);
 } 'keep_objs';

 $idx = REST::Neo4p->get_index_by_name('node','bunch');
 ($the_99th_node) = $nodes[98];
 ($points_to_100th_node) = $the_99th_node->get_outgoing_relationships;
 ($the_100th_node) = $idx->find_entries( name => 'new_node_100');

DESCRIPTION ^

REST::Neo4p::Batch adds some syntactic sugar allowing ordinary REST::Neo4p code to be processed through the Neo4j REST batch API.

batch {} ($action) ^

To execute server calls generated by REST::Neo4p code, wrap the code in a batch block:

 batch {
  # create and manipulate REST::Neo4p objects
 } $action;

The $action parameter must be (there is no default) one of

Errors in batch jobs

batch{}() returns returns an array of REST::Neo4p::Exceptions error objects for each job that returns a server-generated error. If no errors were encountered, it returns undef.

 foreach ( batch { _do_stuff() } 'discard_objs' ) {
   print STDERR $_->message, "(", $_->code, ")\n";
 }

batch will warn() for each error immediately if $REST::Neo4p::VERBOSE is set.

CAVEATS ^

SEE ALSO ^

REST::Neo4p, REST::Neo4p::Agent

AUTHOR ^

    Mark A. Jensen
    CPAN ID: MAJENSEN
    majensen -at- cpan -dot- org

LICENSE ^

Copyright (c) 2012 Mark A. Jensen. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: