Skip to content

Commit

Permalink
Respond to review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
kosak committed Nov 5, 2024
1 parent 57c6b48 commit 531c63c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 24 deletions.
14 changes: 0 additions & 14 deletions src/main/java/io/deephaven/csv/containers/ByteSlice.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,6 @@ public CharSequence subSequence(final int start, final int end) {
return new ByteSlice(data, newBegin, newEnd);
}

/**
* Trim the padding bytes from the front and back of the slice.
*
* @param padding The padding byte.
*/
public void trimPadding(byte padding) {
while (begin != end && data[begin] == padding) {
++begin;
}
while (begin != end && data[end - 1] == padding) {
--end;
}
}

@Override
@NotNull
public String toString() {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/deephaven/csv/reading/ReaderUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public static String[] makeSyntheticHeaders(int numHeaders) {
}

/**
* Trim whitespace from the front and back of the slice.
* Trim spaces and tabs from the front and back of the slice.
*
* @param cs The slice, modified in-place to have whitespace (if any) removed.
* @param cs The slice, modified in-place to have spaces and tabs (if any) removed.
*/
public static void trimWhitespace(final ByteSlice cs) {
public static void trimSpacesAndTabs(final ByteSlice cs) {
final byte[] data = cs.data();
int begin = cs.begin();
int end = cs.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ public void grabNext(final ByteSlice dest, final MutableBoolean lastInRow,
++offset;
processQuotedMode(dest, lastInRow, endOfInput);
if (trim) {
ReaderUtil.trimWhitespace(dest);
ReaderUtil.trimSpacesAndTabs(dest);
}
} else {
processUnquotedMode(dest, lastInRow, endOfInput);
if (ignoreSurroundingSpaces) {
ReaderUtil.trimWhitespace(dest);
ReaderUtil.trimSpacesAndTabs(dest);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.deephaven.csv.CsvSpecs;
import io.deephaven.csv.containers.ByteSlice;
import io.deephaven.csv.reading.ReaderUtil;
import io.deephaven.csv.reading.cells.CellGrabber;
import io.deephaven.csv.util.CsvReaderException;
import io.deephaven.csv.util.MutableBoolean;
Expand Down Expand Up @@ -52,10 +53,7 @@ public static String[] determineHeadersToUse(final CsvSpecs specs,
throw new CsvReaderException(
"Can't proceed because input file is empty and client has not specified headers");
}
headersToUse = new String[firstDataRow.length];
for (int ii = 0; ii < headersToUse.length; ++ii) {
headersToUse[ii] = "Column" + (ii + 1);
}
headersToUse = ReaderUtil.makeSyntheticHeaders(firstDataRow.length);
} else {
firstDataRow = null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/deephaven/csv/tokenization/Tokenizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private static final class Mutating {
* @param bs Modified in place to remove leading and trailing whitespace, if any.
*/
public static void trim(final ByteSlice bs) {
ReaderUtil.trimWhitespace(bs);
ReaderUtil.trimSpacesAndTabs(bs);
}

/**
Expand Down

0 comments on commit 531c63c

Please sign in to comment.