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

Java DocValuesFormat类代码示例

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

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



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

示例1: newDocValuesProducer

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
private RefCount<DocValuesProducer> newDocValuesProducer(SegmentCommitInfo si, IOContext context, Directory dir,
    DocValuesFormat dvFormat, final Long gen, FieldInfos infos, int termsIndexDivisor) throws IOException {
  Directory dvDir = dir;
  String segmentSuffix = "";
  if (gen.longValue() != -1) {
    dvDir = si.info.dir; // gen'd files are written outside CFS, so use SegInfo directory
    segmentSuffix = Long.toString(gen.longValue(), Character.MAX_RADIX);
  }

  // set SegmentReadState to list only the fields that are relevant to that gen
  SegmentReadState srs = new SegmentReadState(dvDir, si.info, infos, context, termsIndexDivisor, segmentSuffix);
  return new RefCount<DocValuesProducer>(dvFormat.fieldsProducer(srs)) {
    @SuppressWarnings("synthetic-access")
    @Override
    protected void release() throws IOException {
      object.close();
      synchronized (SegmentDocValues.this) {
        genDVProducers.remove(gen);
      }
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:SegmentDocValues.java


示例2: flush

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
@Override
void flush(SegmentWriteState state) throws IOException {
  if (!writers.isEmpty()) {
    DocValuesFormat fmt = state.segmentInfo.getCodec().docValuesFormat();
    DocValuesConsumer dvConsumer = fmt.fieldsConsumer(state);
    boolean success = false;
    try {
      for(DocValuesWriter writer : writers.values()) {
        writer.finish(state.segmentInfo.getDocCount());
        writer.flush(state, dvConsumer);
      }
      // TODO: catch missing DV fields here?  else we have
      // null/"" depending on how docs landed in segments?
      // but we can't detect all cases, and we should leave
      // this behavior undefined. dv is not "schemaless": its column-stride.
      writers.clear();
      success = true;
    } finally {
      if (success) {
        IOUtils.close(dvConsumer);
      } else {
        IOUtils.closeWhileHandlingException(dvConsumer);
      }
    }
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:27,代码来源:DocValuesProcessor.java


示例3: newDocValuesProducer

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
private RefCount<DocValuesProducer> newDocValuesProducer(SegmentCommitInfo si, IOContext context, Directory dir,
    DocValuesFormat dvFormat, final Long gen, List<FieldInfo> infos, int termsIndexDivisor) throws IOException {
  Directory dvDir = dir;
  String segmentSuffix = "";
  if (gen.longValue() != -1) {
    dvDir = si.info.dir; // gen'd files are written outside CFS, so use SegInfo directory
    segmentSuffix = Long.toString(gen.longValue(), Character.MAX_RADIX);
  }

  // set SegmentReadState to list only the fields that are relevant to that gen
  SegmentReadState srs = new SegmentReadState(dvDir, si.info, new FieldInfos(infos.toArray(new FieldInfo[infos.size()])), context, termsIndexDivisor, segmentSuffix);
  return new RefCount<DocValuesProducer>(dvFormat.fieldsProducer(srs)) {
    @SuppressWarnings("synthetic-access")
    @Override
    protected void release() throws IOException {
      object.close();
      synchronized (SegmentDocValues.this) {
        genDVProducers.remove(gen);
      }
    }
  };
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:23,代码来源:SegmentDocValues.java


示例4: initDocValuesProducers

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
private void initDocValuesProducers(Codec codec) throws IOException {
    final Directory dir = core.cfsReader != null ? core.cfsReader : si.info.dir;
    final DocValuesFormat dvFormat = codec.docValuesFormat();
    final Map<Long,List<FieldInfo>> genInfos = getGenInfos();
    
//      System.out.println("[" + Thread.currentThread().getName() + "] SR.initDocValuesProducers: segInfo=" + si + "; gens=" + genInfos.keySet());
    
    for (Entry<Long,List<FieldInfo>> e : genInfos.entrySet()) {
      Long gen = e.getKey();
      List<FieldInfo> infos = e.getValue();
      DocValuesProducer dvp = segDocValues.getDocValuesProducer(gen, si, IOContext.READ, dir, dvFormat, infos, getTermInfosIndexDivisor());
      for (FieldInfo fi : infos) {
        dvProducers.put(fi.name, dvp);
      }
    }
    
    dvGens.addAll(genInfos.keySet());
  }
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:19,代码来源:SegmentReader.java


示例5: reloadLuceneSPI

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


示例6: getDocValuesProducer

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
/** Returns the {@link DocValuesProducer} for the given generation. */
synchronized DocValuesProducer getDocValuesProducer(long gen, SegmentCommitInfo si, IOContext context, Directory dir, 
    DocValuesFormat dvFormat, FieldInfos infos, int termsIndexDivisor) throws IOException {
  RefCount<DocValuesProducer> dvp = genDVProducers.get(gen);
  if (dvp == null) {
    dvp = newDocValuesProducer(si, context, dir, dvFormat, gen, infos, termsIndexDivisor);
    assert dvp != null;
    genDVProducers.put(gen, dvp);
  } else {
    dvp.incRef();
  }
  return dvp.get();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:SegmentDocValues.java


示例7: writeFieldInfosGen

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
private Set<String> writeFieldInfosGen(FieldInfos fieldInfos, Directory dir, DocValuesFormat dvFormat, 
    FieldInfosFormat infosFormat) throws IOException {
  final long nextFieldInfosGen = info.getNextFieldInfosGen();
  final String segmentSuffix = Long.toString(nextFieldInfosGen, Character.MAX_RADIX);
  // we write approximately that many bytes (based on Lucene46DVF):
  // HEADER + FOOTER: 40
  // 90 bytes per-field (over estimating long name and attributes map)
  final long estInfosSize = 40 + 90 * fieldInfos.size();
  final IOContext infosContext = new IOContext(new FlushInfo(info.info.getDocCount(), estInfosSize));
  // separately also track which files were created for this gen
  final TrackingDirectoryWrapper trackingDir = new TrackingDirectoryWrapper(dir);
  infosFormat.getFieldInfosWriter().write(trackingDir, info.info.name, segmentSuffix, fieldInfos, infosContext);
  info.advanceFieldInfosGen();
  return trackingDir.getCreatedFiles();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:ReadersAndUpdates.java


示例8: CrankyDocValuesFormat

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
CrankyDocValuesFormat(DocValuesFormat 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,代码来源:CrankyDocValuesFormat.java


示例9: getDocValuesFormatForField

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


示例10: addDocValues

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


示例11: alwaysDocValuesFormat

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
/** Return a Codec that can read any of the
 *  default codecs and formats, but always writes in the specified
 *  format. */
public static Codec alwaysDocValuesFormat(final DocValuesFormat format) {
  // TODO: we really need for docvalues 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 docvalues format to:" + format);
  }
  return new Lucene410Codec() {
    @Override
    public DocValuesFormat getDocValuesFormatForField(String field) {
      return format;
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:TestUtil.java


示例12: getDocValuesFormat

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


示例13: testDifferentDVFormatPerField

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
public void testDifferentDVFormatPerField() throws Exception {
  Directory dir = newDirectory();
  IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
  conf.setCodec(new Lucene410Codec() {
    @Override
    public DocValuesFormat getDocValuesFormatForField(String field) {
      return new Lucene410DocValuesFormat();
    }
  });
  IndexWriter writer = new IndexWriter(dir, conf);
  
  Document doc = new Document();
  doc.add(new StringField("key", "doc", Store.NO));
  doc.add(new BinaryDocValuesField("bdv", toBytes(5L)));
  doc.add(new SortedDocValuesField("sorted", new BytesRef("value")));
  writer.addDocument(doc); // flushed document
  writer.commit();
  writer.addDocument(doc); // in-memory document
  
  writer.updateBinaryDocValue(new Term("key", "doc"), "bdv", toBytes(17L));
  writer.close();
  
  final DirectoryReader reader = DirectoryReader.open(dir);
  
  AtomicReader r = SlowCompositeReaderWrapper.wrap(reader);
  BinaryDocValues bdv = r.getBinaryDocValues("bdv");
  SortedDocValues sdv = r.getSortedDocValues("sorted");
  for (int i = 0; i < r.maxDoc(); i++) {
    assertEquals(17, getValue(bdv, i));
    BytesRef term = sdv.get(i);
    assertEquals(new BytesRef("value"), term);
  }
  
  reader.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:37,代码来源:TestBinaryDocValuesUpdates.java


示例14: testDifferentDVFormatPerField

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
@Test
public void testDifferentDVFormatPerField() throws Exception {
  Directory dir = newDirectory();
  IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
  conf.setCodec(new Lucene410Codec() {
    @Override
    public DocValuesFormat getDocValuesFormatForField(String field) {
      return new Lucene410DocValuesFormat();
    }
  });
  IndexWriter writer = new IndexWriter(dir, conf);
  
  Document doc = new Document();
  doc.add(new StringField("key", "doc", Store.NO));
  doc.add(new NumericDocValuesField("ndv", 5));
  doc.add(new SortedDocValuesField("sorted", new BytesRef("value")));
  writer.addDocument(doc); // flushed document
  writer.commit();
  writer.addDocument(doc); // in-memory document
  
  writer.updateNumericDocValue(new Term("key", "doc"), "ndv", 17L);
  writer.close();
  
  final DirectoryReader reader = DirectoryReader.open(dir);
  
  AtomicReader r = SlowCompositeReaderWrapper.wrap(reader);
  NumericDocValues ndv = r.getNumericDocValues("ndv");
  SortedDocValues sdv = r.getSortedDocValues("sorted");
  for (int i = 0; i < r.maxDoc(); i++) {
    assertEquals(17, ndv.get(i));
    final BytesRef term = sdv.get(i);
    assertEquals(new BytesRef("value"), term);
  }
  
  reader.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:38,代码来源:TestNumericDocValuesUpdates.java


示例15: reloadLuceneSPI

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
/**
 * Reloads all Lucene SPI implementations using the new classloader.
 * This method must be called after {@link #addToClassLoader(String, FileFilter, boolean)}
 * and {@link #addToClassLoader(String,FileFilter,boolean)} before using
 * this ResourceLoader.
 */
void reloadLuceneSPI() {
  // Codecs:
  PostingsFormat.reloadPostingsFormats(this.classLoader);
  DocValuesFormat.reloadDocValuesFormats(this.classLoader);
  Codec.reloadCodecs(this.classLoader);
  // Analysis:
  CharFilterFactory.reloadCharFilters(this.classLoader);
  TokenFilterFactory.reloadTokenFilters(this.classLoader);
  TokenizerFactory.reloadTokenizers(this.classLoader);
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:SolrResourceLoader.java


示例16: getDocValuesFormatForField

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
@Override
public DocValuesFormat getDocValuesFormatForField(String field) {
  if (facetFields.contains(field)) {
    return facetsDVFormat;
  } else {
    return lucene42DVFormat;
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:9,代码来源:Facet42Codec.java


示例17: alwaysDocValuesFormat

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
/** Return a Codec that can read any of the
 *  default codecs and formats, but always writes in the specified
 *  format. */
public static Codec alwaysDocValuesFormat(final DocValuesFormat format) {
  // TODO: we really need for docvalues 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 docvalues format to:" + format);
  }
  return new Lucene42Codec() {
    @Override
    public DocValuesFormat getDocValuesFormatForField(String field) {
      return format;
    }
  };
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:18,代码来源:_TestUtil.java


示例18: reloadLuceneSPI

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
/**
 * Reloads all Lucene SPI implementations using the new classloader.
 * This method must be called after {@link #addToClassLoader(String)}
 * and {@link #addToClassLoader(String,FileFilter)} before using
 * this ResourceLoader.
 */
void reloadLuceneSPI() {
  // Codecs:
  PostingsFormat.reloadPostingsFormats(this.classLoader);
  DocValuesFormat.reloadDocValuesFormats(this.classLoader);
  Codec.reloadCodecs(this.classLoader);
  // Analysis:
  CharFilterFactory.reloadCharFilters(this.classLoader);
  TokenFilterFactory.reloadTokenFilters(this.classLoader);
  TokenizerFactory.reloadTokenizers(this.classLoader);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:17,代码来源:SolrResourceLoader.java


示例19: getDocValuesProducer

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
/** Returns the {@link DocValuesProducer} for the given generation. */
synchronized DocValuesProducer getDocValuesProducer(long gen, SegmentCommitInfo si, IOContext context, Directory dir, 
    DocValuesFormat dvFormat, List<FieldInfo> infos, int termsIndexDivisor) throws IOException {
  RefCount<DocValuesProducer> dvp = genDVProducers.get(gen);
  if (dvp == null) {
    dvp = newDocValuesProducer(si, context, dir, dvFormat, gen, infos, termsIndexDivisor);
    assert dvp != null;
    genDVProducers.put(gen, dvp);
  } else {
    dvp.incRef();
  }
  return dvp.get();
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:14,代码来源:SegmentDocValues.java


示例20: init

import org.apache.lucene.codecs.DocValuesFormat; //导入依赖的package包/类
@Override
public void init(NamedList args) {
  super.init(args);
  codec = new Lucene46Codec() {
    @Override
    public PostingsFormat getPostingsFormatForField(String field) {
      final SchemaField schemaField = core.getLatestSchema().getFieldOrNull(field);
      if (schemaField != null) {
        String postingsFormatName = schemaField.getType().getPostingsFormat();
        if (postingsFormatName != null) {
          return PostingsFormat.forName(postingsFormatName);
        }
      }
      return super.getPostingsFormatForField(field);
    }
    @Override
    public DocValuesFormat getDocValuesFormatForField(String field) {
      final SchemaField schemaField = core.getLatestSchema().getFieldOrNull(field);
      if (schemaField != null) {
        String docValuesFormatName = schemaField.getType().getDocValuesFormat();
        if (docValuesFormatName != null) {
          return DocValuesFormat.forName(docValuesFormatName);
        }
      }
      return super.getDocValuesFormatForField(field);
    }
  };
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:29,代码来源:SchemaCodecFactory.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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