Skip to content

Commit

Permalink
HSEARCH-2035 Avoiding dependency to Lucene's Query type in TimeoutMan…
Browse files Browse the repository at this point in the history
…agerImpl
  • Loading branch information
gunnarmorling committed Nov 12, 2015
1 parent 5212869 commit 847afda
Showing 1 changed file with 7 additions and 8 deletions.
Expand Up @@ -8,11 +8,9 @@

import java.util.concurrent.TimeUnit;

import org.apache.lucene.search.Query;
import org.apache.lucene.util.Counter;

import org.hibernate.search.exception.SearchException;
import org.hibernate.search.engine.spi.TimingSource;
import org.hibernate.search.exception.SearchException;
import org.hibernate.search.query.engine.spi.TimeoutExceptionFactory;
import org.hibernate.search.query.engine.spi.TimeoutManager;

Expand All @@ -24,14 +22,14 @@ public class TimeoutManagerImpl implements TimeoutManager {
private Long timeout;
private long start;
boolean timedOut = false;
private final Query luceneQuery;
private final Object query;
private Type type;
private boolean partialResults;
private final TimeoutExceptionFactory timeoutExceptionFactory;
private final TimingSource timingSource;

public TimeoutManagerImpl(Query query, TimeoutExceptionFactory timeoutExceptionFactory, TimingSource timingSource) {
this.luceneQuery = query;
public TimeoutManagerImpl(Object query, TimeoutExceptionFactory timeoutExceptionFactory, TimingSource timingSource) {
this.query = query;
this.timeoutExceptionFactory = timeoutExceptionFactory;
this.timingSource = timingSource;
}
Expand Down Expand Up @@ -108,7 +106,7 @@ private boolean isTimedOut(long currentTime) {
if ( this.type != Type.LIMIT && timedOut ) {
throw timeoutExceptionFactory.createTimeoutException(
"Full-text query took longer than expected (in microsecond): " + TimeUnit.NANOSECONDS.toMicros( elapsedTime ),
String.valueOf( luceneQuery )
String.valueOf( query )
);
}
return timedOut;
Expand Down Expand Up @@ -166,7 +164,8 @@ public void reactOnQueryTimeoutExceptionWhileExtracting(RuntimeException e) {
if ( e == null ) {
e = timeoutExceptionFactory.createTimeoutException(
"Timeout period exceeded",
String.valueOf( luceneQuery ) );
String.valueOf( query )
);
}
throw e;
}
Expand Down

0 comments on commit 847afda

Please sign in to comment.