Last active
August 5, 2016 22:00
-
-
Save jsanda/91abe44243748d9606818dbf2efca40a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Resets keyspace by truncating all tables in keyspace. | |
// | |
// session is an Rx wrapper around com.datastax.driver.core.Session and | |
// and uses the async methods in Session. The execute method return an | |
// Observable<ResultSet>. | |
public void truncateTables(String keyspace) { | |
session.execute("select table_name from system_schema.tables where keyspace_name = '" + keyspace + "'") | |
.flatMap(Observable::from) | |
.flatMap(row -> session.execute("truncate " + row.getString(0))) | |
.toCompletable() | |
.await(10, TimeUnit.SECONDS); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment