|
9 | 9 | import io.github.dfa1.vortex.reader.array.Array; |
10 | 10 | import io.github.dfa1.vortex.reader.array.ArraySegments; |
11 | 11 | import io.github.dfa1.vortex.reader.array.BoolArray; |
| 12 | +import io.github.dfa1.vortex.reader.array.LazyConstantByteArray; |
| 13 | +import io.github.dfa1.vortex.reader.array.LazyConstantIntArray; |
| 14 | +import io.github.dfa1.vortex.reader.array.LazyConstantLongArray; |
| 15 | +import io.github.dfa1.vortex.reader.array.LazyConstantShortArray; |
12 | 16 | import io.github.dfa1.vortex.reader.array.LazyRleByteArray; |
13 | 17 | import io.github.dfa1.vortex.reader.array.LazyRleIntArray; |
14 | 18 | import io.github.dfa1.vortex.reader.array.LazyRleLongArray; |
15 | 19 | import io.github.dfa1.vortex.reader.array.LazyRleShortArray; |
16 | 20 | import io.github.dfa1.vortex.reader.array.MaskedArray; |
17 | | -import io.github.dfa1.vortex.reader.array.MaterializedBoolArray; |
18 | | -import io.github.dfa1.vortex.reader.array.MaterializedByteArray; |
19 | | -import io.github.dfa1.vortex.reader.array.MaterializedIntArray; |
20 | | -import io.github.dfa1.vortex.reader.array.MaterializedLongArray; |
21 | | -import io.github.dfa1.vortex.reader.array.MaterializedShortArray; |
| 21 | +import io.github.dfa1.vortex.reader.array.OffsetBoolArray; |
22 | 22 |
|
23 | 23 | import java.io.IOException; |
24 | 24 | import java.lang.foreign.MemorySegment; |
@@ -113,28 +113,18 @@ public Array decode(DecodeContext ctx) { |
113 | 113 | if (indicesValidity == null) { |
114 | 114 | return result; |
115 | 115 | } |
116 | | - int validityBytes = (int) ((rowCount + 7) / 8); |
117 | | - MemorySegment validityBuf = ctx.arena().allocate(validityBytes); |
118 | | - for (long j = 0; j < rowCount; j++) { |
119 | | - if (indicesValidity.getBoolean(offset + j)) { |
120 | | - int byteIdx = (int) (j >>> 3); |
121 | | - byte current = validityBuf.get(ValueLayout.JAVA_BYTE, byteIdx); |
122 | | - validityBuf.set(ValueLayout.JAVA_BYTE, byteIdx, (byte) ((current & 0xff) | (1 << (j & 7)))); |
123 | | - } |
124 | | - } |
125 | | - BoolArray outputValidity = new MaterializedBoolArray(new DType.Bool(false), rowCount, validityBuf); |
| 116 | + BoolArray outputValidity = new OffsetBoolArray(new DType.Bool(false), rowCount, indicesValidity, offset); |
126 | 117 | return new MaskedArray(result, outputValidity); |
127 | 118 | } |
128 | 119 |
|
129 | 120 | private static Array emptyArray(DecodeContext ctx) { |
130 | | - MemorySegment empty = ctx.arena().allocate(0); |
131 | 121 | DType dt = ctx.dtype(); |
132 | 122 | PType ptype = ((DType.Primitive) dt).ptype(); |
133 | 123 | return switch (ptype) { |
134 | | - case I64, U64 -> new MaterializedLongArray(dt, 0L, empty); |
135 | | - case I32, U32 -> new MaterializedIntArray(dt, 0L, empty); |
136 | | - case I16, U16 -> new MaterializedShortArray(dt, 0L, empty); |
137 | | - case I8, U8 -> new MaterializedByteArray(dt, 0L, empty); |
| 124 | + case I64, U64 -> new LazyConstantLongArray(dt, 0L, 0L); |
| 125 | + case I32, U32 -> new LazyConstantIntArray(dt, 0L, 0); |
| 126 | + case I16, U16 -> new LazyConstantShortArray(dt, 0L, (short) 0); |
| 127 | + case I8, U8 -> new LazyConstantByteArray(dt, 0L, (byte) 0); |
138 | 128 | default -> throw new VortexException(EncodingId.FASTLANES_RLE, "unsupported ptype " + ptype); |
139 | 129 | }; |
140 | 130 | } |
|
0 commit comments