Package com.mongodb

Examples of com.mongodb.DBCollection.ensureIndex()


          cacheElement = null;
        }
      }//TOTEST
      if (null == cacheElement) {
        // 3) Check key is indexed
        cacheCollection.ensureIndex(new BasicDBObject("key", 1));
       
        // 4) Check key is Text or single value BSON (and what is that value?)
        String keyField = null;
        if (null == customJob.outputKey) {
          throw new RuntimeException("Invalid key: " + customJob.outputKey);
View Full Code Here


        DBCollection dbColl = getCollection(clazz);

        BasicDBObject opts = (BasicDBObject) keyOpts.get();
        if (opts.isEmpty()) {
            log.debug("Ensuring index for " + dbColl.getName() + " with keys:" + fields);
            dbColl.ensureIndex(fields);
        } else {
            log.debug("Ensuring index for " + dbColl.getName() + " with keys:" + fields + " and opts:" + opts);
            dbColl.ensureIndex(fields, opts);
        }
    }
View Full Code Here

        if (opts.isEmpty()) {
            log.debug("Ensuring index for " + dbColl.getName() + " with keys:" + fields);
            dbColl.ensureIndex(fields);
        } else {
            log.debug("Ensuring index for " + dbColl.getName() + " with keys:" + fields + " and opts:" + opts);
            dbColl.ensureIndex(fields, opts);
        }
    }

    /**
     * Causes a (foreground, blocking) index creation across mapped classes.
View Full Code Here

        createTextIndex(indexedClass, cmd);
    }

    private void createTextIndex(Class<?> indexedClass, TextIndexCommand cmd) {
        DBCollection col = getCollection(indexedClass);
        col.ensureIndex(cmd.getKeys(), cmd.getOptions());
    }

    private String getFullFieldName(ArrayList<MappedClass> parentMCs, ArrayList<MappedField> parentMFs, MappedField mf) {
        StringBuilder field = new StringBuilder();
        if (!parentMCs.isEmpty())
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

        || colFamily.equalsIgnoreCase("IntegerIndice")
        || colFamily.equalsIgnoreCase("DecimalIndice")) {
      BasicDBObject index = new BasicDBObject();
      index.append("i", 1);
      index.append("k", 1);
      table.ensureIndex(index);
    }
    String virtual = meta.getColumnFamily();
    String realCf = meta.getRealColumnFamily();
    String realCfLower = realCf.toLowerCase();
    Info info = createInfo(realCf, null, null);
View Full Code Here

    for (String collectionName : COLLECTION_NAMES) {
      DBCollection collection = db.getCollection(collectionName);
      collection.drop();
      collection.getDB().command(getCreateCollectionCommand(collectionName));
      collection.ensureIndex(new BasicDBObject("firstname", -1));
      collection.ensureIndex(new BasicDBObject("lastname", -1));
    }
  }

  private DBObject getCreateCollectionCommand(String name) {
View Full Code Here

    for (String collectionName : COLLECTION_NAMES) {
      DBCollection collection = db.getCollection(collectionName);
      collection.drop();
      collection.getDB().command(getCreateCollectionCommand(collectionName));
      collection.ensureIndex(new BasicDBObject("firstname", -1));
      collection.ensureIndex(new BasicDBObject("lastname", -1));
    }
  }

  private DBObject getCreateCollectionCommand(String name) {
    BasicDBObject dbObject = new BasicDBObject();
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

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.