@VisibleForTesting protected MongoIndexSetService(JacksonDBCollection<IndexSetConfig, ObjectId> collection, StreamService streamService, ClusterConfigService clusterConfigService, ClusterEventBus clusterEventBus) { this.collection = requireNonNull(collection); this.streamService = streamService; this.clusterConfigService = clusterConfigService; this.clusterEventBus = requireNonNull(clusterEventBus); this.collection.getDbCollection().createIndex(DBSort.asc(IndexSetConfig.FIELD_INDEX_PREFIX), null, true); this.collection.getDbCollection().createIndex(DBSort.desc(IndexSetConfig.FIELD_CREATION_DATE)); }
@VisibleForTesting protected MongoIndexSetService(JacksonDBCollection<IndexSetConfig, ObjectId> collection, StreamService streamService, ClusterConfigService clusterConfigService, ClusterEventBus clusterEventBus) { this.collection = requireNonNull(collection); this.streamService = streamService; this.clusterConfigService = clusterConfigService; this.clusterEventBus = requireNonNull(clusterEventBus); this.collection.getDbCollection().createIndex(DBSort.asc(IndexSetConfig.FIELD_INDEX_PREFIX), null, true); this.collection.getDbCollection().createIndex(DBSort.desc(IndexSetConfig.FIELD_CREATION_DATE)); }
/** * Gets all causes flagged as removed in a "raw" JSON format. * * @return the list of removed causes. * @throws Exception if so. */ protected List<DBObject> getRemovedCauses() throws Exception { BasicDBObject query = new BasicDBObject("_removed", new BasicDBObject("$exists", true)); com.mongodb.DBCursor dbCursor = getJacksonCollection().getDbCollection().find(query); List<DBObject> removed = new LinkedList<DBObject>(); while (dbCursor.hasNext()) { removed.add(dbCursor.next()); } return removed; }
/** * Copies all causes flagged as removed from the old database to this one. * * @param oldKnowledgeBase the old database. * @throws Exception if something goes wrong. */ protected void convertRemoved(MongoDBKnowledgeBase oldKnowledgeBase) throws Exception { List<DBObject> removed = oldKnowledgeBase.getRemovedCauses(); DBCollection dbCollection = getJacksonCollection().getDbCollection(); for (DBObject obj : removed) { dbCollection.save(obj); } }
com.mongodb.MapReduceCommand build(JacksonDBCollection<?, ?> collection) { DBObject query = null; if (this.query != null) { query = collection.serializeQuery(this.query); } com.mongodb.MapReduceCommand command = new com.mongodb.MapReduceCommand( collection.getDbCollection(), map, reduce, this.collection, outputType.getDriverType(), query); if (finalize != null) { command.setFinalize(finalize); } if (readPreference != null) { command.setReadPreference(readPreference); } if (outputDB != null) { command.setOutputDB(outputDB); } if (sort != null) { command.setSort(sort); } command.setLimit(limit); if (scope != null) { command.setScope(scope); } command.setVerbose(verbose); return command; }