Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to prepare for fixed-width column support. #219

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

kosak
Copy link
Contributor

@kosak kosak commented Nov 4, 2024

The purpose of this PR is to refactor the code in order to prepare for my next PR, which adds support for fixed-width columns.

This PR should not introduce any behavioral changes.

Partially resolves #212

@kosak kosak self-assigned this Nov 4, 2024
@kosak kosak requested a review from devinrsmith November 4, 2024 01:33
This commit should not introduce any behavioral changes.
@kosak kosak force-pushed the kosak_refactor-prep branch from 80a5fa2 to 57c6b48 Compare November 5, 2024 04:14
*
* @param padding The padding byte.
*/
public void trimPadding(byte padding) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be unused (even when reviewing other PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, deleted

Comment on lines 16 to 21
/**
* Trim whitespace from the front and back of the slice.
*
* @param cs The slice, modified in-place to have whitespace (if any) removed.
*/
public static void trimWhitespace(final ByteSlice cs) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This becoming newly public, I'm going to complain about the name "whitespace", as that has a more strict definition, see java.lang.Character#isWhitespace(char).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Renamed to trimSpacesAndTabs. PTAL

import io.deephaven.csv.util.MutableInt;

public class ReaderUtil {
public static String[] makeSyntheticHeaders(int numHeaders) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be moved / made private to the single callsite?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. There were supposed to be two call sites. Now there are :-). Thanks, good catch.

Comment on lines +15 to +20
public class DelimitedHeaderFinder {
/**
* Determine which headers to use. The result comes from either the first row of the file or the user-specified
* overrides.
*/
public static String[] determineHeadersToUse(final CsvSpecs specs,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be public? Can be placed as package private class at same level as CsvReader?

Copy link
Contributor Author

@kosak kosak Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved a few files into new subpackages deephaven.csv.reading.cells and deephaven.csv.reading.headers
because I thought deephaven.csv.reading was getting a little crowded.

But, I realize Java is a little bit annoying by the way every directory is a subpackage, and one of the evils we have to live to avoid subpackages is we put a lot of .java files in the same directory.

At the end of the day these new subpackages are small. As of the second PR, there will be three files in deephaven.csv.reading.cells and two files in deephaven.csv.reading.headers

If you think it is more Java-canonical to move those files back up into the parent package. I can do that. Let me know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, somewhat annoying the way packaging / visibility works in Java 8. Ultimately, my general preference is to reduce the "public API" to ensure we are free to change implementation details without breaking users. That said, deephaven-csv doesn't really follow this convention (lots of stuff that is "public API" that doesn't technically need to be), so I'm happy keeping this as-is.

If we bump to 9+, we can adopt modules which allows libraries to only export specific packages.

@kosak kosak merged commit 1c52d59 into deephaven:main Nov 5, 2024
3 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 5, 2024
@kosak kosak deleted the kosak_refactor-prep branch November 5, 2024 20:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot handle aligned multi-space-delimited files
2 participants