vinothchandar commented on a change in pull request #3128:
URL: https://github.com/apache/hudi/pull/3128#discussion_r659870711
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/util/collection/DiskBasedMap.java
##########
@@ -395,4 +417,48 @@ public int compareTo(ValueMetadata o) {
return Long.compare(this.offsetOfValue, o.offsetOfValue);
}
}
+
+ private static class DiskCompressionInstance implements Serializable {
+ public static final int DISK_COMPRESSION_INITIAL_BUFFER_SIZE = 1048576;
+
+ // Caching ByteArrayOutputStreams to avoid recreating it for every
operation
+ private final ByteArrayOutputStream compressBaos;
+ private final ByteArrayOutputStream decompressBaos;
+ private final byte[] decompressBuffer;
+
+ DiskCompressionInstance() {
+ compressBaos = new
ByteArrayOutputStream(DISK_COMPRESSION_INITIAL_BUFFER_SIZE);
+ decompressBaos = new
ByteArrayOutputStream(DISK_COMPRESSION_INITIAL_BUFFER_SIZE);
+ decompressBuffer = new byte[8192];
Review comment:
pull this into a static final?
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/util/collection/DiskBasedMap.java
##########
@@ -395,4 +417,48 @@ public int compareTo(ValueMetadata o) {
return Long.compare(this.offsetOfValue, o.offsetOfValue);
}
}
+
+ private static class DiskCompressionInstance implements Serializable {
Review comment:
rename: `Compressor` or `CompressionHandler`
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/util/collection/DiskBasedMap.java
##########
@@ -395,4 +417,48 @@ public int compareTo(ValueMetadata o) {
return Long.compare(this.offsetOfValue, o.offsetOfValue);
}
}
+
+ private static class DiskCompressionInstance implements Serializable {
+ public static final int DISK_COMPRESSION_INITIAL_BUFFER_SIZE = 1048576;
+
+ // Caching ByteArrayOutputStreams to avoid recreating it for every
operation
+ private final ByteArrayOutputStream compressBaos;
+ private final ByteArrayOutputStream decompressBaos;
+ private final byte[] decompressBuffer;
+
+ DiskCompressionInstance() {
+ compressBaos = new
ByteArrayOutputStream(DISK_COMPRESSION_INITIAL_BUFFER_SIZE);
+ decompressBaos = new
ByteArrayOutputStream(DISK_COMPRESSION_INITIAL_BUFFER_SIZE);
+ decompressBuffer = new byte[8192];
Review comment:
what if there is a value beyond 8192? better to use something that is
dynamic?
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/util/collection/DiskBasedMap.java
##########
@@ -395,4 +417,48 @@ public int compareTo(ValueMetadata o) {
return Long.compare(this.offsetOfValue, o.offsetOfValue);
}
}
+
+ private static class DiskCompressionInstance implements Serializable {
+ public static final int DISK_COMPRESSION_INITIAL_BUFFER_SIZE = 1048576;
+
+ // Caching ByteArrayOutputStreams to avoid recreating it for every
operation
+ private final ByteArrayOutputStream compressBaos;
+ private final ByteArrayOutputStream decompressBaos;
+ private final byte[] decompressBuffer;
+
+ DiskCompressionInstance() {
+ compressBaos = new
ByteArrayOutputStream(DISK_COMPRESSION_INITIAL_BUFFER_SIZE);
+ decompressBaos = new
ByteArrayOutputStream(DISK_COMPRESSION_INITIAL_BUFFER_SIZE);
+ decompressBuffer = new byte[8192];
+ }
+
+ public byte[] compressBytes(final byte [] value) throws IOException {
+ compressBaos.reset();
Review comment:
you may have to handle some resizing logic here w.r.t the 8MB limit
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]