Package com.stratio.cassandra.index.schema

Examples of com.stratio.cassandra.index.schema.Columns


    public Columns columns(Row row)
    {
        ColumnFamily columnFamily = row.cf;
        int numClusteringColumns = metadata.clusteringColumns().size();
        Columns columns = new Columns();
        if (numClusteringColumns > 0)
        {
            CellName cellName = clusteringKey(columnFamily);
            if (cellName != null)
            {
                for (int i = 0; i < numClusteringColumns; i++)
                {
                    ByteBuffer value = cellName.get(i);
                    ColumnDefinition columnDefinition = metadata.clusteringColumns().get(i);
                    String name = columnDefinition.name.toString();
                    AbstractType<?> valueType = columnDefinition.type;
                    columns.add(ColumnMapper.column(name, value, valueType));
                }
            }
        }
        return columns;
    }
View Full Code Here


     */
    private boolean accepted(Row row, List<IndexExpression> expressions)
    {
        if (!expressions.isEmpty())
        {
            Columns columns = rowMapper.columns(row);
            for (IndexExpression expression : expressions)
            {
                if (!accepted(columns, expression))
                {
                    return false;
View Full Code Here

    @SuppressWarnings("rawtypes")
    public Columns columns(Row row)
    {
        ColumnFamily columnFamily = row.cf;
        Columns columns = new Columns();

        // Get row's columns iterator skipping clustering column
        Iterator<Cell> cellIterator = columnFamily.iterator();
        cellIterator.next();

        // Stuff for grouping collection columns (sets, lists and maps)
        String name;
        CollectionType collectionType;

        while (cellIterator.hasNext())
        {
            Cell cell = cellIterator.next();
            CellName cellName = cell.name();
            ColumnDefinition columnDefinition = metadata.getColumnDefinition(cellName);
            if (columnDefinition == null)
            {
                continue;
            }

            AbstractType<?> valueType = columnDefinition.type;

            ByteBuffer cellValue = cell.value();

            name = cellName.cql3ColumnName(metadata).toString();

            if (valueType.isCollection())
            {
                collectionType = (CollectionType<?>) valueType;
                switch (collectionType.kind)
                {
                    case SET:
                    {
                        AbstractType<?> type = collectionType.nameComparator();
                        ByteBuffer value = cellName.collectionElement();
                        columns.add(ColumnMapper.column(name, value, type));
                        break;
                    }
                    case LIST:
                    {
                        AbstractType<?> type = collectionType.valueComparator();
                        columns.add(ColumnMapper.column(name, cellValue, type));
                        break;
                    }
                    case MAP:
                    {
                        AbstractType<?> type = collectionType.valueComparator();
                        ByteBuffer keyValue = cellName.collectionElement();
                        AbstractType<?> keyType = collectionType.nameComparator();
                        String nameSufix = keyType.compose(keyValue).toString();
                        columns.add(ColumnMapper.column(name, nameSufix, cellValue, type));
                        break;
                    }
                }
            }
            else
            {
                columns.add(ColumnMapper.column(name, cellValue, valueType));
            }
        }

        return columns;
    }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public Columns columns(Row row)
    {
        Columns columns = new Columns();
        columns.addAll(partitionKeyMapper.columns(row));
        columns.addAll(regularCellsMapper.columns(row));
        return columns;
    }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public Columns columns(Row row)
    {
        Columns columns = new Columns();
        columns.addAll(partitionKeyMapper.columns(row));
        columns.addAll(clusteringKeyMapper.columns(row));
        columns.addAll(regularCellsMapper.columns(row));
        return columns;
    }
View Full Code Here

     * than the second according to a {@link Sorting}.
     */
    @Override
    public int compare(Row row1, Row row2)
    {
        Columns columns1 = rowMapper.columns(row1);
        Columns columns2 = rowMapper.columns(row2);
        return comparatorChain.compare(columns1, columns2);
    }
View Full Code Here

    }

    public Columns columns(Row row)
    {
        DecoratedKey partitionKey = row.key;
        Columns columns = new Columns();
        AbstractType<?> rawKeyType = metadata.getKeyValidator();
        List<ColumnDefinition> columnDefinitions = metadata.partitionKeyColumns();
        for (ColumnDefinition columnDefinition : columnDefinitions)
        {
            String name = columnDefinition.name.toString();
            ByteBuffer[] components = ByteBufferUtils.split(partitionKey.getKey(), rawKeyType);
            int position = columnDefinition.position();
            ByteBuffer value = components[position];
            AbstractType<?> valueType = rawKeyType.getComponents().get(position);
            columns.add(ColumnMapper.column(name, value, valueType));
        }
        return columns;
    }
View Full Code Here

TOP

Related Classes of com.stratio.cassandra.index.schema.Columns

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.