Package org.apache.cassandra.config

Examples of org.apache.cassandra.config.CFMetaData


        if (resolver instanceof RowDigestResolver)
        {
            assert command instanceof ReadCommand : command;
            String table = ((RowDigestResolver) resolver).table;
            String columnFamily = ((ReadCommand) command).getColumnFamilyName();
            CFMetaData cfmd = DatabaseDescriptor.getTableMetaData(table).get(columnFamily);
            return cfmd.getReadRepairChance() > random.get().nextDouble();
        }
        // we don't read repair on range scans
        return false;
    }
View Full Code Here


     * @param superName name of the super column if any
     * @param cfamily the column family to add columns to
     */
    private static void addColumnsToCF(List<?> row, ByteBuffer superName, ColumnFamily cfamily)
    {
        CFMetaData cfm = cfamily.metadata();
        assert cfm != null;

        for (Object c : row)
        {
            JsonColumn col = new JsonColumn<List>((List) c);
View Full Code Here

     * @param row the super columns associated with a row
     * @param cfamily the column family to add columns to
     */
    private static void addToSuperCF(Map<?, ?> row, ColumnFamily cfamily)
    {
        CFMetaData metaData = cfamily.metadata();
        assert metaData != null;

        // Super columns
        for (Map.Entry<?, ?> entry : row.entrySet())
        {
View Full Code Here

    public RowMutation mutationForKey(ByteBuffer key, String keyspace, Long timestamp, ClientState clientState, List<ByteBuffer> variables)
    throws InvalidRequestException
    {
        RowMutation rm = new RowMutation(keyspace, key);

        CFMetaData metadata = validateColumnFamily(keyspace, columnFamily);
        QueryProcessor.validateKeyAlias(metadata, keyName);

        AbstractType<?> comparator = metadata.getComparatorFor(null);

        if (columns.size() < 1)
        {
            // No columns, delete the row
            rm.delete(new QueryPath(columnFamily), (timestamp == null) ? getTimestamp(clientState) : timestamp);
View Full Code Here

        return rm;
    }

    public ParsedStatement.Prepared prepare() throws InvalidRequestException
    {
        CFMetaData metadata = ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
        cfDef = metadata.getCfDef();
        AbstractType[] types = new AbstractType[getBoundsTerms()];
        UpdateStatement.processKeys(cfDef, whereClause, processedKeys, types);
        return new ParsedStatement.Prepared(this, Arrays.<AbstractType<?>>asList(types));
    }
View Full Code Here

            if (hasCommutativeOperation && column.getValue().isUnary())
                throw new InvalidRequestException("Mix of commutative and non-commutative operations is not allowed.");
        }

        CFMetaData metadata = validateColumnFamily(keyspace, columnFamily, hasCommutativeOperation);
        if (hasCommutativeOperation)
            validateCommutativeForWrite(metadata, cLevel);

        QueryProcessor.validateKeyAlias(metadata, keyName);
View Full Code Here

    public Migration getMigration() throws InvalidRequestException, ConfigurationException
    {
        try
        {
            CFMetaData oldCfm = ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
            boolean columnExists = false;
            // mutating oldCfm directly would be bad, but mutating a Thrift copy is fine.  This also
            // sets us up to use validateCfDef to check for index name collisions.
            CfDef cf_def = oldCfm.toThrift();
            for (ColumnDef cd : cf_def.column_metadata)
            {
                if (cd.name.equals(columnName.key))
                {
                    if (cd.index_type != null)
                        throw new InvalidRequestException("Index already exists");
                    if (logger.isDebugEnabled())
                        logger.debug("Updating column {} definition for index {}", columnName, indexName);
                    cd.setIndex_type(IndexType.KEYS);
                    cd.setIndex_name(indexName);
                    columnExists = true;
                    break;
                }
            }
            if (!columnExists)
            {
                CFDefinition cfDef = oldCfm.getCfDef();
                CFDefinition.Name name = cfDef.get(columnName);
                if (name != null)
                {
                    switch (name.kind)
                    {
View Full Code Here

     */
    public CFMetaData getCFMetaData(String keyspace, List<ByteBuffer> variables) throws InvalidRequestException
    {
        validate(variables);

        CFMetaData newCFMD;
        try
        {
            AbstractType<?> comparator = cfProps.getComparator();

            newCFMD = new CFMetaData(keyspace,
                                     name,
                                     ColumnFamilyType.Standard,
                                     comparator,
                                     null);

            newCFMD.comment(cfProps.getProperty(CFPropDefs.KW_COMMENT))
                   .readRepairChance(getPropertyDouble(CFPropDefs.KW_READREPAIRCHANCE, CFMetaData.DEFAULT_READ_REPAIR_CHANCE))
                   .dclocalReadRepairChance(getPropertyDouble(CFPropDefs.KW_DCLOCALREADREPAIRCHANCE, CFMetaData.DEFAULT_DCLOCAL_READ_REPAIR_CHANCE))
                   .replicateOnWrite(getPropertyBoolean(CFPropDefs.KW_REPLICATEONWRITE, CFMetaData.DEFAULT_REPLICATE_ON_WRITE))
                   .gcGraceSeconds(getPropertyInt(CFPropDefs.KW_GCGRACESECONDS, CFMetaData.DEFAULT_GC_GRACE_SECONDS))
                   .defaultValidator(cfProps.getValidator())
View Full Code Here

                    throw new InvalidRequestException("Mix of commutative and non-commutative operations is not allowed.");
            }
        }

        // Deal here with the keyspace overwrite thingy to avoid mistake
        CFMetaData metadata = validateColumnFamily(keyspace(), columnFamily(), hasCommutativeOperation);
        if (hasCommutativeOperation)
            validateCommutativeForWrite(metadata, cLevel);

        cfDef = metadata.getCfDef();

        if (columns == null)
        {
            // Created from an INSERT
            // Don't hate, validate.
View Full Code Here

     */
    private static void serializeRow(SSTableIdentityIterator row, DecoratedKey key, PrintStream out)
    {
        ColumnFamily columnFamily = row.getColumnFamily();
        boolean isSuperCF = columnFamily.isSuper();
        CFMetaData cfMetaData = columnFamily.metadata();
        AbstractType<?> comparator = columnFamily.getComparator();

        writeKey(out, bytesToHex(key.key));
        out.print(isSuperCF ? "{" : "[");

View Full Code Here

TOP

Related Classes of org.apache.cassandra.config.CFMetaData

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.