Example usage for org.apache.cassandra.db Keyspace clear

List of usage examples for org.apache.cassandra.db Keyspace clear

Introduction

In this page you can find the example usage for org.apache.cassandra.db Keyspace clear.

Prototype

public static Keyspace clear(String keyspaceName) 

Source Link

Usage

From source file:me.tango.cassandra.bench.CassandraBenchmark.java

License:Apache License

private void write(Order order, DBState state, int numEntries, int valueSize, int entriesPerBatch)
        throws IOException {
    if (state == DBState.FRESH) {
        if (useExisting) {
            message = "skipping (--use_existing_db is true)";
            return;
        }/*from   w  ww . ja v  a  2  s  .  c o m*/
        Keyspace.clear(db.getName());
        destroyDb();
        open();
        start(); // Do not count time taken to destroy/open
    }

    if (numEntries != num) {
        message = String.format("(%d ops)", numEntries);
    }

    ColumnFamilyStore cfs = db.getColumnFamilyStore("Standard1");
    ByteBuffer empty = ByteBuffer.allocate(0);
    for (int i = 0; i < numEntries; i += entriesPerBatch) {

        for (int j = 0; j < entriesPerBatch; j++) {
            int k = (order == Order.SEQUENTIAL) ? i + j : random.nextInt(num);
            byte[] key = formatNumber(k);
            Mutation rm = new Mutation(databaseDir, ByteBuffer.wrap(key));
            rm.add("Standard1", CellNames.simpleDense(ByteBuffer.wrap(generator.generate(valueSize))), empty,
                    1);
            bytes += valueSize + key.length;
            db.apply(rm, true);
            finishedSingleOp();
        }
    }
}

From source file:me.tango.cassandra.bench.CassandraBenchmark.java

License:Apache License

private void destroyDb() {
    Keyspace.clear(databaseDir);
}