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

Java Context类代码示例

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

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



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

示例1: setMaxWriteMBPerSec

import org.apache.lucene.store.IOContext.Context; //导入依赖的package包/类
/**
 * Sets the maximum (approx) MB/sec allowed by all write IO performed by
 * {@link IndexOutput} created with the given {@link IOContext.Context}. Pass
 * <code>null</code> to have no limit.
 * 
 * <p>
 * <b>NOTE</b>: For already created {@link IndexOutput} instances there is no
 * guarantee this new rate will apply to them; it will only be guaranteed to
 * apply for new created {@link IndexOutput} instances.
 * <p>
 * <b>NOTE</b>: this is an optional operation and might not be respected by
 * all Directory implementations. Currently only {@link FSDirectory buffered}
 * Directory implementations use rate-limiting.
 * 
 * @throws IllegalArgumentException
 *           if context is <code>null</code>
 * @throws AlreadyClosedException if the {@link Directory} is already closed
 * @lucene.experimental
 */
public void setMaxWriteMBPerSec(Double mbPerSec, IOContext.Context context) {
  ensureOpen();
  if (context == null) {
    throw new IllegalArgumentException("Context must not be null");
  }
  final int ord = context.ordinal();
  final RateLimiter limiter = contextRateLimiters[ord];
  if (mbPerSec == null) {
    if (limiter != null) {
      limiter.setMbPerSec(Double.MAX_VALUE);
      contextRateLimiters[ord] = null;
    }
  } else if (limiter != null) {
    limiter.setMbPerSec(mbPerSec);
    contextRateLimiters[ord] = limiter; // cross the mem barrier again
  } else {
    contextRateLimiters[ord] = new RateLimiter.SimpleRateLimiter(mbPerSec);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:RateLimitedDirectoryWrapper.java


示例2: createOutput

import org.apache.lucene.store.IOContext.Context; //导入依赖的package包/类
@Override
public IndexOutput createOutput(String name, IOContext context) throws IOException {
    final IndexOutput output = in.createOutput(name, context);

    StoreRateLimiting rateLimiting = rateLimitingProvider.rateLimiting();
    StoreRateLimiting.Type type = rateLimiting.getType();
    RateLimiter limiter = rateLimiting.getRateLimiter();
    if (type == StoreRateLimiting.Type.NONE || limiter == null) {
        return output;
    }
    if (context.context == Context.MERGE || type == StoreRateLimiting.Type.ALL) {
        // we are merging, and type is either MERGE or ALL, rate limit...
        return new RateLimitedIndexOutput(new RateLimiterWrapper(limiter, rateListener), output);
    }
    // we shouldn't really get here...
    return output;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:RateLimitedFSDirectory.java


示例3: getMaxWriteMBPerSec

import org.apache.lucene.store.IOContext.Context; //导入依赖的package包/类
/**
 * See {@link #setMaxWriteMBPerSec}.
 * 
 * @throws IllegalArgumentException
 *           if context is <code>null</code>
 * @throws AlreadyClosedException if the {@link Directory} is already closed
 * @lucene.experimental
 */
public Double getMaxWriteMBPerSec(IOContext.Context context) {
  ensureOpen();
  if (context == null) {
    throw new IllegalArgumentException("Context must not be null");
  }
  RateLimiter limiter = getRateLimiter(context);
  return limiter == null ? null : limiter.getMbPerSec();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:RateLimitedDirectoryWrapper.java


示例4: CompletionFieldsProducer

import org.apache.lucene.store.IOContext.Context; //导入依赖的package包/类
public CompletionFieldsProducer(SegmentReadState state) throws IOException {
    String suggestFSTFile = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, EXTENSION);
    IndexInput input = state.directory.openInput(suggestFSTFile, state.context);
    version = CodecUtil.checkHeader(input, CODEC_NAME, SUGGEST_CODEC_VERSION, SUGGEST_VERSION_CURRENT);
    FieldsProducer delegateProducer = null;
    boolean success = false;
    try {
        PostingsFormat delegatePostingsFormat = PostingsFormat.forName(input.readString());
        String providerName = input.readString();
        CompletionLookupProvider completionLookupProvider = providers.get(providerName);
        if (completionLookupProvider == null) {
            throw new IllegalStateException("no provider with name [" + providerName + "] registered");
        }
        // TODO: we could clone the ReadState and make it always forward IOContext.MERGE to prevent unecessary heap usage?
        delegateProducer = delegatePostingsFormat.fieldsProducer(state);
        /*
         * If we are merging we don't load the FSTs at all such that we
         * don't consume so much memory during merge
         */
        if (state.context.context != Context.MERGE) {
            // TODO: maybe we can do this in a fully lazy fashion based on some configuration
            // eventually we should have some kind of curciut breaker that prevents us from going OOM here
            // with some configuration
            this.lookupFactory = completionLookupProvider.load(input);
        } else {
            this.lookupFactory = null;
        }
        this.delegateProducer = delegateProducer;
        success = true;
    } finally {
        if (!success) {
            IOUtils.closeWhileHandlingException(delegateProducer, input);
        } else {
            IOUtils.close(input);
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:38,代码来源:Completion090PostingsFormat.java


示例5: openInput

import org.apache.lucene.store.IOContext.Context; //导入依赖的package包/类
@Override
public IndexInput openInput(String name, IOContext context) throws IOException {
  ensureOpen();
  if (context.context != Context.MERGE || context.mergeInfo.estimatedMergeBytes < minBytesDirect || fileLength(name) < minBytesDirect) {
    return delegate.openInput(name, context);
  } else {
    return new NativeUnixIndexInput(new File(getDirectory(), name), mergeBufferSize);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:NativeUnixDirectory.java


示例6: createOutput

import org.apache.lucene.store.IOContext.Context; //导入依赖的package包/类
@Override
public IndexOutput createOutput(String name, IOContext context) throws IOException {
  ensureOpen();
  if (context.context != Context.MERGE || context.mergeInfo.estimatedMergeBytes < minBytesDirect) {
    return delegate.createOutput(name, context);
  } else {
    ensureCanWrite(name);
    return new NativeUnixIndexOutput(new File(getDirectory(), name), mergeBufferSize);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:NativeUnixDirectory.java


示例7: wrapDirectory

import org.apache.lucene.store.IOContext.Context; //导入依赖的package包/类
private static BaseDirectoryWrapper wrapDirectory(Random random, Directory directory, boolean bare) {
  if (rarely(random)) {
    directory = new NRTCachingDirectory(directory, random.nextDouble(), random.nextDouble());
  }
  
  if (rarely(random)) { 
    final double maxMBPerSec = 10 + 5*(random.nextDouble()-0.5);
    if (LuceneTestCase.VERBOSE) {
      System.out.println("LuceneTestCase: will rate limit output IndexOutput to " + maxMBPerSec + " MB/sec");
    }
    final RateLimitedDirectoryWrapper rateLimitedDirectoryWrapper = new RateLimitedDirectoryWrapper(directory);
    switch (random.nextInt(10)) {
      case 3: // sometimes rate limit on flush
        rateLimitedDirectoryWrapper.setMaxWriteMBPerSec(maxMBPerSec, Context.FLUSH);
        break;
      case 2: // sometimes rate limit flush & merge
        rateLimitedDirectoryWrapper.setMaxWriteMBPerSec(maxMBPerSec, Context.FLUSH);
        rateLimitedDirectoryWrapper.setMaxWriteMBPerSec(maxMBPerSec, Context.MERGE);
        break;
      default:
        rateLimitedDirectoryWrapper.setMaxWriteMBPerSec(maxMBPerSec, Context.MERGE);
    }
    directory =  rateLimitedDirectoryWrapper;
    
  }

  if (bare) {
    BaseDirectoryWrapper base = new BaseDirectoryWrapper(directory);
    closeAfterSuite(new CloseableDirectory(base, suiteFailureMarker));
    return base;
  } else {
    MockDirectoryWrapper mock = new MockDirectoryWrapper(random, directory);
    
    mock.setThrottling(TEST_THROTTLING);
    closeAfterSuite(new CloseableDirectory(mock, suiteFailureMarker));
    return mock;
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:39,代码来源:LuceneTestCase.java


示例8: getRateLimiter

import org.apache.lucene.store.IOContext.Context; //导入依赖的package包/类
private RateLimiter getRateLimiter(IOContext.Context context) {
  assert context != null;
  return contextRateLimiters[context.ordinal()];
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:RateLimitedDirectoryWrapper.java


示例9: trainingSetDirectory

import org.apache.lucene.store.IOContext.Context; //导入依赖的package包/类
public @Bean Directory trainingSetDirectory() throws IOException {
    FSDirectory directory = FSDirectory.open(Paths.get(trainingSetCollectionPath));
    return new RAMDirectory(directory, new IOContext(Context.DEFAULT));
}
 
开发者ID:nationalarchives,项目名称:taxonomy,代码行数:5,代码来源:LuceneConfigurationTest.java


示例10: iaViewDirectory

import org.apache.lucene.store.IOContext.Context; //导入依赖的package包/类
public @Bean Directory iaViewDirectory() throws IOException {
    FSDirectory directory = FSDirectory.open(Paths.get(iaviewCollectionPath));
    return new RAMDirectory(directory, new IOContext(Context.DEFAULT));
}
 
开发者ID:nationalarchives,项目名称:taxonomy,代码行数:5,代码来源:LuceneConfigurationTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java WorkingCopyOwner类代码示例发布时间:2022-05-22
下一篇:
Java State类代码示例发布时间: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