MCPcopy Create free account
hub / github.com/e2wugui/zeze / walkDesc

Method walkDesc

ZezeJava/ZezeJava/src/main/java/Zeze/Dbh2/Dbh2.java:313–346  ·  view source on GitHub ↗
(Binary exclusiveStartKey, int proposeLimit, Binary prefix,
							 Action2<Binary, RocksIterator> fill)

Source from the content-addressed store, hash-verified

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 {

Callers 1

walkMethod · 0.95

Calls 12

startsWithMethod · 0.95
getBucketMethod · 0.80
getBucketMetaMethod · 0.80
isValidMethod · 0.80
getDataMethod · 0.65
sizeMethod · 0.65
getKeyLastMethod · 0.65
keyMethod · 0.65
equalsMethod · 0.65
runMethod · 0.65
iteratorMethod · 0.45
copyIfMethod · 0.45

Tested by

no test coverage detected