Package org.apache.cassandra.db.marshal

Examples of org.apache.cassandra.db.marshal.CollectionType


                }

                return false;
            }

            CollectionType type = (CollectionType)def.type;
            switch (type.kind)
            {
                case LIST:
                    assert collectionElement != null;
                    return type.valueComparator().compare(data.getColumn(data.getComparator().create(prefix, def, collectionElement)).value(), expr.value) == 0;
                case SET:
                    return data.getColumn(data.getComparator().create(prefix, def, expr.value)) != null;
                case MAP:
                    if (expr.operator == IndexExpression.Operator.CONTAINS_KEY)
                    {
                        return data.getColumn(data.getComparator().create(prefix, def, expr.value)) != null;
                    }
                    else
                    {
                        assert collectionElement != null;
                        return type.valueComparator().compare(data.getColumn(data.getComparator().create(prefix, def, collectionElement)).value(), expr.value) == 0;
                    }
            }
            throw new AssertionError();
        }
View Full Code Here


        private static boolean collectionSatisfies(ColumnDefinition def, ColumnFamily data, Composite prefix, IndexExpression expr, ByteBuffer collectionElement)
        {
            assert def.type.isCollection();

            CollectionType type = (CollectionType)def.type;
            switch (type.kind)
            {
                case LIST:
                    assert collectionElement != null;
                    return type.valueComparator().compare(data.getColumn(data.getComparator().create(prefix, def.name, collectionElement)).value(), expr.value) == 0;
                case SET:
                    return data.getColumn(data.getComparator().create(prefix, def.name, expr.value)) != null;
                case MAP:
                    if (expr.operator == IndexExpression.Operator.CONTAINS_KEY)
                    {
                        return data.getColumn(data.getComparator().create(prefix, def.name, expr.value)) != null;
                    }
                    else
                    {
                        assert collectionElement != null;
                        return type.valueComparator().compare(data.getColumn(data.getComparator().create(prefix, def.name, collectionElement)).value(), expr.value) == 0;
                    }
            }
            throw new AssertionError();
        }
View Full Code Here

        private static boolean collectionSatisfies(ColumnDefinition def, ColumnFamily data, Composite prefix, IndexExpression expr, ByteBuffer collectionElement)
        {
            assert def.type.isCollection();

            CollectionType type = (CollectionType)def.type;
            switch (type.kind)
            {
                case LIST:
                    assert collectionElement != null;
                    return type.valueComparator().compare(data.getColumn(data.getComparator().create(prefix, def, collectionElement)).value(), expr.value) == 0;
                case SET:
                    return data.getColumn(data.getComparator().create(prefix, def, expr.value)) != null;
                case MAP:
                    if (expr.operator == IndexExpression.Operator.CONTAINS_KEY)
                    {
                        return data.getColumn(data.getComparator().create(prefix, def, expr.value)) != null;
                    }
                    else
                    {
                        assert collectionElement != null;
                        return type.valueComparator().compare(data.getColumn(data.getComparator().create(prefix, def, collectionElement)).value(), expr.value) == 0;
                    }
            }
            throw new AssertionError();
        }
View Full Code Here

                        Pair<CFDefinition.Name, Term> p = iter.next();
                        CFDefinition.Name column = p.left;

                        if (column.type.isCollection())
                        {
                            CollectionType validator = (CollectionType) column.type;
                            Term keySelected = p.right;

                            if (keySelected == null)
                            {
                                // Delete the whole collection
View Full Code Here

        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;
                    }
                }
View Full Code Here

        private static boolean collectionSatisfies(ColumnDefinition def, ColumnFamily data, Composite prefix, IndexExpression expr, ByteBuffer collectionElement)
        {
            assert def.type.isCollection();

            CollectionType type = (CollectionType)def.type;
            switch (type.kind)
            {
                case LIST:
                    assert collectionElement != null;
                    return type.valueComparator().compare(data.getColumn(data.getComparator().create(prefix, def, collectionElement)).value(), expr.value) == 0;
                case SET:
                    return data.getColumn(data.getComparator().create(prefix, def, expr.value)) != null;
                case MAP:
                    if (expr.operator == IndexExpression.Operator.CONTAINS_KEY)
                    {
                        return data.getColumn(data.getComparator().create(prefix, def, expr.value)) != null;
                    }
                    else
                    {
                        assert collectionElement != null;
                        return type.valueComparator().compare(data.getColumn(data.getComparator().create(prefix, def, collectionElement)).value(), expr.value) == 0;
                    }
            }
            throw new AssertionError();
        }
View Full Code Here

TOP

Related Classes of org.apache.cassandra.db.marshal.CollectionType

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.