use of org.apache.cassandra.config.ColumnDefinition in project stargate-core by tuplejump.
the class SearchSupport method getQueryString.
protected String getQueryString(IndexExpression predicate) throws Exception {
ColumnDefinition cd = baseCfs.metadata.getColumnDefinition(predicate.column);
String predicateValue = cd.type.getString(predicate.value);
if (logger.isDebugEnabled()) {
String columnName = cd.name.toString();
logger.debug("Index Searcher - query - predicate value [" + predicateValue + "] column name [" + columnName + "]");
logger.debug("Column name is {}", columnName);
}
return predicateValue;
}
use of org.apache.cassandra.config.ColumnDefinition in project stargate-core by tuplejump.
the class SearchSupport method matchThisIndex.
protected IndexExpression matchThisIndex(List<IndexExpression> clause) {
for (IndexExpression expression : clause) {
ColumnDefinition cfDef = baseCfs.metadata.getColumnDefinition(expression.column);
String colName = cfDef.name.toString();
//we only support Equal - Operators should be a part of the lucene query
if (fieldNames.contains(colName) && expression.operator == Operator.EQ) {
return expression;
} else if (colName.equalsIgnoreCase(tableMapper.primaryColumnName())) {
return expression;
}
}
return null;
}
use of org.apache.cassandra.config.ColumnDefinition in project stargate-core by tuplejump.
the class TableMapper method addKeyColumns.
private void addKeyColumns(Map<String, Integer> positions, Tuple tuple, ByteBuffer rowKey) {
CType keyCType = table.metadata.getKeyValidatorAsCType();
Composite compoundRowKey = keyCType.fromByteBuffer(rowKey);
List<ColumnDefinition> partitionKeys = table.metadata.partitionKeyColumns();
for (ColumnDefinition entry : partitionKeys) {
ByteBuffer value = compoundRowKey.get(entry.position());
String actualColumnName = entry.name.toString();
for (String field : positions.keySet()) {
if (actualColumnName.equalsIgnoreCase(field)) {
tuple.getTuple()[positions.get(field)] = entry.type.compose(value);
}
}
}
}
use of org.apache.cassandra.config.ColumnDefinition in project stargate-core by tuplejump.
the class RowFetcher method getMetaColumn.
protected Cell getMetaColumn(Cell firstColumn, Float score) {
CellNameType cellNameType = table.getComparator();
ColumnDefinition columnDefinition = resultMapper.tableMapper.primaryColumnDefinition;
CellName cellName = cellNameType.create(firstColumn.name(), columnDefinition);
return new BufferCell(cellName, UTF8Type.instance.decompose("{\"score\":" + score.toString() + "}"));
}
use of org.apache.cassandra.config.ColumnDefinition in project eiger by wlloyd.
the class CreateColumnFamilyStatement method getColumns.
// Column definitions
private Map<ByteBuffer, ColumnDefinition> getColumns(AbstractType<?> comparator) throws InvalidRequestException {
Map<ByteBuffer, ColumnDefinition> columnDefs = new HashMap<ByteBuffer, ColumnDefinition>();
for (Map.Entry<Term, String> col : columns.entrySet()) {
try {
ByteBuffer columnName = comparator.fromString(col.getKey().getText());
String validatorClassName = CFPropDefs.comparators.containsKey(col.getValue()) ? CFPropDefs.comparators.get(col.getValue()) : col.getValue();
AbstractType<?> validator = TypeParser.parse(validatorClassName);
columnDefs.put(columnName, new ColumnDefinition(columnName, validator, null, null, null));
} catch (ConfigurationException e) {
InvalidRequestException ex = new InvalidRequestException(e.toString());
ex.initCause(e);
throw ex;
}
}
return columnDefs;
}
Aggregations