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);
}
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";
}
Aggregations