Examples of ensureIndex()


Examples of com.mongodb.DBCollection.ensureIndex()

        DBObject index = new BasicDBObject();
        index.put(NodeMongo.KEY_PATH, Long.valueOf(1));
        index.put(NodeMongo.KEY_REVISION_ID, Long.valueOf(1));
        DBObject options = new BasicDBObject();
        options.put("unique", Boolean.TRUE);
        nodeCollection.ensureIndex(index, options);
        NodeMongo root = new NodeMongo();
        root.setRevisionId(0L);
        root.setPath("/");
        nodeCollection.insert(root);
    }
View Full Code Here

Examples of com.mongodb.DBCollection.ensureIndex()

        DBCollection collection = db.getCollection(MessageUtils.getMetricInboxPath(account));
        BasicDBObject dummyObj = new BasicDBObject();
        collection.insert(dummyObj);

        // add indexes
        collection.ensureIndex("metricGranularity");
        collection.ensureIndex("metricName");

        // remove bogus object
        collection.remove(dummyObj);
    }
View Full Code Here

Examples of com.mongodb.DBCollection.ensureIndex()

        BasicDBObject dummyObj = new BasicDBObject();
        collection.insert(dummyObj);

        // add indexes
        collection.ensureIndex("metricGranularity");
        collection.ensureIndex("metricName");

        // remove bogus object
        collection.remove(dummyObj);
    }
View Full Code Here

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

Examples of com.mongodb.DBCollection.ensureIndex()

      if ((null != job.appendResults) && job.appendResults) { // then we're going to write into collection
       
        //ensure indexes if necessary
        if ((null != job.incrementalMode) && job.incrementalMode) {
          target = DbManager.getCollection(job.getOutputDatabase(), job.outputCollection);
          target.ensureIndex(new BasicDBObject("key", 1));
        }//TODO (INF-2126): TOTEST
      }       
    }
    //drop the collection into which data is going to be written (clears existing sharding)
    //will reshard once job is complete - has a couple of advantages over immediately resharding
View Full Code Here

Examples of com.mongodb.DBCollection.ensureIndex()

      int sortDir = postProcObject.getInt("sortDirection", 1);
      if ((limit > 0) && (null == sortField)) {
        sortField = "_id";         
      }
      if (null != sortField) {
        target.ensureIndex(new BasicDBObject(sortField, sortDir));
      }
      Object indexOrIndexes = postProcObject.get("indexes");
      if (null != indexOrIndexes) {
        if (indexOrIndexes instanceof BasicDBList) {
          for (Object index: (BasicDBList)indexOrIndexes) {
View Full Code Here

Examples of com.mongodb.DBCollection.ensureIndex()

      }
      Object indexOrIndexes = postProcObject.get("indexes");
      if (null != indexOrIndexes) {
        if (indexOrIndexes instanceof BasicDBList) {
          for (Object index: (BasicDBList)indexOrIndexes) {
            target.ensureIndex((DBObject)index);
          }
        }
        else if (indexOrIndexes instanceof BasicDBObject) {
          target.ensureIndex((DBObject)indexOrIndexes);         
        }
View Full Code Here

Examples of com.mongodb.DBCollection.ensureIndex()

          for (Object index: (BasicDBList)indexOrIndexes) {
            target.ensureIndex((DBObject)index);
          }
        }
        else if (indexOrIndexes instanceof BasicDBObject) {
          target.ensureIndex((DBObject)indexOrIndexes);         
        }
      }//TOTEST
    }//TOTEST
   
  }
View Full Code Here

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

Examples of com.mongodb.DBCollection.ensureIndex()

   
    DBCollection endpointCacheCollection = getCacheCollection();
   
    if (!_staticInitializer) {
      _staticInitializer = true;
      endpointCacheCollection.ensureIndex(new BasicDBObject(SimpleFederatedCache.expiryDate_, 1));
    }
    BasicDBObject cacheObj = (BasicDBObject) endpointCacheCollection.findOne(new BasicDBObject(SimpleFederatedCache._id_, url));
    if (null == cacheObj) {
      return null;
    }
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.