Skip to content

Commit 7af0af2

Browse files
dfa1claude
andcommitted
refactor(writer): delegate RleEncodingEncoder.toLongs integer arms to PrimitiveArrays
Rle.toLongs is a superset of PrimitiveArrays.toLongs: identical widen for the eight integer ptypes, plus F32/F64/F16 raw-bit packing unique to RLE. The integer half was a verbatim copy. Keep the float/f16 arms local and route every other ptype through PrimitiveArrays.toLongs via the switch default (floats are matched first, so the default only ever sees integers). Drops ~48 duplicated lines. Ground truth green: JavaWritesRustReads (213). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent ec6b963 commit 7af0af2

1 file changed

Lines changed: 3 additions & 49 deletions

File tree

writer/src/main/java/io/github/dfa1/vortex/writer/encode/RleEncodingEncoder.java

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import io.github.dfa1.vortex.core.PType;
55
import io.github.dfa1.vortex.core.VortexException;
66
import io.github.dfa1.vortex.encoding.EncodingId;
7+
import io.github.dfa1.vortex.encoding.PrimitiveArrays;
78
import io.github.dfa1.vortex.encoding.PTypeIO;
89
import io.github.dfa1.vortex.proto.RLEMetadata;
910

@@ -149,55 +150,6 @@ private static EncodeResult encodeEmpty(EncodeContext ctx) {
149150

150151
private static long[] toLongs(Object data, PType ptype) {
151152
return switch (ptype) {
152-
case I8 -> {
153-
byte[] arr = (byte[]) data;
154-
long[] r = new long[arr.length];
155-
for (int i = 0; i < arr.length; i++) {
156-
r[i] = arr[i];
157-
}
158-
yield r;
159-
}
160-
case U8 -> {
161-
byte[] arr = (byte[]) data;
162-
long[] r = new long[arr.length];
163-
for (int i = 0; i < arr.length; i++) {
164-
r[i] = Byte.toUnsignedLong(arr[i]);
165-
}
166-
yield r;
167-
}
168-
case I16 -> {
169-
short[] arr = (short[]) data;
170-
long[] r = new long[arr.length];
171-
for (int i = 0; i < arr.length; i++) {
172-
r[i] = arr[i];
173-
}
174-
yield r;
175-
}
176-
case U16 -> {
177-
short[] arr = (short[]) data;
178-
long[] r = new long[arr.length];
179-
for (int i = 0; i < arr.length; i++) {
180-
r[i] = Short.toUnsignedLong(arr[i]);
181-
}
182-
yield r;
183-
}
184-
case I32 -> {
185-
int[] arr = (int[]) data;
186-
long[] r = new long[arr.length];
187-
for (int i = 0; i < arr.length; i++) {
188-
r[i] = arr[i];
189-
}
190-
yield r;
191-
}
192-
case U32 -> {
193-
int[] arr = (int[]) data;
194-
long[] r = new long[arr.length];
195-
for (int i = 0; i < arr.length; i++) {
196-
r[i] = Integer.toUnsignedLong(arr[i]);
197-
}
198-
yield r;
199-
}
200-
case I64, U64 -> (long[]) data;
201153
case F32 -> {
202154
float[] arr = (float[]) data;
203155
long[] r = new long[arr.length];
@@ -222,6 +174,8 @@ private static long[] toLongs(Object data, PType ptype) {
222174
}
223175
yield r;
224176
}
177+
// Integer ptypes share the standard widen; floats above keep RLE's raw-bit packing.
178+
default -> PrimitiveArrays.toLongs(data, ptype, EncodingId.FASTLANES_RLE);
225179
};
226180
}
227181

0 commit comments

Comments
 (0)