@Test public void testConvertsMetadataNoOutput() throws DataConversionException { DummyConverter dummyConverter = new DummyConverter(0); MetadataConverterWrapper<String, String, String, String> wrapper = new MetadataConverterWrapper<>(dummyConverter); Iterable<RecordWithMetadata<String>> records = wrapper.convertRecord("foo", new RecordWithMetadata<String>("bar", buildMetadata(1)), new WorkUnitState()); Assert.assertFalse(records.iterator().hasNext()); }
@Override public Iterable<RecordWithMetadata<DO>> convertRecord(SO outputSchema, Object inputRecord, WorkUnitState workUnit) throws DataConversionException { final Metadata metadata = getMetadataFromRecord(inputRecord); final DI innerRecord = getRecordFromRecord(inputRecord); Iterable<DO> outputRecords = innerConverter.convertRecord(outputSchema, innerRecord, workUnit); return Iterables.transform(outputRecords, new Function<DO, RecordWithMetadata<DO>>() { @Nullable @Override public RecordWithMetadata<DO> apply(@Nullable DO input) { return new RecordWithMetadata<>(input, metadata); } }); }
MetadataConverterWrapper extends Converter<SI, SO, Object, RecordWithMetadata<DO>> { @Override public Iterable<RecordWithMetadata<DO>> convertRecord(SO outputSchema, Object inputRecord, WorkUnitState workUnit) throws DataConversionException { final Metadata metadata = getMetadataFromRecord(inputRecord); final DI innerRecord = getRecordFromRecord(inputRecord); Iterable<DO> outputRecords = innerConverter.convertRecord(outputSchema, innerRecord, workUnit); return Iterables.transform(outputRecords, new Function<DO, RecordWithMetadata<DO>>() { @Nullable @Override public RecordWithMetadata<DO> apply(@Nullable DO input) { return new RecordWithMetadata<>(input, metadata); } }); } }
MetadataConverterWrapper extends Converter<SI, SO, Object, RecordWithMetadata<DO>> { @Override public Iterable<RecordWithMetadata<DO>> convertRecord(SO outputSchema, Object inputRecord, WorkUnitState workUnit) throws DataConversionException { final Metadata metadata = getMetadataFromRecord(inputRecord); final DI innerRecord = getRecordFromRecord(inputRecord); Iterable<DO> outputRecords = innerConverter.convertRecord(outputSchema, innerRecord, workUnit); return Iterables.transform(outputRecords, new Function<DO, RecordWithMetadata<DO>>() { @Nullable @Override public RecordWithMetadata<DO> apply(@Nullable DO input) { return new RecordWithMetadata<>(input, metadata); } }); } MetadataConverterWrapper(Converter<SI, SO, DI, DO> innerConverter); }
MetadataConverterWrapper extends Converter<SI, SO, Object, RecordWithMetadata<DO>> { @Override public Iterable<RecordWithMetadata<DO>> convertRecord(SO outputSchema, Object inputRecord, WorkUnitState workUnit) throws DataConversionException { final Metadata metadata = getMetadataFromRecord(inputRecord); final DI innerRecord = getRecordFromRecord(inputRecord); Iterable<DO> outputRecords = innerConverter.convertRecord(outputSchema, innerRecord, workUnit); return Iterables.transform(outputRecords, new Function<DO, RecordWithMetadata<DO>>() { @Nullable @Override public RecordWithMetadata<DO> apply(@Nullable DO input) { return new RecordWithMetadata<>(input, metadata); } }); } MetadataConverterWrapper(Converter<SI, SO, DI, DO> innerConverter); @Override Converter<SI, SO, Object, RecordWithMetadata<DO>> init(WorkUnitState workUnit); @Override void close(); @Override SO convertSchema(SI inputSchema, WorkUnitState workUnit); @Override Iterable<RecordWithMetadata<DO>> convertRecord(SO outputSchema, Object inputRecord, WorkUnitState workUnit); @Override State getFinalState(); }
MetadataConverterWrapper extends Converter<SI, SO, Object, RecordWithMetadata<DO>> { @Override public Iterable<RecordWithMetadata<DO>> convertRecord(SO outputSchema, Object inputRecord, WorkUnitState workUnit) throws DataConversionException { final Metadata metadata = getMetadataFromRecord(inputRecord); final DI innerRecord = getRecordFromRecord(inputRecord); Iterable<DO> outputRecords = innerConverter.convertRecord(outputSchema, innerRecord, workUnit); return Iterables.transform(outputRecords, new Function<DO, RecordWithMetadata<DO>>() { @Nullable @Override public RecordWithMetadata<DO> apply(@Nullable DO input) { return new RecordWithMetadata<>(input, metadata); } }); } MetadataConverterWrapper(Converter<SI, SO, DI, DO> innerConverter); @Override Converter<SI, SO, Object, RecordWithMetadata<DO>> init(WorkUnitState workUnit); @Override void close(); @Override SO convertSchema(SI inputSchema, WorkUnitState workUnit); @Override Iterable<RecordWithMetadata<DO>> convertRecord(SO outputSchema, Object inputRecord, WorkUnitState workUnit); @Override State getFinalState();  }