Skip to content

Instantly share code, notes, and snippets.

@zeryx
Created January 22, 2016 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeryx/dda25e7a5e95ff28187a to your computer and use it in GitHub Desktop.
Save zeryx/dda25e7a5e95ff28187a to your computer and use it in GitHub Desktop.
object TitanCon extends InMemory with InCassandra{
lazy var Graph: TitanGraph
def connect(backendType: String): Unit = {
Graph = backendType match {
case "inMemory" => memoryConnect()
case "inCassandra" => cassandraConnect()
}
}
}
trait InMemory {
def memoryConnect(): TitanGraph = {
val conf = new BaseConfiguration()
conf.setProperty("storage.backend","inmemory")
TitanFactory.open(conf)
}
}
trait InCassandra {
def cassandraConnect(): TitanGraph = {
TitanFactory.open("titan-cassandra.properties")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment