GitHub user dongjoon-hyun opened a pull request:
https://github.com/apache/spark/pull/12072
[SPARK-14282][SQL] CodeFormatter should handle oneline comment with /* */
properly
## What changes were proposed in this pull request?
This PR improves `CodeFormatter` to fix the following malformed
indentations.
```java
/* 019 */ public java.lang.Object apply(java.lang.Object _i) {
/* 020 */ InternalRow i = (InternalRow) _i;
/* 021 */ /* createexternalrow(if (isnull(input[0, double])) null else
input[0, double], if (isnull(input[1, int])) null else input[1, int], ... */
/* 022 */ boolean isNull = false;
/* 023 */ final Object[] values = new Object[2];
/* 024 */ /* if (isnull(input[0, double])) null else input[0, double]
*/
/* 025 */ /* isnull(input[0, double]) */
...
/* 053 */ if (!false && false) {
/* 054 */ /* null */
/* 055 */ final int value9 = -1;
/* 056 */ isNull6 = true;
/* 057 */ value6 = value9;
/* 058 */ } else {
...
/* 077 */ return mutableRow;
/* 078 */ }
/* 079 */ }
/* 080 */
```
After this PR, the code will be formatted like the following.
```java
/* 053 */ if (!false && false) {
/* 054 */ /* null */
/* 055 */ final int value9 = -1;
/* 056 */ isNull6 = true;
/* 057 */ value6 = value9;
/* 058 */ } else {
...
/* 019 */ public java.lang.Object apply(java.lang.Object _i) {
/* 020 */ InternalRow i = (InternalRow) _i;
/* 021 */ /* createexternalrow(if (isnull(input[0, double])) null else
input[0, double], if (isnull(input[1, int])) null else input[1, int], ... */
/* 022 */ boolean isNull = false;
/* 023 */ final Object[] values = new Object[2];
/* 024 */ /* if (isnull(input[0, double])) null else input[0, double] */
/* 025 */ /* isnull(input[0, double]) */
...
/* 077 */ return mutableRow;
/* 078 */ }
/* 079 */ }
/* 080 */
```
Also, this issue fixes the following too. (Similar with SPARK-14185)
```java
16/03/30 12:39:24 DEBUG WholeStageCodegen: /* 001 */ public Object
generate(Object[] references) {
/* 002 */ return new GeneratedIterator(references);
/* 003 */ }
```
```java
16/03/30 12:46:32 DEBUG WholeStageCodegen:
/* 001 */ public Object generate(Object[] references) {
/* 002 */ return new GeneratedIterator(references);
/* 003 */ }
```
## How was this patch tested?
Pass the Jenkins tests (including new CodeFormatterSuite testcases.)
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/dongjoon-hyun/spark SPARK-14282
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/12072.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #12072
----
commit 904197e82b93caa9653f9352d7d23cd0460edcdb
Author: Dongjoon Hyun <[email protected]>
Date: 2016-03-30T21:05:32Z
[SPARK-14282][SQL] CodeFormatter should handle oneline comment with /* */
properly.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]