Skip to content

Commit

Permalink
Cover both reader and writer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruslan Altynnikov committed Aug 26, 2023
1 parent 59af158 commit 4ce709b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ public int run(InputStream stdin, PrintStream out, PrintStream err, List<String>
return 0;
}

private static Schema getSchema(String readerSchemaStr, String readerSchemaFile) throws IOException {
static Schema getSchema(String schemaStr, String schemaFile) throws IOException {
Schema readerSchema = null;
if (readerSchemaFile != null) {
LOG.info("Reading schema from file'{}'", readerSchemaFile);
readerSchema = Util.parseSchemaFromFS(readerSchemaFile);
} else if (readerSchemaStr != null) {
LOG.info("Reading schema from string '{}'", readerSchemaStr);
readerSchema = new Schema.Parser().parse(readerSchemaStr);
if (schemaFile != null) {
LOG.info("Reading schema from file '{}'", schemaFile);
readerSchema = Util.parseSchemaFromFS(schemaFile);
} else if (schemaStr != null) {
LOG.info("Reading schema from string '{}'", schemaStr);
readerSchema = new Schema.Parser().parse(schemaStr);
}
return readerSchema;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public int run(InputStream stdin, PrintStream out, PrintStream err, List<String>
p.printHelpOn(err);
return 1;
}
Schema schema = (schemafile != null) ? Util.parseSchemaFromFS(schemafile) : new Schema.Parser().parse(schemastr);
Schema schema = DataFileReadTool.getSchema(schemastr, schemafile);

DatumReader<Object> reader = new GenericDatumReader<>(schema);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void repairAfterCorruptRecord() throws Exception {
}

private void checkFileContains(File repairedFile, String... lines) throws IOException {
DataFileReader r = new DataFileReader<>(repairedFile, new GenericDatumReader<>(SCHEMA));
DataFileReader<Object> r = new DataFileReader<>(repairedFile, new GenericDatumReader<>(SCHEMA));
for (String line : lines) {
assertEquals(line, r.next().toString());
}
Expand Down

0 comments on commit 4ce709b

Please sign in to comment.