src/java/org/apache/cassandra/cli/CliClient.java
/**
     * Creates a CLI script for the CfDef including meta data to the supplied StringBuilder.
     * @param sb
     * @param cfDef
     */
Creates a CLI script for the CfDef including meta data to the supplied StringBuilder.
@param sb
@param cfDef
Creates a CLI script for the CfDef including meta data to the supplied StringBuilder . @param sb @param cfDef
private void showColumnFamily(StringBuilder sb, CfDef cfDef)
    {
        sb.append("create column family " + CliUtils.escapeSQLString(cfDef.name));
        writeAttr(sb, true, "column_type", cfDef.column_type);
        writeAttr(sb, false, "comparator", normaliseType(cfDef.comparator_type, "org.apache.cassandra.db.marshal"));
        if (cfDef.column_type.equals("Super"))
            writeAttr(sb, false, "subcomparator", normaliseType(cfDef.subcomparator_type, "org.apache.cassandra.db.marshal"));
        if (!StringUtils.isEmpty(cfDef.default_validation_class))
            writeAttr(sb, false, "default_validation_class",
                        normaliseType(cfDef.default_validation_class, "org.apache.cassandra.db.marshal"));
        writeAttr(sb, false, "key_validation_class",
                    normaliseType(cfDef.key_validation_class, "org.apache.cassandra.db.marshal"));
        writeAttr(sb, false, "read_repair_chance", cfDef.read_repair_chance);
        writeAttr(sb, false, "gc_grace", cfDef.gc_grace_seconds);
        writeAttr(sb, false, "min_compaction_threshold", cfDef.min_compaction_threshold);
        writeAttr(sb, false, "max_compaction_threshold", cfDef.max_compaction_threshold);
        writeAttr(sb, false, "replicate_on_write", cfDef.replicate_on_write);
        writeAttr(sb, false, "compaction_strategy", cfDef.compaction_strategy);
        writeAttr(sb, false, "caching", cfDef.caching);
        if (cfDef.isSetBloom_filter_fp_chance())
            writeAttr(sb, false, "bloom_filter_fp_chance", cfDef.bloom_filter_fp_chance);
        if (!cfDef.compaction_strategy_options.isEmpty())
        {
            StringBuilder cOptions = new StringBuilder();
            cOptions.append("{");
            Map<String, String> options = cfDef.compaction_strategy_options;
            int i = 0, size = options.size();
            for (Map.Entry<String, String> entry : options.entrySet())
            {
                cOptions.append(CliUtils.quote(entry.getKey())).append(" : ").append(CliUtils.quote(entry.getValue()));
                if (i != size - 1)
                    cOptions.append(", ");
                i++;
            }
            cOptions.append("}");
            writeAttrRaw(sb, false, "compaction_strategy_options", cOptions.toString());
        }
        if (!StringUtils.isEmpty(cfDef.comment))
            writeAttr(sb, false, "comment", cfDef.comment);
        if (!cfDef.column_metadata.isEmpty())
        {
            StringBuilder colSb = new StringBuilder();
            colSb.append("[");
            boolean first = true;
            for (ColumnDef colDef : cfDef.column_metadata)
            {
                if (!first)
                    colSb.append(",");
                first = false;
                showColumnMeta(colSb, cfDef, colDef);
            }
            colSb.append("]");
            writeAttrRaw(sb, false, "column_metadata", colSb.toString());
        }
        if (cfDef.compression_options != null && !cfDef.compression_options.isEmpty())
        {
            StringBuilder compOptions = new StringBuilder();
            compOptions.append("{");
            int i = 0, size = cfDef.compression_options.size();
            for (Map.Entry<String, String> entry : cfDef.compression_options.entrySet())
            {
                compOptions.append(CliUtils.quote(entry.getKey())).append(" : ").append(CliUtils.quote(entry.getValue()));
                if (i != size - 1)
                    compOptions.append(", ");
                i++;
            }
            compOptions.append("}");
            writeAttrRaw(sb, false, "compression_options", compOptions.toString());
        }
        sb.append(";");
        sb.append(NEWLINE);
        sb.append(NEWLINE);
    }
private void showColumnFamily ( StringBuilder sb , CfDef cfDef ) { sb . append ( "create column family " + CliUtils . escapeSQLString ( cfDef . name ) ) ; writeAttr ( sb , true , "column_type" , cfDef . column_type ) ; writeAttr ( sb , false , "comparator" , normaliseType ( cfDef . comparator_type , "org.apache.cassandra.db.marshal" ) ) ; if ( cfDef . column_type . equals ( "Super" ) ) writeAttr ( sb , false , "subcomparator" , normaliseType ( cfDef . subcomparator_type , "org.apache.cassandra.db.marshal" ) ) ; if ( ! StringUtils . isEmpty ( cfDef . default_validation_class ) ) writeAttr ( sb , false , "default_validation_class" , normaliseType ( cfDef . default_validation_class , "org.apache.cassandra.db.marshal" ) ) ; writeAttr ( sb , false , "key_validation_class" , normaliseType ( cfDef . key_validation_class , "org.apache.cassandra.db.marshal" ) ) ; writeAttr ( sb , false , "read_repair_chance" , cfDef . read_repair_chance ) ; writeAttr ( sb , false , "gc_grace" , cfDef . gc_grace_seconds ) ; writeAttr ( sb , false , "min_compaction_threshold" , cfDef . min_compaction_threshold ) ; writeAttr ( sb , false , "max_compaction_threshold" , cfDef . max_compaction_threshold ) ; writeAttr ( sb , false , "replicate_on_write" , cfDef . replicate_on_write ) ; writeAttr ( sb , false , "compaction_strategy" , cfDef . compaction_strategy ) ; writeAttr ( sb , false , "caching" , cfDef . caching ) ; if ( cfDef . isSetBloom_filter_fp_chance ( ) ) writeAttr ( sb , false , "bloom_filter_fp_chance" , cfDef . bloom_filter_fp_chance ) ; if ( ! cfDef . compaction_strategy_options . isEmpty ( ) ) { StringBuilder cOptions = new StringBuilder ( ) ; cOptions . append ( "{" ) ; Map < String , String > options = cfDef . compaction_strategy_options ; int i = 0 , size = options . size ( ) ; for ( Map . Entry < String , String > entry : options . entrySet ( ) ) { cOptions . append ( CliUtils . quote ( entry . getKey ( ) ) ) . append ( " : " ) . append ( CliUtils . quote ( entry . getValue ( ) ) ) ; if ( i != size - 1 ) cOptions . append ( ", " ) ; i ++ ; } cOptions . append ( "}" ) ; writeAttrRaw ( sb , false , "compaction_strategy_options" , cOptions . toString ( ) ) ; } if ( ! StringUtils . isEmpty ( cfDef . comment ) ) writeAttr ( sb , false , "comment" , cfDef . comment ) ; if ( ! cfDef . column_metadata . isEmpty ( ) ) { StringBuilder colSb = new StringBuilder ( ) ; colSb . append ( "[" ) ; boolean first = true ; for ( ColumnDef colDef : cfDef . column_metadata ) { if ( ! first ) colSb . append ( "," ) ; first = false ; showColumnMeta ( colSb , cfDef , colDef ) ; } colSb . append ( "]" ) ; writeAttrRaw ( sb , false , "column_metadata" , colSb . toString ( ) ) ; } if ( cfDef . compression_options != null && ! cfDef . compression_options . isEmpty ( ) ) { StringBuilder compOptions = new StringBuilder ( ) ; compOptions . append ( "{" ) ; int i = 0 , size = cfDef . compression_options . size ( ) ; for ( Map . Entry < String , String > entry : cfDef . compression_options . entrySet ( ) ) { compOptions . append ( CliUtils . quote ( entry . getKey ( ) ) ) . append ( " : " ) . append ( CliUtils . quote ( entry . getValue ( ) ) ) ; if ( i != size - 1 ) compOptions . append ( ", " ) ; i ++ ; } compOptions . append ( "}" ) ; writeAttrRaw ( sb , false , "compression_options" , compOptions . toString ( ) ) ; } sb . append ( ";" ) ; sb . append ( NEWLINE ) ; sb . append ( NEWLINE ) ; }
Creates a CLI script for the CfDef including meta data to the supplied StringBuilder.
Creates a CLI script for the CfDef including meta data to the supplied StringBuilder .