Package org.apache.lucene.util

Examples of org.apache.lucene.util.Counter


    }
  }

  private PossiblyLimitedTopDocs getTopDocs(Query query, Sort sort) throws IOException {
    final TopFieldCollector topCollector = TopFieldCollector.create(sort, maxHits, true, false, false, false);
    final Counter clock = Counter.newCounter(true);
    final int waitMillis = 1000;
    // TODO: if we interrupt the whole thread anyway, do we still need the TimeLimitingCollector?
    final TimeLimitingCollector collector = new TimeLimitingCollector(topCollector, clock, maxSearchTimeMillis / waitMillis);
    collector.setBaseline(0);
    final Thread counterThread = new Thread() {
      @Override
      public void run() {
        final long startTime = System.currentTimeMillis();
        while (true) {
          final long runTimeMillis = System.currentTimeMillis() - startTime;
          if (runTimeMillis > maxSearchTimeMillis) {
            // make sure there's no lingering thread for too long
            return;
          }
          clock.addAndGet(1);
          try {
            Thread.sleep(waitMillis);
          } catch (InterruptedException e) {
            throw new RuntimeException(e);
          }
View Full Code Here


  private Collector decorateWithTimeOutCollector(Collector collector) {
    Collector maybeTimeLimitingCollector = collector;
    if ( timeoutManager.getType() == TimeoutManager.Type.LIMIT ) {
      final Long timeoutLeft = timeoutManager.getTimeoutLeftInMilliseconds();
      if ( timeoutLeft != null ) {
        Counter counter = timeoutManager.getLuceneTimeoutCounter();
        maybeTimeLimitingCollector = new TimeLimitingCollector( collector, counter, timeoutLeft);
      }
    }
    return maybeTimeLimitingCollector;
  }
View Full Code Here

  private Collector decorateWithTimeOutCollector(Collector collector) {
    Collector maybeTimeLimitingCollector = collector;
    if ( timeoutManager.getType() == TimeoutManager.Type.LIMIT ) {
      final Long timeoutLeft = timeoutManager.getTimeoutLeftInMilliseconds();
      if ( timeoutLeft != null ) {
        Counter counter = timeoutManager.getLuceneTimeoutCounter();
        maybeTimeLimitingCollector = new TimeLimitingCollector( collector, counter, timeoutLeft);
      }
    }
    return maybeTimeLimitingCollector;
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.util.Counter

Copyright © 2018 www.massapicom. 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.