Giter Club home page Giter Club logo

cassandra_caseclass_adapter's Introduction

Cassandra Case Class Adapters

Build Status

Maps Case classes to the Cassandra Java Driver using shapeless powered type classes.

Note:

  • this is in early development stage
  • contains weird hacks and class casts
  • not API stable

Thanks a lot to the Shapeless team for their wonderful work.

Add Dependency

Builds are available for Scala 2.11, 2.12 having a dependency to the Cassandra Driver 4.7.2.

Add this to your build.sbt:

libraryDependencies += "net.reactivecore" %% "cassandra-caseclass-adapter" % "0.0.2"

If you use Scala 2.10, you also need (see Shapeless Documentation)

libraryDependencies += compilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)

Usage

Define a case class

case class Person (
    id: UUID,
    name: String,
    age: Int
  )

Have a cassandra table

  CREATE TABLE persons (
    id UUID,
    name TEXT,
    age INT,
    PRIMARY KEY (id)
  );

And let the Adapter automatically generated

  import net.reactivecore.cca.CassandraCaseClassAdapter

  val adapter = CassandraCaseClassAdapter.make[Person]("persons")
  val session = // open cassandra session
  val person = Person(UUIDs.random(), "John Doe", 42)
  adapter.insert(person, session)
  
  val back: Seq[Person] = adapter.loadAllFromCassandra(session)

Supported

  • boiler plate free fromRow, insert, loadAllFromCassandra

Supported Types

  • Most fundamental types
  • Option
  • Set of Primitives and of UDT
  • List of Primitives (as Seq) and of UDT
  • Primitive UDT handling

Not supported / tested yet

  • Map
  • Tuples
  • Combination of Set/Seq with more than one UDT
  • Adding custom types
  • Prepared Statements for fast insert

Not planned (yet)

  • Query Helpers

Testing

  • The unit tests need a Cassandra Instance running on 127.0.0.1
  • They will recreate a keyspace called unittest on each single testcase.

cassandra_caseclass_adapter's People

Contributors

guntherw avatar nob13 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

guntherw

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.