Package com.mongodb

Examples of com.mongodb.DBCollection.ensureIndex()


      DBObject options = new BasicDBObject();
      for (String key : keys) {
        index.put(key, 1);
      }
      options.put("unique", 1);
      coll.ensureIndex(index, options);
    }
    return coll;
  }
 
  private void createIndex(DBCollection coll, String... keys) throws T2DBException {
View Full Code Here


        DBCollection collection = getBlobCollection();
        DBObject index = new BasicDBObject();
        index.put(MongoBlob.KEY_ID, 1L);
        DBObject options = new BasicDBObject();
        options.put("unique", Boolean.TRUE);
        collection.ensureIndex(index, options);
    }

    private MongoBlob getBlob(String id, long lastMod) {
        DBObject query = getBlobQuery(id, lastMod);
View Full Code Here

        index.put("_mod", -1L);
        // and then id (ascending)
        index.put("_id", 1L);
        DBObject options = new BasicDBObject();
        // options.put("unique", Boolean.TRUE);
        nodes.ensureIndex(index, options);

        // index on (_id, _mod):
        // Query plan: { "cursor" : "BtreeCursor _id_1__mod_-1" ,
        // "isMultiKey" : false , "n" : 2000 , "nscannedObjects" : 2000 ,
        // "nscanned" : 954647 , "nscannedObjectsAllPlans" : 1907080 ,
View Full Code Here

        index.put("_mod", -1L);
        // and then id (ascending)
        index.put("_id", 1L);
        DBObject options = new BasicDBObject();
        // options.put("unique", Boolean.TRUE);
        nodes.ensureIndex(index, options);

        long time;
        time = System.currentTimeMillis();

        int nodeCount = 4500;
View Full Code Here

            doStuff( c, count );
        }

        DBObject idx = new BasicDBObject();
        idx.put( "date", 1 );
        c.ensureIndex( idx );
    }
}
View Full Code Here

        BasicDBObject o = new BasicDBObject();
        for (String f : fields) {
            o.append(f, 1);
        }

        col.ensureIndex(o, new BasicDBObject("unique", unique).append("sparse", sparse));
        log.debugv("Created index {0}, fields={1}, unique={2}, sparse={3}", name, Arrays.toString(fields), unique, sparse);
    }

    protected void deleteEntries(String collection) {
        db.getCollection(collection).remove(new BasicDBObject());
View Full Code Here

    }

    @Override
    public void update() throws ClassNotFoundException {
        DBCollection realmsCollection = db.getCollection("realms");
        realmsCollection.ensureIndex(new BasicDBObject("name", 1), new BasicDBObject("unique", true));

        DefaultMongoUpdaterProvider.log.debugv("Created collection {0}", "realms");

        createCollection("users");
        ensureIndex("users", new String[] { "realmId", "username"}, true, false);
View Full Code Here

        DBObject index = new BasicDBObject();
        index.put(MongoCommit.KEY_REVISION_ID, 1L);
        index.put(MongoCommit.KEY_BRANCH_ID, 1L);
        DBObject options = new BasicDBObject();
        options.put("unique", Boolean.TRUE);
        commitCollection.ensureIndex(index, options);
        MongoCommit commit = new MongoCommit();
        commit.setAffectedPaths(Collections.singleton("/"));
        commit.setBaseRevisionId(0L);
        commit.setDiff(INITIAL_COMMIT_DIFF);
        commit.setMessage(INITIAL_COMMIT_MESSAGE);
View Full Code Here

        index.put(MongoNode.KEY_BRANCH_ID, 1L);

        DBObject options = new BasicDBObject();
        options.put("unique", Boolean.TRUE);

        nodeCollection.ensureIndex(index, options);

        MongoNode root = new MongoNode();
        root.setRevisionId(0L);
        root.setPath("/");
        nodeCollection.insert(root);
View Full Code Here

        DBCollection collection = getBlobCollection();
        DBObject index = new BasicDBObject();
        index.put(MongoBlob.KEY_ID, 1L);
        DBObject options = new BasicDBObject();
        options.put("unique", Boolean.TRUE);
        collection.ensureIndex(index, options);
    }

    private MongoBlob getBlob(String id, long lastMod) {
        DBObject query = getBlobQuery(id, lastMod);
        return (MongoBlob)getBlobCollection().findOne(query);
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.