bitflicker64 opened a new pull request, #898:
URL: https://github.com/apache/hugegraph-toolchain/pull/898

   ## Purpose of the PR
   
   No linked issue. These came out of a read through 
`hugegraph-spark-connector`, looking for small bugs and code that can move to 
Java 17 syntax without changing behaviour.
   
   `HGOptions` accepts the `data-type` option in any case: 
`DataTypeEnum.validDataType` and `DataTypeEnum.isEdge` both ignore case. 
`HGBatchWriterFactory.createWriter` then compares it with `dataType == 
"vertex"`, so `data-type=Vertex` or `VERTEX` passes validation and gets an 
`HGEdgeWriter`, whose constructor throws `NullPointerException` in 
`HGUtils.edgeMappingFromConf` because `source-name` is not set (after it has 
already switched the graph to LOADING mode).
   
   ## Main Changes
   
   Bug fixes (each covered by a new test that fails without the fix):
   
   - `HGBatchWriterFactory` picks the writer with 
`DataTypeEnum.isVertex(dataType)`. `DataTypeEnum` was already imported there.
   - The invalid-boolean message in `DataTypeUtils.parseBoolean` printed the 
key and the raw value in each other's places. It now reads `Failed to convert 
'right'(key='boolean') to Boolean`.
   
   Cleanup, no behaviour change:
   
   - Pattern matching for `instanceof` in `DataTypeUtils` and 
`ElementBuilder.isEmptyPkValue`.
   - `HGVertexWriter.sinkOnce`: drop `verticesBuffer.foreach(e => e.id())`, 
which does nothing, and the `successIds` local, which is never read.
   - `HGEdgeWriter.sinkOnce`: the local holding the saved edges was named 
`successfulVertices`; it is now `successfulEdges`, and the count comes from it 
directly instead of from an id list built only to be counted.
   
   No Spark option name or default, data source capability, or write and commit 
behaviour changes.
   
   Tests: a new `HGBatchWriterFactoryTest` (against the test server, like the 
builder tests) creates a writer for `vertex`, `Vertex` and `VERTEX` and checks 
each is an `HGVertexWriter`. `DataTypeUtilsTest.testConvertSingleBoolean` now 
also checks the message.
   
   ## Verifying these changes
   
   - [ ] Trivial rework / code cleanup without any test coverage. (No Need)
   - [ ] Already covered by existing tests, such as *(please modify tests 
here)*.
   - [x] Need tests and can be verified as follows:
       - `mvn -ntp -pl hugegraph-spark-connector -am test 
-Dtest='org/apache/hugegraph/spark/**/*Test' 
-Dsurefire.failIfNoSpecifiedTests=false` at 242547d2 on JDK 17 (Linux), against 
a HugeGraph 1.8.0 server with auth on, set up the way 
`start-hugegraph-servers.sh` does it. The pattern selects the same 13 classes 
that plain `mvn test` in the module picks up, `SinkExampleTest` included: 67 
tests, 0 failures, 0 skipped.
       - With only `hugegraph-spark-connector/src/main` reverted to master, 
both changed tests fail: `HGBatchWriterFactoryTest.testDataTypeIgnoresCase` 
with `NullPointerException` at `HGOptions.splitStr` (from 
`HGOptions.sourceName`), and `DataTypeUtilsTest.testConvertSingleBoolean`, 
whose message read `Failed to convert 'boolean'(key='right') to Boolean`.
   
   ## Does this PR potentially affect the following parts?
   
   - [x]  Nope
   - [ ]  Dependencies (add/update license info)
   - [ ]  Modify configurations
   - [ ]  The public API
   - [ ]  Other affects (typed here)
   
   ## Documentation Status
   
   - [ ]  `Doc - TODO`
   - [ ]  `Doc - Done`
   - [x]  `Doc - No Need`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to