But truncate is still slow, especially if it can't use JNA (windows) as it snapshots. Depending on how much data you are inserting during your unit tests, just paging through all the keys and then deleting them is the fastest way, though if you use timestamps besides "now" this won't work, as the timestamps need to be increasing between test runs.
On Oct 4, 2011, at 9:33 AM, Joseph Norton wrote: > > I didn't consider using truncate because a set of potentially random Column > Families are created dynamically during the test. > > Are there any configuration knobs that could be adjusted for drop + recreate? > > thanks in advance, > > - Joe N > > > Joseph Norton > nor...@alum.mit.edu > > > > On Oct 4, 2011, at 11:19 PM, Jonathan Ellis wrote: > >> Truncate is faster than drop + recreate. >> >> On Tue, Oct 4, 2011 at 9:15 AM, Joseph Norton <nor...@lovely.email.ne.jp> >> wrote: >>> >>> Hello. >>> >>> For unit test purposes, I have a single node Cassandra cluster. I need to >>> drop and re-create several keyspaces between each test iteration. This >>> process takes approximately 10 seconds for a single node installation. >>> >>> Can you recommend any tricks or recipes to reduce the time required for >>> such operations and/or for "Waiting for schema agreement" to complete? >>> >>> regards, >>> >>> - Joe N. >>> >>> >>> >>> >>> $ time ./setupDB.sh >>> Deleteing cassandra keyspaces >>> Connected to: "Foo" on 127.0.0.1/9160 >>> ed9c7fc0-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> ee8c36f0-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> eeb14b20-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> Insert data >>> Creating cassandra keyspaces >>> Connected to: "Foo" on 127.0.0.1/9160 >>> ef1a6d30-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> Authenticated to keyspace: Bars >>> ef4af310-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> ef9bab20-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> efbceec0-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> f00e4310-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> f0589280-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> f0821380-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> f0c44ca0-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> Authenticated to keyspace: Baz >>> f121d5f0-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> f1619e10-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> f18b4620-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> Authenticated to keyspace: Buz >>> f1debd50-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> f20690a0-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> f25043d0-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> f29a1e10-ee91-11e0-0000-534d24a6e7f7 >>> Waiting for schema agreement... >>> ... schemas agree across the cluster >>> Inserting data in cassandra >>> Connected to: "Foo" on 127.0.0.1/9160 >>> Authenticated to keyspace: Boo >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> Value inserted. >>> >>> real 0m9.554s >>> user 0m2.729s >>> sys 0m0.194s >>> >>> >>> Joseph Norton >>> nor...@alum.mit.edu >>> >>> >>> >>> >> >> >> >> -- >> Jonathan Ellis >> Project Chair, Apache Cassandra >> co-founder of DataStax, the source for professional Cassandra support >> http://www.datastax.com >