Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should handle 'index_options' for CUSTOM type index #534

Open
ghost opened this issue Sep 26, 2012 · 0 comments
Open

Should handle 'index_options' for CUSTOM type index #534

ghost opened this issue Sep 26, 2012 · 0 comments

Comments

@ghost
Copy link

ghost commented Sep 26, 2012

When building a CUSTOM secondary index on a column, the custom index class name should be provided.

With cassandra-cli, we can do it like below:

create column family test with
    comparator = UTF8Type and
    key_validation_class=UTF8Type and
    column_metadata = [
        {
            column_name : col1, 
            validation_class: UTF8Type, 
            index_type : CUSTOM,
            index_options : {class_name : 'net.abc.MyIndex'}
        },
        ...
    ];

And in Cassandra, index_options will be checked like below:

if (c.index_type == IndexType.CUSTOM) {
    if (c.index_options == null || !c.index_options.containsKey(SecondaryIndex.CUSTOM_INDEX_OPTION_NAME))
                        throw new InvalidRequestException("Required index option missing: " + SecondaryIndex.CUSTOM_INDEX_OPTION_NAME);                    
}

In org.apache.cassandra.thrift.ColumnDef, there is a method can set this option.

public ColumnDef setIndex_options(Map<String,String> index_options)

But in Hector, in me.prettyprint.cassandra.service.ThriftColumnDef, seems it doesn't handle the index_options.

public ThriftColumnDef(ColumnDef cd) {
    Assert.notNull(cd, "ColumnDef is null");
    name = cd.name;
    validationClass = cd.validation_class;
    indexType = indexTypeFromThrift(cd.index_type);
    indexName = cd.index_name;
}

So if we try to build a CUSTOM secondary index with Hector, it will fail and cause an exception.

Exception in thread "main" me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequestException(why:Required index option missing: class_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants