-
Notifications
You must be signed in to change notification settings - Fork 932
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
Add in support for setting delim when parsing JSON through java #16867
Add in support for setting delim when parsing JSON through java #16867
Conversation
Signed-off-by: Robert (Bobby) Evans <[email protected]>
@@ -38,6 +38,7 @@ public final class JSONOptions extends ColumnFilterOptions { | |||
private final boolean allowLeadingZeros; | |||
private final boolean allowNonNumericNumbers; | |||
private final boolean allowUnquotedControlChars; | |||
private final byte delim; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the full name delimiter
.
private final byte delim; | |
private final byte delimiter; |
delim = builder.delim; | ||
} | ||
|
||
public byte getDelim() { | ||
return delim; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delim = builder.delim; | |
} | |
public byte getDelim() { | |
return delim; | |
delim = builder.delim; | |
} | |
public byte getDelimiter() { | |
return delimiter; |
private byte delim = '\n'; | ||
|
||
public Builder withDelim(char delimiter) { | ||
if (delimiter > Byte.MAX_VALUE) { | ||
throw new IllegalArgumentException("Only basic ASCII values are supported " + delimiter); | ||
} | ||
delim = (byte)delimiter; | ||
return this; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private byte delim = '\n'; | |
public Builder withDelim(char delimiter) { | |
if (delimiter > Byte.MAX_VALUE) { | |
throw new IllegalArgumentException("Only basic ASCII values are supported " + delimiter); | |
} | |
delim = (byte)delimiter; | |
return this; | |
} | |
private byte delimiter = '\n'; | |
public Builder withDelimiter(char delimiter) { | |
if (delimiter > Byte.MAX_VALUE) { | |
throw new IllegalArgumentException("Only basic ASCII values are supported " + delimiter); | |
} | |
this.delimiter = (byte)delimiter; | |
return this; | |
} |
@@ -258,7 +258,8 @@ private static native long readJSON(int[] numChildren, String[] columnNames, | |||
boolean strictValidation, | |||
boolean allowLeadingZeros, | |||
boolean allowNonNumericNumbers, | |||
boolean allowUnquotedControl) throws CudfException; | |||
boolean allowUnquotedControl, | |||
byte delim) throws CudfException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
byte delim) throws CudfException; | |
byte delimiter) throws CudfException; |
@@ -272,6 +273,7 @@ private static native long readJSONFromDataSource(int[] numChildren, String[] co | |||
boolean allowLeadingZeros, | |||
boolean allowNonNumericNumbers, | |||
boolean allowUnquotedControl, | |||
byte delim, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
byte delim, | |
byte delimiter, |
@@ -284,6 +286,7 @@ private static native long readAndInferJSONFromDataSource(boolean dayFirst, bool | |||
boolean allowLeadingZeros, | |||
boolean allowNonNumericNumbers, | |||
boolean allowUnquotedControl, | |||
byte delim, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
byte delim, | |
byte delimiter, |
@@ -297,7 +300,8 @@ private static native long readAndInferJSON(long address, long length, | |||
boolean strictValidation, | |||
boolean allowLeadingZeros, | |||
boolean allowNonNumericNumbers, | |||
boolean allowUnquotedControl) throws CudfException; | |||
boolean allowUnquotedControl, | |||
byte delim) throws CudfException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
byte delim) throws CudfException; | |
byte delimiter) throws CudfException; |
@@ -1321,7 +1325,8 @@ public static Table readJSON(Schema schema, JSONOptions opts, File path) { | |||
opts.strictValidation(), | |||
opts.leadingZerosAllowed(), | |||
opts.nonNumericNumbersAllowed(), | |||
opts.unquotedControlChars()))) { | |||
opts.unquotedControlChars(), | |||
opts.getDelim()))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opts.getDelim()))) { | |
opts.getDelimiter()))) { |
@@ -1404,7 +1409,8 @@ public static TableWithMeta readJSON(JSONOptions opts, HostMemoryBuffer buffer, | |||
opts.strictValidation(), | |||
opts.leadingZerosAllowed(), | |||
opts.nonNumericNumbersAllowed(), | |||
opts.unquotedControlChars())); | |||
opts.unquotedControlChars(), | |||
opts.getDelim())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opts.getDelim())); | |
opts.getDelimiter())); |
@@ -1426,6 +1432,7 @@ public static TableWithMeta readAndInferJSON(JSONOptions opts, DataSource ds) { | |||
opts.leadingZerosAllowed(), | |||
opts.nonNumericNumbersAllowed(), | |||
opts.unquotedControlChars(), | |||
opts.getDelim(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opts.getDelim(), | |
opts.getDelimiter(), |
@@ -1479,7 +1486,8 @@ public static Table readJSON(Schema schema, JSONOptions opts, HostMemoryBuffer b | |||
opts.strictValidation(), | |||
opts.leadingZerosAllowed(), | |||
opts.nonNumericNumbersAllowed(), | |||
opts.unquotedControlChars()))) { | |||
opts.unquotedControlChars(), | |||
opts.getDelim()))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opts.getDelim()))) { | |
opts.getDelimiter()))) { |
@@ -1518,6 +1526,7 @@ public static Table readJSON(Schema schema, JSONOptions opts, DataSource ds, int | |||
opts.leadingZerosAllowed(), | |||
opts.nonNumericNumbersAllowed(), | |||
opts.unquotedControlChars(), | |||
opts.getDelim(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opts.getDelim(), | |
opts.getDelimiter(), |
Schema schema = Schema.builder().addColumn(DType.STRING, "a").build(); | ||
JSONOptions opts = JSONOptions.builder() | ||
.withLines(true) | ||
.withDelim('\0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.withDelim('\0') | |
.withDelimiter('\0') |
/merge |
…dsai#16867) This just adds in JNI APIs to allow for changing the delimiter when parsing JSON. Authors: - Robert (Bobby) Evans (https://github.com/revans2) Approvers: - Alessandro Bellina (https://github.com/abellina) - Nghia Truong (https://github.com/ttnghia) URL: rapidsai#16867
…) (#16880) This is a back-port of #16867 to 24.10. Authors: - Robert (Bobby) Evans (https://github.com/revans2) Approvers: - Alessandro Bellina (https://github.com/abellina) URL: #16880
Description
This just adds in JNI APIs to allow for changing the delimiter when parsing JSON.
Checklist