@@ -708,7 +708,13 @@ public static long decompressedDirectByteBufferSize(ByteBuffer src, int srcPosit
708
708
* @return the number of bytes into buffer 'dictBuffer' or an error code if
709
709
* it fails (which can be tested using ZSTD_isError())
710
710
*/
711
- public static native long trainFromBuffer (byte [][] samples , byte [] dictBuffer , boolean legacy );
711
+ public static long trainFromBuffer (byte [][] samples , byte [] dictBuffer , boolean legacy ) {
712
+ if (samples .length <= 10 ) {
713
+ throw new ZstdException (Zstd .errGeneric (), "nb of samples too low" );
714
+ }
715
+ return trainFromBuffer0 (samples , dictBuffer , legacy );
716
+ }
717
+ private static native long trainFromBuffer0 (byte [][] samples , byte [] dictBuffer , boolean legacy );
712
718
713
719
/**
714
720
* Creates a new dictionary to tune a kind of samples
@@ -720,7 +726,13 @@ public static long decompressedDirectByteBufferSize(ByteBuffer src, int srcPosit
720
726
* @return the number of bytes into buffer 'dictBuffer' or an error code if
721
727
* it fails (which can be tested using ZSTD_isError())
722
728
*/
723
- public static native long trainFromBufferDirect (ByteBuffer samples , int [] sampleSizes , ByteBuffer dictBuffer , boolean legacy );
729
+ public static long trainFromBufferDirect (ByteBuffer samples , int [] sampleSizes , ByteBuffer dictBuffer , boolean legacy ) {
730
+ if (sampleSizes .length <= 10 ) {
731
+ throw new ZstdException (Zstd .errGeneric (), "nb of samples too low" );
732
+ }
733
+ return trainFromBufferDirect0 (samples , sampleSizes , dictBuffer , legacy );
734
+ }
735
+ private static native long trainFromBufferDirect0 (ByteBuffer samples , int [] sampleSizes , ByteBuffer dictBuffer , boolean legacy );
724
736
725
737
/**
726
738
* Get DictId from a compressed frame
0 commit comments