@@ -226,13 +226,15 @@ public AppendResult putKey(
226
226
public CompletableFuture <List <IndexItem >> queryAsync (
227
227
String topic , String key , int maxCount , long beginTime , long endTime ) {
228
228
229
+ if (beginTime > endTime ) {
230
+ return CompletableFuture .completedFuture (new ArrayList <>());
231
+ }
232
+
229
233
CompletableFuture <List <IndexItem >> future = new CompletableFuture <>();
230
234
try {
231
235
readWriteLock .readLock ().lock ();
232
- long firstFileTimeStamp = this .timeStoreTable .lowerKey (beginTime ) == null ?
233
- this .timeStoreTable .firstKey () : this .timeStoreTable .lowerKey (beginTime );
234
236
ConcurrentNavigableMap <Long , IndexFile > pendingMap =
235
- this .timeStoreTable .subMap (firstFileTimeStamp , true , endTime , true );
237
+ this .timeStoreTable .subMap (beginTime , true , endTime , true );
236
238
List <CompletableFuture <Void >> futureList = new ArrayList <>(pendingMap .size ());
237
239
ConcurrentHashMap <String /* queueId-offset */ , IndexItem > result = new ConcurrentHashMap <>();
238
240
@@ -260,6 +262,8 @@ public CompletableFuture<List<IndexItem>> queryAsync(
260
262
}
261
263
});
262
264
} catch (Exception e ) {
265
+ log .error ("IndexStoreService#queryAsync, topicId={}, key={}, maxCount={}, timestamp={}-{}" ,
266
+ topic , key , maxCount , beginTime , endTime , e );
263
267
future .completeExceptionally (e );
264
268
} finally {
265
269
readWriteLock .readLock ().unlock ();
0 commit comments