0.0
No commit activity in last 3 years
No release in over 3 years
Makes neography-batches better composable (for neography-batches see https://github.com/maxdemarzi/neography/wiki/Batch)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.0.6
>= 0.8.7
>= 2.11
 Project Readme

Introduction

Neography-Batch makes neography-batches better composable. By composing batches you can

  • reduce the number of calls to the neo4j-server and therefore reducing network latency
  • implement transactions by aggregating the results of smaller computations into one large transactional batch
batch_1 = Neography::Composable::Batch.new
john = batch_1 << [:create_node, {'name' => 'john'}]

batch_2 = Neography::Composable::Batch.new
lucy = batch_2 << [:create_node, {'name' => 'lucy'}]

batch_3 = Neography::Composable::Batch.new
batch_3 << [:create_relationship, 'friend_of', john, lucy]

super_batch = batch_1 << batch_2 << batch_3
super_batch.submit()

If you want to know more about my motivations please read this post.

Installation

Gemfile:

Add neography-batch to your Gemfile:

gem 'neography-batch'

And run Bundler:

$ bundle install

Manually:

Or install neography-batch manually:

$ gem install 'neography-batch'

And require the gem in your Ruby code:

require 'neography-batch'

Usage

Creating a batch

A batch is created by

batch = Neography::Composable::Batch.new
# add commands to the batch here

or

batch = Neography::Composable::Batch.new do |b|
    # add commands to the batch here
end

See also read and write examples.

Adding commands & submitting

batch << [:create_node, {'name' => 'john'}]
batch << [:create_node, {'name' => 'lucy'}]
batch.submit()

You can add everything that is supported by neography's-batch. See here for details.

Aggregating & submitting

super_batch = persons_batch << employee_batch << wages_batch
super_batch.submit()

See also reference and notification examples.

Referencing & submitting

ibm = company_batch << [:create_node, {'name' => 'IBM'}]
john = persons_batch << [:create_node, {'name' => 'john'}]
lucy = persons_batch << [:create_node, {'name' => 'lucy'}]
employee_batch <<  [:create_relationship, 'employee', ibm, john]
employee_batch <<  [:create_relationship, 'employee', ibm, lucy]

super_batch = company_batch << persons_batch << employee_batch
super_batch.submit()

See also reference and notification examples.

Running tests

Installing & starting neo4j

A few tests run against a neo4j-instance. This instance can be installed and run using following rake commands:

rake neo4j:install                           # Install Neo4j to the neo4j directory under your project
rake neo4j:start                             # Start Neo4j
rake neo4j:stop                              # Stop Neo4j

For a complete documentation see neography's rake tasks.

Tests

Tests can best be executed with:

rake spec

License

This work is licensed under GNU General Public License (v3 or later)

3-party licenses