Skip to content

Thrift columns

Flavian Alexandru edited this page May 29, 2015 · 9 revisions

Build Status Coverage Status Maven Central Download

Integrating Thrift columns

To use Thrift columns, first and foremost you need a dependency on phantom-thrift. The Thrift module has no explicit dependency on any Apache Thrift library and instead allows Twitter Scrooge, the real underlying serialization mechanism for Apache Thrift, to set the version it needs.

Scrooge is a very powerful integration tool for Scala services built atop Twitter Finagle and Apache Thrift and has the ability to automatically generate entire server and client applications from a simple IDL, and mixing that with a Phantom/Cassandra database store will help you build a very powerful distributed system with minimal effort. Read more about Twitter Scrooge.

libraryDependencies ++= Seq(
  "com.websudos" %% "phantom-thrift" % PhantomVersion
)

These columns are especially useful if you are building Thrift services. They are deeply integrated with Twitter Scrooge and relevant to the Twitter ecosystem(Finagle, Zipkin, Storm etc) They are available via the phantom-thrift module and you need to import the Thrift package to get all necessary types into scope.

import com.websudos.phantom.thrift._

In the below scenario, the Cassandra type is always text and the type you need to pass to the column is a Thrift struct, specifically com.twitter.scrooge .ThriftStruct. phantom will use a CompactThriftSerializer, store the record as a binary string and then reparse it on fetch.

Thrift serialization and de-serialization is extremely fast, so you don't need to worry about speed or performance overhead. You generally use these to store collections(small number of items), not big things.

phantom columns Cassandra columns
ThriftColumn.<type> text
ThriftListColumn.<type> list<text>
ThriftSetColumn.<type> set<text>
ThriftMapColumn.<type, type> map<text, text>