me.prettyprint.cassandra.model.BasicColumnDefinition Java Examples

The following examples show how to use me.prettyprint.cassandra.model.BasicColumnDefinition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Cassandra12xTripleIndexDAO.java    From cumulusrdf with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a column family definition.
 * 
 * @param colName the column family name.
 * @param validationClass the validation class.
 * @param indexName the index name.
 * @return the column family definition.
 */
protected ColumnDefinition createCDef(
		final byte[] colName,
		final String validationClass,
		final String indexName) {

	final BasicColumnDefinition colDef = new BasicColumnDefinition();
	colDef.setName(ByteBuffer.wrap(colName));
	colDef.setValidationClass(validationClass);
	colDef.setIndexType(ColumnIndexType.KEYS);
	colDef.setIndexName(indexName);
	return colDef;
}
 
Example #2
Source File: Cassandra12xMapDAO.java    From cumulusrdf with Apache License 2.0 5 votes vote down vote up
@Override
public void createRequiredSchemaEntities() throws DataAccessLayerException {
	final String keyspace_name = _keyspace.getKeyspaceName();
	final KeyspaceDefinition ksdef = _factory.getCluster().describeKeyspace(keyspace_name);

	if (!hasColumnFamily(ksdef, _cf_name)) {

		final ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(keyspace_name, _cf_name);
		final Map<String, String> compressionOptions = new HashMap<String, String>();
		compressionOptions.put("sstable_compression", "SnappyCompressor");
		cfDef.setCompressionOptions(compressionOptions);
		
		cfDef.setColumnType(ColumnType.STANDARD);
		cfDef.setKeyValidationClass(ComparatorType.BYTESTYPE.getClassName());
		cfDef.setDefaultValidationClass(ComparatorType.BYTESTYPE.getClassName());
		cfDef.setCompactionStrategy("LeveledCompactionStrategy");

		if (_isBidirectional) {

			BasicColumnDefinition colDef = new BasicColumnDefinition();
			colDef.setName(BytesArraySerializer.get().toByteBuffer(COLUMN_NAME));
			colDef.setValidationClass(ComparatorType.BYTESTYPE.getClassName());
			colDef.setIndexType(ColumnIndexType.KEYS);
			colDef.setIndexName(_cf_name + "_val_idx");

			cfDef.addColumnDefinition(colDef);
		}

		_factory.getCluster().addColumnFamily(new ThriftCfDef(cfDef), true);
	}
}