Skip to content

Spark: Remove ImmutableMap from SparkPartition (spark 3.2) - #3597

Closed
dubeme wants to merge 2 commits into
apache:masterfrom
dubeme:switch_to_core_java_map
Closed

dubeme wants to merge 2 commits into
apache:masterfrom
dubeme:switch_to_core_java_map

Conversation

@dubeme

@dubeme dubeme commented Nov 23, 2021

Copy link
Copy Markdown
Contributor

Issue #3586 shows situation where Kyro is unable to serialize the SparkPartition object (@rdblue points it out from the stack trace). This commit replaces the ImmutableMap with HashMap

I tested this manually, by creating a .jar, then running a local spark application. I unfortunately don't have the deep understanding to add the Unit tests for the add_files action.

Issue apache#3586 shows situation where Kyro is unable to serialize the SparkPartition object (@rdblue points it out from the stack trace). This commit replaces the ImmutableMap with HashMap

public SparkPartition(Map<String, String> values, String uri, String format) {
this.values = ImmutableMap.copyOf(values);
this.values = new HashMap<>(values);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you use Maps.newHashMap? We prefer the Guava factory methods to individual implementations.

Also, can you add a test for this that does a round-trip serialization using Kryo?

@rdblue

rdblue commented Nov 24, 2021

Copy link
Copy Markdown
Contributor

Thanks for working on this, @dubeme!

@kbendick kbendick left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the contribution @dubeme!

For the serialization test, it would probably be sufficient to simply instantiate a SparkPartition and then ensure it can be round tripped (same object before and after) via Kryo serde.

There's a helper function for this, org.apache.iceberg.KryoHelpers.roundTripSerialize, which you can see in this similar test that can be used for checking the before and after:

public void testHadoopFileIOKryoSerialization() throws IOException {
FileIO io = table.io();
Configuration expectedConf = ((HadoopFileIO) io).conf();
Table serializableTable = SerializableTable.copyOf(table);
FileIO deserializedIO = KryoHelpers.roundTripSerialize(serializableTable.io());
Configuration actualConf = ((HadoopFileIO) deserializedIO).conf();
Assert.assertEquals("Conf pairs must match", toMap(expectedConf), toMap(actualConf));
Assert.assertEquals("Conf values must be present", "v1", actualConf.get("k1"));
Assert.assertEquals("Conf values must be present", "v2", actualConf.get("k2"));
}

@kbendick kbendick added this to the Iceberg 0.13.0 Release milestone Nov 30, 2021
@jackye1995

Copy link
Copy Markdown
Contributor

Hi @dubeme, we are approaching the release of 0.13, and this is a critical bug that needs to be merged before the branch cut. Would you have time to update this PR? If not I can put up the same fix and mark you as coauthor.

@kbendick

kbendick commented Dec 3, 2021

Copy link
Copy Markdown
Contributor

Hi @dubeme, we are approaching the release of 0.13, and this is a critical bug that needs to be merged before the branch cut. Would you have time to update this PR? If not I can put up the same fix and mark you as coauthor.

Agreed. I’d say we give them a few more days and then we mark them as co-author. I’d be happy to do it as well if you’re busy. Let me know!

@rdblue

rdblue commented Dec 5, 2021

Copy link
Copy Markdown
Contributor

Thanks, @dubeme! This was fixed by #3667.

@rdblue rdblue closed this Dec 5, 2021
@dubeme
dubeme deleted the switch_to_core_java_map branch December 6, 2021 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants