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


Java Lucene41RWCodec类代码示例

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


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

示例1: testDisableImpersonation

import org.apache.lucene.codecs.lucene41.Lucene41RWCodec; //导入依赖的package包/类
public void testDisableImpersonation() throws Exception {
  Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(), new Lucene42RWCodec() };
  Directory dir = newDirectory();
  IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
  conf.setCodec(oldCodecs[random().nextInt(oldCodecs.length)]);
  IndexWriter writer = new IndexWriter(dir, conf);
  
  Document doc = new Document();
  doc.add(new StringField("f", "bar", Store.YES));
  doc.add(new NumericDocValuesField("n", 18L));
  writer.addDocument(doc);
  
  OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
  try {
    writer.close();
    fail("should not have succeeded to impersonate an old format!");
  } catch (UnsupportedOperationException e) {
    writer.rollback();
  } finally {
    OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
  }
  
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:TestCodecs.java

示例2: testDisableImpersonation

import org.apache.lucene.codecs.lucene41.Lucene41RWCodec; //导入依赖的package包/类
public void testDisableImpersonation() throws Exception {
  Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(), new Lucene42RWCodec() };
  Directory dir = newDirectory();
  IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
  conf.setCodec(oldCodecs[random().nextInt(oldCodecs.length)]);
  IndexWriter writer = new IndexWriter(dir, conf);
  
  Document doc = new Document();
  doc.add(new StringField("f", "bar", Store.YES));
  doc.add(new NumericDocValuesField("n", 18L));
  writer.addDocument(doc);
  
  OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
  try {
    writer.close();
    fail("should not have succeeded to impersonate an old format!");
  } catch (UnsupportedOperationException e) {
    writer.rollback();
  } finally {
    OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
  }
  
  dir.close();
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:25,代码来源:TestCodecs.java

示例3: testUpdateOldSegments

import org.apache.lucene.codecs.lucene41.Lucene41RWCodec; //导入依赖的package包/类
public void testUpdateOldSegments() throws Exception {
  Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(), new Lucene42RWCodec(), new Lucene45RWCodec() };
  Directory dir = newDirectory();
  
  boolean oldValue = OLD_FORMAT_IMPERSONATION_IS_ACTIVE;
  // create a segment with an old Codec
  IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
  conf.setCodec(oldCodecs[random().nextInt(oldCodecs.length)]);
  OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
  IndexWriter writer = new IndexWriter(dir, conf);
  Document doc = new Document();
  doc.add(new StringField("id", "doc", Store.NO));
  doc.add(new BinaryDocValuesField("f", toBytes(5L)));
  writer.addDocument(doc);
  writer.close();
  
  conf = newIndexWriterConfig(new MockAnalyzer(random()));
  writer = new IndexWriter(dir, conf);
  writer.updateBinaryDocValue(new Term("id", "doc"), "f", toBytes(4L));
  OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
  try {
    writer.close();
    fail("should not have succeeded to update a segment written with an old Codec");
  } catch (UnsupportedOperationException e) {
    writer.rollback(); 
  } finally {
    OLD_FORMAT_IMPERSONATION_IS_ACTIVE = oldValue;
  }
  
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:32,代码来源:TestBinaryDocValuesUpdates.java

示例4: testUpdateOldSegments

import org.apache.lucene.codecs.lucene41.Lucene41RWCodec; //导入依赖的package包/类
@Test
public void testUpdateOldSegments() throws Exception {
  Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(), new Lucene42RWCodec(), new Lucene45RWCodec() };
  Directory dir = newDirectory();
  
  boolean oldValue = OLD_FORMAT_IMPERSONATION_IS_ACTIVE;
  // create a segment with an old Codec
  IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
  conf.setCodec(oldCodecs[random().nextInt(oldCodecs.length)]);
  OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
  IndexWriter writer = new IndexWriter(dir, conf);
  Document doc = new Document();
  doc.add(new StringField("id", "doc", Store.NO));
  doc.add(new NumericDocValuesField("f", 5));
  writer.addDocument(doc);
  writer.close();
  
  conf = newIndexWriterConfig(new MockAnalyzer(random()));
  writer = new IndexWriter(dir, conf);
  writer.updateNumericDocValue(new Term("id", "doc"), "f", 4L);
  OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
  try {
    writer.close();
    fail("should not have succeeded to update a segment written with an old Codec");
  } catch (UnsupportedOperationException e) {
    writer.rollback(); 
  } finally {
    OLD_FORMAT_IMPERSONATION_IS_ACTIVE = oldValue;
  }
  
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:33,代码来源:TestNumericDocValuesUpdates.java

示例5: testUpdateOldSegments

import org.apache.lucene.codecs.lucene41.Lucene41RWCodec; //导入依赖的package包/类
@Test
public void testUpdateOldSegments() throws Exception {
  Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(), new Lucene42RWCodec(), new Lucene45RWCodec() };
  Directory dir = newDirectory();
  
  // create a segment with an old Codec
  IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
  conf.setCodec(oldCodecs[random().nextInt(oldCodecs.length)]);
  IndexWriter writer = new IndexWriter(dir, conf);
  Document doc = new Document();
  doc.add(new StringField("id", "doc", Store.NO));
  doc.add(new NumericDocValuesField("f", 5));
  writer.addDocument(doc);
  writer.close();
  
  conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
  writer = new IndexWriter(dir, conf);
  writer.updateNumericDocValue(new Term("id", "doc"), "f", 4L);
  OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
  try {
    writer.close();
    fail("should not have succeeded to update a segment written with an old Codec");
  } catch (UnsupportedOperationException e) {
    writer.rollback(); 
  } finally {
    OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
  }
  
  dir.close();
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:31,代码来源:TestNumericDocValuesUpdates.java


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