@@ -862,12 +862,26 @@ public static long getDirectByteBufferFrameContentSize(ByteBuffer src, int srcPo
862862 * it fails (which can be tested using ZSTD_isError())
863863 */
864864 public static long trainFromBuffer (byte [][] samples , byte [] dictBuffer , boolean legacy ) {
865+ return trainFromBuffer (samples , dictBuffer , legacy , defaultCompressionLevel ());
866+ }
867+
868+ /**
869+ * Creates a new dictionary to tune a kind of samples
870+ *
871+ * @param samples the samples buffer array
872+ * @param dictBuffer the new dictionary buffer
873+ * @param legacy use the legacy training algorithm; otherwise cover
874+ * @param compressionLevel optimal if using the same level as when compressing.
875+ * @return the number of bytes into buffer 'dictBuffer' or an error code if
876+ * it fails (which can be tested using ZSTD_isError())
877+ */
878+ public static long trainFromBuffer (byte [][] samples , byte [] dictBuffer , boolean legacy , int compressionLevel ) {
865879 if (samples .length <= 10 ) {
866880 throw new ZstdException (Zstd .errGeneric (), "nb of samples too low" );
867881 }
868- return trainFromBuffer0 (samples , dictBuffer , legacy );
882+ return trainFromBuffer0 (samples , dictBuffer , legacy , compressionLevel );
869883 }
870- private static native long trainFromBuffer0 (byte [][] samples , byte [] dictBuffer , boolean legacy );
884+ private static native long trainFromBuffer0 (byte [][] samples , byte [] dictBuffer , boolean legacy , int compressionLevel );
871885
872886 /**
873887 * Creates a new dictionary to tune a kind of samples
@@ -880,12 +894,29 @@ public static long trainFromBuffer(byte[][] samples, byte[] dictBuffer, boolean
880894 * it fails (which can be tested using ZSTD_isError())
881895 */
882896 public static long trainFromBufferDirect (ByteBuffer samples , int [] sampleSizes , ByteBuffer dictBuffer , boolean legacy ) {
897+ return trainFromBufferDirect (samples , sampleSizes , dictBuffer , legacy , defaultCompressionLevel ());
898+ }
899+
900+ /**
901+ * Creates a new dictionary to tune a kind of samples
902+ *
903+ * @param samples the samples direct byte buffer array
904+ * @param sampleSizes java integer array of sizes
905+ * @param dictBuffer the new dictionary buffer (preallocated direct byte buffer)
906+ * @param legacy use the legacy training algorithm; oter
907+ * @param compressionLevel optimal if using the same level as when compressing.
908+ * @return the number of bytes into buffer 'dictBuffer' or an error code if
909+ * it fails (which can be tested using ZSTD_isError())
910+ */
911+ public static long trainFromBufferDirect (ByteBuffer samples , int [] sampleSizes , ByteBuffer dictBuffer , boolean legacy , int compressionLevel ) {
883912 if (sampleSizes .length <= 10 ) {
884913 throw new ZstdException (Zstd .errGeneric (), "nb of samples too low" );
885914 }
886- return trainFromBufferDirect0 (samples , sampleSizes , dictBuffer , legacy );
915+ return trainFromBufferDirect0 (samples , sampleSizes , dictBuffer , legacy , compressionLevel );
887916 }
888- private static native long trainFromBufferDirect0 (ByteBuffer samples , int [] sampleSizes , ByteBuffer dictBuffer , boolean legacy );
917+
918+
919+ private static native long trainFromBufferDirect0 (ByteBuffer samples , int [] sampleSizes , ByteBuffer dictBuffer , boolean legacy , int compressionLevel );
889920
890921 /**
891922 * Get DictId from a compressed frame
0 commit comments