@@ -34,21 +34,21 @@ public final class AlpEncoding implements Encoding {
3434
3535 // Powers of 10 for F64 — shared by encode (exponent search) and decode (reconstruction).
3636 static final double [] F10_F64 = {
37- 1e0 , 1e1 , 1e2 , 1e3 , 1e4 , 1e5 , 1e6 , 1e7 , 1e8 , 1e9 ,
38- 1e10 , 1e11 , 1e12 , 1e13 , 1e14 , 1e15 , 1e16 , 1e17 , 1e18 , 1e19 ,
39- 1e20 , 1e21 , 1e22 , 1e23
37+ 1e0 , 1e1 , 1e2 , 1e3 , 1e4 , 1e5 , 1e6 , 1e7 , 1e8 , 1e9 ,
38+ 1e10 , 1e11 , 1e12 , 1e13 , 1e14 , 1e15 , 1e16 , 1e17 , 1e18 , 1e19 ,
39+ 1e20 , 1e21 , 1e22 , 1e23
4040 };
4141 static final double [] IF10_F64 = {
42- 1e-0 , 1e-1 , 1e-2 , 1e-3 , 1e-4 , 1e-5 , 1e-6 , 1e-7 , 1e-8 , 1e-9 ,
43- 1e-10 , 1e-11 , 1e-12 , 1e-13 , 1e-14 , 1e-15 , 1e-16 , 1e-17 , 1e-18 , 1e-19 ,
44- 1e-20 , 1e-21 , 1e-22 , 1e-23
42+ 1e-0 , 1e-1 , 1e-2 , 1e-3 , 1e-4 , 1e-5 , 1e-6 , 1e-7 , 1e-8 , 1e-9 ,
43+ 1e-10 , 1e-11 , 1e-12 , 1e-13 , 1e-14 , 1e-15 , 1e-16 , 1e-17 , 1e-18 , 1e-19 ,
44+ 1e-20 , 1e-21 , 1e-22 , 1e-23
4545 };
4646 // Powers of 10 for F32 — shared by encode (exponent search) and decode (reconstruction).
4747 static final float [] F10_F32 = {
48- 1e0f , 1e1f , 1e2f , 1e3f , 1e4f , 1e5f , 1e6f , 1e7f , 1e8f , 1e9f , 1e10f
48+ 1e0f , 1e1f , 1e2f , 1e3f , 1e4f , 1e5f , 1e6f , 1e7f , 1e8f , 1e9f , 1e10f
4949 };
5050 static final float [] IF10_F32 = {
51- 1e-0f , 1e-1f , 1e-2f , 1e-3f , 1e-4f , 1e-5f , 1e-6f , 1e-7f , 1e-8f , 1e-9f , 1e-10f
51+ 1e-0f , 1e-1f , 1e-2f , 1e-3f , 1e-4f , 1e-5f , 1e-6f , 1e-7f , 1e-8f , 1e-9f , 1e-10f
5252 };
5353 static final DType I64_DTYPE = new DType .Primitive (PType .I64 , false );
5454 static final DType I32_DTYPE = new DType .Primitive (PType .I32 , false );
@@ -95,8 +95,8 @@ private static final class Encoder {
9595 private static EncodeResult encode (DType dtype , Object data , EncodeContext ctx ) {
9696 PType ptype = ((DType .Primitive ) dtype ).ptype ();
9797 return switch (ptype ) {
98- case F64 -> encodeF64 ((double []) data , dtype , ctx );
99- case F32 -> encodeF32 ((float []) data , dtype , ctx );
98+ case F64 -> encodeF64 ((double []) data , ctx );
99+ case F32 -> encodeF32 ((float []) data , ctx );
100100 default -> throw new UnsupportedOperationException ("ALP encode not supported for " + ptype );
101101 };
102102 }
@@ -178,7 +178,7 @@ private static AlpF64Data computeF64(double[] values) {
178178 return new AlpF64Data (expE , expF , encodedArr , patchIndices , patchValues , statsMin , statsMax );
179179 }
180180
181- private static EncodeResult encodeF64 (double [] values , DType dtype , EncodeContext ctx ) {
181+ private static EncodeResult encodeF64 (double [] values , EncodeContext ctx ) {
182182 AlpF64Data d = computeF64 (values );
183183 int n = values .length ;
184184
@@ -191,9 +191,9 @@ private static EncodeResult encodeF64(double[] values, DType dtype, EncodeContex
191191
192192 if (d .patchIndices ().isEmpty ()) {
193193 byte [] metaBytes = EncodingProtos .ALPMetadata .newBuilder ()
194- .setExpE (d .expE ()).setExpF (d .expF ()).build ().toByteArray ();
194+ .setExpE (d .expE ()).setExpF (d .expF ()).build ().toByteArray ();
195195 EncodeNode root = new EncodeNode (EncodingId .VORTEX_ALP ,
196- ByteBuffer .wrap (metaBytes ), new EncodeNode []{encodedNode }, new int [0 ]);
196+ ByteBuffer .wrap (metaBytes ), new EncodeNode []{encodedNode }, new int [0 ]);
197197 return new EncodeResult (root , List .of (encodedBuf ), d .statsMin (), d .statsMax ());
198198 }
199199
@@ -207,29 +207,27 @@ private static EncodeResult encodeF64(double[] values, DType dtype, EncodeContex
207207
208208 EncodingProtos .PatchesMetadata patches = buildPatchesMeta (numPatches );
209209 byte [] metaBytes = EncodingProtos .ALPMetadata .newBuilder ()
210- .setExpE (d .expE ()).setExpF (d .expF ()).setPatches (patches ).build ().toByteArray ();
210+ .setExpE (d .expE ()).setExpF (d .expF ()).setPatches (patches ).build ().toByteArray ();
211211
212212 EncodeNode idxNode = EncodeNode .leaf (EncodingId .VORTEX_PRIMITIVE , 1 );
213213 EncodeNode valNode = EncodeNode .leaf (EncodingId .VORTEX_PRIMITIVE , 2 );
214214 EncodeNode root = new EncodeNode (EncodingId .VORTEX_ALP ,
215- ByteBuffer .wrap (metaBytes ),
216- new EncodeNode []{encodedNode , idxNode , valNode },
217- new int [0 ]);
215+ ByteBuffer .wrap (metaBytes ),
216+ new EncodeNode []{encodedNode , idxNode , valNode },
217+ new int [0 ]);
218218 return new EncodeResult (root , List .of (encodedBuf , idxBuf , valBuf ), d .statsMin (), d .statsMax ());
219219 }
220220
221221 /// Cascade-aware F64 encode: I64 child is an open ChildSlot so the compressor
222222 /// can bitpack it. Patch idx/val buffers (if any) stay in ownedBuffers.
223223 private static CascadeStep encodeCascadeF64 (double [] values , EncodeContext ctx ) {
224224 AlpF64Data d = computeF64 (values );
225- int n = values .length ;
226-
227225 if (d .patchIndices ().isEmpty ()) {
228226 byte [] metaBytes = EncodingProtos .ALPMetadata .newBuilder ()
229- .setExpE (d .expE ()).setExpF (d .expF ()).build ().toByteArray ();
227+ .setExpE (d .expE ()).setExpF (d .expF ()).build ().toByteArray ();
230228 // children[0] will be filled by the compressor after recursing on the ChildSlot
231229 EncodeNode partialRoot = new EncodeNode (EncodingId .VORTEX_ALP ,
232- ByteBuffer .wrap (metaBytes ), new EncodeNode [1 ], new int [0 ]);
230+ ByteBuffer .wrap (metaBytes ), new EncodeNode [1 ], new int [0 ]);
233231 ChildSlot slot = new ChildSlot (I64_DTYPE , d .encodedArr (), 0 );
234232 return new CascadeStep (partialRoot , List .of (), List .of (slot ), d .statsMin (), d .statsMax (), true );
235233 }
@@ -244,13 +242,13 @@ private static CascadeStep encodeCascadeF64(double[] values, EncodeContext ctx)
244242
245243 EncodingProtos .PatchesMetadata patches = buildPatchesMeta (numPatches );
246244 byte [] metaBytes = EncodingProtos .ALPMetadata .newBuilder ()
247- .setExpE (d .expE ()).setExpF (d .expF ()).setPatches (patches ).build ().toByteArray ();
245+ .setExpE (d .expE ()).setExpF (d .expF ()).setPatches (patches ).build ().toByteArray ();
248246
249247 // ownedBuffers[0]=idxBuf, [1]=valBuf; child I64 will be appended after (starting at idx 2)
250248 EncodeNode idxNode = EncodeNode .leaf (EncodingId .VORTEX_PRIMITIVE , 0 );
251249 EncodeNode valNode = EncodeNode .leaf (EncodingId .VORTEX_PRIMITIVE , 1 );
252250 EncodeNode partialRoot = new EncodeNode (EncodingId .VORTEX_ALP ,
253- ByteBuffer .wrap (metaBytes ), new EncodeNode []{null , idxNode , valNode }, new int [0 ]);
251+ ByteBuffer .wrap (metaBytes ), new EncodeNode []{null , idxNode , valNode }, new int [0 ]);
254252 ChildSlot slot = new ChildSlot (I64_DTYPE , d .encodedArr (), 0 );
255253 return new CascadeStep (partialRoot , List .of (idxBuf , valBuf ), List .of (slot ), d .statsMin (), d .statsMax (), true );
256254 }
@@ -286,7 +284,7 @@ private static int[] findExponentsF32(float[] values) {
286284 return new int []{bestExpE , bestExpF };
287285 }
288286
289- private static EncodeResult encodeF32 (float [] values , DType dtype , EncodeContext ctx ) {
287+ private static EncodeResult encodeF32 (float [] values , EncodeContext ctx ) {
290288 int n = values .length ;
291289 int [] exps = findExponentsF32 (values );
292290 int expE = exps [0 ], expF = exps [1 ];
@@ -331,9 +329,9 @@ private static EncodeResult encodeF32(float[] values, DType dtype, EncodeContext
331329
332330 if (patchIndices .isEmpty ()) {
333331 byte [] metaBytes = EncodingProtos .ALPMetadata .newBuilder ()
334- .setExpE (expE ).setExpF (expF ).build ().toByteArray ();
332+ .setExpE (expE ).setExpF (expF ).build ().toByteArray ();
335333 EncodeNode root = new EncodeNode (EncodingId .VORTEX_ALP ,
336- ByteBuffer .wrap (metaBytes ), new EncodeNode []{encodedNode }, new int [0 ]);
334+ ByteBuffer .wrap (metaBytes ), new EncodeNode []{encodedNode }, new int [0 ]);
337335 return new EncodeResult (root , List .of (encodedBuf ), statsMin , statsMax );
338336 }
339337
@@ -346,28 +344,28 @@ private static EncodeResult encodeF32(float[] values, DType dtype, EncodeContext
346344 }
347345
348346 EncodingProtos .PatchesMetadata patches = EncodingProtos .PatchesMetadata .newBuilder ()
349- .setLen (numPatches )
350- .setOffset (0 )
351- .setIndicesPtype (DTypeProtos .PType .forNumber (PType .U32 .ordinal ()))
352- .build ();
347+ .setLen (numPatches )
348+ .setOffset (0 )
349+ .setIndicesPtype (DTypeProtos .PType .forNumber (PType .U32 .ordinal ()))
350+ .build ();
353351 byte [] metaBytes = EncodingProtos .ALPMetadata .newBuilder ()
354- .setExpE (expE ).setExpF (expF ).setPatches (patches ).build ().toByteArray ();
352+ .setExpE (expE ).setExpF (expF ).setPatches (patches ).build ().toByteArray ();
355353
356354 EncodeNode idxNode = EncodeNode .leaf (EncodingId .VORTEX_PRIMITIVE , 1 );
357355 EncodeNode valNode = EncodeNode .leaf (EncodingId .VORTEX_PRIMITIVE , 2 );
358356 EncodeNode root = new EncodeNode (EncodingId .VORTEX_ALP ,
359- ByteBuffer .wrap (metaBytes ),
360- new EncodeNode []{encodedNode , idxNode , valNode },
361- new int [0 ]);
357+ ByteBuffer .wrap (metaBytes ),
358+ new EncodeNode []{encodedNode , idxNode , valNode },
359+ new int [0 ]);
362360 return new EncodeResult (root , List .of (encodedBuf , idxBuf , valBuf ), statsMin , statsMax );
363361 }
364362
365363 private static EncodingProtos .PatchesMetadata buildPatchesMeta (int numPatches ) {
366364 return EncodingProtos .PatchesMetadata .newBuilder ()
367- .setLen (numPatches )
368- .setOffset (0 )
369- .setIndicesPtype (DTypeProtos .PType .forNumber (PType .U32 .ordinal ()))
370- .build ();
365+ .setLen (numPatches )
366+ .setOffset (0 )
367+ .setIndicesPtype (DTypeProtos .PType .forNumber (PType .U32 .ordinal ()))
368+ .build ();
371369 }
372370
373371 private static byte [] scalarF64 (double v ) {
@@ -441,7 +439,7 @@ private static Array decodeF64(DecodeContext ctx, EncodingProtos.ALPMetadata met
441439 }
442440
443441 if (meta .hasPatches ()) {
444- applyPatches (ctx , meta .getPatches (), buf , PTypeIO . LE_LONG , 8 );
442+ applyPatches (ctx , meta .getPatches (), buf , 8 );
445443 }
446444
447445 return new DoubleArray (ctx .dtype (), n , buf .asReadOnly (), ArrayStats .empty ());
@@ -467,14 +465,14 @@ private static Array decodeF32(DecodeContext ctx, EncodingProtos.ALPMetadata met
467465 }
468466
469467 if (meta .hasPatches ()) {
470- applyPatches (ctx , meta .getPatches (), buf32 , PTypeIO . LE_INT , 4 );
468+ applyPatches (ctx , meta .getPatches (), buf32 , 4 );
471469 }
472470
473471 return new FloatArray (ctx .dtype (), n , buf32 .asReadOnly (), ArrayStats .empty ());
474472 }
475473
476474 private static void applyPatches (DecodeContext ctx , EncodingProtos .PatchesMetadata pm ,
477- MemorySegment out , ValueLayout elemLayout , int elemBytes ) {
475+ MemorySegment out , int elemBytes ) {
478476 long numPatches = pm .getLen ();
479477 long offset = pm .getOffset ();
480478 PType idxPtype = ptypeFromProto (pm .getIndicesPtype ());
@@ -494,7 +492,7 @@ private static void applyPatches(DecodeContext ctx, EncodingProtos.PatchesMetada
494492 private static Array decodeChildAs (DecodeContext parent , int childIdx , DType dtype , long rowCount ) {
495493 ArrayNode childNode = parent .node ().children ()[childIdx ];
496494 DecodeContext childCtx = new DecodeContext (
497- childNode , dtype , rowCount , parent .segmentBuffers (), parent .registry (), parent .arena ());
495+ childNode , dtype , rowCount , parent .segmentBuffers (), parent .registry (), parent .arena ());
498496 return parent .registry ().decode (childCtx );
499497 }
500498
0 commit comments