apache / apache/parquet-java

Use StringBuilder instead of StringBuffer

Open
#2,530 0 comments 0 reactions 0 assignees View on GitHub
Component: Java Component: Parquet Priority: Trivial Type: enhancement
Dominant language
Java
Stars
3.1k
Forks
1.6k
Avg merge
3d 12h
Merged PRs (30d)
33

Description

```java

private StringBuffer currentLine = new StringBuffer();

....

public String nextToken() {
while (st.hasMoreTokens()) {
String t = st.nextToken();
if (t.equals("\n")) {
++ line;
currentLine.setLength(0);
} else {
currentLine.append(t);
}
if (!isWhitespace(t)) {
return t;
}
}
throw new IllegalArgumentException("unexpected end of schema");
}
```

Use `StringBuilder` instead of `StringBuffer` as `StringBuffer` is synchronized (which is not required here).

**Reporter**: [David Mollitor](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=belugabehr) / @belugabehr

**Note**: *This issue was originally created as [PARQUET-1921](https://issues.apache.org/jira/browse/PARQUET-1921). Please see the [migration documentation](https://issues.apache.org/jira/browse/PARQUET-2502) for further details.*

Contributor guide

No contributing guide indexed for this repository

Research direction

Search the repository for the shown StringBuffer declaration and currentLine usage, then read the surrounding tokenizer code to confirm the buffer is not shared between threads. Replace the identified use with StringBuilder and run the repository's relevant Java build or test command to verify the tokenizer still behaves correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
data-engineering
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.