本文整理汇总了Java中me.prettyprint.cassandra.model.BasicColumnFamilyDefinition类的典型用法代码示例。如果您正苦于以下问题:Java BasicColumnFamilyDefinition类的具体用法?Java BasicColumnFamilyDefinition怎么用?Java BasicColumnFamilyDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicColumnFamilyDefinition类属于me.prettyprint.cassandra.model包,在下文中一共展示了BasicColumnFamilyDefinition类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCF_SP_Ox
import me.prettyprint.cassandra.model.BasicColumnFamilyDefinition; //导入依赖的package包/类
/**
* Creates SPO? column family.
*
* @param cfName the column family name.
* @return the SPO? column family definition.
*/
protected ColumnFamilyDefinition createCF_SP_Ox(final String cfName) {
final BasicColumnFamilyDefinition cfdef = new BasicColumnFamilyDefinition();
cfdef.setKeyspaceName(_dataAccessLayerFactory.getKeyspaceName());
cfdef.setName(cfName);
cfdef.setColumnType(ColumnType.STANDARD);
cfdef.setComparatorType(ComparatorType.getByClassName("org.apache.cassandra.db.marshal.DoubleType"));
cfdef.setCompactionStrategy("LeveledCompactionStrategy");
cfdef.setKeyValidationClass(ComparatorType.BYTESTYPE.getClassName());
cfdef.setDefaultValidationClass(ComparatorType.BYTESTYPE.getClassName());
cfdef.setCompressionOptions(_compressionOptions);
return new ThriftCfDef(cfdef);
}
示例2: createSchema
import me.prettyprint.cassandra.model.BasicColumnFamilyDefinition; //导入依赖的package包/类
private void createSchema() {
// ColumnFamily 1
BasicColumnDefinition columnDefinition1_1 = new BasicColumnDefinition();
columnDefinition1_1.setName(stringSerializer.toByteBuffer("name"));
columnDefinition1_1.setValidationClass(ComparatorType.LONGTYPE.getClassName());
BasicColumnDefinition columnDefinition1_2 = new BasicColumnDefinition();
columnDefinition1_2.setName(stringSerializer.toByteBuffer("column_A_B"));
columnDefinition1_2.setValidationClass(ComparatorType.UTF8TYPE.getClassName());
BasicColumnFamilyDefinition columnFamilyDefinition1 = new BasicColumnFamilyDefinition();
columnFamilyDefinition1.setKeyspaceName(KEYSPACE_NAME);
columnFamilyDefinition1.setName(COLUMN_FAMILY_NAME_1);
columnFamilyDefinition1.addColumnDefinition(columnDefinition1_1);
columnFamilyDefinition1.addColumnDefinition(columnDefinition1_2);
ColumnFamilyDefinition cfDef1 = new ThriftCfDef(columnFamilyDefinition1);
// ColumnFamily 2
BasicColumnDefinition columnDefinitionIndexed1 = new BasicColumnDefinition();
columnDefinitionIndexed1.setName(stringSerializer.toByteBuffer("column_test_1"));
columnDefinitionIndexed1.setIndexType(ColumnIndexType.KEYS);
columnDefinitionIndexed1.setIndexName("INDEX_COLUMN_TEST_1");
columnDefinitionIndexed1.setValidationClass(ComparatorType.UTF8TYPE.getClassName());
BasicColumnDefinition columnDefinitionIndexed2 = new BasicColumnDefinition();
columnDefinitionIndexed2.setName(stringSerializer.toByteBuffer("birthdate"));
columnDefinitionIndexed2.setIndexType(ColumnIndexType.KEYS);
columnDefinitionIndexed2.setIndexName("INDEX_BIRTH_DATE");
columnDefinitionIndexed2.setValidationClass(ComparatorType.LONGTYPE.getClassName());
BasicColumnFamilyDefinition columnFamilyDefinitionIndexed = new BasicColumnFamilyDefinition();
columnFamilyDefinitionIndexed.setKeyspaceName(KEYSPACE_NAME);
columnFamilyDefinitionIndexed.setName(COLUMN_FAMILY_INDEXED_1);
columnFamilyDefinitionIndexed.addColumnDefinition(columnDefinitionIndexed1);
columnFamilyDefinitionIndexed.addColumnDefinition(columnDefinitionIndexed2);
ColumnFamilyDefinition cfDef2 = new ThriftCfDef(columnFamilyDefinitionIndexed);
// ColumnFamilySuper
BasicColumnDefinition columnDefinitionSuper1 = new BasicColumnDefinition();
columnDefinitionSuper1.setName(stringSerializer.toByteBuffer("Super_Column_1"));
columnDefinitionSuper1.setValidationClass(ComparatorType.UTF8TYPE.getClassName());
BasicColumnFamilyDefinition columnFamilyDefinitionSuper2 = new BasicColumnFamilyDefinition();
columnFamilyDefinitionSuper2.setKeyspaceName(KEYSPACE_NAME);
columnFamilyDefinitionSuper2.setName(COLUMN_FAMILY_SUPER_1);
columnFamilyDefinitionSuper2.setColumnType(ColumnType.SUPER);
columnFamilyDefinitionSuper2.addColumnDefinition(columnDefinitionSuper1);
ColumnFamilyDefinition cfDefSuper = new ThriftCfDef(columnFamilyDefinitionSuper2);
KeyspaceDefinition keyspaceDefinition = HFactory.createKeyspaceDefinition(KEYSPACE_NAME,
SimpleStrategy.class.getName(), 1, Arrays.asList(cfDef1, cfDef2, cfDefSuper));
cluster.addKeyspace(keyspaceDefinition, true);
// cluster.updateKeyspace(keyspaceDefinition);
}