use of com.intel.gkl.compression.IntelInflaterFactory in project gatk by broadinstitute.
the class CommandLineProgram method instanceMainPostParseArgs.
public Object instanceMainPostParseArgs() {
// Provide one temp directory if the caller didn't
if (this.TMP_DIR == null)
this.TMP_DIR = new ArrayList<>();
if (this.TMP_DIR.isEmpty())
TMP_DIR.add(IOUtil.getDefaultTmpDir());
// Build the default headers
final ZonedDateTime startDateTime = ZonedDateTime.now();
this.defaultHeaders.add(new StringHeader(commandLine));
this.defaultHeaders.add(new StringHeader("Started on: " + Utils.getDateTimeForDisplay(startDateTime)));
// propagate the VERBOSITY level to logging frameworks
LoggingUtils.setLoggingLevel(VERBOSITY);
for (final File f : TMP_DIR) {
// need a tmp_dir. If this fails, the problem will be discovered downstream.
if (!f.exists())
f.mkdirs();
f.setReadable(true, false);
f.setWritable(true, false);
// in loop so that last one takes effect
System.setProperty("java.io.tmpdir", f.getAbsolutePath());
}
//Set defaults (note: setting them here means they are not controllable by the user)
if (!useJdkDeflater) {
BlockCompressedOutputStream.setDefaultDeflaterFactory(new IntelDeflaterFactory());
}
if (!useJdkInflater) {
BlockGunzipper.setDefaultInflaterFactory(new IntelInflaterFactory());
}
if (!QUIET) {
System.err.println("[" + Utils.getDateTimeForDisplay(startDateTime) + "] " + commandLine);
// Output a one liner about who/where and what software/os we're running on
try {
System.err.println("[" + Utils.getDateTimeForDisplay(startDateTime) + "] Executing as " + System.getProperty("user.name") + "@" + InetAddress.getLocalHost().getHostName() + " on " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch") + "; " + System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version") + "; Version: " + getVersion());
// Print important settings to the logger:
printSettings();
} catch (final Exception e) {
/* Unpossible! */
}
}
try {
return runTool();
} finally {
// Emit the time even if program throws
if (!QUIET) {
final ZonedDateTime endDateTime = ZonedDateTime.now();
final double elapsedMinutes = (Duration.between(startDateTime, endDateTime).toMillis()) / (1000d * 60d);
final String elapsedString = new DecimalFormat("#,##0.00").format(elapsedMinutes);
System.err.println("[" + Utils.getDateTimeForDisplay(endDateTime) + "] " + getClass().getName() + " done. Elapsed time: " + elapsedString + " minutes.");
System.err.println("Runtime.totalMemory()=" + Runtime.getRuntime().totalMemory());
}
}
}
use of com.intel.gkl.compression.IntelInflaterFactory in project gatk by broadinstitute.
the class IntelInflaterDeflaterIntegrationTest method deflateInflateWithIntel.
@Test
public void deflateInflateWithIntel() throws DataFormatException {
if (!isIntelInflaterDeflaterSupported()) {
throw new SkipException("IntelInflater/IntelDeflater not available on this platform");
}
// create buffers and random input
final int LEN = 64 * 1024;
final byte[] input = new RandomDNA().nextBases(LEN);
final byte[] compressed = new byte[2 * LEN];
final byte[] result = new byte[LEN];
final IntelInflaterFactory intelInflaterFactory = new IntelInflaterFactory();
final IntelDeflaterFactory intelDeflaterFactory = new IntelDeflaterFactory();
Assert.assertTrue(intelInflaterFactory.usingIntelInflater());
Assert.assertTrue(intelDeflaterFactory.usingIntelDeflater());
for (int i = 0; i < 10; i++) {
// create deflater with compression level i
final Deflater deflater = intelDeflaterFactory.makeDeflater(i, true);
// setup deflater
deflater.setInput(input);
deflater.finish();
// compress data
int compressedBytes = 0;
// so this loop should always finish in one iteration
while (!deflater.finished()) {
compressedBytes = deflater.deflate(compressed, 0, compressed.length);
}
deflater.end();
// decompress and check output == input
Inflater inflater = intelInflaterFactory.makeInflater(true);
inflater.setInput(compressed, 0, compressedBytes);
inflater.inflate(result);
inflater.end();
Assert.assertEquals(input, result);
// clear compressed and result buffers for next iteration
Arrays.fill(compressed, (byte) 0);
Arrays.fill(result, (byte) 0);
}
}
Aggregations