Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding other args
  • Loading branch information
xstevens committed Apr 26, 2012
1 parent 797c57d commit 576ea79
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/java/com/twitter/elephantbird/pig/load/SequenceFileLoader.java
Expand Up @@ -82,6 +82,7 @@ public class SequenceFileLoader<K extends Writable, V extends Writable> extends
private static final String READ_VALUE_PARAM = "_readValue";
protected final CommandLine keyArguments;
protected final CommandLine valueArguments;
protected final CommandLine otherArguments;
protected final WritableConverter<K> keyConverter;
protected final WritableConverter<V> valueConverter;
private final DataByteArray keyDataByteArray = new DataByteArray();
Expand Down Expand Up @@ -135,15 +136,17 @@ private enum SequenceFileLoaderCounters { EOFError };
*
* @param keyArgs
* @param valueArgs
* @param otherArgs
* @throws ParseException
* @throws IOException
*/
public SequenceFileLoader(String keyArgs, String valueArgs) throws ParseException, IOException {
public SequenceFileLoader(String keyArgs, String valueArgs, String otherArgs) throws ParseException, IOException {
// parse key, value arguments
Options options = getOptions();
keyArguments = parseArguments(options, keyArgs);
valueArguments = parseArguments(options, valueArgs);

otherArguments = parseArguments(options, otherArgs);

// construct key, value converters
keyConverter = getWritableConverter(keyArguments);
valueConverter = getWritableConverter(valueArguments);
Expand All @@ -162,6 +165,16 @@ public SequenceFileLoader() throws ParseException, IOException {
this("", "");
}

/**
* Constructor without other args (backwards compatible).
*
* @throws ParseException
* @throws IOException
*/
public SequenceFileLoader(String keyArgs, String valueArgs) throws ParseException, IOException {
this(keyArgs, valueArgs, "");
}

/**
* @return Options instance containing valid key/value options.
*/
Expand Down Expand Up @@ -452,7 +465,7 @@ public Tuple getNext() throws IOException {
}
return tupleFactory.newTupleNoCopy(tuple);
} catch (EOFException e) {
if (valueArguments.hasOption(SKIP_EOF_ERRORS_PARAM)) {
if (otherArguments.hasOption(SKIP_EOF_ERRORS_PARAM)) {
// prefer to keep reading rather than causing the job to fail when it hits a file still
// being written
LOG.warn("EOFException encountered while reading input", e);
Expand Down

0 comments on commit 576ea79

Please sign in to comment.