refactor: replace CometPlainVector boolean flags with VectorKind enum #7830
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.53) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.53 · 542 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.377
Shallow Review Depth
shallow_review_depth
0.344
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #7830"
general
weight: 0.35
comphead
<!-- copilot-assessment:v1 -->
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
f7e1b13184a1fe2f87ebdb8ca9a0bde0e4451e78| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 9.5/10 | ↑ Replaces boolean flags and sentinel dispatch checks with
VectorKindusing direct==comparisons (VARIABLE_WIDTHfirst),javap -cconfirms zero$SwitchMap/ordinal()overhead, Javaspotless:check(104/104 Java files),TestCometPlainVector(8/8), and 5 Scala vector/Arrow suites (78/78 tests) all passed.<br>↓ Full Linux CI suite is pending workflow approval. |<!-- /copilot-assessment -->
Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example
Closes #123indicates that this PR will close issue #123.-->
Closes #4433.
Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
CometPlainVectorpreviously dispatched on vector kinds using boolean flags (isBaseFixedWidthVector,isLargeVarWidth),-1sentinel checks (offsetBufferAddress != -1,valueBufferAddress == -1), and aninstanceof BaseFixedWidthVectorcheck ingetBinary. Replacing those dispatch checks with a singleVectorKindenum makes vector-kind classification explicit and extensible.What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
spark/src/main/java/org/apache/comet/vector/CometPlainVector.java:- Introduced
private enum VectorKind { NULL, FIXED_WIDTH, VARIABLE_WIDTH, LARGE_VARIABLE_WIDTH, OTHER }classified once invectorKindOf(ValueVector), followed by single assignments tovalueBufferAddressandoffsetBufferAddress(which still hold-1Lwhen a vector kind has no corresponding buffer).- Replaced the boolean-flag, sentinel, and
instanceofdispatch checks ingetUTF8String,getBinary, andisNullAtwith directVectorKindreference comparisons (==), checking the commonVARIABLE_WIDTHcase first to avoid javac$SwitchMapoverhead.- Widened the fixed-width byte-offset calculation in
getUTF8StringandgetBinaryfromint(rowId length) tolong((long) rowId length) to prevent 32-bit signed overflow past 2 GiB.spark/src/test/java/org/apache/comet/vector/TestCometPlainVector.java:- Added unit tests covering
LargeVarCharVector,LargeVarBinaryVector,FixedSizeBinaryVector(plain and UUID decoding),NullVector, andIntervalMonthDayNanoVector.How are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
.\mvnw.cmd -B spotless:check "-DspotlessFiles=.*\.java"— passed (6/6 Java files incomet-common, 98/98 Java files incomet-spark; 0 violations).javap -c spark\target\classes\org\apache\comet\vector\CometPlainVector.class— verified no$SwitchMap,ordinal(), or synthetic switch class is generated; bothgetUTF8StringandgetBinarytestVectorKind.VARIABLE_WIDTHwith a singlegetfield+getstatic+if_acmpne..\mvnw.cmd -B test-compile surefire:test "-Dtest=org.apache.comet.vector.TestCometPlainVector" "-Dscalastyle.skip=true" "-Dspotless.check.skip=true"— passed (8/8 tests)..\mvnw.cmd -B test "-Dtest=none" "-Dsuites=org.apache.spark.sql.comet.util.UtilsSuite,org.apache.comet.vector.CometVectorUtilsSuite,org.apache.comet.DirectColumnarToRowConverterSuite,org.apache.spark.sql.comet.execution.arrow.CometArrowStreamSuite,org.apache.spark.sql.comet.execution.arrow.CachedBatchRowIteratorSuite" "-Dscalastyle.skip=true" "-Dspotless.check.skip=true"— passed (5/5 suites, 78/78 tests).