houssam-eldeen / agiato Goto Github PK
View Code? Open in Web Editor NEWThis project forked from pranab/agiato
A simple no frill Cassandra java API
Home Page: http://pkghosh.wordpress.com/
This project forked from pranab/agiato
A simple no frill Cassandra java API
Home Page: http://pkghosh.wordpress.com/
Agiato is a simple no frill Cassandra NOSQL database API. My goal has been to make sure that it does not take someone more than hour to learn the API and start using it. It DOES the following --------------------- - Supports Cassandra version .7x - Simple wrapper around thrift API - API does not support different data types. Basically deals with ByteBuffer - An Util class is provided for conversion between ByteBuffer and basic data types, which the client app may use - API only understands ByteBuffer - The whole API is defined in one class - There is database connection pooling using appache commons pool library - There is a simple round robin load balancer, out of the box. - User defined load balancer can be plugged in - There is JSON file that defines cluster, connection configuration, key space definitions, indexes and named queries - The API loads the JSON on start up and creates the key space and column families if necessary - The client app needs to make sure cassandra.json file is placed in the class path The API DOES NO DO the following -------------------------------- - Object mapping - Data type support It WILL DO the following in future ---------------------------------- - Support named query and index defined in JSON Setup ----- Here is a sample cassandra.json file. You should change the content to meet your need. Agiato expects this file in the class path. { "cluster" : { "hosts" : [ { "name" : "localhost", "port" : 9160 } ], "loadBalancerClass" : "agiato.cassandra.connect.RoundRobinLoadBalancer", "poolConfig" : { "maxActive" : 8, "maxIdle" : 8 } }, "keySpace" : { "name" : "PatientMonitor", "replicaPlacementStrategy" : "org.apache.cassandra.locator.SimpleStrategy", "replicationFactor" : 1, "endPointSnitch" : "org.apache.cassandra.locator.EndPointSnitch", "columnFamilies" : [ { "name" : "MonitorData", "columnType" : "Standard", "compareWith" : "UTF8Type", "keysCached" : 1000, "rowsCached" : 10 }, { "name" : "Patient", "columnType" : "Standard", "compareWith" : "UTF8Type", "keysCached" : 100, "rowsCached" : 10 } ], "indexes" : [ { "name" : "monitorDataByPatientID", "colFamily" : "MonitorData", "type" : "1.1.1.2", "indexedColumnName" : "patientID", "indexedDataType" : 1, "storedDataType" : 2, "indexKeysCached" : 10, "indexRowsCached" : 5 } ] } } Example client code ------------------- //when your app starts DataManager.initialize(false); //insert a super column into MonitorData column family DataAccess dataAccess = new DataAccess(); List<SuperColumnValue> superColValues = new ArrayList<SuperColumnValue>(); long rowKey = ... long superColName = ... List<ColumnValue> colValues = new ArrayList<ColumnValue>(); ColumnValue colVal = new ColumnValue(); colVal.write("ecg", getEcg()); colValues.add(colVal); colVal = new ColumnValue(); colVal.write("diaBp", getDiaBp()); colValues.add(colVal); colVal = new ColumnValue(); colVal.write("sysBp", getSysBp()); colValues.add(colVal); colVal = new ColumnValue(); colVal.write("temp", getTemp()); colValues.add(colVal); colVal = new ColumnValue(); colVal.write("pulse", getPulse()); colValues.add(colVal); SuperColumnValue superColVal = new SuperColumnValue(); superColVal.setNameFromLong(superColName); superColVal.setValues(colValues); superColValues.add(superColVal); dataAccess.insertSuperColumns("MonitorData", rowKey, superColValues, ConsistencyLevel.ALL); Note ---- Index and named query is not fully tested. It's work in progress. I will provide an update when it's functional Reference --------- For background material on this please visit my following blogs http://pkghosh.wordpress.com/2011/03/02/cassandra-secondary-index-patterns/ http://pkghosh.wordpress.com/2010/12/11/easy-cassandra-data-access/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.