Skip to content

[ISSUE-796] Clean up PartitionType TODOs in rocksdb store module - #823

Open
yyyCode wants to merge 2 commits into
apache:masterfrom
yyyCode:fix/issue-796-partition-type-todo
Open

[ISSUE-796] Clean up PartitionType TODOs in rocksdb store module#823
yyyCode wants to merge 2 commits into
apache:masterfrom
yyyCode:fix/issue-796-partition-type-todo

Conversation

@yyyCode

@yyyCode yyyCode commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Closes #796.

Cleans up two stale TODOs on the PartitionType enum in the rocksdb graph store (geaflow-store-rocksdb):

  • DT// TODO: Support dt partition: DT partition is already implemented via SyncGraphDtPartitionProxy and dispatched by ProxyBuilder, so this TODO is obsolete and is removed.
  • DT_LABEL// TODO: Support label dt partition: this combination has no proxy implementation. Previously, configuring partition.type=dt_label fell through to a generic "unexpected partition type" error. ProxyBuilder.build now rejects DT_LABEL explicitly with a message that names the unsupported type (fail-fast), and the TODO is replaced with a NOTE documenting the gap for future implementers.

No behavior change for the supported partition types (NONE, LABEL, DT).

How was this PR tested?

  • Tests have Added for the changes
  • Production environment verified

Added PartitionTypeTest covering:

  • case-insensitive enum lookup and rejection of unknown types;
  • the partition flags of DT / DT_LABEL / NONE;
  • ProxyBuilder rejecting DT_LABEL with an explicit message that names the type;
  • ProxyBuilder still dispatching DT to a real proxy.

The test targets ProxyBuilder directly, so it does not require opening a native RocksDB instance. mvn test -Dtest=PartitionTypeTest passes (5/5) and mvn checkstyle:check reports 0 violations on the module.

The `PartitionType` enum in the rocksdb store carried two stale `TODO`s:

- `// TODO: Support dt partition` on `DT` — DT partition is already
  implemented (`SyncGraphDtPartitionProxy`, dispatched by `ProxyBuilder`),
  so the TODO is removed.
- `// TODO: Support label dt partition` on `DT_LABEL` — this combination
  has no proxy implementation. Configuring it previously fell through to a
  generic "unexpected partition type" error. `ProxyBuilder.build` now
  rejects `DT_LABEL` explicitly with a message that names the unsupported
  type, and the TODO is replaced with a NOTE documenting the gap.

Adds `PartitionTypeTest` covering the enum lookup/flags, the explicit
`DT_LABEL` rejection, and that `DT` is still dispatched to a real proxy.
The test targets `ProxyBuilder` directly so it does not depend on opening
a native RocksDB instance.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
return new SyncGraphLabelPartitionProxy<>(rocksdbClient, encoder, config);
} else if (partitionType == PartitionType.DT) {
return new SyncGraphDtPartitionProxy<>(rocksdbClient, encoder, config);
} else if (partitionType == PartitionType.DT_LABEL) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DT_LABEL is rejected here, but this is not fail-fast in the actual store initialization path

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The real path is StaticGraphRocksdbStoreBase.init -> super.init() (which opens the native RocksDB in BaseRocksdbStore.init) -> ProxyBuilder.build(), so rejecting DT_LABEL only inside build() means the DB is already opened on disk before we fail.

Fixed in 5b01c37: extracted ProxyBuilder.checkPartitionTypeSupported(PartitionType) and call it in StaticGraphRocksdbStoreBase.init before super.init(), so an unsupported partition.type now fails fast without leaving a half-initialized store on disk. build() still calls the same check as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @Leomrlin. Verified locally on the latest commit: an unsupported partition.type now fails in StaticGraphRocksdbStoreBase.init before super.init() opens the native RocksDB, so no half-initialized store is left on disk, and ProxyBuilder.build() keeps the same guard. mvn -Dtest=PartitionTypeTest test passes 5/5. Could you take another look when you have a moment?

* proxy constructor fails with a {@link NullPointerException}, which confirms the builder got
* past partition-type dispatch rather than throwing a {@link GeaflowRuntimeException}.
*/
@Test(expectedExceptions = NullPointerException.class)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NullPointerException does not clearly indicate the issue

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, inferring dispatch from an incidental NullPointerException is fragile and does not state the intent. Fixed in 5b01c37: the test now mocks RocksdbClient/encoder (mockito-all, version managed by the parent pom) and asserts the returned proxy is a SyncGraphDtPartitionProxy, so it directly verifies that DT is dispatched to the DT proxy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Leomrlin. Updated so the test asserts proxy instanceof SyncGraphDtPartitionProxy directly (mocking RocksdbClient/encoder) instead of inferring dispatch from an incidental NullPointerException, which makes the intent explicit. Verified locally: PartitionTypeTest passes 5/5. PTAL when you get a chance.

- Extract ProxyBuilder.checkPartitionTypeSupported and call it in
  StaticGraphRocksdbStoreBase.init before super.init() opens the RocksDB
  instance, so an unsupported partition.type fails fast without leaving a
  half-initialized store on disk.
- Rewrite the DT-dispatch test to mock RocksdbClient/encoder and assert the
  returned proxy is a SyncGraphDtPartitionProxy, instead of inferring dispatch
  from an incidental NullPointerException.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@Leomrlin Leomrlin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up a small TODO in the store module

2 participants