sv2000 commented on a change in pull request #2956: GOBBLIN-1116: Avoid registering schema with schema registry during Me… URL: https://github.com/apache/incubator-gobblin/pull/2956#discussion_r410377834
########## File path: gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/reporter/util/MetricReportUtils.java ########## @@ -114,4 +115,46 @@ public synchronized static MetricReport deserializeReportFromAvroSerialization(M closer.close(); } } + + /** + * Parses a {@link org.apache.gobblin.metrics.MetricReport} from a byte array Avro serialization. + * @param reuse MetricReport to reuse. + * @param bytes Input bytes. + * @param schemaId Expected schemaId. + * @param schemaIdLengthBytes length of schema id in bytes. + * @return MetricReport. + * @throws java.io.IOException + */ + public synchronized static MetricReport deserializeReportFromAvroSerialization(MetricReport reuse, byte[] bytes, String schemaId, int schemaIdLengthBytes) + throws IOException { + if (!READER.isPresent()) { + READER = Optional.of(new SpecificDatumReader<>(MetricReport.class)); + } + + Closer closer = Closer.create(); + + try { + DataInputStream inputStream = closer.register(new DataInputStream(new ByteArrayInputStream(bytes))); Review comment: Thanks! Refactored the code to avoid duplication. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services