Search in sources :

Example 11 with ColumnDefinition

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;
}
Also used : ColumnDefinition(org.apache.cassandra.config.ColumnDefinition)

Example 12 with ColumnDefinition

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;
}
Also used : ColumnDefinition(org.apache.cassandra.config.ColumnDefinition)

Example 13 with ColumnDefinition

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);
            }
        }
    }
}
Also used : ByteBuffer(java.nio.ByteBuffer) ColumnDefinition(org.apache.cassandra.config.ColumnDefinition)

Example 14 with ColumnDefinition

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() + "}"));
}
Also used : CellNameType(org.apache.cassandra.db.composites.CellNameType) CellName(org.apache.cassandra.db.composites.CellName) ColumnDefinition(org.apache.cassandra.config.ColumnDefinition)

Example 15 with ColumnDefinition

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;
}
Also used : HashMap(java.util.HashMap) ConfigurationException(org.apache.cassandra.config.ConfigurationException) InvalidRequestException(org.apache.cassandra.thrift.InvalidRequestException) ByteBuffer(java.nio.ByteBuffer) HashMap(java.util.HashMap) Map(java.util.Map) ColumnDefinition(org.apache.cassandra.config.ColumnDefinition)

Aggregations

ColumnDefinition (org.apache.cassandra.config.ColumnDefinition)17 ByteBuffer (java.nio.ByteBuffer)5 CFMetaData (org.apache.cassandra.config.CFMetaData)3 IOException (java.io.IOException)2 CellName (org.apache.cassandra.db.composites.CellName)2 Composite (org.apache.cassandra.db.composites.Composite)2 Options (com.tuplejump.stargate.lucene.Options)1 Properties (com.tuplejump.stargate.lucene.Properties)1 Type (com.tuplejump.stargate.lucene.Type)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConfigurationException (org.apache.cassandra.config.ConfigurationException)1 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)1 KSMetaData (org.apache.cassandra.config.KSMetaData)1 CQL3Type (org.apache.cassandra.cql3.CQL3Type)1 ColumnIdentifier (org.apache.cassandra.cql3.ColumnIdentifier)1 CType (org.apache.cassandra.db.composites.CType)1 CellNameType (org.apache.cassandra.db.composites.CellNameType)1 ColumnSlice (org.apache.cassandra.db.filter.ColumnSlice)1 QueryFilter (org.apache.cassandra.db.filter.QueryFilter)1