@@ -862,12 +862,26 @@ public static long getDirectByteBufferFrameContentSize(ByteBuffer src, int srcPo
862
862
* it fails (which can be tested using ZSTD_isError())
863
863
*/
864
864
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 ) {
865
879
if (samples .length <= 10 ) {
866
880
throw new ZstdException (Zstd .errGeneric (), "nb of samples too low" );
867
881
}
868
- return trainFromBuffer0 (samples , dictBuffer , legacy );
882
+ return trainFromBuffer0 (samples , dictBuffer , legacy , compressionLevel );
869
883
}
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 );
871
885
872
886
/**
873
887
* Creates a new dictionary to tune a kind of samples
@@ -880,12 +894,29 @@ public static long trainFromBuffer(byte[][] samples, byte[] dictBuffer, boolean
880
894
* it fails (which can be tested using ZSTD_isError())
881
895
*/
882
896
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 ) {
883
912
if (sampleSizes .length <= 10 ) {
884
913
throw new ZstdException (Zstd .errGeneric (), "nb of samples too low" );
885
914
}
886
- return trainFromBufferDirect0 (samples , sampleSizes , dictBuffer , legacy );
915
+ return trainFromBufferDirect0 (samples , sampleSizes , dictBuffer , legacy , compressionLevel );
887
916
}
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 );
889
920
890
921
/**
891
922
* Get DictId from a compressed frame
0 commit comments