Search in sources :

Example 6 with CompositeType

use of org.apache.cassandra.db.marshal.CompositeType in project stargate-core by tuplejump.

the class FieldCreator method toString.

public static String toString(ByteBuffer byteBuffer, AbstractType<?> type) {
    if (type instanceof CompositeType) {
        CompositeType composite = (CompositeType) type;
        List<AbstractType<?>> types = composite.types;
        ByteBuffer[] components = composite.split(byteBuffer);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < components.length; i++) {
            AbstractType<?> componentType = types.get(i);
            ByteBuffer component = components[i];
            sb.append(componentType.compose(component));
            if (i < types.size() - 1) {
                sb.append(':');
            }
        }
        return sb.toString();
    } else {
        return type.compose(byteBuffer).toString();
    }
}
Also used : AbstractType(org.apache.cassandra.db.marshal.AbstractType) ByteBuffer(java.nio.ByteBuffer) CompositeType(org.apache.cassandra.db.marshal.CompositeType)

Aggregations

ByteBuffer (java.nio.ByteBuffer)6 CompositeType (org.apache.cassandra.db.marshal.CompositeType)6 AbstractType (org.apache.cassandra.db.marshal.AbstractType)2 IOException (java.io.IOException)1 CollectionType (org.apache.cassandra.db.marshal.CollectionType)1 Cell (org.apache.cassandra.db.rows.Cell)1 ColumnMetadata (org.apache.cassandra.schema.ColumnMetadata)1