当前位置: 首页>>代码示例>>Java>>正文


Java PostingsFormat类代码示例

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


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


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