buchireddy commented on a change in pull request #4432: #4401 Reuse a 
ThreadLocal byte[] when reading String elements from the variable length value 
reader.
URL: https://github.com/apache/incubator-pinot/pull/4432#discussion_r303624630
 
 

 ##########
 File path: 
pinot-core/src/main/java/org/apache/pinot/core/io/util/VarLengthBytesValueReaderWriter.java
 ##########
 @@ -204,7 +223,26 @@ public double getDouble(int index) {
 
   @Override
   public String getUnpaddedString(int index, int numBytesPerValue, byte 
paddingByte, byte[] buffer) {
-    return StringUtil.decodeUtf8(getBytes(index, numBytesPerValue, buffer));
+    // Read the offset of the byte array first and then read the actual byte 
array.
+    int offset = _dataBuffer.getInt(_dataSectionStartOffSet + Integer.BYTES * 
index);
+
+    // To get the length of the byte array, we use the next byte array offset.
+    int length = _dataBuffer.getInt(_dataSectionStartOffSet + Integer.BYTES * 
(index + 1)) - offset;
+
+    byte[] b;
+    if (buffer != null && buffer.length >= length) {
+      b = buffer;
+    } else {
+      // Check if the current instance of ThreadLocal buffer is big enough. If 
not, resize it to double the size.
+      b = _reusableBytes.get();
+      if (b.length < length) {
+        b = new byte[nextPowerOf2(length)];
 
 Review comment:
   @mcvsubbu @mayankshriv Actually, good point. Jackie has merged the PR but 
this can be addressed in another PR too.
   
   @mcvsubbu pointer to the config you're talking about please?

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to