From 531c63cdf07eeef89be0b450025bdbc3e75f9e4d Mon Sep 17 00:00:00 2001 From: Corey Kosak Date: Tue, 5 Nov 2024 15:01:49 -0500 Subject: [PATCH] Respond to review feedback --- .../io/deephaven/csv/containers/ByteSlice.java | 14 -------------- .../java/io/deephaven/csv/reading/ReaderUtil.java | 6 +++--- .../csv/reading/cells/DelimitedCellGrabber.java | 4 ++-- .../csv/reading/headers/DelimitedHeaderFinder.java | 6 ++---- .../io/deephaven/csv/tokenization/Tokenizer.java | 2 +- 5 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/main/java/io/deephaven/csv/containers/ByteSlice.java b/src/main/java/io/deephaven/csv/containers/ByteSlice.java index 7c894576..f3ba5628 100644 --- a/src/main/java/io/deephaven/csv/containers/ByteSlice.java +++ b/src/main/java/io/deephaven/csv/containers/ByteSlice.java @@ -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() { diff --git a/src/main/java/io/deephaven/csv/reading/ReaderUtil.java b/src/main/java/io/deephaven/csv/reading/ReaderUtil.java index 46859959..08c026f9 100644 --- a/src/main/java/io/deephaven/csv/reading/ReaderUtil.java +++ b/src/main/java/io/deephaven/csv/reading/ReaderUtil.java @@ -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(); diff --git a/src/main/java/io/deephaven/csv/reading/cells/DelimitedCellGrabber.java b/src/main/java/io/deephaven/csv/reading/cells/DelimitedCellGrabber.java index b1b5a8ff..0fed3f04 100644 --- a/src/main/java/io/deephaven/csv/reading/cells/DelimitedCellGrabber.java +++ b/src/main/java/io/deephaven/csv/reading/cells/DelimitedCellGrabber.java @@ -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); } } } diff --git a/src/main/java/io/deephaven/csv/reading/headers/DelimitedHeaderFinder.java b/src/main/java/io/deephaven/csv/reading/headers/DelimitedHeaderFinder.java index 850f9471..9fea0514 100644 --- a/src/main/java/io/deephaven/csv/reading/headers/DelimitedHeaderFinder.java +++ b/src/main/java/io/deephaven/csv/reading/headers/DelimitedHeaderFinder.java @@ -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; @@ -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; } diff --git a/src/main/java/io/deephaven/csv/tokenization/Tokenizer.java b/src/main/java/io/deephaven/csv/tokenization/Tokenizer.java index c0ccab0d..17ac2bd2 100644 --- a/src/main/java/io/deephaven/csv/tokenization/Tokenizer.java +++ b/src/main/java/io/deephaven/csv/tokenization/Tokenizer.java @@ -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); } /**