Giter VIP home page Giter VIP logo

cassitory's Introduction

Cassitory

Development status Build Status Coverage Status Maven Central

Cassitory allows you to handle redundancy tables in Cassandra (In case that Apache Spark is not an option or to complex for your needs)

In a normal scenario you would have to define a cassandra entity per table that holds the cassandra annotations, and for each of them a Repository that will be used by your service coordinating all the write operations and making sure that you persist to both tables by using both repositories, therefore you will have to create one instance per cassandra entity to persist.

The idea behind Cassitory is to hide all that complexity from you. Although you will still need to have your cassandra entities but no Repositories, no creation of multiple Cassandra entity instances.
Instead you will have DTO that contains the data and knows how to map to each Cassandra entity and a Single repository to handle all the persistence layer to the multiple tables. Based on the mapping it will create an instance of each Cassandra Entity and save it.

ASYNC is awesome! so you can save and delete using async operations but also provides a sync way in case that you have go down that route.

NO REFLEXION: Cassitory does not use reflexion to do all the operations that provides and because of it there are some compromises if you want to use it.

  • Your Cassandra entities must have a Getters and Setters.
  • Your DTO must have Getters.

Cassitory use annotation processing to generate code than otherwise you would have to write it and it is quite good that if there is any error you would get it at compile time.

Important Release Note:

  • up to 0.2.1: supports only Mappers Repositories
  • higher than 1.0.0: support for Mappers and Prepered statements

Motivation

it is well known that Cassandra recommends de-normalisation of your model. Meaning that in order to support different search criteria for searching the data, Cassandra recommends to create a redundancy table having as partition key the fields that you want search for. Applying this pattern in your application could be very difficult to maintain. it would be nice to have a generic repository that allowing you to have support multiple tables and also execute queries and decide which table is the correct one.

Introduction

Cassitory is quite simple to use just following the steps and it will give you a Repository for your DTO ready to use in your application. Cassitory gives you two type of repositories.

Using Cassandra entities

The first one is by using Cassandra Entities Classes where you have to create your POJO and annotate them using Cassandra Object Mapper library. and apart of those POJO you will have to create your DTO entity and annotate it with Cassitory annotations and it will be used to map the values to your Cassandra entities. Here you have the annotations that you will have to use:

  • uk.co.caeldev.cassitory.entities.CassitoryEntity
  • uk.co.caeldev.cassitory.entities.Mapping

Using Prepared Statements and queries

with this repo you don't have to create your Cassandra entities, just your DTO annotated with Cassitory annotations. Here you have the annotations that you will have to use:

  • uk.co.caeldev.cassitory.statements.CassitoryEntity
  • uk.co.caeldev.cassitory.statements.Mapping

How to use it

Add to your gradle dependency to run the annotation processor and follow one of the two kind of repositories that Cassitory offers you.

finally annotate your DTO class with the Cassitory annotations that fits better for your project.

cassitory's People

Contributors

caelcs avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

cassitory's Issues

Add validation or lazy initiation against Cassandra

Two topics very related each other.

  • First one is to provide a way to validate that the parameters and query are correct against cassandra.

  • Second is to support lazy initialisation to create the prepared statements knowing that the session can or not be available. This is particularly useful when you use a DI framework and your session is not ready when the application context has finished but you don't want you application not to start because of it.

Support for queries

The goal here is for the repository to provide a way to run queries an populate the pojo again.

support for writing to sub set of tables driven by configuration

In the case of migration of tables... it would be nice to have a way to decide whether to write to both tables and then later on write to one driven only by config...
Eventually when the old tables is ready to be deleted then the reference can be removed from Cassitory annotations.

Generation of Integration test for the code generated

It would be nice to generate integration test for the Repository and see if there is any typo in the queries or mapping.
One way to do this is by using test annotation processor that would generate all the tests but it would need Cassandra unit as dependency.

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.