Coder Social home page Coder Social logo

sumo_db_riak's Introduction

sumo_db_riak

Build Status

This is the Riak adapter for sumo_db.

Implementation Notes

These are some implementation notes you should know:

  1. This Riak adapter is implemented using Riak Data Types.
  2. The modeled sumo docs/entities are mapped to Riak Maps.
  3. This Riak adapter allows nested docs/entities, ang again, those entities are treat them as Riak Maps too.
  4. Bulk operations such as: delete_all/1, delete_by/2, find_all/1,4 and find_by/2,4,5, they were optimized using streaming. Records are streamed in chunks (using Riak 2i to stream keys first), and then the current operation is applied. E.g: supposing we are executing a find_all/1, all keys are fetched first, and then the values corresponding to each key are fetched (remember that fetch a doc by the key is the fastest way, O(1)). This allows better memory and cpu efficiency.
  5. Query functions were implemented using Riak Search on Data Types, to get better performance and flexibility.

Riak

Install Riak

To install/upgrade Riak please follow the instructions in this link: Installing and Upgrading Riak.

Initial Configurations

Due to the fact that Riak comes with default configuration, we need to change some parameters required by sumo_db.

Riak has a main configuration file riak.conf, which you can find into your installation path $YOUR_INSTALL_PATH/etc/riak.conf.

Note: For more information check this link Configuration Files.

First parameter to change is the default Riak backend from Bitcask to LevelDB. This change also enables the use of Riak Secondary Indexes.

storage_backend = leveldb

Then proceed to enable search capabilities:

search = on

Note: For more information check this link Riak Search Settings.

Configuring Riak Data Types and Search

First, let's create and activate a bucket type simply called maps that is set up to store Riak maps:

Because sumo_db_riak adapter is implemented using Riak Data Types, and docs/entities are mapped to Riak Maps, we need to create a Riak Bucket Type for those docs that will be stored.

Taking as example our tests, let's call the bucket type maps.

$ riak-admin bucket-type create maps '{"props":{"datatype":"map"}}'
$ riak-admin bucket-type activate maps

Now, let's create a search index called sumo_test_index using the default schema:

$ curl -XPUT $RIAK_HOST/search/index/sumo_test_index \
    -H 'Content-Type: application/json' \
    -d '{"schema":"_yz_default"}'

With our index created, we can associate our new sumo_test_index index with our maps bucket type:

$ riak-admin bucket-type update maps '{"props":{"search_index":"sumo_test_index"}}'

Now we can start working with Riak from sumo_db.

Note: For more information check this link Riak Data Types and Search.

Getting Started

To start use sumo_db with this Riak adapter sumo_db_riak is pretty easy, you only has to follow these steps:

  1. Add sumo_db_riak as dependencies in your project.
{deps, [
  {sumo_db_riak, "0.1.0"}
]}.
  1. You need at least one doc/entity, let's use sumo_test_people_riak as example.

  2. Provide the configuration file, e.g.: test.config.

  3. Now you can run your app and start using sumo from there.

Running sumo from an Erlang console

$ rebar3 shell --config test/test.config

Now you're ready to play with sumo and Riak:

> sumo:find_all(people).
[]

Contact Us

For questions or general comments regarding the use of this library, please use our public hipchat room.

If you find any bugs or have a problem while using this library, please [open an issue][issue] in this repo (or a pull request :)).

And you can check all of our open-source projects at inaka.github.io

sumo_db_riak's People

Contributors

cabol avatar elbrujohalcon avatar euen avatar ferigis avatar frepond avatar harenson avatar lucafavatella avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.