apache / incubator-gluten

Gluten is a middle layer responsible for offloading JVM-based SQL engines' execution to native engines.
https://gluten.apache.org/
Apache License 2.0
1.07k stars 378 forks source link

[Core] Enhance jni signature with a more readable way #5890

Open Donvi opened 1 month ago

Donvi commented 1 month ago

Description

Current the method signature is set with current plain text, which is not so good to maintain and read like "(J[J[II[B)V" and confusing for onboarding and in maintenance. The signature is generated by the parameter type list and the return value type. A better way is like below :

  1. Build a map from type, which is via typeid in cpp, to signature
  2. Create a method to generate the signature by the parameters type list and return type
  3. Update the getMethodIdOrError from current signature to the parameter list and return type and call the method above
  4. To make the above more readable and a better comprehensibility and encapsulation, we can declare a series variables to show the detailed meaning and pass it to the getMethodIdOrError.
  5. Currently a draft PR for 1 and 2 are https://github.com/apache/incubator-gluten/pull/5888/files. I'll update the PR for step 3 and 4. cc: @zhouyuan , @zhztheplayer , @FelixYBW
Donvi commented 1 month ago

A good example is splitResultConstructor, which seems not matched with java definition. There are 6 long variables in its java code, while the signature contains 7.