saurabhd336 commented on code in PR #11674:
URL: https://github.com/apache/pinot/pull/11674#discussion_r1340320116


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/writer/impl/VarByteChunkForwardIndexWriterV4.java:
##########
@@ -142,6 +144,51 @@ public void putBytes(byte[] bytes) {
     _nextDocId++;
   }
 
+  @Override
+  public void putStringMV(String[] values) {
+    // num values + length of each value
+    int headerSize = Integer.BYTES + Integer.BYTES * values.length;
+    int size = headerSize;
+    for (String value : values) {
+      size += value.getBytes(UTF_8).length;
+    }
+
+    // Format : 
[numValues][length1][length2]...[lengthN][value1][value2]...[valueN]
+    byte[] serializedBytes = new byte[size];
+    ByteBuffer byteBuffer = ByteBuffer.wrap(serializedBytes);
+    byteBuffer.putInt(values.length);
+    byteBuffer.position(headerSize);
+    for (int i = 0; i < values.length; i++) {
+      byte[] utf8 = values[i].getBytes(UTF_8);
+      byteBuffer.putInt((i + 1) * Integer.BYTES, utf8.length);
+      byteBuffer.put(utf8);
+    }
+
+    putBytes(byteBuffer.array());
+  }
+
+  @Override
+  public void putBytesMV(byte[][] values) {
+    // num values + length of each value
+    int headerSize = Integer.BYTES + Integer.BYTES * values.length;
+    int size = headerSize;
+    for (byte[] value : values) {
+      size += value.length;
+    }
+
+    // Format : 
[numValues][length1][length2]...[lengthN][bytes1][bytes2]...[bytesN]
+    byte[] serializedBytes = new byte[size];
+    ByteBuffer byteBuffer = ByteBuffer.wrap(serializedBytes);
+    byteBuffer.putInt(values.length);
+    byteBuffer.position(headerSize);
+    for (int i = 0; i < values.length; i++) {
+      byteBuffer.putInt((i + 1) * Integer.BYTES, values[i].length);
+      byteBuffer.put(values[i]);
+    }
+
+    putBytes(byteBuffer.array());

Review Comment:
   Ack



-- 
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]


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

Reply via email to