Java源码示例:me.prettyprint.hector.api.ddl.ColumnIndexType

示例1
/**
 * 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;
}
 
示例2
@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);
	}
}