Skip to content

Commit

Permalink
Modified the Converter interfaces to remove the IOException
Browse files Browse the repository at this point in the history
  • Loading branch information
Plaban Dash committed Mar 24, 2015
1 parent 6f09a99 commit ae7912d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
3 changes: 1 addition & 2 deletions gobblin-api/src/main/java/gobblin/converter/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public abstract SO convertSchema(SI inputSchema, WorkUnitState workUnit)
* @param workUnit a {@link WorkUnitState} object carrying configuration properties
* @return converted data record
* @throws DataConversionException if it fails to convert the input data record
* @throws IOException
*/
public abstract Iterable<DO> convertRecord(SO outputSchema, DI inputRecord, WorkUnitState workUnit)
throws DataConversionException, IOException;
throws DataConversionException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public class CsvToJsonConverter extends Converter<String, JsonArray, String, Jso
* @return a JsonArray representation of the schema
*/
@Override
public JsonArray convertSchema(String inputSchema, WorkUnitState workUnit)
throws SchemaConversionException {
public JsonArray convertSchema(String inputSchema, WorkUnitState workUnit) throws SchemaConversionException {
JsonParser jsonParser = new JsonParser();
JsonElement jsonSchema = jsonParser.parse(inputSchema);
return jsonSchema.getAsJsonArray();
Expand All @@ -53,12 +52,16 @@ public JsonArray convertSchema(String inputSchema, WorkUnitState workUnit)
*/
@Override
public Iterable<JsonObject> convertRecord(JsonArray outputSchema, String inputRecord, WorkUnitState workUnit)
throws DataConversionException, IOException {
throws DataConversionException {
InputStreamCSVReader reader =
new InputStreamCSVReader(inputRecord, workUnit.getProp(ConfigurationKeys.CONVERTER_CSV_TO_JSON_DELIMITER)
.trim().charAt(0));
List<String> recordSplit = Lists.newArrayList(reader.splitRecord());

List<String> recordSplit;
try {
recordSplit = Lists.newArrayList(reader.splitRecord());
} catch (IOException e) {
throw new DataConversionException(e);
}
JsonObject outputRecord = new JsonObject();

for (int i = 0; i < outputSchema.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ public Iterator<Object> iterator() {
return new MultiConverterIterator(inputRecord, workUnit);
} catch (DataConversionException dce) {
throw new RuntimeException(dce);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}
};
Expand All @@ -90,8 +88,7 @@ private class MultiConverterIterator implements Iterator<Object> {
private final Deque<Iterator<Object>> converterIteratorStack = Lists.newLinkedList();
private Iterator<Object> outputIterator;

public MultiConverterIterator(Object inputRecord, WorkUnitState workUnitState) throws DataConversionException,
IOException {
public MultiConverterIterator(Object inputRecord, WorkUnitState workUnitState) throws DataConversionException {
this.workUnitState = workUnitState;

// Construct the initial stack of converter iterators
Expand Down Expand Up @@ -146,8 +143,6 @@ public boolean hasNext() {
}
} catch (DataConversionException dce) {
throw new RuntimeException(dce);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}

Expand Down

0 comments on commit ae7912d

Please sign in to comment.