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

Check LZO index file existence when check splitability of LZO files #485

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions hive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
<groupId>com.twitter.elephantbird</groupId>
<artifactId>elephant-bird-core</artifactId>
</dependency>
<dependency>
<groupId>com.hadoop.gplcompression</groupId>
Copy link
Contributor

Choose a reason for hiding this comment

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

folks, this is not an apache license compatible package.
EB needs to clean up these dependencies, adding more of them makes the problem worse.

Making this class explicitly aware of one specific type of file extension seems pretty brute-force. This whole thing is a wrapper -- is there a way to delegate to underlying machinery to determine if the wrapped InputFormat is splittable?

<artifactId>hadoop-lzo</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.twitter.elephantbird.mapreduce.input.MultiInputFormat;
import com.twitter.elephantbird.mapreduce.io.BinaryWritable;
import com.twitter.elephantbird.util.TypeRef;

import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.exec.Utilities;
import org.apache.hadoop.hive.ql.plan.PartitionDesc;
Expand All @@ -23,6 +26,9 @@
import java.util.Map;
import java.util.Properties;

import static com.hadoop.compression.lzo.LzoIndex.LZO_INDEX_SUFFIX;
import static com.hadoop.compression.lzo.LzoInputFormatCommon.isLzoFile;

/**
* Hive-specific wrapper around {@link MultiInputFormat}. This is necessary to set the
* {@link TypeRef} because Hive does not support InputFormat constructor arguments.
Expand Down Expand Up @@ -88,4 +94,18 @@ public RecordReader<LongWritable, BinaryWritable> getRecordReader(InputSplit spl
initialize((FileSplit) split, job);
return super.getRecordReader(split, job, reporter);
}

@Override
public boolean isSplitable(FileSystem fs, Path filename) {
if (isLzoFile(filename.toString())) {
Path indexFile = filename.suffix(LZO_INDEX_SUFFIX);
try {
return fs.exists(indexFile);
}
catch (IOException e) {
return false;
}
}
return super.isSplitable(fs, filename);
}
}