Package org.apache.lucene.search

Examples of org.apache.lucene.search.CachingCollector.collect()


      CachingCollector cc = CachingCollector.create(new NoOpCollector(false), cacheScores, 1);
      cc.setScorer(new MockScorer());
     
      // collect 1000 docs
      for (int i = 0; i < 1000; i++) {
        cc.collect(i);
      }
     
      // now replay them
      cc.replay(new Collector() {
        int prevDocID = -1;
View Full Code Here


    CachingCollector cc = CachingCollector.create(new NoOpCollector(false), true, 50 * ONE_BYTE);
    cc.setScorer(new MockScorer());
   
    // collect 130 docs, this should be enough for triggering cache abort.
    for (int i = 0; i < 130; i++) {
      cc.collect(i);
    }
   
    assertFalse("CachingCollector should not be cached due to low memory limit", cc.isCached());
   
    try {
View Full Code Here

    // is valid with the Collector passed to the ctor
   
    // 'src' Collector does not support out-of-order
    CachingCollector cc = CachingCollector.create(new NoOpCollector(false), true, 50 * ONE_BYTE);
    cc.setScorer(new MockScorer());
    for (int i = 0; i < 10; i++) cc.collect(i);
    cc.replay(new NoOpCollector(true)); // this call should not fail
    cc.replay(new NoOpCollector(false)); // this call should not fail

    // 'src' Collector supports out-of-order
    cc = CachingCollector.create(new NoOpCollector(true), true, 50 * ONE_BYTE);
 
View Full Code Here

    cc.replay(new NoOpCollector(false)); // this call should not fail

    // 'src' Collector supports out-of-order
    cc = CachingCollector.create(new NoOpCollector(true), true, 50 * ONE_BYTE);
    cc.setScorer(new MockScorer());
    for (int i = 0; i < 10; i++) cc.collect(i);
    cc.replay(new NoOpCollector(true)); // this call should not fail
    try {
      cc.replay(new NoOpCollector(false)); // this call should fail
      fail("should have failed if an in-order Collector was given to replay(), " +
          "while CachingCollector was initialized with out-of-order collection");
View Full Code Here

    for (boolean cacheScores : new boolean[] { false, true }) {
      int bytesPerDoc = cacheScores ? 8 : 4;
      CachingCollector cc = CachingCollector.create(new NoOpCollector(false),
          cacheScores, bytesPerDoc * ONE_BYTE * numDocs);
      cc.setScorer(new MockScorer());
      for (int i = 0; i < numDocs; i++) cc.collect(i);
      assertTrue(cc.isCached());
     
      // The 151's document should terminate caching
      cc.collect(numDocs);
      assertFalse(cc.isCached());
View Full Code Here

      cc.setScorer(new MockScorer());
      for (int i = 0; i < numDocs; i++) cc.collect(i);
      assertTrue(cc.isCached());
     
      // The 151's document should terminate caching
      cc.collect(numDocs);
      assertFalse(cc.isCached());
    }
  }

  public void testNoWrappedCollector() throws Exception {
View Full Code Here

    for (boolean cacheScores : new boolean[] { false, true }) {
      // create w/ null wrapped collector, and test that the methods work
      CachingCollector cc = CachingCollector.create(true, cacheScores, 50 * ONE_BYTE);
      cc.setNextReader(null, 0);
      cc.setScorer(new MockScorer());
      cc.collect(0);
     
      assertTrue(cc.isCached());
      cc.replay(new NoOpCollector(true));
    }
  }
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.