@@ -64,15 +64,16 @@ private record ChunkResult(MemorySegment chunkMeta, MemorySegment page, int page
6464 }
6565
6666 // Per-stream encoded ANS state. Used for both single-stream (Classic) and dual-stream (IntMult) modes.
67- @ SuppressWarnings ("java:S6218" ) // internal data carrier; record components are arrays of immutable primitives or refs that flow through pipelines without ever being compared.
67+ @ SuppressWarnings ("java:S6218" )
68+ // internal data carrier; record components are arrays of immutable primitives or refs that flow through pipelines without ever being compared.
6869 private record StreamData (
69- int [] symbols ,
70- long [] offsets ,
71- int [] binOffsetBits ,
72- int ansSizeLog ,
73- long [][] batchBits ,
74- int [][] batchNumBits ,
75- int [] initialStateIdxs
70+ int [] symbols ,
71+ long [] offsets ,
72+ int [] binOffsetBits ,
73+ int ansSizeLog ,
74+ long [][] batchBits ,
75+ int [][] batchNumBits ,
76+ int [] initialStateIdxs
7677 ) {
7778 }
7879
@@ -83,7 +84,7 @@ static EncodeResult encode(DType dtype, Object data, EncodeContext ctx) {
8384 int n = allLatents .length ;
8485
8586 if (n == 0 ) {
86- return encodeEmpty (ctx . arena () );
87+ return encodeEmpty ();
8788 }
8889
8990 List <MemorySegment > chunkMetas = new ArrayList <>();
@@ -178,12 +179,12 @@ private static ChunkResult encodeChunkClassic(long[] latents, int dtypeSize, Are
178179 PcoAnsEncoder ansEncoder = PcoAnsEncoder .build (deltaQ .sizeLog (), deltaQ .weights ());
179180 chunkMetaSeg = buildClassicChunkMeta (dtypeSize , deltaBins , deltaQ , 1 , 1 , arena );
180181 pageSeg = buildClassicPage (deltas , toSortKeys (deltas ), deltaBins ,
181- deltaQ .sizeLog (), ansEncoder , dtypeSize , latents [0 ], true , arena );
182+ deltaQ .sizeLog (), ansEncoder , dtypeSize , latents [0 ], true , arena );
182183 } else {
183184 PcoAnsEncoder ansEncoder = PcoAnsEncoder .build (noOpQ .sizeLog (), noOpQ .weights ());
184185 chunkMetaSeg = buildClassicChunkMeta (dtypeSize , noOpBins , noOpQ , 0 , 0 , arena );
185186 pageSeg = buildClassicPage (latents , sortKeys , noOpBins ,
186- noOpQ .sizeLog (), ansEncoder , dtypeSize , 0L , false , arena );
187+ noOpQ .sizeLog (), ansEncoder , dtypeSize , 0L , false , arena );
187188 }
188189
189190 return new ChunkResult (chunkMetaSeg , pageSeg , n );
@@ -194,7 +195,6 @@ private static ChunkResult encodeChunkClassic(long[] latents, int dtypeSize, Are
194195 // Returns null if IntMult fails to actually beat Classic after full bin optimization.
195196 private static ChunkResult tryEncodeIntMult (long [] latents , long base , int dtypeSize , Arena arena ) {
196197 int n = latents .length ;
197- long mask = typeMask (dtypeSize );
198198 long [] mults = new long [n ];
199199 long [] adjs = new long [n ];
200200 for (int i = 0 ; i < n ; i ++) {
@@ -233,9 +233,9 @@ private static ChunkResult tryEncodeIntMult(long[] latents, long base, int dtype
233233
234234 MemorySegment chunkMetaSeg = buildIntMultChunkMeta (dtypeSize , base , multBins , multQ , adjBins , adjQ , arena );
235235 MemorySegment pageSeg = buildIntMultPage (
236- mults , multSortKeys , multBins , multQ .sizeLog (), multAnsEncoder ,
237- adjs , adjSortKeys , adjBins , adjQ .sizeLog (), adjAnsEncoder ,
238- arena );
236+ mults , multSortKeys , multBins , multQ .sizeLog (), multAnsEncoder ,
237+ adjSortKeys , adjBins , adjQ .sizeLog (), adjAnsEncoder ,
238+ arena );
239239 return new ChunkResult (chunkMetaSeg , pageSeg , n );
240240 }
241241
@@ -280,7 +280,7 @@ private static List<PcoHistBin> buildHistogram(long[] sortedKeys, int n, int nBi
280280 targetEnd ++;
281281 }
282282 int end = Math .min (targetEnd , n );
283- bins .add (new PcoHistBin (sortedKeys [start ], sortedKeys [end - 1 ], end - start ));
283+ bins .add (new PcoHistBin (sortedKeys [start ], sortedKeys [end - 1 ], ( long ) end - start ));
284284 start = end ;
285285 }
286286 return bins ;
@@ -289,8 +289,8 @@ private static List<PcoHistBin> buildHistogram(long[] sortedKeys, int n, int nBi
289289 // ── Classic chunk meta ────────────────────────────────────────────────
290290
291291 private static MemorySegment buildClassicChunkMeta (
292- int dtypeSize , List <PcoBinOptimizer .Bin > bins , PcoWeightQuantizer .Result qw ,
293- int deltaVariant , int deltaOrder , Arena arena ) {
292+ int dtypeSize , List <PcoBinOptimizer .Bin > bins , PcoWeightQuantizer .Result qw ,
293+ int deltaVariant , int deltaOrder , Arena arena ) {
294294 int ansSizeLog = qw .sizeLog ();
295295 int [] weights = qw .weights ();
296296 LeBitWriter w = new LeBitWriter (64 );
@@ -316,10 +316,10 @@ private static MemorySegment buildClassicChunkMeta(
316316 // ── IntMult chunk meta ────────────────────────────────────────────────
317317
318318 private static MemorySegment buildIntMultChunkMeta (
319- int dtypeSize , long base ,
320- List <PcoBinOptimizer .Bin > primaryBins , PcoWeightQuantizer .Result primaryQ ,
321- List <PcoBinOptimizer .Bin > secondaryBins , PcoWeightQuantizer .Result secondaryQ ,
322- Arena arena ) {
319+ int dtypeSize , long base ,
320+ List <PcoBinOptimizer .Bin > primaryBins , PcoWeightQuantizer .Result primaryQ ,
321+ List <PcoBinOptimizer .Bin > secondaryBins , PcoWeightQuantizer .Result secondaryQ ,
322+ Arena arena ) {
323323 int primaryAnsSizeLog = primaryQ .sizeLog ();
324324 int [] primaryWeights = primaryQ .weights ();
325325 int secondaryAnsSizeLog = secondaryQ .sizeLog ();
@@ -358,10 +358,10 @@ private static MemorySegment buildIntMultChunkMeta(
358358 // ── Classic page encoding ─────────────────────────────────────────────
359359
360360 private static MemorySegment buildClassicPage (
361- long [] values , long [] valueSortKeys ,
362- List <PcoBinOptimizer .Bin > bins , int ansSizeLog ,
363- PcoAnsEncoder ansEncoder , int dtypeSize ,
364- long moment , boolean hasMoment , Arena arena ) {
361+ long [] values , long [] valueSortKeys ,
362+ List <PcoBinOptimizer .Bin > bins , int ansSizeLog ,
363+ PcoAnsEncoder ansEncoder , int dtypeSize ,
364+ long moment , boolean hasMoment , Arena arena ) {
365365
366366 int n = values .length ;
367367 StreamData stream = prepareStream (valueSortKeys , bins , ansSizeLog , ansEncoder );
@@ -387,11 +387,11 @@ private static MemorySegment buildClassicPage(
387387 // ── IntMult page encoding ─────────────────────────────────────────────
388388
389389 private static MemorySegment buildIntMultPage (
390- long [] mults , long [] multSortKeys , List <PcoBinOptimizer .Bin > multBins ,
391- int multAnsSizeLog , PcoAnsEncoder multAnsEncoder ,
392- long [] adjs , long [] adjSortKeys , List <PcoBinOptimizer .Bin > adjBins ,
393- int adjAnsSizeLog , PcoAnsEncoder adjAnsEncoder ,
394- Arena arena ) {
390+ long [] mults , long [] multSortKeys , List <PcoBinOptimizer .Bin > multBins ,
391+ int multAnsSizeLog , PcoAnsEncoder multAnsEncoder ,
392+ long [] adjSortKeys , List <PcoBinOptimizer .Bin > adjBins ,
393+ int adjAnsSizeLog , PcoAnsEncoder adjAnsEncoder ,
394+ Arena arena ) {
395395
396396 int n = mults .length ;
397397 StreamData primary = prepareStream (multSortKeys , multBins , multAnsSizeLog , multAnsEncoder );
@@ -428,7 +428,7 @@ private static MemorySegment buildIntMultPage(
428428 // ── Stream preparation: ANS encode LIFO, collect bits per batch ──────
429429
430430 private static StreamData prepareStream (
431- long [] sortKeys , List <PcoBinOptimizer .Bin > bins , int ansSizeLog , PcoAnsEncoder ansEncoder ) {
431+ long [] sortKeys , List <PcoBinOptimizer .Bin > bins , int ansSizeLog , PcoAnsEncoder ansEncoder ) {
432432 int n = sortKeys .length ;
433433 long [] binLowers = new long [bins .size ()];
434434 int [] binOffsetBits = new int [bins .size ()];
@@ -475,7 +475,7 @@ private static StreamData prepareStream(
475475 }
476476
477477 return new StreamData (symbols , offsets , binOffsetBits , ansSizeLog ,
478- batchBits , batchNumBits , initialStateIdxs );
478+ batchBits , batchNumBits , initialStateIdxs );
479479 }
480480
481481 private static long streamPayloadBits (StreamData s ) {
@@ -564,7 +564,7 @@ private static long[] toSortKeys(long[] latents) {
564564 // ── weight quantization ───────────────────────────────────────────────
565565
566566 private static PcoWeightQuantizer .Result quantize (
567- List <PcoBinOptimizer .Bin > bins , int totalCount , int maxSizeLog ) {
567+ List <PcoBinOptimizer .Bin > bins , int totalCount , int maxSizeLog ) {
568568 int [] counts = new int [bins .size ()];
569569 for (int i = 0 ; i < counts .length ; i ++) {
570570 counts [i ] = bins .get (i ).weight ();
@@ -574,7 +574,7 @@ private static PcoWeightQuantizer.Result quantize(
574574
575575 // ── metadata ─────────────────────────────────────────────────────────
576576
577- private static EncodeResult encodeEmpty (Arena arena ) {
577+ private static EncodeResult encodeEmpty () {
578578 byte [] header = {PCO_FORMAT_MAJOR , PCO_FORMAT_MINOR };
579579 PcoMetadata meta = new PcoMetadata (header , List .of ());
580580 ByteBuffer metaBuf = ByteBuffer .wrap (meta .encode ());
@@ -644,8 +644,8 @@ private static long[] toLatents(PType ptype, Object data) {
644644 for (int i = 0 ; i < arr .length ; i ++) {
645645 int bits = Float .floatToRawIntBits (arr [i ]);
646646 l [i ] = (bits & 0x80000000 ) != 0
647- ? (~bits ) & 0xFFFFFFFFL
648- : (bits ^ 0x80000000 ) & 0xFFFFFFFFL ;
647+ ? (~bits ) & 0xFFFFFFFFL
648+ : (bits ^ 0x80000000 ) & 0xFFFFFFFFL ;
649649 }
650650 yield l ;
651651 }
0 commit comments