|
28 | 28 | import java.util.Map; |
29 | 29 | import java.util.Set; |
30 | 30 | import java.util.concurrent.CompletableFuture; |
31 | | -import java.util.concurrent.ConcurrentHashMap; |
32 | 31 | import java.util.concurrent.ConcurrentNavigableMap; |
33 | 32 | import java.util.concurrent.ConcurrentSkipListMap; |
34 | 33 | import java.util.concurrent.TimeUnit; |
@@ -238,15 +237,15 @@ public CompletableFuture<List<IndexItem>> queryAsync( |
238 | 237 | ConcurrentNavigableMap<Long, IndexFile> pendingMap = |
239 | 238 | this.timeStoreTable.subMap(beginTime, true, endTime, true); |
240 | 239 | List<CompletableFuture<Void>> futureList = new ArrayList<>(pendingMap.size()); |
241 | | - ConcurrentHashMap<String /* queueId-offset */, IndexItem> result = new ConcurrentHashMap<>(); |
| 240 | + ConcurrentSkipListMap<String /* queueId-offset */, IndexItem> result = new ConcurrentSkipListMap<>(); |
242 | 241 |
|
243 | 242 | for (Map.Entry<Long, IndexFile> entry : pendingMap.descendingMap().entrySet()) { |
244 | 243 | CompletableFuture<Void> completableFuture = entry.getValue() |
245 | 244 | .queryAsync(topic, key, maxCount, beginTime, endTime) |
246 | 245 | .thenAccept(itemList -> itemList.forEach(indexItem -> { |
247 | 246 | if (result.size() < maxCount) { |
248 | 247 | result.put(String.format( |
249 | | - "%d-%d", indexItem.getQueueId(), indexItem.getOffset()), indexItem); |
| 248 | + "%d-%20d", indexItem.getQueueId(), indexItem.getOffset()), indexItem); |
250 | 249 | } |
251 | 250 | })); |
252 | 251 | futureList.add(completableFuture); |
@@ -349,7 +348,8 @@ public void destroyExpiredFile(long expireTimestamp) { |
349 | 348 | flatAppendFile.destroyExpiredFile(expireTimestamp); |
350 | 349 | timeStoreTable.entrySet().removeIf(entry -> |
351 | 350 | IndexFile.IndexStatusEnum.UPLOAD.equals(entry.getValue().getFileStatus()) && |
352 | | - entry.getKey() < flatAppendFile.getMinTimestamp()); |
| 351 | + (flatAppendFile.getFileSegmentList().isEmpty() || |
| 352 | + entry.getKey() < flatAppendFile.getMinTimestamp())); |
353 | 353 | int tableSize = (int) timeStoreTable.entrySet().stream() |
354 | 354 | .filter(entry -> IndexFile.IndexStatusEnum.UPLOAD.equals(entry.getValue().getFileStatus())) |
355 | 355 | .count(); |
|
0 commit comments