Search in sources :

Example 1 with IndexMode

use of org.apache.cassandra.index.sasi.conf.IndexMode in project cassandra by apache.

the class SASIIndex method validateOptions.

public static Map<String, String> validateOptions(Map<String, String> options, TableMetadata metadata) {
    if (!(metadata.partitioner instanceof Murmur3Partitioner))
        throw new ConfigurationException("SASI only supports Murmur3Partitioner.");
    String targetColumn = options.get("target");
    if (targetColumn == null)
        throw new ConfigurationException("unknown target column");
    Pair<ColumnMetadata, IndexTarget.Type> target = TargetParser.parse(metadata, targetColumn);
    if (target == null)
        throw new ConfigurationException("failed to retrieve target column for: " + targetColumn);
    if (target.left.isComplex())
        throw new ConfigurationException("complex columns are not yet supported by SASI");
    IndexMode.validateAnalyzer(options);
    IndexMode mode = IndexMode.getMode(target.left, options);
    if (mode.mode == Mode.SPARSE) {
        if (mode.isLiteral)
            throw new ConfigurationException("SPARSE mode is only supported on non-literal columns.");
        if (mode.isAnalyzed)
            throw new ConfigurationException("SPARSE mode doesn't support analyzers.");
    }
    return Collections.emptyMap();
}
Also used : ColumnMetadata(org.apache.cassandra.schema.ColumnMetadata) AbstractType(org.apache.cassandra.db.marshal.AbstractType) OperationType(org.apache.cassandra.db.compaction.OperationType) ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException) IndexMode(org.apache.cassandra.index.sasi.conf.IndexMode) Murmur3Partitioner(org.apache.cassandra.dht.Murmur3Partitioner)

Aggregations

OperationType (org.apache.cassandra.db.compaction.OperationType)1 AbstractType (org.apache.cassandra.db.marshal.AbstractType)1 Murmur3Partitioner (org.apache.cassandra.dht.Murmur3Partitioner)1 ConfigurationException (org.apache.cassandra.exceptions.ConfigurationException)1 IndexMode (org.apache.cassandra.index.sasi.conf.IndexMode)1 ColumnMetadata (org.apache.cassandra.schema.ColumnMetadata)1