Examples of CFDefinition


Examples of org.apache.cassandra.cql3.CFDefinition

        for (CfDef cfDef : ksDef.cf_defs)
        {
            if (cfDef.name.equalsIgnoreCase(cfName))
            {
                CFMetaData cfMeta = CFMetaData.fromThrift(cfDef);
                CFDefinition cfDefinition = new CFDefinition(cfMeta);
                for (ColumnIdentifier key : cfDefinition.keys.keySet())
                    partitionBoundColumns.add(new BoundColumn(key.toString()));
                for (ColumnIdentifier column : cfDefinition.columns.keySet())
                    clusterColumns.add(new BoundColumn(column.toString()));
                parseKeyValidators(cfDef.key_validation_class);
View Full Code Here

Examples of org.apache.cassandra.cql3.CFDefinition

        return column_metadata.remove(def.name) != null;
    }

    private CFMetaData updateCfDef()
    {
        cqlCfDef = new CFDefinition(this);
        return this;
    }
View Full Code Here

Examples of org.apache.cassandra.cql3.CFDefinition

    }

    public void validateFields(CFMetaData metadata) throws MarshalException
    {
        validateName(metadata);
        CFDefinition cfdef = metadata.getCfDef();

        // If this is a CQL table, we need to pull out the CQL column name to look up the correct column type.
        // (Note that COMPACT composites are handled by validateName, above.)
        ByteBuffer internalName;
        internalName = (cfdef.isComposite && !cfdef.isCompact)
View Full Code Here

Examples of org.apache.cassandra.cql3.CFDefinition

                throw new org.apache.cassandra.exceptions.InvalidRequestException("supercolumn name must not be empty");
            if (metadata.cfType == ColumnFamilyType.Standard)
                throw new org.apache.cassandra.exceptions.InvalidRequestException("supercolumn specified to ColumnFamily " + metadata.cfName + " containing normal columns");
        }
        AbstractType<?> comparator = SuperColumns.getComparatorFor(metadata, superColumnName);
        CFDefinition cfDef = metadata.getCfDef();
        boolean isCQL3Table = !metadata.isThriftCompatible();
        for (ByteBuffer name : column_names)
        {
            if (name.remaining() > maxNameLength)
                throw new org.apache.cassandra.exceptions.InvalidRequestException("column name length must not be greater than " + maxNameLength);
            if (name.remaining() == 0)
                throw new org.apache.cassandra.exceptions.InvalidRequestException("column name must not be empty");
            try
            {
                comparator.validate(name);
            }
            catch (MarshalException e)
            {
                throw new org.apache.cassandra.exceptions.InvalidRequestException(e.getMessage());
            }

            if (isCQL3Table)
            {
                // CQL3 table don't support having only part of their composite column names set
                CompositeType composite = (CompositeType)comparator;
                ByteBuffer[] components = composite.split(name);
                int minComponents = composite.types.size() - (cfDef.hasCollections ? 1 : 0);
                if (components.length < minComponents)
                    throw new org.apache.cassandra.exceptions.InvalidRequestException(String.format("Not enough components (found %d but %d expected) for column name since %s is a CQL3 table",
                                                                                                    components.length, minComponents, metadata.cfName));

                // Furthermore, the column name must be a declared one.
                int columnIndex = composite.types.size() - (cfDef.hasCollections ? 2 : 1);
                ByteBuffer CQL3ColumnName = components[columnIndex];
                if (!CQL3ColumnName.hasRemaining())
                    continue; // Row marker, ok

                ColumnIdentifier columnId = new ColumnIdentifier(CQL3ColumnName, composite.types.get(columnIndex));
                CFDefinition.Name columnName = cfDef.get(columnId);
                if (columnName == null || columnName.isPrimaryKeyColumn())
                    throw new org.apache.cassandra.exceptions.InvalidRequestException(String.format("Invalid cell for CQL3 table %s. The CQL3 column component (%s) does not correspond to a defined CQL3 column",
                                                                                                    metadata.cfName, columnId));

                // On top of that, if we have a collection component, he (CQL3) column must be a collection
View Full Code Here

Examples of org.apache.cassandra.cql3.CFDefinition

         * object (partitionKeyColumns, ...) and the one stored in CFDefinition.
         * Ultimately, we should probably merge both. However, there is enough details to fix that
         * it's worth doing that in a separate issue.
         */
        rebuildCQL3Metadata();
        cqlCfDef = new CFDefinition(this);
        return this;
    }
View Full Code Here

Examples of org.apache.cassandra.cql3.CFDefinition

                keys.add(cDef);
            }
            // classic thrift tables
            if (keys.size() == 0)
            {
                CFDefinition cfDefinition = getCfDefinition(keyspace, column_family, client);
                for (CFDefinition.Name column : cfDefinition.partitionKeys())
                {
                    String key = column.name.toString();
                    logger.debug("name: {} ", key);
                    ColumnDef cDef = new ColumnDef();
                    cDef.name = ByteBufferUtil.bytes(key);
                    keys.add(cDef);
                }
                for (CFDefinition.Name column : cfDefinition.clusteringColumns())
                {
                    String key = column.name.toString();
                    logger.debug("name: {} ", key);
                    ColumnDef cDef = new ColumnDef();
                    cDef.name = ByteBufferUtil.bytes(key);
View Full Code Here

Examples of org.apache.cassandra.cql3.CFDefinition

            // if CassandraStorage, just return the empty list
            if (cassandraStorage)
                return columnDefs;

            // otherwise for CqlStorage, check metadata for classic thrift tables
            CFDefinition cfDefinition = getCfDefinition(keyspace, column_family, client);
            for (CFDefinition.Name column : Iterables.concat(cfDefinition.staticColumns(), cfDefinition.regularColumns()))
            {
                ColumnDef cDef = new ColumnDef();
                String columnName = column.name.toString();
                String type = column.type.toString();
                logger.debug("name: {}, type: {} ", columnName, type);
                cDef.name = ByteBufferUtil.bytes(columnName);
                cDef.validation_class = type;
                columnDefs.add(cDef);
            }
            // we may not need to include the value column for compact tables as we
            // could have already processed it as schema_columnfamilies.value_alias
            if (columnDefs.size() == 0 && includeCompactValueColumn)
            {
                String value = cfDefinition.compactValue() != null ? cfDefinition.compactValue().toString() : null;
                if ("value".equals(value))
                {
                    ColumnDef cDef = new ColumnDef();
                    cDef.name = ByteBufferUtil.bytes(value);
                    cDef.validation_class = cfDefinition.compactValue().type.toString();
                    columnDefs.add(cDef);
                }
            }
            return columnDefs;
        }
View Full Code Here

Examples of org.apache.cassandra.cql3.CFDefinition

    {
        KsDef ksDef = client.describe_keyspace(ks);
        for (CfDef cfDef : ksDef.cf_defs)
        {
            if (cfDef.name.equalsIgnoreCase(cf))
                return new CFDefinition(CFMetaData.fromThrift(cfDef));
        }
        return null;
    }
View Full Code Here

Examples of org.apache.cassandra.cql3.CFDefinition

        return column_metadata.remove(def.name) != null;
    }

    private CFMetaData updateCfDef()
    {
        cqlCfDef = new CFDefinition(this);
        return this;
    }
View Full Code Here

Examples of org.apache.cassandra.cql3.CFDefinition

                String keyAliases = ByteBufferUtil.string(cqlRow.columns.get(5).value);
                keys = FBUtilities.fromJsonList(keyAliases);
                // classis thrift tables
                if (keys.size() == 0 && cqlRow.columns.get(6).value == null)
                {
                    CFDefinition cfDefinition = getCfDefinition(keyspace, column_family, client);
                    for (ColumnIdentifier column : cfDefinition.keys.keySet())
                    {
                        String key = column.toString();
                        String type = cfDefinition.keys.get(column).type.toString();
                        logger.debug("name: {}, type: {} ", key, type);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.