@@ -226,13 +226,15 @@ public AppendResult putKey(
226226 public CompletableFuture <List <IndexItem >> queryAsync (
227227 String topic , String key , int maxCount , long beginTime , long endTime ) {
228228
229+ if (beginTime > endTime ) {
230+ return CompletableFuture .completedFuture (new ArrayList <>());
231+ }
232+
229233 CompletableFuture <List <IndexItem >> future = new CompletableFuture <>();
230234 try {
231235 readWriteLock .readLock ().lock ();
232- long firstFileTimeStamp = this .timeStoreTable .lowerKey (beginTime ) == null ?
233- this .timeStoreTable .firstKey () : this .timeStoreTable .lowerKey (beginTime );
234236 ConcurrentNavigableMap <Long , IndexFile > pendingMap =
235- this .timeStoreTable .subMap (firstFileTimeStamp , true , endTime , true );
237+ this .timeStoreTable .subMap (beginTime , true , endTime , true );
236238 List <CompletableFuture <Void >> futureList = new ArrayList <>(pendingMap .size ());
237239 ConcurrentHashMap <String /* queueId-offset */ , IndexItem > result = new ConcurrentHashMap <>();
238240
@@ -260,6 +262,8 @@ public CompletableFuture<List<IndexItem>> queryAsync(
260262 }
261263 });
262264 } catch (Exception e ) {
265+ log .error ("IndexStoreService#queryAsync, topicId={}, key={}, maxCount={}, timestamp={}-{}" ,
266+ topic , key , maxCount , beginTime , endTime , e );
263267 future .completeExceptionally (e );
264268 } finally {
265269 readWriteLock .readLock ().unlock ();
0 commit comments