src/java/org/apache/cassandra/cli/CliClient.java
/**
     * Creates a CLI script to create the Keyspace it's Column Families
     * @param sb StringBuilder to write to.
     * @param ksDef KsDef to create the cli script for.
     */
Creates a CLI script to create the Keyspace it's Column Families
@param sb StringBuilder to write to.
@param ksDef KsDef to create the cli script for.
Creates a CLI script to create the Keyspace it ' s Column Families @param sb StringBuilder to write to . @param ksDef KsDef to create the cli script for .
private void showKeyspace(StringBuilder sb, KsDef ksDef)
    {
        sb.append("create keyspace " + ksDef.name);
        writeAttr(sb, true, "placement_strategy", normaliseType(ksDef.strategy_class, "org.apache.cassandra.locator"));
        if (ksDef.strategy_options != null && !ksDef.strategy_options.isEmpty())
        {
            final StringBuilder opts = new StringBuilder();
            opts.append("{");
            String prefix = "";
            for (Map.Entry<String, String> opt : ksDef.strategy_options.entrySet())
            {
                opts.append(prefix + CliUtils.escapeSQLString(opt.getKey()) + " : " + CliUtils.escapeSQLString(opt.getValue()));
                prefix = ", ";
            }
            opts.append("}");
            writeAttrRaw(sb, false, "strategy_options", opts.toString());
        }
        writeAttr(sb, false, "durable_writes", ksDef.durable_writes);
        sb.append(";" + NEWLINE);
        sb.append(NEWLINE);
        sb.append("use " + ksDef.name + ";");
        sb.append(NEWLINE);
        sb.append(NEWLINE);
        Collections.sort(ksDef.cf_defs, new CfDefNamesComparator());
        for (CfDef cfDef : ksDef.cf_defs)
            showColumnFamily(sb, cfDef);
        sb.append(NEWLINE);
        sb.append(NEWLINE);
    }
private void showKeyspace ( StringBuilder sb , KsDef ksDef ) { sb . append ( "create keyspace " + ksDef . name ) ; writeAttr ( sb , true , "placement_strategy" , normaliseType ( ksDef . strategy_class , "org.apache.cassandra.locator" ) ) ; if ( ksDef . strategy_options != null && ! ksDef . strategy_options . isEmpty ( ) ) { final StringBuilder opts = new StringBuilder ( ) ; opts . append ( "{" ) ; String prefix = "" ; for ( Map . Entry < String , String > opt : ksDef . strategy_options . entrySet ( ) ) { opts . append ( prefix + CliUtils . escapeSQLString ( opt . getKey ( ) ) + " : " + CliUtils . escapeSQLString ( opt . getValue ( ) ) ) ; prefix = ", " ; } opts . append ( "}" ) ; writeAttrRaw ( sb , false , "strategy_options" , opts . toString ( ) ) ; } writeAttr ( sb , false , "durable_writes" , ksDef . durable_writes ) ; sb . append ( ";" + NEWLINE ) ; sb . append ( NEWLINE ) ; sb . append ( "use " + ksDef . name + ";" ) ; sb . append ( NEWLINE ) ; sb . append ( NEWLINE ) ; Collections . sort ( ksDef . cf_defs , new CfDefNamesComparator ( ) ) ; for ( CfDef cfDef : ksDef . cf_defs ) showColumnFamily ( sb , cfDef ) ; sb . append ( NEWLINE ) ; sb . append ( NEWLINE ) ; }
Creates a CLI script to create the Keyspace it's Column Families
 @param sb StringBuilder to write to.
Creates a CLI script to create the Keyspace it ' s Column Families @param sb StringBuilder to write to .