• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Index类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.data.mongodb.core.index.Index的典型用法代码示例。如果您正苦于以下问题:Java Index类的具体用法?Java Index怎么用?Java Index使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Index类属于org.springframework.data.mongodb.core.index包,在下文中一共展示了Index类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: init

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
@Override
    public void init() throws DaoException {
        if (collectionName == null) {
            throw makeNoSensorException();
        }
        if (!mongoOperation.collectionExists(collectionName)) {
            mongoOperation.createCollection(collectionName);
            mongoOperation.indexOps(collectionName).ensureIndex(new Index("timestamp", Sort.Direction.ASC).unique());

            // Distribute the database across multiple servers (useful in prod)
/*            BasicDBObject shardCommand = new BasicDBObject("shardcollection", shardDbName + "." + collectionName);
            shardCommand.put("key", new BasicDBObject("timestamp", 1));
            CommandResult result = adminMongoOperation.executeCommand(shardCommand);
            System.out.println(result.toString()); */
        }
    }
 
开发者ID:S23Y,项目名称:myconsumption-server,代码行数:17,代码来源:ValuesRepositoryImpl.java


示例2: run

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
@Override
public void run(String... strings) throws Exception {
    createCollectionIfMissing(IAViewUpdate.class);
    createCollectionIfMissing(MongoInformationAssetView.class);

    mongoTemplate.indexOps(IAViewUpdate.class).ensureIndex(
            new Index().on("creationDate", Sort.Direction.DESC).background()
    );
    mongoTemplate.indexOps(IAViewUpdate.class).ensureIndex(
            new Index().on("creationDate", Sort.Direction.ASC).on("docReference", Sort.Direction.ASC).background()
    );
    mongoTemplate.indexOps(IAViewUpdate.class).ensureIndex(
            new Index().on("docReference", Sort.Direction.ASC).background()
    );
    mongoTemplate.indexOps(MongoInformationAssetView.class).ensureIndex(
            new Index().on("series", Sort.Direction.ASC).on("categories", Sort.Direction
                    .ASC).background()
    );
}
 
开发者ID:nationalarchives,项目名称:taxonomy,代码行数:20,代码来源:EnsureMongoIndexes.java


示例3: init

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
@PostConstruct
public void init(){
    log.info("|- INIT BulbPresetRepositoryImpl..");
    log.info(" - DB used: " + mongo.getDb().getName());
    
    IndexOperations iOps = mongo.indexOps(Preset.class);
    
    iOps.ensureIndex(new Index()
            .on("_id.presetUuid", Sort.Direction.ASC)
            .on("_id.creator", Sort.Direction.ASC)
            .unique(Index.Duplicates.DROP)
    );
    iOps.ensureIndex(new Index()
            .on("name", Sort.Direction.ASC)
            .on("_id.creator", Sort.Direction.ASC));
}
 
开发者ID:datenstrudel,项目名称:bulbs-core,代码行数:17,代码来源:PresetRepositoryImpl.java


示例4: ensureIndexes

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
/**
 * Method ensures that there is a TTL index on {@literal expireAt} field. It's has
 * {@literal expireAfterSeconds} set to zero seconds, so the expiration time is
 * controlled by the application.
 *
 * It can be extended in custom converters when there is a need for creating
 * additional custom indexes.
 * @param sessionCollectionIndexes {@link IndexOperations} to use
 */
protected void ensureIndexes(IndexOperations sessionCollectionIndexes) {

	for (IndexInfo info : sessionCollectionIndexes.getIndexInfo()) {
		if (EXPIRE_AT_FIELD_NAME.equals(info.getName())) {
			LOG.debug("TTL index on field " + EXPIRE_AT_FIELD_NAME + " already exists");
			return;
		}
	}

	LOG.info("Creating TTL index on field " + EXPIRE_AT_FIELD_NAME);
	sessionCollectionIndexes
		.ensureIndex(new Index(EXPIRE_AT_FIELD_NAME, Sort.Direction.ASC).named(EXPIRE_AT_FIELD_NAME).expire(0));
}
 
开发者ID:spring-projects,项目名称:spring-session-data-mongodb,代码行数:23,代码来源:AbstractMongoSessionConverter.java


示例5: init

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
@Override
public void init() {
    if (!mongoOperation.collectionExists(COLLECTION_NAME)) {
        mongoOperation.createCollection(COLLECTION_NAME);
        mongoOperation.indexOps(User.class).ensureIndex(new Index("name", Sort.Direction.ASC).unique());
    }
}
 
开发者ID:S23Y,项目名称:myconsumption-server,代码行数:8,代码来源:UserRepositoryImpl.java


示例6: initIndices

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
@PostConstruct
public void initIndices() {
    log.info("Init BulbsContextUserRepositoryImpl..");
    IndexOperations iOps = mongo.indexOps(BulbsContextUser.class);
    iOps.ensureIndex(new Index().on("email", Sort.Direction.ASC).unique(Index.Duplicates.RETAIN));
    iOps.ensureIndex(new Index().on("apiKey", Sort.Direction.ASC).unique(Index.Duplicates.RETAIN));
}
 
开发者ID:datenstrudel,项目名称:bulbs-core,代码行数:8,代码来源:BulbsContextUserRepositoryImpl.java


示例7: init

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
@PostConstruct
public void init(){
    log.info("|- INIT BulbGroupRepositoryImpl..");
    log.info(" - DB used: " + mongo.getDb().getName());
    
    IndexOperations iOps = mongo.indexOps(BulbGroup.class);
    
    iOps.ensureIndex(new Index()
            .on("name", Sort.Direction.ASC));
    iOps.ensureIndex(new Index()
            .on("_id", Sort.Direction.ASC)
            .on("name", Sort.Direction.ASC));

}
 
开发者ID:datenstrudel,项目名称:bulbs-core,代码行数:15,代码来源:BulbGroupRepositoryImpl.java


示例8: init

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
@PostConstruct
public void init(){
    log.info("|- INIT ScheduledActuationRepositoryImpl..");
    log.info(" - DB used: " + mongo.getDb().getName());
    
    IndexOperations iOps = mongo.indexOps(ScheduledActuation.class);
    
    iOps.ensureIndex(new Index()
            .on("name", Sort.Direction.ASC) );
}
 
开发者ID:datenstrudel,项目名称:bulbs-core,代码行数:11,代码来源:ScheduledActuationRepositoryImpl.java


示例9: clearAndIndexCollection

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
private void clearAndIndexCollection(String profiledCollectionName) {
    Query query = new Query();
    da.mongoTemplate.remove(query, profiledCollectionName);

    List<String> indexes = getIndexes();
    for(int i = 0; i < indexes.size(); i++) {
        da.mongoTemplate.indexOps(profiledCollectionName).ensureIndex(new Index().on(indexes.get(i), Order.ASCENDING)); 
    }
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:10,代码来源:MongoProcessor.java


示例10: setup

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
private void setup(String profiledCollectionName) {
    // setup
    da.mongoTemplate.dropCollection(profiledCollectionName);
    da.mongoTemplate.createCollection(profiledCollectionName);

       List<String> indexes = getIndexes();
       for(int i = 0; i < indexes.size(); i++) {
           da.mongoTemplate.indexOps(profiledCollectionName).ensureIndex(new Index().on(indexes.get(i), Order.ASCENDING)); 
       }
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:11,代码来源:MongoProcessor.java


示例11: init

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
@PostConstruct
public void init() {
    this.mongoTemplate.indexOps(AccessToken.class).
            ensureIndex(new Index().on("lastUsed", Sort.Direction.ASC).expire(expire, TimeUnit.SECONDS));
}
 
开发者ID:swarmcom,项目名称:jSynapse,代码行数:6,代码来源:AccessTokenServiceImpl.java


示例12: setupFileNameIndex

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
/**
 * We expect filenames in GridFS to be unique.
 */
@PostConstruct
protected void setupFileNameIndex() {
  mongoOperations.indexOps("fs.files").ensureIndex(
      new Index().on("filename", Direction.ASC).unique());   
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:9,代码来源:FileService.java


示例13: init

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
@PostConstruct
public void init(){
    IndexOperations iOps = mongo.indexOps(BulbBridge.class);
    iOps.ensureIndex(new Index()
            .on("owner", Sort.Direction.ASC));
}
 
开发者ID:datenstrudel,项目名称:bulbs-core,代码行数:7,代码来源:BulbBridgeRepositoryImpl.java


示例14: init

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
@PostConstruct
    public void init(){
        IndexOperations iOps = mongo.indexOps(StoredEvent.class);
        log.info("Preparing stored EventStore Mongo JS..");
        if(!mongo.collectionExists(StoredEvent.class) ){
            DBCollection c = mongo.createCollection(
                    StoredEvent.class,
                    new CollectionOptions(EVT_STORE_SIZE, EVT_STORE_COUNT, Boolean.TRUE)
                    );
            COLL_NAME = c.getName();
        }else{
            COLL_NAME = mongo.getCollectionName(StoredEvent.class);
        }
        iOps.ensureIndex(new Index()
                .on("_id", Sort.Direction.ASC));
        DBCollection coll_Counters = mongo.getDb().getCollection("counters");
        DBObject eventCollCounter = coll_Counters.findOne(new BasicDBObject("_id", COLL_NAME));
        if(eventCollCounter == null){ 
            // We create a new counter, that actually holds the state of the last ID requested
            CommandResult counterCollRes = mongo.getDb().doEval(
                    "db.counters.insert(" +
                    "   {" +
//                    "      _id: '" + COLL_NAME + "'," +
                    "      collTarget: '" + COLL_NAME + "'," +
                    "      seq: 0" +
                    "   }" +
                    ")"
                    );
            counterCollRes.throwOnError();
        }
        CommandResult nextSeqFnRes = mongo.getDb().doEval(
                    "db.system.js.save(" +
                    "   {" +
                    "     _id : 'getNextSequence' ," +
                    "     value : " +
                    "       function getNextSequence(name) { " +
                    "           var oldVal = db.counters.findOne( {collTarget : 'storedEvent'}, {seq:1}).seq; " +
                    "           var ret = db.counters.findAndModify(" + 
                    "           {" + 
                    "               query: { collTarget: name },"+ 
                    "               update: { $set : { seq: oldVal + 1} },"+ 
                    "               'new' : true" + 
                    "           });" +
                    "           return ret.seq;" +
                    "       }" +
                          // Increment ($inc) doesn't work on Mongopi version  
//                            "function getNextSequence(name) {" +
//                            "   var ret = db.counters.findAndModify(" +
//                            "          {" +
//                            "            query: { collTarget: name }," +
//                            "            update: { $inc: { seq: 1 } }," +
//                            "            new: true" +
//                            "          }" +
//                            "   );" +
//                            "   return ret.seq;" +
//                            "}" +
                    "   }" +
                    ");"
                );
        nextSeqFnRes.throwOnError();
        log.info(nextSeqFnRes.toString());
        
    }
 
开发者ID:datenstrudel,项目名称:bulbs-core,代码行数:64,代码来源:DomainEventStoreMongo.java


示例15: createIndexIfNotExisting

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
private void createIndexIfNotExisting() {
    LOGGER.debug("Creating index on OpenIdAssociation collection if none exists.");
    this.mongoTemplate.indexOps(OpenIdAssociation.class).ensureIndex(
            new Index().on(HANDLE_FIELD, ASCENDING).unique());
}
 
开发者ID:patka,项目名称:cognitor,代码行数:6,代码来源:MongoOpenIdAssociationDao.java


示例16: createIndexIfNotExisting

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
private void createIndexIfNotExisting() {
    LOGGER.debug("Creating index on User collection if none exists.");
    this.mongoTemplate.indexOps(OpenIdAssociation.class).ensureIndex(
            new Index().on(EMAIL_FIELD, ASCENDING).unique());
}
 
开发者ID:patka,项目名称:cognitor,代码行数:6,代码来源:MongoUserDao.java


示例17: initDb

import org.springframework.data.mongodb.core.index.Index; //导入依赖的package包/类
@PostConstruct
public void initDb() throws Exception {
    MongoTemplate mongoTemplate = mongoTemplate();
    mongoTemplate.indexOps(StopTime.class).ensureIndex(new Index().on("trip", Direction.ASC));
    mongoTemplate.indexOps(Trip.class).ensureIndex(new Index().on("route", Direction.ASC));
}
 
开发者ID:trein,项目名称:gtfs-java,代码行数:7,代码来源:MongoRepositoryConfig.java



注:本文中的org.springframework.data.mongodb.core.index.Index类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HandlerUtils类代码示例发布时间:2022-05-22
下一篇:
Java LocalToken类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap