adarshsanjeev commented on code in PR #15917:
URL: https://github.com/apache/druid/pull/15917#discussion_r1494178033


##########
processing/src/main/java/org/apache/druid/frame/read/columnar/StringFrameColumnReader.java:
##########
@@ -231,7 +201,9 @@ private static long getStartOfStringDataSection(
     final int totalNumValues;
 
     if (multiValue) {
-      totalNumValues = 
adjustCumulativeRowLength(getCumulativeRowLength(memory, numRows - 1));
+      totalNumValues = FrameColumnReaderUtils.adjustCumulativeRowLength(

Review Comment:
   Should this be changed to `getAdjustedCumulativeRowLength` instead?



##########
processing/src/main/java/org/apache/druid/frame/read/columnar/StringFrameColumnReader.java:
##########
@@ -489,15 +461,24 @@ private String getString(final int index)
     private Object getRowAsObject(final int physicalRow, final boolean decode)
     {
       if (multiValue) {
-        final int cumulativeRowLength = getCumulativeRowLength(memory, 
physicalRow);
+        final int cumulativeRowLength = 
FrameColumnReaderUtils.getCumulativeRowLength(
+            memory,
+            getStartOfCumulativeLengthSection(),
+            physicalRow
+        );
         final int rowLength;
 
-        if (isNullRow(cumulativeRowLength)) {
+        if (FrameColumnReaderUtils.isNullRow(cumulativeRowLength)) {
           return null;
         } else if (physicalRow == 0) {
           rowLength = cumulativeRowLength;
         } else {
-          rowLength = cumulativeRowLength - 
adjustCumulativeRowLength(getCumulativeRowLength(memory, physicalRow - 1));
+          rowLength = cumulativeRowLength - 
FrameColumnReaderUtils.adjustCumulativeRowLength(

Review Comment:
   Should this also be getAdjustedRowLength since the function exists?



##########
processing/src/main/java/org/apache/druid/frame/read/columnar/FloatArrayFrameColumnReader.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.frame.read.columnar;
+
+import com.google.common.math.LongMath;
+import org.apache.datasketches.memory.Memory;
+import org.apache.druid.frame.Frame;
+import org.apache.druid.frame.write.columnar.FrameColumnWriters;
+import org.apache.druid.segment.column.ColumnType;
+
+/**
+ * Reaaers for columns written by {@link 
org.apache.druid.frame.write.columnar.LongArrayFrameColumnWriter}

Review Comment:
   nit: spelling



##########
processing/src/main/java/org/apache/druid/frame/write/columnar/NumericArrayFrameColumnWriter.java:
##########
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.frame.write.columnar;
+
+import org.apache.datasketches.memory.WritableMemory;
+import org.apache.druid.error.DruidException;
+import org.apache.druid.frame.allocation.AppendableMemory;
+import org.apache.druid.frame.allocation.MemoryAllocator;
+import org.apache.druid.frame.allocation.MemoryRange;
+import org.apache.druid.frame.write.FrameWriterUtils;
+import org.apache.druid.segment.ColumnValueSelector;
+
+import java.util.List;
+
+/**
+ * Parent class for the family of writers writing numeric arrays in columnar 
frames. Since the numeric primitives are
+ * fixed width, we don't need to store the width of each element. The memory 
layout of a column written by this writer
+ * is as follows:
+ *
+ * n : Total number of rows
+ * k : Total number of elements in all the rows, cumulative
+ *
+ * | Section | Length of the section | Denotion                                
                                             |
+ * 
|---------|-----------------------|--------------------------------------------------------------------------------------|
+ * | 0       | 1                     | typeCode                                
                                             |
+ * | 1       | n * Integer.BYTES     | n integers, where i-th integer 
represents the cumulative length of the array         |
+ * | 2       | k * Byte.BYTES        | k bytes, where i-th byte represent 
whether the i-th value from the start is null     |
+ * | 3       | k * ELEMENT_SIZE      | k values, each representing the 
element, or null equivalent value (e.g 0 for double) |
+ *
+ * Note on cumulative lengths stored in section 1: Cumulative lengths are 
stored so that its fast to offset into the
+ * elements of the array. We also use negative cumulative length to denote 
that the array itself is null (as opposed to
+ * individual elements being null, which we store in section 2)

Review Comment:
   Thanks for the detailed doc! This made it a lot easier to follow



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