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

Proposal for #267 - configurable option to disable lzo index lookup #431

Closed
wants to merge 1 commit into from
Closed
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 @@ -6,6 +6,7 @@
import java.util.List;

import com.twitter.elephantbird.util.HadoopCompat;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
Expand All @@ -29,6 +30,8 @@
public abstract class LzoInputFormat<K, V> extends FileInputFormat<K, V> {
private static final Logger LOG = LoggerFactory.getLogger(LzoInputFormat.class);

public static final String READ_INDEXES_KEY = "elephantbird.index.read";

private final PathFilter hiddenPathFilter = new PathFilter() {
// avoid hidden files and directories.
@Override
Expand Down Expand Up @@ -112,6 +115,11 @@ protected boolean isSplitable(JobContext context, Path filename) {
public List<InputSplit> getSplits(JobContext job) throws IOException {
List<InputSplit> defaultSplits = super.getSplits(job);

Configuration config = HadoopCompat.getConfiguration(job);

boolean readIndexes = config.getBoolean(READ_INDEXES_KEY, true);
if (!readIndexes) return defaultSplits;

// Find new starts and ends of the file splits that align with the lzo blocks.
List<InputSplit> result = new ArrayList<InputSplit>();

Expand All @@ -127,7 +135,7 @@ public List<InputSplit> getSplits(JobContext job) throws IOException {
if ( file.equals(prevFile) ) {
index = prevIndex;
} else {
index = LzoIndex.readIndex(file.getFileSystem(HadoopCompat.getConfiguration(job)), file);
index = LzoIndex.readIndex(file.getFileSystem(config), file);
prevFile = file;
prevIndex = index;
}
Expand Down