Java Code Examples for me.prettyprint.hector.api.ddl.ColumnFamilyDefinition#setCompactionStrategy()

The following examples show how to use me.prettyprint.hector.api.ddl.ColumnFamilyDefinition#setCompactionStrategy() . 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: Cassandra12xCounterDAO.java    From cumulusrdf with Apache License 2.0 6 votes vote down vote up
@Override
public void createRequiredSchemaEntities() throws DataAccessLayerException {
	final String keyspaceName = _keyspace.getKeyspaceName();
	KeyspaceDefinition ksdef = _factory.getCluster().describeKeyspace(keyspaceName);

	if (!hasColumnFamily(ksdef, _cf_name)) {
		ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(keyspaceName, _cf_name);
		cfDef.setKeyValidationClass(ComparatorType.UTF8TYPE.getClassName());
		cfDef.setComparatorType(ComparatorType.UTF8TYPE);
		cfDef.setCompactionStrategy("LeveledCompactionStrategy");
		cfDef.setDefaultValidationClass(ComparatorType.COUNTERTYPE.getClassName());
		cfDef.setColumnType(ColumnType.STANDARD);
		_factory.getCluster().addColumnFamily(cfDef, true);
	}

	setDefaultValue(-1L);
}
 
Example 2
Source File: CassandraService.java    From usergrid with Apache License 2.0 6 votes vote down vote up
/**
 * Lazy creates a column family in the keyspace. If it doesn't exist, it will be created, then the call will sleep
 * until all nodes have acknowledged the schema change
 */
public void createColumnFamily( String keyspace, ColumnFamilyDefinition cfDef ) {

    if ( !keySpaceExists( keyspace ) ) {
        createKeySpace( keyspace );
    }


    //add the cf

    if ( !cfExists( keyspace, cfDef.getName() ) ) {

        //default read repair chance to 0.1
        cfDef.setReadRepairChance( 0.1d );
        cfDef.setCompactionStrategy( "LeveledCompactionStrategy" );
        cfDef.setCompactionStrategyOptions( new MapUtils.HashMapBuilder().map("sstable_size_in_mb", "512"  ) );

        cluster.addColumnFamily( cfDef, true );
        logger.info( "Created column family {} in keyspace {}", cfDef.getName(), keyspace );
    }
}
 
Example 3
Source File: Cassandra12xTripleIndexDAO.java    From cumulusrdf with Apache License 2.0 5 votes vote down vote up
/**
 * Creates POS? column family.
 * 
 * @param cfName the column family name.
 * @return the POS? column family definition.
 */
protected ColumnFamilyDefinition createCF_PO_Sx(final String cfName) {

	final ColumnFamilyDefinition cfdef = HFactory.createColumnFamilyDefinition(_dataAccessLayerFactory.getKeyspaceName(), cfName, ComparatorType.COMPOSITETYPE);
	cfdef.setColumnType(ColumnType.STANDARD);
	cfdef.setKeyValidationClass(ComparatorType.BYTESTYPE.getClassName());
	cfdef.setDefaultValidationClass(ComparatorType.BYTESTYPE.getClassName());
	cfdef.setComparatorTypeAlias("(DoubleType, BytesType)");
	cfdef.setCompactionStrategy("LeveledCompactionStrategy");
	
	cfdef.setCompressionOptions(_compressionOptions);
	return new ThriftCfDef(cfdef);
}
 
Example 4
Source File: Cassandra12xTripleIndexDAO.java    From cumulusrdf with Apache License 2.0 5 votes vote down vote up
/**
 * Creates POS? column family used for date range queries.
 * 
 * @param cfName the column family name.
 * @return the POS? column family definition.
 */
protected ColumnFamilyDefinition createCF_RDT_PO_S(final String cfName) {
	final ColumnFamilyDefinition cfdef = HFactory.createColumnFamilyDefinition(_dataAccessLayerFactory.getKeyspaceName(), cfName, ComparatorType.COMPOSITETYPE);
	cfdef.setColumnType(ColumnType.STANDARD);
	cfdef.setKeyValidationClass(ComparatorType.BYTESTYPE.getClassName());
	cfdef.setDefaultValidationClass(ComparatorType.BYTESTYPE.getClassName());
	cfdef.setComparatorTypeAlias("(LongType, BytesType)");
	cfdef.setCompactionStrategy("LeveledCompactionStrategy");

	cfdef.setCompressionOptions(_compressionOptions);
	return new ThriftCfDef(cfdef);
}
 
Example 5
Source File: Cassandra12xTripleIndexDAO.java    From cumulusrdf with Apache License 2.0 5 votes vote down vote up
/**
 * Creates SPO? column family used for date range queries.
 * 
 * @param cfName the column family name.
 * @return the SPO? column family definition.
 */
protected ColumnFamilyDefinition createCF_RDT_SP_O(final String cfName) {
	final ColumnFamilyDefinition cfdef = HFactory.createColumnFamilyDefinition(_dataAccessLayerFactory.getKeyspaceName(), cfName, ComparatorType.LONGTYPE);
	cfdef.setColumnType(ColumnType.STANDARD);
	cfdef.setKeyValidationClass(ComparatorType.BYTESTYPE.getClassName());
	cfdef.setDefaultValidationClass(ComparatorType.BYTESTYPE.getClassName());
	cfdef.setCompactionStrategy("LeveledCompactionStrategy");

	cfdef.setCompressionOptions(_compressionOptions);
	return new ThriftCfDef(cfdef);
}
 
Example 6
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);
	}
}
 
Example 7
Source File: Cassandra12xTripleIndexDAO.java    From cumulusrdf with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a column family definition.
 * 
 * @param cfName the column family name.
 * @param indexedCols names of columns that will be indexed.
 * @param keyComp the key comparator.
 * @param valueValidationClass the value validation class.
 * @param compositeCol a flag that indicates if columns are composite.
 * @return the column family definition.
 */
protected ColumnFamilyDefinition createCF(
		final String cfName,
		final List<byte[]> indexedCols,
		final ComparatorType keyComp,
		final ComparatorType valueValidationClass,
		final boolean compositeCol) {

	final ColumnFamilyDefinition cfdef = HFactory.createColumnFamilyDefinition(
			_dataAccessLayerFactory.getKeyspaceName(), 
			cfName, 
			compositeCol
				? ComparatorType.COMPOSITETYPE
				: ComparatorType.BYTESTYPE);
	cfdef.setKeyspaceName(_dataAccessLayerFactory.getKeyspaceName());
	cfdef.setColumnType(ColumnType.STANDARD);
	cfdef.setCompactionStrategy("LeveledCompactionStrategy");

	if (compositeCol) {
		cfdef.setComparatorTypeAlias("(BytesType, BytesType, BytesType)");
	}

	for (byte[] col : indexedCols) {
		final String indexColumnFamilyName = "index_" + cfName + "_" + Arrays.hashCode(col);
		try {
			_dataAccessLayerFactory.getCluster().dropColumnFamily(
					_dataAccessLayerFactory.getKeyspaceName(),
					indexColumnFamilyName,
					true);
		} catch (HInvalidRequestException ignore) {
			// Nothing to be done here...
		}
		cfdef.addColumnDefinition(createCDef(col, valueValidationClass.getClassName(), indexColumnFamilyName));
	}

	cfdef.setKeyValidationClass(keyComp.getClassName());
	cfdef.setDefaultValidationClass(valueValidationClass.getClassName());
	cfdef.setCompressionOptions(_compressionOptions);

	return new ThriftCfDef(cfdef);
}