@@ -579,6 +579,28 @@ public static long decompressDirectByteBufferFastDict(ByteBuffer dst, int dstOff
579
579
public static native int setRefMultipleDDicts (long stream , boolean useMultiple );
580
580
581
581
/* Utility methods */
582
+ /**
583
+ * Return the original size of a compressed buffer (if known)
584
+ *
585
+ * @param src the compressed buffer
586
+ * @param srcPosition offset of the compressed data inside the src buffer
587
+ * @param srcSize length of the compressed data inside the src buffer
588
+ * @param magicless whether the buffer contains a magicless frame
589
+ * @return the number of bytes of the original buffer
590
+ * 0 if the original size is not known,
591
+ * negative if there is an error decoding the frame header
592
+ */
593
+ public static long getFrameContentSize (byte [] src , int srcPosition , int srcSize , boolean magicless ) {
594
+ if (srcPosition >= src .length ) {
595
+ throw new ArrayIndexOutOfBoundsException (srcPosition );
596
+ }
597
+ if (srcPosition + srcSize > src .length ) {
598
+ throw new ArrayIndexOutOfBoundsException (srcPosition + srcSize );
599
+ }
600
+ return getFrameContentSize0 (src , srcPosition , srcSize , magicless );
601
+ }
602
+
603
+ private static native long getFrameContentSize0 (byte [] src , int srcPosition , int srcSize , boolean magicless );
582
604
583
605
/**
584
606
* Return the original size of a compressed buffer (if known)
@@ -589,7 +611,10 @@ public static long decompressDirectByteBufferFastDict(ByteBuffer dst, int dstOff
589
611
* @param magicless whether the buffer contains a magicless frame
590
612
* @return the number of bytes of the original buffer
591
613
* 0 if the original size is not known
614
+ * @deprecated
615
+ * Use `getFrameContentSize` that return also the errors
592
616
*/
617
+ @ Deprecated
593
618
public static long decompressedSize (byte [] src , int srcPosition , int srcSize , boolean magicless ) {
594
619
if (srcPosition >= src .length ) {
595
620
throw new ArrayIndexOutOfBoundsException (srcPosition );
@@ -602,6 +627,20 @@ public static long decompressedSize(byte[] src, int srcPosition, int srcSize, bo
602
627
603
628
private static native long decompressedSize0 (byte [] src , int srcPosition , int srcSize , boolean magicless );
604
629
630
+ /**
631
+ * Return the original size of a compressed buffer (if known)
632
+ *
633
+ * @param src the compressed buffer
634
+ * @param srcPosition offset of the compressed data inside the src buffer
635
+ * @param srcSize length of the compressed data inside the src buffer
636
+ * @return the number of bytes of the original buffer
637
+ * 0 if the original size is not known,
638
+ * negative if there is an error decoding the frame header
639
+ */
640
+ public static long getFrameContentSize (byte [] src , int srcPosition , int srcSize ) {
641
+ return getFrameContentSize (src , srcPosition , srcSize , false );
642
+ }
643
+
605
644
/**
606
645
* Return the original size of a compressed buffer (if known)
607
646
*
@@ -610,30 +649,67 @@ public static long decompressedSize(byte[] src, int srcPosition, int srcSize, bo
610
649
* @param srcSize length of the compressed data inside the src buffer
611
650
* @return the number of bytes of the original buffer
612
651
* 0 if the original size is not known
652
+ * @deprecated
653
+ * Use `getFrameContentSize` that return also the errors
613
654
*/
655
+ @ Deprecated
614
656
public static long decompressedSize (byte [] src , int srcPosition , int srcSize ) {
615
657
return decompressedSize (src , srcPosition , srcSize , false );
616
658
}
617
659
660
+ /**
661
+ * Return the original size of a compressed buffer (if known)
662
+ *
663
+ * @param src the compressed buffer
664
+ * @param srcPosition offset of the compressed data inside the src buffer
665
+ * @param srcSize length of the compressed data inside the src buffer
666
+ * @return the number of bytes of the original buffer
667
+ * 0 if the original size is not known,
668
+ * negative if there is an error decoding the frame header
669
+ */
670
+ public static long getFrameContentSize (byte [] src , int srcPosition ) {
671
+ return getFrameContentSize (src , srcPosition , src .length - srcPosition );
672
+ }
673
+
618
674
/**
619
675
* Return the original size of a compressed buffer (if known)
620
676
*
621
677
* @param src the compressed buffer
622
678
* @param srcPosition offset of the compressed data inside the src buffer
623
679
* @return the number of bytes of the original buffer
624
680
* 0 if the original size is not known
681
+ * @deprecated
682
+ * Use `getFrameContentSize` that return also the errors
625
683
*/
684
+ @ Deprecated
626
685
public static long decompressedSize (byte [] src , int srcPosition ) {
627
686
return decompressedSize (src , srcPosition , src .length - srcPosition );
628
687
}
629
688
689
+ /**
690
+ * Return the original size of a compressed buffer (if known)
691
+ *
692
+ * @param src the compressed buffer
693
+ * @param srcPosition offset of the compressed data inside the src buffer
694
+ * @param srcSize length of the compressed data inside the src buffer
695
+ * @return the number of bytes of the original buffer
696
+ * 0 if the original size is not known,
697
+ * negative if there is an error decoding the frame header
698
+ */
699
+ public static long getFrameContentSize (byte [] src ) {
700
+ return getFrameContentSize (src , 0 );
701
+ }
702
+
630
703
/**
631
704
* Return the original size of a compressed buffer (if known)
632
705
*
633
706
* @param src the compressed buffer
634
707
* @return the number of bytes of the original buffer
635
708
* 0 if the original size is not known
709
+ * @deprecated
710
+ * Use `getFrameContentSize` that return also the errors
636
711
*/
712
+ @ Deprecated
637
713
public static long decompressedSize (byte [] src ) {
638
714
return decompressedSize (src , 0 );
639
715
};
@@ -647,9 +723,25 @@ public static long decompressedSize(byte[] src) {
647
723
* @param magicless whether the buffer contains a magicless frame
648
724
* @return the number of bytes of the original buffer
649
725
* 0 if the original size is not known
726
+ * @deprecated
727
+ * Use `getDirectByteBuferFrameContentSize` that return also the errors
650
728
*/
729
+ @ Deprecated
651
730
public static native long decompressedDirectByteBufferSize (ByteBuffer src , int srcPosition , int srcSize , boolean magicless );
652
731
732
+ /**
733
+ * Return the original size of a compressed buffer (if known)
734
+ *
735
+ * @param src the compressed buffer
736
+ * @param srcPosition offset of the compressed data inside the src buffer
737
+ * @param srcSize length of the compressed data inside the src buffe
738
+ * @param magicless whether the buffer contains a magicless frame
739
+ * @return the number of bytes of the original buffer
740
+ * 0 if the original size is not known
741
+ * negative if there is an error decoding the frame header
742
+ */
743
+ public static native long getDirectByteBuferFrameContentSize (ByteBuffer src , int srcPosition , int srcSize , boolean magicless );
744
+
653
745
/**
654
746
* Return the original size of a compressed buffer (if known)
655
747
*
@@ -658,11 +750,28 @@ public static long decompressedSize(byte[] src) {
658
750
* @param srcSize length of the compressed data inside the src buffe
659
751
* @return the number of bytes of the original buffer
660
752
* 0 if the original size is not known
753
+ * @deprecated
754
+ * Use `getDirectByteBuferFrameContentSize` that return also the errors
661
755
*/
756
+ @ Deprecated
662
757
public static long decompressedDirectByteBufferSize (ByteBuffer src , int srcPosition , int srcSize ) {
663
758
return decompressedDirectByteBufferSize (src , srcPosition , srcSize , false );
664
759
}
665
760
761
+ /**
762
+ * Return the original size of a compressed buffer (if known)
763
+ *
764
+ * @param src the compressed buffer
765
+ * @param srcPosition offset of the compressed data inside the src buffer
766
+ * @param srcSize length of the compressed data inside the src buffe
767
+ * @return the number of bytes of the original buffer
768
+ * 0 if the original size is not known
769
+ * negative if there is an error decoding the frame header
770
+ */
771
+ public static long getDirectByteBuferFrameContentSize (ByteBuffer src , int srcPosition , int srcSize ) {
772
+ return getDirectByteBuferFrameContentSize (src , srcPosition , srcSize , false );
773
+ }
774
+
666
775
/**
667
776
* Maximum size of the compressed data
668
777
*
0 commit comments