Package com.mongodb

Examples of com.mongodb.DBCollection.ensureIndex()


        DBCollection collection = MongoUtils.getConnection().getDB().getCollection("batchInsertTest");
        DBObject index = new BasicDBObject();
        index.put("_path", 1L);
        DBObject options = new BasicDBObject();
        options.put("unique", Boolean.TRUE);
        collection.ensureIndex(index, options);

        log("Inserting " + n + " batch? " + batch);
        long start = System.currentTimeMillis();

        if (batch) {
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

        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

        DBCollection collection = MongoUtils.getConnection().getDB().getCollection("batchInsertTest");
        DBObject index = new BasicDBObject();
        index.put("_path", 1L);
        DBObject options = new BasicDBObject();
        options.put("unique", Boolean.TRUE);
        collection.ensureIndex(index, options);

        log("Inserting " + n + " batch? " + batch);
        long start = System.currentTimeMillis();

        if (batch) {
View Full Code Here

      for (String key : keys) {
        dbObject.put(key, 1);
      }
    }
    DBCollection dbcollection =  getCollection(classT);
    dbcollection.ensureIndex(dbObject);
    List<DBObject> list = dbcollection.getIndexInfo();
    for (DBObject o : list) {
      System.out.println("index: " + o);
    }
  }
View Full Code Here

      for (MongoEntityIndex mei : moe.getIndexes()) {
        DBCollection coll = db.getCollection(collName);
        DBObject keys = moe.formatObject(mei.getFields());
        // 采用默认的名称
        if (Strings.isBlank(mei.getName())) {
          coll.ensureIndex(keys, Mongos.dbo("unique", mei.isUnique()));
        }
        // 采用自定义名称
        else {
          coll.ensureIndex(keys, mei.getName(), mei.isUnique());
        }
View Full Code Here

        if (Strings.isBlank(mei.getName())) {
          coll.ensureIndex(keys, Mongos.dbo("unique", mei.isUnique()));
        }
        // 采用自定义名称
        else {
          coll.ensureIndex(keys, mei.getName(), mei.isUnique());
        }
      }
    }
  }
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.