Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated to use 0.8, added superCF example

  • Loading branch information...
commit 466eb95be6d04d9ce548cc43f7ee2d4df66dc96c 1 parent 826ea32
zznate authored
View
12 pom.xml
@@ -28,7 +28,7 @@
<dependency>
<groupId>me.prettyprint</groupId>
<artifactId>hector-core</artifactId>
- <version>0.7.0-24</version>
+ <version>0.8.0-2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@@ -41,16 +41,6 @@
<version>1.5.11</version>
</dependency>
<dependency>
- <groupId>org.apache.cassandra</groupId>
- <artifactId>cassandra-all</artifactId>
- <version>0.7.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cassandra.deps</groupId>
- <artifactId>libthrift</artifactId>
- <version>0.5.0</version>
- </dependency>
- <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.1</version>
View
31 src/main/java/com/riptano/cassandra/hector/example/SchemaManipulation.java
@@ -11,6 +11,7 @@
import me.prettyprint.hector.api.Cluster;
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition;
import me.prettyprint.hector.api.ddl.ColumnIndexType;
+import me.prettyprint.hector.api.ddl.ColumnType;
import me.prettyprint.hector.api.ddl.ComparatorType;
import me.prettyprint.hector.api.ddl.KeyspaceDefinition;
import me.prettyprint.hector.api.exceptions.HectorException;
@@ -31,6 +32,7 @@
private static final String DYN_KEYSPACE = "DynamicKeyspace";
private static final String DYN_CF = "DynamicCf";
+ private static final String CF_SUPER = "SuperCf";
private static StringSerializer stringSerializer = StringSerializer.get();
@@ -39,7 +41,9 @@ public static void main(String[] args) throws Exception {
Cluster cluster = HFactory.getOrCreateCluster("TestCluster", "localhost:9160");
try {
- cluster.dropKeyspace(DYN_KEYSPACE);
+ if ( cluster.describeKeyspace(DYN_KEYSPACE) != null ) {
+ cluster.dropKeyspace(DYN_KEYSPACE);
+ }
BasicColumnDefinition columnDefinition = new BasicColumnDefinition();
columnDefinition.setName(stringSerializer.toByteBuffer("birthdate"));
@@ -51,10 +55,19 @@ public static void main(String[] args) throws Exception {
columnFamilyDefinition.setName(DYN_CF);
columnFamilyDefinition.addColumnDefinition(columnDefinition);
- ColumnFamilyDefinition cfDef = new ThriftCfDef(columnFamilyDefinition);
+ BasicColumnFamilyDefinition superCfDefinition = new BasicColumnFamilyDefinition();
+ superCfDefinition.setKeyspaceName(DYN_KEYSPACE);
+ superCfDefinition.setName(CF_SUPER);
+ superCfDefinition.setColumnType(ColumnType.SUPER);
+
+
+
+ ColumnFamilyDefinition cfDefStandard = new ThriftCfDef(columnFamilyDefinition);
+ ColumnFamilyDefinition cfDefSuper = new ThriftCfDef(superCfDefinition);
KeyspaceDefinition keyspaceDefinition =
- HFactory.createKeyspaceDefinition(DYN_KEYSPACE, "org.apache.cassandra.locator.SimpleStrategy", 1, Arrays.asList(cfDef));
+ HFactory.createKeyspaceDefinition(DYN_KEYSPACE, "org.apache.cassandra.locator.SimpleStrategy",
+ 1, Arrays.asList(cfDefStandard, cfDefSuper));
cluster.addKeyspace(keyspaceDefinition);
@@ -67,10 +80,14 @@ public static void main(String[] args) throws Exception {
System.out.println("RF: " +kd.getReplicationFactor());
System.out.println("strategy class: " +kd.getStrategyClass());
List<ColumnFamilyDefinition> cfDefs = kd.getCfDefs();
- ColumnFamilyDefinition def = cfDefs.get(0);
- System.out.println(" CF Name: " +def.getName());
- System.out.println(" CF Metadata: " +def.getColumnMetadata());
- }
+ for (ColumnFamilyDefinition def : cfDefs) {
+ System.out.println(" CF Type: " +def.getColumnType());
+ System.out.println(" CF Name: " +def.getName());
+ System.out.println(" CF Metadata: " +def.getColumnMetadata());
+ }
+
+
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.