Examples of MockRAMDirectory


Examples of org.apache.lucene.store.MockRAMDirectory

  /*
    Run above stress test against RAMDirectory and then
    FSDirectory.
  */
  public void testThreadedOptimize() throws Exception {
    Directory directory = new MockRAMDirectory();
    runTest(directory, new SerialMergeScheduler());
    runTest(directory, new ConcurrentMergeScheduler());
    directory.close();

    String tempDir = System.getProperty("tempDir");
    if (tempDir == null)
      throw new IOException("tempDir undefined, cannot run test");

    String dirName = tempDir + "/luceneTestThreadedOptimize";
    directory = FSDirectory.open(new File(dirName));
    runTest(directory, new SerialMergeScheduler());
    runTest(directory, new ConcurrentMergeScheduler());
    directory.close();
    _TestUtil.rmDir(dirName);
  }
View Full Code Here

Examples of org.apache.lucene.store.MockRAMDirectory

    reader.close();
  }

  public void testEnforceDeletions() throws Exception {
    Directory dir = new MockRAMDirectory();
    IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
    IndexReader reader = writer.getReader();
    IndexSearcher searcher = new IndexSearcher(reader);

    // add a doc, refresh the reader, and check that its there
View Full Code Here

Examples of org.apache.lucene.store.MockRAMDirectory

    /** test for field count */
    assertEquals(2, doc.fields.size());
   
    /** add the doc to a ram index */
    MockRAMDirectory dir = new MockRAMDirectory();
    IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
    writer.addDocument(doc);
    writer.close();
   
    /** open a reader and fetch the document */
    IndexReader reader = IndexReader.open(dir, false);
    Document docFromReader = reader.document(0);
    assertTrue(docFromReader != null);
   
    /** fetch the binary stored field and compare it's content with the original one */
    String binaryFldStoredTest = new String(docFromReader.getBinaryValue("binaryStored"));
    assertTrue(binaryFldStoredTest.equals(binaryValStored));
   
    /** fetch the string field and compare it's content with the original one */
    String stringFldStoredTest = docFromReader.get("stringStored");
    assertTrue(stringFldStoredTest.equals(binaryValStored));
   
    /** delete the document from index */
    reader.deleteDocument(0);
    assertEquals(0, reader.numDocs());
   
    reader.close();
    dir.close();
  }
View Full Code Here

Examples of org.apache.lucene.store.MockRAMDirectory

   
    doc.add(binaryFldCompressed);
    doc.add(stringFldCompressed);
   
    /** add the doc to a ram index */
    MockRAMDirectory dir = new MockRAMDirectory();
    IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
    writer.addDocument(doc);
    writer.close();
   
    /** open a reader and fetch the document */
    IndexReader reader = IndexReader.open(dir, false);
    Document docFromReader = reader.document(0);
    assertTrue(docFromReader != null);
   
    /** fetch the binary compressed field and compare it's content with the original one */
    String binaryFldCompressedTest = new String(CompressionTools.decompress(docFromReader.getBinaryValue("binaryCompressed")));
    assertTrue(binaryFldCompressedTest.equals(binaryValCompressed));
    assertTrue(CompressionTools.decompressString(docFromReader.getBinaryValue("stringCompressed")).equals(binaryValCompressed));

    reader.close();
    dir.close();
  }
View Full Code Here

Examples of org.apache.lucene.store.MockRAMDirectory

  public void testIncompatibleIndexes() throws IOException {
    // two documents:
    Directory dir1 = getDir1();

    // one document only:
    Directory dir2 = new MockRAMDirectory();
    IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
    Document d3 = new Document();
    d3.add(new Field("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
    w2.addDocument(d3);
    w2.close();
View Full Code Here

Examples of org.apache.lucene.store.MockRAMDirectory

    }
  }

  // Fields 1-4 indexed together:
  private Searcher single() throws IOException {
    Directory dir = new MockRAMDirectory();
    IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
    Document d1 = new Document();
    d1.add(new Field("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
    d1.add(new Field("f2", "v1", Field.Store.YES, Field.Index.ANALYZED));
    d1.add(new Field("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
View Full Code Here

Examples of org.apache.lucene.store.MockRAMDirectory

    pr.add(IndexReader.open(dir2, false));
    return new IndexSearcher(pr);
  }

  private Directory getDir1() throws IOException {
    Directory dir1 = new MockRAMDirectory();
    IndexWriter w1 = new IndexWriter(dir1, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
    Document d1 = new Document();
    d1.add(new Field("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
    d1.add(new Field("f2", "v1", Field.Store.YES, Field.Index.ANALYZED));
    w1.addDocument(d1);
View Full Code Here

Examples of org.apache.lucene.store.MockRAMDirectory

    }
    writer.close();
    searcher = new IndexSearcher(directory, true);

    // Make big index
    dir2 = new MockRAMDirectory(directory);

    // First multiply small test index:
    mulFactor = 1;
    int docCount = 0;
    do {
View Full Code Here

Examples of org.apache.lucene.store.MockRAMDirectory

      return true;
    }
  }

  public void testRandomExceptions() throws Throwable {
    MockRAMDirectory dir = new MockRAMDirectory();

    MockIndexWriter writer  = new MockIndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
    ((ConcurrentMergeScheduler) writer.getMergeScheduler()).setSuppressExceptions();
    //writer.setMaxBufferedDocs(10);
    writer.setRAMBufferSizeMB(0.1);
View Full Code Here

Examples of org.apache.lucene.store.MockRAMDirectory

    _TestUtil.checkIndex(dir);
  }

  public void testRandomExceptionsThreads() throws Throwable {

    MockRAMDirectory dir = new MockRAMDirectory();
    MockIndexWriter writer  = new MockIndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
    ((ConcurrentMergeScheduler) writer.getMergeScheduler()).setSuppressExceptions();
    //writer.setMaxBufferedDocs(10);
    writer.setRAMBufferSizeMB(0.2);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.