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

Java FieldsConsumer类代码示例

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

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



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

示例1: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
  PostingsWriterBase postingsWriter = new Lucene41PostingsWriter(state);

  boolean success = false;
  try {
    FieldsConsumer ret = new BlockTreeTermsWriter(state, 
                                                  postingsWriter,
                                                  minTermBlockSize, 
                                                  maxTermBlockSize);
    success = true;
    return ret;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(postingsWriter);
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:Lucene41PostingsFormat.java


示例2: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
  PostingsWriterBase postingsWriter = new Lucene41PostingsWriter(state);

  boolean success = false;
  try {
    FieldsConsumer ret = new OrdsBlockTreeTermsWriter(state, 
                                                      postingsWriter,
                                                      minTermBlockSize, 
                                                      maxTermBlockSize);
    success = true;
    return ret;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(postingsWriter);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:Ords41PostingsFormat.java


示例3: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
  PostingsWriterBase docsWriter = null;

  // Terms that have <= freqCutoff number of docs are
  // "pulsed" (inlined):
  PostingsWriterBase pulsingWriter = null;

  // Terms dict
  boolean success = false;
  try {
    docsWriter = wrappedPostingsBaseFormat.postingsWriterBase(state);

    // Terms that have <= freqCutoff number of docs are
    // "pulsed" (inlined):
    pulsingWriter = new PulsingPostingsWriter(state, freqCutoff, docsWriter);
    FieldsConsumer ret = new BlockTreeTermsWriter(state, pulsingWriter, minBlockSize, maxBlockSize);
    success = true;
    return ret;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(docsWriter, pulsingWriter);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:PulsingPostingsFormat.java


示例4: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
  PostingsWriterBase postingsWriter = new IDVersionPostingsWriter(state);
  boolean success = false;
  try {
    FieldsConsumer ret = new VersionBlockTreeTermsWriter(state, 
                                                         postingsWriter,
                                                         minTermsInBlock, 
                                                         maxTermsInBlock);
    success = true;
    return ret;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(postingsWriter);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:IDVersionPostingsFormat.java


示例5: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
  if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) {
    return super.fieldsConsumer(state);
  } else {
    PostingsWriterBase docs = new Lucene40PostingsWriter(state);
    
    // TODO: should we make the terms index more easily
    // pluggable?  Ie so that this codec would record which
    // index impl was used, and switch on loading?
    // Or... you must make a new Codec for this?
    boolean success = false;
    try {
      FieldsConsumer ret = new BlockTreeTermsWriter(state, docs, minBlockSize, maxBlockSize);
      success = true;
      return ret;
    } finally {
      if (!success) {
        docs.close();
      }
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:Lucene40RWPostingsFormat.java


示例6: write

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
private void write(final FieldInfos fieldInfos, final Directory dir, final FieldData[] fields, boolean allowPreFlex) throws Throwable {

    final int termIndexInterval = TestUtil.nextInt(random(), 13, 27);
    final Codec codec = Codec.getDefault();
    final SegmentInfo si = new SegmentInfo(dir, Version.LATEST, SEGMENT, 10000, false, codec, null);
    final SegmentWriteState state = new SegmentWriteState(InfoStream.getDefault(), dir, si, fieldInfos, termIndexInterval, null, newIOContext(random()));

    final FieldsConsumer consumer = codec.postingsFormat().fieldsConsumer(state);
    Arrays.sort(fields);
    for (final FieldData field : fields) {
      if (!allowPreFlex && codec instanceof Lucene3xCodec) {
        // code below expects unicode sort order
        continue;
      }
      field.write(consumer);
    }
    consumer.close();
  }
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TestCodecs.java


示例7: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {

  final String fileName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, EXTENSION);
  final IndexOutput out = state.directory.createOutput(fileName, state.context);
  
  return new FieldsConsumer() {
    @Override
    public TermsConsumer addField(FieldInfo field) {
      //System.out.println("\naddField field=" + field.name);
      return new TermsWriter(out, field, doPackFST, acceptableOverheadRatio);
    }

    @Override
    public void close() throws IOException {
      // EOF marker:
      try {
        out.writeVInt(0);
      } finally {
        out.close();
      }
    }
  };
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:25,代码来源:MemoryPostingsFormat.java


示例8: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
  PostingsWriterBase docsWriter = null;

  // Terms that have <= freqCutoff number of docs are
  // "pulsed" (inlined):
  PostingsWriterBase pulsingWriter = null;

  // Terms dict
  boolean success = false;
  try {
    docsWriter = wrappedPostingsBaseFormat.postingsWriterBase(state);

    // Terms that have <= freqCutoff number of docs are
    // "pulsed" (inlined):
    pulsingWriter = new PulsingPostingsWriter(freqCutoff, docsWriter);
    FieldsConsumer ret = new BlockTreeTermsWriter(state, pulsingWriter, minBlockSize, maxBlockSize);
    success = true;
    return ret;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(docsWriter, pulsingWriter);
    }
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:26,代码来源:PulsingPostingsFormat.java


示例9: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
  PostingsWriterBase docs = new Lucene40PostingsWriter(state);

  // TODO: should we make the terms index more easily
  // pluggable?  Ie so that this codec would record which
  // index impl was used, and switch on loading?
  // Or... you must make a new Codec for this?
  boolean success = false;
  try {
    FieldsConsumer ret = new BlockTreeTermsWriter(state, docs, minBlockSize, maxBlockSize);
    success = true;
    return ret;
  } finally {
    if (!success) {
      docs.close();
    }
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:20,代码来源:Lucene40RWPostingsFormat.java


示例10: write

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
private void write(final FieldInfos fieldInfos, final Directory dir, final FieldData[] fields, boolean allowPreFlex) throws Throwable {

    final int termIndexInterval = _TestUtil.nextInt(random(), 13, 27);
    final Codec codec = Codec.getDefault();
    final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, false, codec, null, null);
    final SegmentWriteState state = new SegmentWriteState(InfoStream.getDefault(), dir, si, fieldInfos, termIndexInterval, null, newIOContext(random()));

    final FieldsConsumer consumer = codec.postingsFormat().fieldsConsumer(state);
    Arrays.sort(fields);
    for (final FieldData field : fields) {
      if (!allowPreFlex && codec instanceof Lucene3xCodec) {
        // code below expects unicode sort order
        continue;
      }
      field.write(consumer);
    }
    consumer.close();
  }
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:19,代码来源:TestCodecs.java


示例11: write

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
private void write(final FieldInfos fieldInfos, final Directory dir, final FieldData[] fields, boolean allowPreFlex) throws Throwable {

    final int termIndexInterval = _TestUtil.nextInt(random(), 13, 27);
    final Codec codec = Codec.getDefault();
    final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, false, codec, null);
    final SegmentWriteState state = new SegmentWriteState(InfoStream.getDefault(), dir, si, fieldInfos, termIndexInterval, null, newIOContext(random()));

    final FieldsConsumer consumer = codec.postingsFormat().fieldsConsumer(state);
    Arrays.sort(fields);
    for (final FieldData field : fields) {
      if (!allowPreFlex && codec instanceof Lucene3xCodec) {
        // code below expects unicode sort order
        continue;
      }
      field.write(consumer);
    }
    consumer.close();
  }
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:19,代码来源:TestCodecs.java


示例12: mergeTerms

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
private void mergeTerms(SegmentWriteState segmentWriteState) throws IOException {
  
  final List<Fields> fields = new ArrayList<>();
  final List<ReaderSlice> slices = new ArrayList<>();

  int docBase = 0;

  for(int readerIndex=0;readerIndex<mergeState.readers.size();readerIndex++) {
    final AtomicReader reader = mergeState.readers.get(readerIndex);
    final Fields f = reader.fields();
    final int maxDoc = reader.maxDoc();
    if (f != null) {
      slices.add(new ReaderSlice(docBase, maxDoc, readerIndex));
      fields.add(f);
    }
    docBase += maxDoc;
  }

  final FieldsConsumer consumer = codec.postingsFormat().fieldsConsumer(segmentWriteState);
  boolean success = false;
  try {
    consumer.merge(mergeState,
                   new MultiFields(fields.toArray(Fields.EMPTY_ARRAY),
                                   slices.toArray(ReaderSlice.EMPTY_ARRAY)));
    success = true;
  } finally {
    if (success) {
      IOUtils.close(consumer);
    } else {
      IOUtils.closeWhileHandlingException(consumer);
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:SegmentMerger.java


示例13: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {

  final String fileName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, EXTENSION);
  final IndexOutput out = state.directory.createOutput(fileName, state.context);
  boolean success = false;
  try {
    CodecUtil.writeHeader(out, CODEC_NAME, VERSION_CURRENT);
    success = true;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(out);
    }
  }
  
  return new FieldsConsumer() {
    @Override
    public TermsConsumer addField(FieldInfo field) {
      //System.out.println("\naddField field=" + field.name);
      return new TermsWriter(out, field, doPackFST, acceptableOverheadRatio);
    }

    @Override
    public void close() throws IOException {
      // EOF marker:
      try {
        out.writeVInt(0);
        CodecUtil.writeFooter(out);
      } finally {
        out.close();
      }
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:35,代码来源:MemoryPostingsFormat.java


示例14: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
  PostingsWriterBase postingsWriter = new Lucene41PostingsWriter(state);

  boolean success = false;
  try {
    FieldsConsumer ret = new FSTOrdTermsWriter(state, postingsWriter);
    success = true;
    return ret;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(postingsWriter);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:FSTOrdPostingsFormat.java


示例15: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
  PostingsWriterBase postingsWriter = new Lucene41PostingsWriter(state);

  boolean success = false;
  try {
    FieldsConsumer ret = new FSTTermsWriter(state, postingsWriter);
    success = true;
    return ret;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(postingsWriter);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:FSTPostingsFormat.java


示例16: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state)
    throws IOException {
  if (delegatePostingsFormat == null) {
    throw new UnsupportedOperationException("Error - " + getClass().getName()
        + " has been constructed without a choice of PostingsFormat");
  }
  return new BloomFilteredFieldsConsumer(
      delegatePostingsFormat.fieldsConsumer(state), state,
      delegatePostingsFormat);
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:BloomFilteringPostingsFormat.java


示例17: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState writeState) throws IOException {
  final int id = nextID.getAndIncrement();

  // TODO -- ok to do this up front instead of
  // on close....?  should be ok?
  // Write our ID:
  final String idFileName = IndexFileNames.segmentFileName(writeState.segmentInfo.name, writeState.segmentSuffix, ID_EXTENSION);
  IndexOutput out = writeState.directory.createOutput(idFileName, writeState.context);
  boolean success = false;
  try {
    CodecUtil.writeHeader(out, RAM_ONLY_NAME, VERSION_LATEST);
    out.writeVInt(id);
    success = true;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(out);
    } else {
      IOUtils.close(out);
    }
  }
  
  final RAMPostings postings = new RAMPostings();
  final RAMFieldsConsumer consumer = new RAMFieldsConsumer(postings);

  synchronized(state) {
    state.put(id, postings);
  }
  return consumer;
}
 
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:RAMOnlyPostingsFormat.java


示例18: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
  if (random.nextInt(100) == 0) {
    throw new IOException("Fake IOException from PostingsFormat.fieldsConsumer()");
  }  
  return new CrankyFieldsConsumer(delegate.fieldsConsumer(state), random);
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:CrankyPostingsFormat.java


示例19: fieldsConsumer

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
  PostingsWriterBase docsWriter = new Lucene40PostingsWriter(state);
  boolean success = false;
  try {
    FieldsConsumer ret = new AppendingTermsWriter(state, docsWriter, BlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE, BlockTreeTermsWriter.DEFAULT_MAX_BLOCK_SIZE);
    success = true;
    return ret;
  } finally {
    if (!success) {
      docsWriter.close();
    }
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:15,代码来源:AppendingRWPostingsFormat.java


示例20: mergeTerms

import org.apache.lucene.codecs.FieldsConsumer; //导入依赖的package包/类
private void mergeTerms(SegmentWriteState segmentWriteState) throws IOException {
  
  final List<Fields> fields = new ArrayList<Fields>();
  final List<ReaderSlice> slices = new ArrayList<ReaderSlice>();

  int docBase = 0;

  for(int readerIndex=0;readerIndex<mergeState.readers.size();readerIndex++) {
    final AtomicReader reader = mergeState.readers.get(readerIndex);
    final Fields f = reader.fields();
    final int maxDoc = reader.maxDoc();
    if (f != null) {
      slices.add(new ReaderSlice(docBase, maxDoc, readerIndex));
      fields.add(f);
    }
    docBase += maxDoc;
  }

  final FieldsConsumer consumer = codec.postingsFormat().fieldsConsumer(segmentWriteState);
  boolean success = false;
  try {
    consumer.merge(mergeState,
                   new MultiFields(fields.toArray(Fields.EMPTY_ARRAY),
                                   slices.toArray(ReaderSlice.EMPTY_ARRAY)));
    success = true;
  } finally {
    if (success) {
      IOUtils.close(consumer);
    } else {
      IOUtils.closeWhileHandlingException(consumer);
    }
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:34,代码来源:SegmentMerger.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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