Search in sources :

Example 21 with CFMetaData

use of org.apache.cassandra.config.CFMetaData in project eiger by wlloyd.

the class KeysIndex method init.

public void init() {
    assert baseCfs != null && columnDefs != null;
    ColumnDefinition columnDef = columnDefs.iterator().next();
    CFMetaData indexedCfMetadata = CFMetaData.newIndexMetadata(baseCfs.metadata, columnDef, indexComparator());
    indexCfs = ColumnFamilyStore.createColumnFamilyStore(baseCfs.table, indexedCfMetadata.cfName, new LocalPartitioner(columnDef.getValidator()), indexedCfMetadata);
}
Also used : CFMetaData(org.apache.cassandra.config.CFMetaData) ColumnDefinition(org.apache.cassandra.config.ColumnDefinition)

Example 22 with CFMetaData

use of org.apache.cassandra.config.CFMetaData in project eiger by wlloyd.

the class ThriftValidationTest method testColumnValueSizeForIndexedColumn.

@Test
public void testColumnValueSizeForIndexedColumn() throws ConfigurationException, InvalidRequestException {
    CfDef cfDef = Schema.instance.getCFMetaData("Keyspace1", "Standard1").toThrift();
    ByteBuffer columnName = AsciiType.instance.fromString("indexed");
    // add an indexed column definition
    cfDef.addToColumn_metadata(new ColumnDef(columnName, UTF8Type.class.getCanonicalName()).setIndex_type(IndexType.KEYS).setIndex_name("indexed_col"));
    CFMetaData metaData = CFMetaData.fromThrift(cfDef);
    Column column = new Column(columnName).setValue(new byte[FBUtilities.MAX_UNSIGNED_SHORT + 1]).setTimestamp(System.currentTimeMillis());
    boolean gotException = false;
    try {
        // this run should throw an exception
        ThriftValidation.validateColumnData(metaData, column, false);
    } catch (InvalidRequestException e) {
        gotException = true;
    }
    assert gotException : "expected InvalidRequestException but not received.";
    // change value to be less than unsigned short size
    column.setValue(new byte[12]);
    // reset flag
    gotException = false;
    try {
        // this run should run clean
        ThriftValidation.validateColumnData(metaData, column, false);
    } catch (InvalidRequestException e) {
        gotException = true;
    }
    assert !gotException : "got unexpected InvalidRequestException";
}
Also used : CFMetaData(org.apache.cassandra.config.CFMetaData) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

CFMetaData (org.apache.cassandra.config.CFMetaData)22 ByteBuffer (java.nio.ByteBuffer)4 ColumnDefinition (org.apache.cassandra.config.ColumnDefinition)3 ConfigurationException (org.apache.cassandra.config.ConfigurationException)3 AbstractType (org.apache.cassandra.db.marshal.AbstractType)3 InvalidRequestException (org.apache.cassandra.thrift.InvalidRequestException)3 Test (org.junit.Test)3 KSMetaData (org.apache.cassandra.config.KSMetaData)2 IMutation (org.apache.cassandra.db.IMutation)2 RowMutation (org.apache.cassandra.db.RowMutation)2 QueryPath (org.apache.cassandra.db.filter.QueryPath)2 File (java.io.File)1 IOException (java.io.IOException)1 CharacterCodingException (java.nio.charset.CharacterCodingException)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 UUID (java.util.UUID)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)1