Package com.mongodb

Examples of com.mongodb.DBCollection.drop()


    @Test
    public void testDropCollection() throws Exception {
        DBCollection collection = readOnlyClient.getDB("testdb").getCollection("foo");
        try {
            collection.drop();
            fail("MongoException expected");
        } catch (MongoException e) {
            // okay
        }
    }
View Full Code Here


    //  *write* advantage performance wise anyway
    if ((null == job.appendResults) || !job.appendResults) { // then we're going to write into temp
     
      try {
        target = DbManager.getCollection(job.getOutputDatabase(), job.outputCollectionTemp);
        target.drop();
        DbManager.getDB(job.getOutputDatabase()).getLastError();
      }
      catch (Exception e) {} // That's fine, it probably just doesn't exist yet...
    }
    // If we need any indexes for sorting/whatever then declare them here, which is faster
View Full Code Here

   
    // optionally drop the existing collection
    boolean drop = conf.getBoolean("mongo.output.drop", false);
    DBCollection coll = db.getCollection(collection);
    if(drop) {
      coll.drop();
    }
    else {
      if(coll.count() > 0) {
        // don't shard an existing collection - may already be sharded ...
        return;
View Full Code Here

   
    // optionally drop the existing collection
    boolean drop = conf.getBoolean("mongo.output.drop", false);
    DBCollection coll = db.getCollection(collection);
    if(drop) {
      coll.drop();
    }
    else {
      if(coll.count() > 0) {
        // don't shard an existing collection - may already be sharded ...
        return;
View Full Code Here

        new DbJob() {
            @Override
            public Object doRun() throws Exception {
                try {
                    if (dropCollection) {
                        col.drop();
                    }
                    DBObject obj = null;
                    List<DBObject> batch = new ArrayList<DBObject>();
                    while ((obj = dd.readObject()) != null) {
                        try {
View Full Code Here

            }
        }

        // add temp collection to sort chunks with shard key
        final DBCollection tmpchunks = config.getCollection("_tmpchunks_" + col);
        tmpchunks.drop();
        // should be safe environment, and dup keys should be ignored
        tmpchunks.setWriteConcern(WriteConcern.NORMAL);
        // can use shardKey as unique _id
//        tmpchunks.ensureIndex(shardKey, "shardKey", true);
View Full Code Here

    protected void createEmptyCollection(final Class clazz) {
        running(fakeApplication(TestConfig.getInstance().config()), new Runnable() {
            @Override
            public void run() {
                DBCollection col = MorphiaPlugin.db().getCollection(clazz.getSimpleName());
                col.drop();
            }
        });
    }

    protected void createEmptyCollection(final String colName) {
View Full Code Here

    protected void createEmptyCollection(final String colName) {
        running(fakeApplication(TestConfig.getInstance().config()), new Runnable() {
            @Override
            public void run() {
                DBCollection col = MorphiaPlugin.db().getCollection(colName);
                col.drop();
            }
        });
    }

    protected void dropAllCollections() {
View Full Code Here

        if (proceedWithUnitTest()) {
            DBCollection col = db.createCollection("my_collection", null);

            // delete if already exists
            {
                col.drop();
                col = db.createCollection("my_collection", null);
            }

            // create 3 records
            for (int i = 0; i < 3; i++) {
View Full Code Here

            DBCollection col = db.createCollection("my_collection", null);

            // delete if already exists
            {
                col.drop();
                col = db.createCollection("my_collection", null);
            }

            // create 1000 records
            for (int i = 0; i < 1000; i++) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.