Java Code Examples for org.apache.cassandra.config.ColumnDefinition#position()

The following examples show how to use org.apache.cassandra.config.ColumnDefinition#position() . 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: SelectStatement.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
private void updateRestrictionsForRelation(SelectStatement stmt, ColumnDefinition def, SingleColumnRelation relation, VariableSpecifications names) throws InvalidRequestException
{
    switch (def.kind)
    {
        case PARTITION_KEY:
            stmt.keyRestrictions[def.position()] = updateSingleColumnRestriction(def, stmt.keyRestrictions[def.position()], relation, names);
            break;
        case CLUSTERING_COLUMN:
            stmt.columnRestrictions[def.position()] = updateSingleColumnRestriction(def, stmt.columnRestrictions[def.position()], relation, names);
            break;
        case COMPACT_VALUE:
            throw new InvalidRequestException(String.format("Predicates on the non-primary-key column (%s) of a COMPACT table are not yet supported", def.name));
        case REGULAR:
        case STATIC:
            // We only all IN on the row key and last clustering key so far, never on non-PK columns, and this even if there's an index
            Restriction r = updateSingleColumnRestriction(def, stmt.metadataRestrictions.get(def.name), relation, names);
            if (r.isIN() && !((Restriction.IN)r).canHaveOnlyOneValue())
                // Note: for backward compatibility reason, we conside a IN of 1 value the same as a EQ, so we let that slide.
                throw new InvalidRequestException(String.format("IN predicates on non-primary-key columns (%s) is not yet supported", def.name));
            stmt.metadataRestrictions.put(def.name, r);
            break;
    }
}
 
Example 2
Source File: SelectStatement.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
private static Restriction getExistingRestriction(SelectStatement stmt, ColumnDefinition def)
{
    switch (def.kind)
    {
        case PARTITION_KEY:
            return stmt.keyRestrictions[def.position()];
        case CLUSTERING_COLUMN:
            return stmt.columnRestrictions[def.position()];
        case REGULAR:
        case STATIC:
            return stmt.metadataRestrictions.get(def.name);
        default:
            throw new AssertionError();
    }
}
 
Example 3
Source File: CompositesIndexOnCollectionValue.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public static CellNameType buildIndexComparator(CFMetaData baseMetadata, ColumnDefinition columnDef)
{
    int prefixSize = columnDef.position();
    List<AbstractType<?>> types = new ArrayList<>(prefixSize + 2);
    types.add(SecondaryIndex.keyComparator);
    for (int i = 0; i < prefixSize; i++)
        types.add(baseMetadata.comparator.subtype(i));
    types.add(((CollectionType)columnDef.type).nameComparator()); // collection key
    return new CompoundDenseCellNameType(types);
}
 
Example 4
Source File: CompositesIndexOnClusteringKey.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public static CellNameType buildIndexComparator(CFMetaData baseMetadata, ColumnDefinition columnDef)
{
    // Index cell names are rk ck_0 ... ck_{i-1} ck_{i+1} ck_n, so n
    // components total (where n is the number of clustering keys)
    int ckCount = baseMetadata.clusteringColumns().size();
    List<AbstractType<?>> types = new ArrayList<AbstractType<?>>(ckCount);
    types.add(SecondaryIndex.keyComparator);
    for (int i = 0; i < columnDef.position(); i++)
        types.add(baseMetadata.clusteringColumns().get(i).type);
    for (int i = columnDef.position() + 1; i < ckCount; i++)
        types.add(baseMetadata.clusteringColumns().get(i).type);
    return new CompoundDenseCellNameType(types);
}
 
Example 5
Source File: CompositesIndexOnRegular.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public static CellNameType buildIndexComparator(CFMetaData baseMetadata, ColumnDefinition columnDef)
{
    int prefixSize = columnDef.position();
    List<AbstractType<?>> types = new ArrayList<AbstractType<?>>(prefixSize + 1);
    types.add(SecondaryIndex.keyComparator);
    for (int i = 0; i < prefixSize; i++)
        types.add(baseMetadata.comparator.subtype(i));
    return new CompoundDenseCellNameType(types);
}