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


A zipped version of my Terracotta project is attached below.

I downloaded the BigMemory Max tar ball (yes, no zip version!) after filling in the mandatory form (no guest download)

The folder structure after unzipping was

Server setup

Compared to the other systems I evaluated, the documentation accompanying Terracotta is not the best in terms of completeness or ease of use.

You will receive a license key file: terracotta-license.key

Place it under the root directory (bigmemory-max-4.0.5 dir in the above image)

I started the server by running start-tc-server.bat under the server/bin directory. When running my test cases, it soon ran out of memory.

Open start-tc-server.bat under server/bin and make the JVM size as 1G as shown

Configuration files

The main config file to use is ehcache.xml which can be found under the resources folder.

The client side also needs the license file so I have added that too to the folder

The documentation suggested that the addition of this line

    <terracottaConfig rejoin="true" url="localhost:9510"/>

would allow client connectivity to the server. But that never worked for me. Innumerable Google and StackOverflow searches later, I got a tip that adding <terracotta/> to each cache would do the trick.It did.

You will therefore find an entry in all the caches in the config

Another annoying discovery was that you can only search on attributes marked as searchable in the config. The config therefore is typically
  <cache name="tradedata" maxBytesLocalHeap="64M">
            <searchAttribute name="strikeDate"/>
            <searchAttribute name="call"/>

Data Population

Not surprising, given that there is a cache that underpins this system, the data population is done with a cache "put". However instead of taking a key/value pair, you need to wrap that in an Element object which is what the "put" takes as an argument. For example
        effectiveDate = sdf.parse("18-Jun-1999");
        Element putmd = new Element("EMD18Jun1999", mdc.createDataFor(effectiveDate, 0.07, 0.22, 0.01));

where Element is ehcache Element

Querying and Filtering

As mentioned earlier, only attributes marked searchable 'a priori' can be searched. For example, to retrieve the market data for a particular date
        Cache markets = cacheManager.getCache("marketdata");
        Attribute<Object> ed = markets.getSearchAttribute("effectiveDate");
        Query query = markets.createQuery().addCriteria(ed.eq(effectiveDate)).includeValues();
        Results results = query.execute();

Raj Subramani,
13 Nov 2013, 10:04