-
Notifications
You must be signed in to change notification settings - Fork 2.7k
InputFormat support for Iceberg #843
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
15de263
InputFormat support for Iceberg
rdsr 7a287b1
Address review comments
rdsr a38b8e3
Address review comments [Take 2]
rdsr 3567b02
c
rdsr 25bb2cd
[Address comments - take 3] Using Hadoop catalog to test custom catalog
rdsr 4068021
Better name for filter residuals option
rdsr a1c8e6e
Added more test cases
rdsr e327bd7
Address review comments. Added more test cases
rdsr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,6 @@ spark/tmp/ | |
.project | ||
.settings | ||
bin/ | ||
|
||
# Hive/metastore files | ||
metastore_db/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
mr/src/main/java/org/apache/iceberg/mr/SerializationUtil.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.iceberg.mr; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.ObjectInputStream; | ||
import java.io.ObjectOutputStream; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Base64; | ||
import org.apache.iceberg.exceptions.RuntimeIOException; | ||
|
||
public class SerializationUtil { | ||
|
||
private SerializationUtil() { | ||
} | ||
|
||
public static byte[] serializeToBytes(Object obj) { | ||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
ObjectOutputStream oos = new ObjectOutputStream(baos)) { | ||
oos.writeObject(obj); | ||
return baos.toByteArray(); | ||
} catch (IOException e) { | ||
throw new RuntimeIOException("Failed to serialize object", e); | ||
} | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static <T> T deserializeFromBytes(byte[] bytes) { | ||
if (bytes == null) { | ||
return null; | ||
} | ||
|
||
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes); | ||
ObjectInputStream ois = new ObjectInputStream(bais)) { | ||
return (T) ois.readObject(); | ||
} catch (IOException e) { | ||
throw new RuntimeIOException("Failed to deserialize object", e); | ||
} catch (ClassNotFoundException e) { | ||
throw new RuntimeException("Could not read object ", e); | ||
} | ||
} | ||
|
||
public static String serializeToBase64(Object obj) { | ||
byte[] bytes = serializeToBytes(obj); | ||
return new String(Base64.getMimeEncoder().encode(bytes), StandardCharsets.UTF_8); | ||
} | ||
|
||
public static <T> T deserializeFromBase64(String base64) { | ||
if (base64 == null) { | ||
return null; | ||
} | ||
byte[] bytes = Base64.getMimeDecoder().decode(base64.getBytes(StandardCharsets.UTF_8)); | ||
return deserializeFromBytes(bytes); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.