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

API: Add generic FileIO JSON serialization #5178

Merged
merged 3 commits into from
Jul 3, 2022

Conversation

rdblue
Copy link
Contributor

@rdblue rdblue commented Jul 1, 2022

This adds a JSON parser to serialize FileIO instances to and from JSON. The format is an object with an io-impl and configuration properties. Deserialization uses CatalogUtil to re-create an instance from an environment Hadoop Configuration (optional), the IO impl class, and the configuration used to create the original FileIO.

public static String generate(ToJson toJson, boolean pretty) {
try {
StringWriter writer = new StringWriter();
JsonGenerator generator = JsonUtil.factory().createGenerator(writer);
Copy link
Contributor

Choose a reason for hiding this comment

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

The JsonGenerator is closable, so we should probably be using TWR or closing with finally.

@danielcweeks danielcweeks merged commit 0420cde into apache:master Jul 3, 2022
namrathamyske pushed a commit to namrathamyske/iceberg that referenced this pull request Jul 10, 2022
* API: Add generic FileIO JSON serialization.

* Fix checkstyle.

* Close StringWriter and JsonGenerator.
namrathamyske pushed a commit to namrathamyske/iceberg that referenced this pull request Jul 10, 2022
* API: Add generic FileIO JSON serialization.

* Fix checkstyle.

* Close StringWriter and JsonGenerator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants