richardstartin commented on code in PR #8499: URL: https://github.com/apache/pinot/pull/8499#discussion_r848057124
########## pinot-core/src/main/java/org/apache/pinot/core/common/datatable/DataTableImplV3.java: ########## @@ -350,32 +340,29 @@ private byte[] serializeMetadata() * This is to make V3 implementation keep the consumers of Map<String, String> getMetadata() API in the code happy * by internally converting it. */ - private Map<String, String> deserializeMetadata(byte[] bytes) + private Map<String, String> deserializeMetadata(ByteBuffer buffer) throws IOException { - try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); - DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream)) { - int numEntries = dataInputStream.readInt(); - Map<String, String> metadata = new HashMap<>(); - for (int i = 0; i < numEntries; i++) { - int keyId = dataInputStream.readInt(); - MetadataKey key = MetadataKey.getByOrdinal(keyId); - // Ignore unknown keys. - if (key == null) { - continue; - } - if (key.getValueType() == MetadataValueType.INT) { - String value = String.valueOf(DataTableUtils.decodeInt(dataInputStream)); - metadata.put(key.getName(), value); - } else if (key.getValueType() == MetadataValueType.LONG) { - String value = String.valueOf(DataTableUtils.decodeLong(dataInputStream)); - metadata.put(key.getName(), value); - } else { - String value = String.valueOf(DataTableUtils.decodeString(dataInputStream)); - metadata.put(key.getName(), value); - } + int numEntries = buffer.getInt(); + Map<String, String> metadata = new HashMap<>(); + for (int i = 0; i < numEntries; i++) { + int keyId = buffer.getInt(); + MetadataKey key = MetadataKey.getByOrdinal(keyId); + // Ignore unknown keys. + if (key == null) { + continue; + } + if (key.getValueType() == MetadataValueType.INT) { + String value = "" + buffer.getInt(); Review Comment: it's both faster and shorter -- 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. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org