-
Notifications
You must be signed in to change notification settings - Fork 3k
Core: Fix the kryo serialization issue in BaseFile. #2343
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
7 commits
Select commit
Hold shift + click to select a range
9788024
Core: Fix the kryo serialization issue in BaseFile.
openinx 712d084
Minior fixes
openinx fe9ce10
Fix the broken unit tests
openinx 6e4d109
Add flink unit tests.
openinx 7278a71
Fix the broken unit tests.
openinx 8bade3a
Revert the unnecessary changes.
openinx 15b3e20
Address comments
openinx 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
124 changes: 124 additions & 0 deletions
124
core/src/main/java/org/apache/iceberg/SerializableMap.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,124 @@ | ||
| /* | ||
| * 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; | ||
|
|
||
| import java.io.Serializable; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import org.apache.iceberg.relocated.com.google.common.collect.Maps; | ||
|
|
||
| public class SerializableMap<K, V> implements Map<K, V>, Serializable { | ||
|
|
||
| private final Map<K, V> copiedMap; | ||
| private Map<K, V> immutableMap; | ||
|
|
||
| SerializableMap() { | ||
| this.copiedMap = Maps.newHashMap(); | ||
| } | ||
|
|
||
| private SerializableMap(Map<K, V> map) { | ||
| this.copiedMap = Maps.newHashMap(); | ||
| this.copiedMap.putAll(map); | ||
| } | ||
|
|
||
| public static <K, V> SerializableMap<K, V> copyOf(Map<K, V> map) { | ||
| return map == null ? null : new SerializableMap<>(map); | ||
| } | ||
|
|
||
| public Map<K, V> immutableMap() { | ||
| if (immutableMap == null) { | ||
| immutableMap = Collections.unmodifiableMap(copiedMap); | ||
| } | ||
|
|
||
| return immutableMap; | ||
| } | ||
|
|
||
| @Override | ||
| public int size() { | ||
| return copiedMap.size(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isEmpty() { | ||
| return copiedMap.isEmpty(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean containsKey(Object key) { | ||
| return copiedMap.containsKey(key); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean containsValue(Object value) { | ||
| return copiedMap.containsValue(value); | ||
| } | ||
|
|
||
| @Override | ||
| public V get(Object key) { | ||
| return copiedMap.get(key); | ||
| } | ||
|
|
||
| @Override | ||
| public V put(K key, V value) { | ||
| return copiedMap.put(key, value); | ||
| } | ||
|
|
||
| @Override | ||
| public V remove(Object key) { | ||
| return copiedMap.remove(key); | ||
| } | ||
|
|
||
| @Override | ||
| public void putAll(Map<? extends K, ? extends V> m) { | ||
| copiedMap.putAll(m); | ||
| } | ||
|
|
||
| @Override | ||
| public void clear() { | ||
| copiedMap.clear(); | ||
| } | ||
|
|
||
| @Override | ||
| public Set<K> keySet() { | ||
| return copiedMap.keySet(); | ||
| } | ||
|
|
||
| @Override | ||
| public Collection<V> values() { | ||
| return copiedMap.values(); | ||
| } | ||
|
|
||
| @Override | ||
| public Set<Entry<K, V>> entrySet() { | ||
| return copiedMap.entrySet(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| return copiedMap.equals(o); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return copiedMap.hashCode(); | ||
| } | ||
| } |
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.
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.
Later, we should check whether we need two wrappers, but it isn't a blocker here.
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.
We do need
SerializableByteBufferMapfor now as byte buffers may not be serializable.