astyanax icon indicating copy to clipboard operation
astyanax copied to clipboard

astyanax-cql support for collections set, list and map

Open kontact-chan opened this issue 9 years ago • 1 comments

Dear Engineers,

We are trying to read the SET using cql java driver. We are getting this exception: datastax.driver.core.exceptions.InvalidTypeException: Value paths is of type set

Code here:

Column<String> column = columns.getColumnByName(LabelVerticesFieldEnum.PATHS.getFieldStr());
SetSerializer<String> serializer = new SetSerializer<>(UTF8Type.instance);
if (!CommonUtils.isNullOrBlank(column.getValue(serializer))) {
    labelVertices.setPaths(column.getValue(serializer));
}

The datastax row has a method to access the SET values, but there is no way from the CqlColumnImpl i could access it.

Here is the datastax row method:

public class Row { 
    public <T> Set<T> getSet(int i, Class<T> elementsClass) 
}

Instead the column.getValue(serializer) hits this method in the datastax driver:

 public ByteBuffer getBytes(int i) {
        metadata.checkType(i, DataType.Name.BLOB);
        return getBytesUnsafe(i);
    }

that throws this exception - datastax.driver.core.exceptions.InvalidTypeException: Value paths is of type set

Any idea when this would be supported?

Is there anything we are doing wrong? Please let me know.

We wanted to move away from ThriftFamilyFactory and use the CqlFamilyFactory.

Thanks, Chandran.

kontact-chan avatar Sep 01 '15 02:09 kontact-chan

I added a quick fix for astyanax-cql to work for collection set:

https://gist.github.com/7032ced375bedb9b81b3

If you like this, i would like to submit a patch for all the collections - set, list and map.

Please let me know.

kontact-chan avatar Sep 01 '15 08:09 kontact-chan