Skip to content

Commit

Permalink
optimize read csv
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Feb 9, 2025
1 parent c033ccf commit 5b34823
Show file tree
Hide file tree
Showing 9 changed files with 486 additions and 255 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public static void fastjson2() {
long millis = System.currentTimeMillis() - start;
System.out.println("fastjson2 millis : " + millis);
// zulu8.68.0.21 : 3621 3270 2788 2424 2431 2123
// zulu11.62.17 : 2576 1848 2155 1567 1522
// zulu17.40.19 : 3501 3134 2586 2788 2733 2682
// zulu11.62.17 : 2576 1848 2155 1567 1522 1307
// zulu17.40.19 : 3501 3134 2586 2788 2733 2682 2494
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected boolean seekLine() throws IOException {
}

if (!lineTerminated) {
if (input != null && !inputEnd) {
if (input != null && !(inputEnd && off >= end)) {
int len = end - off;
if (off > 0) {
if (len > 0) {
Expand Down Expand Up @@ -145,7 +145,7 @@ protected boolean seekLine() throws IOException {

public <T> T readLineObject() {
try {
if (inputEnd) {
if (inputEnd && off >= end) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ public boolean tryAdvance(Consumer<? super T> action) {
throw new IllegalArgumentException("action must not be null");
}
T object = next();
if (streamReader.inputEnd || object == null) {
if ((streamReader.inputEnd && streamReader.off >= streamReader.end) || object == null) {
return false;
} else {
action.accept(object);
Expand All @@ -611,7 +611,7 @@ public Spliterator<T> trySplit() {

@Override
public long estimateSize() {
return streamReader.inputEnd ? 0L : Long.MAX_VALUE;
return (streamReader.inputEnd && streamReader.off >= streamReader.end) ? 0L : Long.MAX_VALUE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public T readLineObject() {
if (!objectSupport) {
throw new UnsupportedOperationException("this method should not be called, try specify objectClass or method readLineValues instead ?");
}
if (inputEnd) {
if (inputEnd && off == end) {
return null;
}

Expand Down
Loading

0 comments on commit 5b34823

Please sign in to comment.