Example usage for org.apache.cassandra.db.rows Cell path

List of usage examples for org.apache.cassandra.db.rows Cell path

Introduction

In this page you can find the example usage for org.apache.cassandra.db.rows Cell path.

Prototype

public abstract CellPath path();

Source Link

Document

For cells belonging to complex types (non-frozen collection and UDT), the path to the cell.

Usage

From source file:com.stratio.cassandra.lucene.column.ColumnsMapper.java

License:Apache License

private void addColumns(Columns columns, Cell cell) {
    if (cell != null) {
        ColumnDefinition columnDefinition = cell.column();
        String name = columnDefinition.name.toString();
        AbstractType<?> type = cell.column().type;
        ByteBuffer value = cell.value();
        ColumnBuilder builder = Column.builder(name);
        if (type.isCollection() && !type.isFrozenCollection()) {
            CollectionType<?> collectionType = (CollectionType<?>) type;
            switch (collectionType.kind) {
            case SET: {
                type = collectionType.nameComparator();
                value = cell.path().get(0);
                addColumns(columns, builder, type, value);
                break;
            }/*from   w w w. ja v a  2  s . co  m*/
            case LIST: {
                type = collectionType.valueComparator();
                addColumns(columns, builder, type, value);
                break;
            }
            case MAP: {
                type = collectionType.valueComparator();
                ByteBuffer keyValue = cell.path().get(0);
                AbstractType<?> keyType = collectionType.nameComparator();
                String nameSuffix = keyType.compose(keyValue).toString();
                addColumns(columns, builder.withMapName(nameSuffix), type, value);
                break;
            }
            default: {
                throw new IndexException("Unknown collection type %s", collectionType.kind);
            }
            }
        } else {
            addColumns(columns, Column.builder(name), type, value);
        }
    }
}