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

Make AbstractFastaSequenceFile serializable by Kryo for Spark. #1408

Merged
merged 1 commit into from
Aug 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@

import java.io.File;
import java.io.InputStream;
import java.io.Serializable;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.function.Supplier;

/**
* Provide core sequence dictionary functionality required by all fasta file readers.
Expand All @@ -62,7 +64,8 @@ abstract class AbstractFastaSequenceFile implements ReferenceSequenceFile {
AbstractFastaSequenceFile(final Path path) {
this.path = path;
this.source = path == null ? "unknown" : path.toAbsolutePath().toString();
this.dictionary = new Lazy<>(() -> findAndLoadSequenceDictionary(path));
// ensure lambda is serializable (by Kryo, when used with Spark)
this.dictionary = new Lazy<>((Supplier<SAMSequenceDictionary> & Serializable) (() -> findAndLoadSequenceDictionary(path)));
}

/**
Expand All @@ -74,7 +77,8 @@ abstract class AbstractFastaSequenceFile implements ReferenceSequenceFile {
AbstractFastaSequenceFile(final Path path, final String source, final SAMSequenceDictionary sequenceDictionary) {
this.path = path;
this.source = source;
this.dictionary = new Lazy<>(() -> sequenceDictionary);
// ensure lambda is serializable (by Kryo, when used with Spark)
this.dictionary = new Lazy<>((Supplier<SAMSequenceDictionary> & Serializable) (() -> sequenceDictionary));
}

/** Attempts to find and load the sequence dictionary if present. */
Expand Down