home‎ > ‎Programming‎ > ‎Comparing NoSQL Data Stores‎ > ‎

Cassandra

You can download the correct version of Cassandra for your OS from the DataStax website. A zipped version of my project is attached below.


On installation, the folder looked like this on my Windows laptop



Project setup

The Cassandra dependencies added to the pom imports all the jars required to run the project (in other words, they were not manually added)

 
       <dependency>
            <groupId>com.datastax.cassandra</groupId>
            <artifactId>cassandra-driver-core</artifactId>
            <version>1.0.3</version>
        </dependency>

        <dependency>
            <groupId>com.datastax.cassandra</groupId>
            <artifactId>cassandra-driver-core</artifactId>
            <version>1.0.3-dse</version>
        </dependency>


Server setup

Simply start cassandra.bat  under apache-cassandra/bin to start the server.


Once you have started the server,
you can use the connectivity test to check if you are able to connect to it.


Schema and Table setup (and tear down)

Once connectivity has been established successfully, you need to create the market data schema and tables
before inserting market data. There is a method to drop the schema (I real life you might "ALTER", but here DROP sufficed)


Similarly, for the trade data schema, use testCreateSchema to create the schema and tables and use the testDropSchema to tear it down

Data Population

For populating the market data use one of these methods
  • testInsetTestMarketData - will insert one test data (for effective date 15-May-1998)
  • testInsertMarketDataForDates - will insert market data for two other dates
For populating the trade data use either of these
  • testInsertTestTradeData - will insert the one test trade (for effective date 15-May-1998)
  • testNextTradeData - will insert a trade with random parameters (within tolerance)
NOTE: the trade population for Cassandra was reduced to 500,000 instead of One million due to severe performance issues

Once you have run testInsetTestMarketData and testInsertTestTradeData (as the bare minimum), you should be able to run the test pricer to verify that the whole setup works. The method is testPricingTestData and checks that the NPV is as expected.

Querying and Filtering

  • testRetrieveTestMarketData - will retrieve a single market data object (which is the one used for pricing)
  • testRetrieveAllMarketData - since market data for multiple dates were inserted, this method retrieves them all
Since assetClass was not added as an index, it was neccessary to add "allow filltering" when creating the CQL query

SELECT data from marketdata.markets where assetClass=? allow filtering

The caveat being, not all data is guaranteed to be returned (which made Cassandra the least favorite of the system I analyzed, not to mention the performance issues encountered when query across the full One million population set)

ċ
cassandra.zip
(54k)
Raj Subramani,
13 Nov 2013, 10:03