當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。