(Binary exclusiveStartKey, int proposeLimit, Binary prefix, Action2<Binary, RocksIterator> fill)
| 311 | } |
| 312 | |
| 313 | private boolean walkDesc(Binary exclusiveStartKey, int proposeLimit, Binary prefix, |
| 314 | Action2<Binary, RocksIterator> fill) throws Exception { |
| 315 | try (var it = stateMachine.getBucket().getData().iterator()) { |
| 316 | if (exclusiveStartKey.size() > 0) { |
| 317 | it.seekForPrev(exclusiveStartKey.copyIf()); |
| 318 | } else { |
| 319 | // 分桶过程中,可能存在Last之后的数据,必须根据Last的情况定位,不能直接使用seekToLast。 |
| 320 | var lastKey = stateMachine.getBucket().getBucketMeta().getKeyLast(); |
| 321 | if (lastKey.size() > 0) |
| 322 | it.seekForPrev(lastKey.copyIf()); |
| 323 | else |
| 324 | it.seekToLast(); |
| 325 | } |
| 326 | if (it.isValid()) { |
| 327 | var firstKey = it.key(); |
| 328 | //noinspection EqualsBetweenInconvertibleTypes |
| 329 | if (exclusiveStartKey.size() > 0 && exclusiveStartKey.equals(firstKey)) |
| 330 | it.prev(); // skip exclusive key if need. |
| 331 | } |
| 332 | |
| 333 | var count = proposeLimit; |
| 334 | var bucketEnd = false; |
| 335 | for (; it.isValid() && count > 0; it.prev(), count--) { |
| 336 | var key = new Binary(it.key()); |
| 337 | if (prefix.size() > 0 && !key.startsWith(prefix)) { |
| 338 | bucketEnd = true; |
| 339 | break; |
| 340 | } |
| 341 | fill.run(key, it); |
| 342 | } |
| 343 | |
| 344 | return bucketEnd || !it.isValid(); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | private boolean walk(Binary exclusiveStartKey, int proposeLimit, boolean desc, Binary prefix, |
| 349 | Action2<Binary, RocksIterator> fill) throws Exception { |
no test coverage detected