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

Java PostingsFormat类代码示例

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

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



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

示例1: fieldsProducer

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
@Override
public FieldsProducer fieldsProducer(SegmentReadState state) throws IOException {
  FieldsProducer postings = PostingsFormat.forName("Lucene41").fieldsProducer(state);
  if (state.context.context != IOContext.Context.MERGE) {
    FieldsProducer loadedPostings;
    try {
      postings.checkIntegrity();
      loadedPostings = new DirectFields(state, postings, minSkipCount, lowFreqCutoff);
    } finally {
      postings.close();
    }
    return loadedPostings;
  } else {
    // Don't load postings for merge:
    return postings;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:DirectPostingsFormat.java


示例2: checkCodecRestrictions

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
/**
 * Check codec restrictions.
 * 
 * @throws AssumptionViolatedException if the class does not work with a given codec.
 */
private void checkCodecRestrictions(Codec codec) {
  assumeFalse("Class not allowed to use codec: " + codec.getName() + ".",
      shouldAvoidCodec(codec.getName()));

  if (codec instanceof RandomCodec && !avoidCodecs.isEmpty()) {
    for (String name : ((RandomCodec)codec).formatNames) {
      assumeFalse("Class not allowed to use postings format: " + name + ".",
          shouldAvoidCodec(name));
    }
  }

  PostingsFormat pf = codec.postingsFormat();
  assumeFalse("Class not allowed to use postings format: " + pf.getName() + ".",
      shouldAvoidCodec(pf.getName()));

  assumeFalse("Class not allowed to use postings format: " + LuceneTestCase.TEST_POSTINGSFORMAT + ".", 
      shouldAvoidCodec(LuceneTestCase.TEST_POSTINGSFORMAT));
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:TestRuleSetupAndRestoreClassEnv.java


示例3: newConfig

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
private IndexWriterConfig newConfig(final Analyzer analyzer) {
    final IndexWriterConfig config = new IndexWriterConfig(analyzer);
    final Codec codec = new Lucene62Codec() {
        @Override
        public PostingsFormat getPostingsFormatForField(String field) {
            if (field.equals("id")) {
                return PostingsFormat.forName("Memory");
            } else {
                return PostingsFormat.forName("Lucene50");
            }
        }
    };
    config.setCodec(codec);

    return config;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:17,代码来源:DirectoryFactory.java


示例4: fieldsProducer

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
@Override
public FieldsProducer fieldsProducer(SegmentReadState state) throws IOException {
  FieldsProducer postings = PostingsFormat.forName("Lucene41").fieldsProducer(state);
  if (state.context.context != IOContext.Context.MERGE) {
    FieldsProducer loadedPostings;
    try {
      loadedPostings = new DirectFields(state, postings, minSkipCount, lowFreqCutoff);
    } finally {
      postings.close();
    }
    return loadedPostings;
  } else {
    // Don't load postings for merge:
    return postings;
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:17,代码来源:DirectPostingsFormat.java


示例5: getPostingsFormatForField

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
@Override
public PostingsFormat getPostingsFormatForField(String field) {
    final MappedFieldType fieldType = mapperService.fullName(field);
    if (fieldType == null) {
        logger.warn("no index mapper found for field: [{}] returning default postings format", field);
    } else if (fieldType instanceof CompletionFieldMapper.CompletionFieldType) {
        return CompletionFieldMapper.CompletionFieldType.postingsFormat();
    }
    return super.getPostingsFormatForField(field);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:PerFieldMappingPostingFormatCodec.java


示例6: postingsFormat

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
/**
 * @return postings format to use for this field-type
 */
public static synchronized PostingsFormat postingsFormat() {
    if (postingsFormat == null) {
        postingsFormat = new Completion50PostingsFormat();
    }
    return postingsFormat;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:CompletionFieldMapper.java


示例7: reloadLuceneSPI

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
/**
 * Reloads all Lucene SPI implementations using the new classloader.
 * This method must be called after the new classloader has been created to
 * register the services for use.
 */
static void reloadLuceneSPI(ClassLoader loader) {
    // do NOT change the order of these method calls!

    // Codecs:
    PostingsFormat.reloadPostingsFormats(loader);
    DocValuesFormat.reloadDocValuesFormats(loader);
    Codec.reloadCodecs(loader);
    // Analysis:
    CharFilterFactory.reloadCharFilters(loader);
    TokenFilterFactory.reloadTokenFilters(loader);
    TokenizerFactory.reloadTokenizers(loader);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:PluginsService.java


示例8: CompletionFieldsProducer

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的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


示例9: getPostingsFormatForField

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
@Override
public PostingsFormat getPostingsFormatForField(String field) {
    final MappedFieldType indexName = mapperService.indexName(field);
    if (indexName == null) {
        logger.warn("no index mapper found for field: [{}] returning default postings format", field);
    } else if (indexName instanceof CompletionFieldMapper.CompletionFieldType) {
        // CompletionFieldMapper needs a special postings format
        final CompletionFieldMapper.CompletionFieldType fieldType = (CompletionFieldMapper.CompletionFieldType) indexName;
        final PostingsFormat defaultFormat = super.getPostingsFormatForField(field);
        return fieldType.postingsFormat(defaultFormat);
    }
    return super.getPostingsFormatForField(field);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:14,代码来源:PerFieldMappingPostingFormatCodec.java


示例10: postingsFormat

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
public synchronized PostingsFormat postingsFormat(PostingsFormat in) {
    if (in instanceof Completion090PostingsFormat) {
        throw new IllegalStateException("Double wrapping of " + Completion090PostingsFormat.class);
    }
    if (postingsFormat == null) {
        postingsFormat = new Completion090PostingsFormat(in, analyzingSuggestLookupProvider);
    }
    return postingsFormat;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:CompletionFieldMapper.java


示例11: getPostingsFormatForField

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
@Override
public PostingsFormat getPostingsFormatForField(String field)
{
  if (field.endsWith("-mem"))
    return PostingsFormat.forName("Memory");
  return PostingsFormat.forName("Lucene50");
}
 
开发者ID:oeuvres,项目名称:Alix,代码行数:8,代码来源:ChapitreCodec.java


示例12: BloomFilteredFieldsProducer

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
public BloomFilteredFieldsProducer(SegmentReadState state)
    throws IOException {
  
  String bloomFileName = IndexFileNames.segmentFileName(
      state.segmentInfo.name, state.segmentSuffix, BLOOM_EXTENSION);
  ChecksumIndexInput bloomIn = null;
  boolean success = false;
  try {
    bloomIn = state.directory.openChecksumInput(bloomFileName, state.context);
    int version = CodecUtil.checkHeader(bloomIn, BLOOM_CODEC_NAME, VERSION_START, VERSION_CURRENT);
    // // Load the hash function used in the BloomFilter
    // hashFunction = HashFunction.forName(bloomIn.readString());
    // Load the delegate postings format
    PostingsFormat delegatePostingsFormat = PostingsFormat.forName(bloomIn
        .readString());
    
    this.delegateFieldsProducer = delegatePostingsFormat
        .fieldsProducer(state);
    int numBlooms = bloomIn.readInt();
    for (int i = 0; i < numBlooms; i++) {
      int fieldNum = bloomIn.readInt();
      FuzzySet bloom = FuzzySet.deserialize(bloomIn);
      FieldInfo fieldInfo = state.fieldInfos.fieldInfo(fieldNum);
      bloomsByFieldName.put(fieldInfo.name, bloom);
    }
    if (version >= VERSION_CHECKSUM) {
      CodecUtil.checkFooter(bloomIn);
    } else {
      CodecUtil.checkEOF(bloomIn);
    }
    IOUtils.close(bloomIn);
    success = true;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(bloomIn, delegateFieldsProducer);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:39,代码来源:BloomFilteringPostingsFormat.java


示例13: postingsFormat

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
@Override
public PostingsFormat postingsFormat() {
  if (LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) {
    return postings;
  } else {
    return super.postingsFormat();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:PreFlexRWCodec.java


示例14: CrankyPostingsFormat

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
CrankyPostingsFormat(PostingsFormat delegate, Random random) {
  // we impersonate the passed-in codec, so we don't need to be in SPI,
  // and so we dont change file formats
  super(delegate.getName());
  this.delegate = delegate;
  this.random = random;
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:CrankyPostingsFormat.java


示例15: getPostingsFormatForField

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
@Override
public PostingsFormat getPostingsFormatForField(String name) {
  PostingsFormat codec = previousMappings.get(name);
  if (codec == null) {
    codec = formats.get(Math.abs(perFieldSeed ^ name.hashCode()) % formats.size());
    if (codec instanceof SimpleTextPostingsFormat && perFieldSeed % 5 != 0) {
      // make simpletext rarer, choose again
      codec = formats.get(Math.abs(perFieldSeed ^ name.toUpperCase(Locale.ROOT).hashCode()) % formats.size());
    }
    previousMappings.put(name, codec);
    // Safety:
    assert previousMappings.size() < 10000: "test went insane";
  }
  return codec;
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:RandomCodec.java


示例16: add

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
private final void add(Set<String> avoidCodecs, PostingsFormat... postings) {
  for (PostingsFormat p : postings) {
    if (!avoidCodecs.contains(p.getName())) {
      formats.add(p);
      formatNames.add(p.getName());
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:RandomCodec.java


示例17: alwaysPostingsFormat

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
/** Return a Codec that can read any of the
 *  default codecs and formats, but always writes in the specified
 *  format. */
public static Codec alwaysPostingsFormat(final PostingsFormat format) {
  // TODO: we really need for postings impls etc to announce themselves
  // (and maybe their params, too) to infostream on flush and merge.
  // otherwise in a real debugging situation we won't know whats going on!
  if (LuceneTestCase.VERBOSE) {
    System.out.println("forcing postings format to:" + format);
  }
  return new Lucene410Codec() {
    @Override
    public PostingsFormat getPostingsFormatForField(String field) {
      return format;
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:TestUtil.java


示例18: getPostingsFormat

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
public static String getPostingsFormat(Codec codec, String field) {
  PostingsFormat p = codec.postingsFormat();
  if (p instanceof PerFieldPostingsFormat) {
    return ((PerFieldPostingsFormat)p).getPostingsFormatForField(field).getName();
  } else {
    return p.getName();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:TestUtil.java


示例19: getPostingsFormatForField

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
@Override
public PostingsFormat getPostingsFormatForField(String field) {
  if (field.equals("id")) {
    return simpleText;
  } else if (field.equals("content")) {
    return mockSep;
  } else {
    return lucene40;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:TestPerFieldPostingsFormat2.java


示例20: testSameCodecDifferentInstance

import org.apache.lucene.codecs.PostingsFormat; //导入依赖的package包/类
public void testSameCodecDifferentInstance() throws Exception {
  Codec codec = new Lucene410Codec() {
    @Override
    public PostingsFormat getPostingsFormatForField(String field) {
      if ("id".equals(field)) {
        return new Pulsing41PostingsFormat(1);
      } else if ("date".equals(field)) {
        return new Pulsing41PostingsFormat(1);
      } else {
        return super.getPostingsFormatForField(field);
      }
    }
  };
  doTestMixedPostings(codec);
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:TestPerFieldPostingsFormat2.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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