|
32 | 32 | import java.io.IOException; |
33 | 33 |
|
34 | 34 | import static org.apache.fluss.record.LogRecordBatchFormat.LENGTH_LENGTH; |
| 35 | + |
35 | 36 | /** |
36 | | - * An immutable log record for @CompactedRow which can be directly persisted. The on-wire schema is |
37 | | - * identical to IndexedLogRecord but the row payload uses the CompactedRow binary format: |
| 37 | + * An immutable log record for {@link CompactedRow} which can be directly persisted. The on-wire |
| 38 | + * schema is identical to IndexedLogRecord but the row payload uses the CompactedRow binary format: |
38 | 39 | * |
39 | 40 | * <ul> |
40 | | - * <li>Length => int32 (total number of bytes following this length field)</li> |
41 | | - * <li>Attributes => int8 (low 4 bits encode {@link ChangeType})</li> |
42 | | - * <li>Value => {@link CompactedRow} (bytes in compacted row format)</li> |
| 41 | + * <li>Length => int32 (total number of bytes following this length field) |
| 42 | + * <li>Attributes => int8 (low 4 bits encode {@link ChangeType}) |
| 43 | + * <li>Value => {@link CompactedRow} (bytes in compacted row format) |
43 | 44 | * </ul> |
44 | 45 | * |
45 | 46 | * <p>Differences vs {@link IndexedLogRecord}: - Uses CompactedRow encoding which is space-optimized |
|
48 | 49 | * in a CompactedRow with a {@link CompactedRowDeserializer} and only decode to object values when a |
49 | 50 | * field is accessed. - The record header (Length + Attributes) layout and attribute semantics are |
50 | 51 | * the same. |
51 | | - * Differences vs {@link IndexedLogRecord}: |
52 | | - * - Uses CompactedRow encoding which is space-optimized (VLQ for ints/longs, per-row null bitset) and |
53 | | - * trades CPU for smaller storage; random access to fields is not supported without decoding. |
54 | | - * - Deserialization is lazy: we wrap the underlying bytes in a CompactedRow with a |
55 | | - * {@link CompactedRowDeserializer} and only decode to object values when a field is accessed. |
56 | | - * - The record header (Length + Attributes) layout and attribute semantics are the same. |
57 | 52 | * |
58 | 53 | * <p>The offset computes the difference relative to the base offset of the batch containing this |
59 | 54 | * record. |
@@ -170,24 +165,22 @@ private static int calculateSizeInBytes(BinaryRow row) { |
170 | 165 | int size = 1; // one byte for attributes |
171 | 166 | size += row.getSizeInBytes(); |
172 | 167 | return size; |
173 | | - int rowOffset = LENGTH_LENGTH + ATTRIBUTES_LENGTH; |
174 | | - return deserializeCompactedRow( |
175 | | - sizeInBytes - rowOffset, segment, offset + rowOffset, fieldTypes, LogFormat.COMPACTED); |
176 | 168 | } |
177 | 169 |
|
178 | | - |
179 | 170 | private static InternalRow deserializeCompactedRow( |
180 | 171 | int length, |
181 | 172 | MemorySegment segment, |
182 | 173 | int position, |
183 | 174 | DataType[] fieldTypes, |
184 | 175 | LogFormat logFormat) { |
185 | 176 | if (logFormat == LogFormat.COMPACTED) { |
186 | | - CompactedRow compactedRow = new CompactedRow(fieldTypes.length, compactedDeserializer); |
| 177 | + CompactedRow compactedRow = |
| 178 | + new CompactedRow(fieldTypes.length, new CompactedRowDeserializer(fieldTypes)); |
187 | 179 | compactedRow.pointTo(segment, position, length); |
188 | 180 | return compactedRow; |
189 | 181 | } else { |
190 | | - throw new IllegalArgumentException("No such compacted row deserializer for: " + logFormat); |
| 182 | + throw new IllegalArgumentException( |
| 183 | + "No such compacted row deserializer for: " + logFormat); |
191 | 184 | } |
192 | 185 | } |
193 | 186 | } |
0 commit comments