[improve][metadata] Add streaming scanChildren to MetadataStore#25701
Merged
merlimat merged 1 commit intoapache:masterfrom May 7, 2026
Merged
[improve][metadata] Add streaming scanChildren to MetadataStore#25701merlimat merged 1 commit intoapache:masterfrom
merlimat merged 1 commit intoapache:masterfrom
Conversation
Adds `MetadataStore.scanChildren(parentPath, ScanConsumer consumer)` — the value-bearing counterpart to `getChildren`. Same hierarchy semantics (direct children only, no descendants), but each record carries the value and `Stat` alongside the path. Results are delivered via a `ScanConsumer` callback (`onNext` / `onError` / `onCompleted`) so a large result set is never materialized as a single in-memory `List`. Default implementation (used by ZooKeeper / MockZooKeeper) lists children with `getChildrenFromStore` and fetches each value sequentially — one extra round trip per child. Native overrides: - `LocalMemoryMetadataStore` — `NavigableMap.subMap` with a direct-child filter. - `RocksdbMetadataStore` — `RocksIterator.seek` over the parent's prefix. - `OxiaMetadataStore` — `client.rangeScan` over `[parent + "/", parent + "//")`, the same convention `getChildrenFromStore` uses with `client.list`. Wrappers: - `DualMetadataStore` routes by migration phase. - `FaultInjectionMetadataStore` adds `OperationType.SCAN_CHILDREN`. Tests run against all five backends via the existing `impl` data provider.
65ffd9a to
b9f8cdf
Compare
dao-jun
approved these changes
May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
MetadataStore.scanChildren(parentPath, ScanConsumer consumer)— the value-bearing counterpart togetChildren. Same hierarchy semantics (direct children only, no descendants), but each record carries the value andStatalongside the path.Results are delivered to a
ScanConsumerviaonNext/onError/onCompletedso a large result set is never materialized as a single in-memoryList.Default implementation
getChildrenFromStore(parent)+ sequentialstoreGetper child. Used by ZooKeeper / MockZooKeeper. One round trip per child.Native overrides
LocalMemoryMetadataStore—NavigableMap.subMapwith a direct-child filter.RocksdbMetadataStore—RocksIterator.seekover the parent's prefix.OxiaMetadataStore—client.rangeScanover[parent + "/", parent + "//"), the same conventiongetChildrenFromStoreuses withclient.list.Wrappers
DualMetadataStoreroutes by migration phase.FaultInjectionMetadataStoreaddsOperationType.SCAN_CHILDRENfor fault injection.Motivation
Sub-PIP groundwork for PIP-471: the metadata-driven transaction components need to stream the children of a parent path together with their values (to enumerate ops for a transaction, ack records for a subscription, etc.) without paying for repeated round trips or for accumulating large result lists in broker memory.
Cache integration is a separate follow-up — sits more naturally on
MetadataCache<T>(typed) than onMetadataStore(raw bytes).Test plan
./gradlew :pulsar-metadata:test --tests "org.apache.pulsar.metadata.MetadataStoreScanChildrenTest"— 4 cases × 5 backends (ZooKeeper, Memory, RocksDB, Oxia, MockZooKeeper) = 20 invocations, all passing.pulsar-metadatatests still pass.