diff --git a/build.gradle b/build.gradle index ae45d019..d4df35fb 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ compileTestJava { } repositories { - maven { url uri('/home/gspowley/.m2/repository/')} + // maven { url uri('/home/gspowley/.m2/repository/')} mavenLocal() mavenCentral() maven { url "https://artifactory.broadinstitute.org/artifactory/libs-snapshot/" } @@ -24,7 +24,7 @@ dependencies { compile 'org.broadinstitute:gatk-native-bindings:0.0.3' compile 'org.apache.logging.log4j:log4j-api:2.5' compile 'org.apache.logging.log4j:log4j-core:2.5' - compile 'com.github.samtools:htsjdk:2.7.0-18-g4d0070b-SNAPSHOT' + compile 'com.github.samtools:htsjdk:2.8.1-28-g3a8fa8e-SNAPSHOT' testCompile 'org.testng:testng:6.9.9' } diff --git a/src/main/java/com/intel/gkl/compression/IntelDeflater.java b/src/main/java/com/intel/gkl/compression/IntelDeflater.java index ec29e6f2..4953e547 100644 --- a/src/main/java/com/intel/gkl/compression/IntelDeflater.java +++ b/src/main/java/com/intel/gkl/compression/IntelDeflater.java @@ -79,6 +79,7 @@ public synchronized boolean load(File tempDir) { private int level; private int strategy; private boolean nowrap; + /** * Creates a new compressor using the specified compression level. @@ -119,6 +120,7 @@ public void reset() { resetNative(nowrap); inputBuffer = null; inputBufferLength = 0; + endOfStream = false; finished = false; } @@ -142,6 +144,8 @@ public void setInput(byte[] b, int off, int len) throws NullPointerException { inputBuffer = b; inputBufferLength = len; + + } /** @@ -167,6 +171,7 @@ public void finish() { */ @Override public int deflate(byte[] b, int off, int len ) { + return deflateNative(b, len); } diff --git a/src/main/java/com/intel/gkl/compression/IntelInflaterFactory.java b/src/main/java/com/intel/gkl/compression/IntelInflaterFactory.java index 9ae473bc..9aaaade0 100644 --- a/src/main/java/com/intel/gkl/compression/IntelInflaterFactory.java +++ b/src/main/java/com/intel/gkl/compression/IntelInflaterFactory.java @@ -24,7 +24,7 @@ public IntelInflaterFactory() { } public Inflater makeInflater(final boolean nowrap) { - if (intelInflaterSupported) { + if (intelInflaterSupported && nowrap) { return new IntelInflater(nowrap); } logger.warn("IntelInflater is not supported, using Java.util.zip.Inflater"); diff --git a/src/main/native/compression/IntelDeflater.cc b/src/main/native/compression/IntelDeflater.cc index 76b0d5e6..676a3194 100644 --- a/src/main/native/compression/IntelDeflater.cc +++ b/src/main/native/compression/IntelDeflater.cc @@ -54,8 +54,8 @@ static jfieldID FID_inputBuffer; static jfieldID FID_inputBufferLength; static jfieldID FID_endOfStream; static jfieldID FID_finished; -static jfieldID FID_finish; static jfieldID FID_level; +//static jfieldID FID_inputBufferOffset; @@ -69,8 +69,8 @@ JNIEXPORT void JNICALL Java_com_intel_gkl_compression_IntelDeflater_initNative FID_inputBufferLength = env->GetFieldID(cls, "inputBufferLength", "I"); FID_endOfStream = env->GetFieldID(cls, "endOfStream", "Z"); FID_finished = env->GetFieldID(cls, "finished", "Z"); - FID_finish = env->GetFieldID(cls, "finish", "Z"); FID_level = env->GetFieldID(cls,"level","I"); +// FID_inputBufferOffset = env->GetFieldID(cls, "inputBufferOffset", "I"); } @@ -185,9 +185,10 @@ JNIEXPORT jint JNICALL Java_com_intel_gkl_compression_IntelDeflater_deflateNativ jbyteArray inputBuffer = (jbyteArray)env->GetObjectField(obj, FID_inputBuffer); jint inputBufferLength = env->GetIntField(obj, FID_inputBufferLength); + //jint inputBufferOffset = env->GetIntField(obj, FID_inputBufferOffset); jboolean endOfStream = env->GetBooleanField(obj, FID_endOfStream); jint level = env->GetIntField(obj, FID_level); - jboolean finish = env->GetBooleanField(obj, FID_finish); + if(level == 1) { @@ -198,11 +199,11 @@ JNIEXPORT jint JNICALL Java_com_intel_gkl_compression_IntelDeflater_deflateNativ jbyte* next_in = (jbyte*)env->GetPrimitiveArrayCritical(inputBuffer, 0); jbyte* next_out = (jbyte*)env->GetPrimitiveArrayCritical(outputBuffer, 0); - lz_stream->next_in = (UINT8*)next_in; + lz_stream->next_in = (UINT8*)(next_in); lz_stream->avail_in = inputBufferLength; lz_stream->end_of_stream = endOfStream; - lz_stream->next_out = (UINT8*)next_out; - lz_stream->avail_out = outputBufferLength; + lz_stream->next_out = (UINT8*) (next_out); + lz_stream->avail_out = outputBufferLength ; int bytes_in = inputBufferLength; @@ -316,4 +317,5 @@ Java_com_intel_gkl_compression_IntelDeflater_endNative(JNIEnv *env, jobject obj) if (level != 1) { deflateEnd(lz_stream); } + else free(lz_stream); } diff --git a/src/main/native/compression/IntelInflater.cc b/src/main/native/compression/IntelInflater.cc index fba9b168..c01cf0ab 100644 --- a/src/main/native/compression/IntelInflater.cc +++ b/src/main/native/compression/IntelInflater.cc @@ -83,7 +83,7 @@ JNIEXPORT void JNICALL Java_com_intel_gkl_compression_IntelInflater_resetNative } env->SetLongField(obj, FID_inf_lz_stream, (jlong)lz_stream); - + } isal_inflate_init(lz_stream); lz_stream->avail_in = 0; @@ -91,8 +91,6 @@ JNIEXPORT void JNICALL Java_com_intel_gkl_compression_IntelInflater_resetNative lz_stream->avail_out = 0; lz_stream->next_out = Z_NULL; - } - } diff --git a/src/test/java/com/intel/gkl/compression/InflaterUnitTest.java b/src/test/java/com/intel/gkl/compression/InflaterUnitTest.java index ceb62729..bdfbe24d 100644 --- a/src/test/java/com/intel/gkl/compression/InflaterUnitTest.java +++ b/src/test/java/com/intel/gkl/compression/InflaterUnitTest.java @@ -21,9 +21,10 @@ public class InflaterUnitTest { private final static String INPUT_FILE = IntelGKLUtils.pathToTestResource("HiSeq.1mb.1RG.2k_lines.bam"); @Test(enabled = true) - public void integrationTest() throws IOException { + public void inflaterUnitTest() throws IOException { final File inputFile = new File(INPUT_FILE); + long inputBytes = inputFile.length(); int compressedBytes = 0; final byte[] inputbuffer = new byte[(int)inputBytes]; @@ -66,5 +67,7 @@ public void integrationTest() throws IOException { inflater.end(); deflater.end(); } + + } }