Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Titan with Cassandra CQL #364

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<module>titan-test</module>
<module>titan-berkeleyje</module>
<module>titan-cassandra</module>
<module>titan-cassandra-cql</module>
<module>titan-persistit</module>
<module>titan-hbase</module>
<module>titan-es</module>
Expand Down
49 changes: 49 additions & 0 deletions titan-cassandra-cql/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.thinkaurelius.titan</groupId>
<artifactId>titan</artifactId>
<version>0.4.0-SNAPSHOT</version>
</parent>
<artifactId>titan-cassandra-cql</artifactId>
<name>titan-cassandra-cql</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.thinkaurelius.titan</groupId>
<artifactId>titan-core</artifactId>
<version>${titan.version}</version>
</dependency>
<dependency>
<groupId>com.thinkaurelius.titan</groupId>
<artifactId>titan-test</artifactId>
<version>${titan.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>${metrics.version}</version>
</dependency>
<!-- JNA is not required to run Cassandra, but it improves efficiency of
certain of Cassandra's filesystem and memory operations. DataStax describes
JNA as "required for production installations": http://www.datastax.com/docs/1.2/install/install_jre -->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>3.2.7</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package org.titan.cassandra.cql;

import com.datastax.driver.core.ConsistencyLevel;
import com.google.common.base.Preconditions;

/**
* Map CQL consistency levels to Titan.
*
* @author gciuloaica
*
*/
public enum Consistency {
ONE, TWO, THREE, ANY, ALL, QUORUM, LOCAL_QUORUM, EACH_QUORUM;

public static Consistency parse(String value) {
Preconditions.checkArgument(value != null && !value.isEmpty());
value = value.trim();
if (value.equals("1"))
return ONE;
else if (value.equals("2"))
return TWO;
else if (value.equals("3"))
return THREE;
else {
for (Consistency c : values()) {
if (c.toString().equalsIgnoreCase(value))
return c;
}
}
throw new IllegalArgumentException(
"Unrecognized cassandra consistency level: " + value);
}

public ConsistencyLevel getCqlConsistency() {
switch (this) {
case ONE:
return ConsistencyLevel.ONE;
case TWO:
return ConsistencyLevel.TWO;
case THREE:
return ConsistencyLevel.THREE;
case ALL:
return ConsistencyLevel.ALL;
case ANY:
return ConsistencyLevel.ANY;
case QUORUM:
return ConsistencyLevel.QUORUM;
case LOCAL_QUORUM:
return ConsistencyLevel.LOCAL_QUORUM;
case EACH_QUORUM:
return ConsistencyLevel.EACH_QUORUM;
default:
throw new IllegalArgumentException(
"Unrecognized consistency level: " + this);
}
}

}
Loading