rash67 commented on code in PR #12879:
URL: https://github.com/apache/druid/pull/12879#discussion_r957808723


##########
processing/src/main/java/org/apache/druid/segment/serde/cell/CellWriter.java:
##########
@@ -0,0 +1,191 @@
+/*
+ * 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.segment.serde.cell;
+
+import org.apache.druid.java.util.common.io.smoosh.FileSmoosher;
+import org.apache.druid.segment.data.CompressionStrategy;
+import org.apache.druid.segment.serde.Serializer;
+import org.apache.druid.segment.writeout.SegmentWriteOutMedium;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.WritableByteChannel;
+
+/**
+ * <pre>
+ * serialized data is of the form:
+ *
+ *    <cell index>
+ *    <payload storage>
+ *
+ * each of these items is stored in compressed streams of blocks with a block 
index.
+ *
+ * A BlockCompressedPayloadWriter stores byte[] payloads. These may be 
accessed by creating a
+ * BlockCompressedPayloadReader over the produced ByteBuffer. Reads may be 
done by giving a location in the
+ * uncompressed stream and a size
+ *
+ * NOTE: {@link BlockCompressedPayloadBuffer} does not store nulls on write(). 
However, the cellIndex stores an entry
+ * with a size of 0 for nulls and {@link CellReader} will return null for any 
null written
+ *
+ * * blockIndexSize:int
+ * |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+ * |      block index
+ * |      compressed block # -> block start in compressed stream position 
(relative to data start)
+ * |
+ * |      0: [block position: int]
+ * |      1: [block position: int]
+ * |      ...
+ * |      i: [block position: int]
+ * |      ...
+ * |      n: [block position: int]
+ * |      n+1: [total compressed size ] // stored to simplify invariant of
+ * |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+ * dataSize:int
+ * |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+ * | <compressed payload block 1>
+ * | <compressed payload block 2>
+ * | ...
+ * | <compressed paylod block n>
+ * |
+ *
+ * the CellIndexWriter stores an array of longs using the 
BlockCompressedPayloadWriter
+ *
+ * logically this an array of longs
+ *
+ * |    0: start_0 : long
+ * |    1: start_1 : long
+ * |    ...
+ * |    n: start_n : long
+ * |    n+1: start_n + length_n : long  //ie, next position that would have 
been written to
+ *                                      //used again for invariant of length_i 
= row_i+1 - row_i
+ *
+ *      but this will be stored as block compressed. Reads are done by 
addressing it as a long array of bytes
+ *
+ * |    <block index size>
+ * |    <block index>
+ * |
+ * |    <data stream size>
+ * |    <block compressed payload stream>
+ *
+ * resulting in
+ *
+ * |    <cell index size>
+ * | ----cell index------------------------
+ * |    <block index size>
+ * |    <block index>
+ * |    <data stream size>
+ * |    <block compressed payload stream>
+ * | -------------------------------------
+ * |    <data stream size>
+ * | ----data stream------------------------
+ * |    <block index size>
+ * |    <block index>
+ * |    <data stream size>
+ * |    <block compressed payload stream>
+ * | -------------------------------------
+ * </pre>
+ */
+
+public class CellWriter implements Serializer, Closeable

Review Comment:
   added javadoc



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