Skip to content

Commit

Permalink
inflaterIntegrationTest
Browse files Browse the repository at this point in the history
  • Loading branch information
pnvaidya committed Feb 14, 2017
1 parent a68ccd1 commit fb5d0a2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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/" }
Expand All @@ -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'
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/intel/gkl/compression/IntelDeflater.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -119,6 +120,7 @@ public void reset() {
resetNative(nowrap);
inputBuffer = null;
inputBufferLength = 0;

endOfStream = false;
finished = false;
}
Expand All @@ -142,6 +144,8 @@ public void setInput(byte[] b, int off, int len) throws NullPointerException {

inputBuffer = b;
inputBufferLength = len;


}

/**
Expand All @@ -167,6 +171,7 @@ public void finish() {
*/
@Override
public int deflate(byte[] b, int off, int len ) {

return deflateNative(b, len);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
14 changes: 8 additions & 6 deletions src/main/native/compression/IntelDeflater.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;



Expand All @@ -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");

}

Expand Down Expand Up @@ -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) {

Expand All @@ -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;

Expand Down Expand Up @@ -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);
}
4 changes: 1 addition & 3 deletions src/main/native/compression/IntelInflater.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,14 @@ 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;
lz_stream->next_in = Z_NULL;
lz_stream->avail_out = 0;
lz_stream->next_out = Z_NULL;

}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -66,5 +67,7 @@ public void integrationTest() throws IOException {
inflater.end();
deflater.end();
}


}
}

0 comments on commit fb5d0a2

Please sign in to comment.