You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2016/02/24 15:54:02 UTC
[1/6] commons-compress git commit: Working version of deferred block
decompression for skipped entries.
Repository: commons-compress
Updated Branches:
refs/heads/master 3baf454c2 -> 1d66f1208
Working version of deferred block decompression for skipped entries.
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/a53ab172
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/a53ab172
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/a53ab172
Branch: refs/heads/master
Commit: a53ab172b2a9b7c1a57be9f8d6dc82977af02bff
Parents: deb891f
Author: Dawid Weiss <da...@carrotsearch.com>
Authored: Tue Feb 23 16:19:25 2016 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Wed Feb 24 15:42:19 2016 +0100
----------------------------------------------------------------------
.../compress/archivers/sevenz/SevenZFile.java | 72 +++++++++++---------
1 file changed, 41 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/a53ab172/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
index 90bda16..60ffea8 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
@@ -26,6 +26,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.LinkedList;
@@ -74,9 +75,10 @@ public class SevenZFile implements Closeable {
private int currentEntryIndex = -1;
private int currentFolderIndex = -1;
private InputStream currentFolderInputStream = null;
- private InputStream currentEntryInputStream = null;
private byte[] password;
-
+
+ private ArrayList<InputStream> deferredBlockStreams = new ArrayList<InputStream>();
+
static final byte[] sevenZSignature = {
(byte)'7', (byte)'z', (byte)0xBC, (byte)0xAF, (byte)0x27, (byte)0x1C
};
@@ -809,17 +811,25 @@ public class SevenZFile implements Closeable {
private void buildDecodingStream() throws IOException {
final int folderIndex = archive.streamMap.fileFolderIndex[currentEntryIndex];
if (folderIndex < 0) {
- currentEntryInputStream = new BoundedInputStream(
- new ByteArrayInputStream(new byte[0]), 0);
+ deferredBlockStreams.clear();
+ // TODO: previously it'd return an empty stream?
+ // new BoundedInputStream(new ByteArrayInputStream(new byte[0]), 0);
return;
}
final SevenZArchiveEntry file = archive.files[currentEntryIndex];
if (currentFolderIndex == folderIndex) {
+ // (COMPRESS-320).
+ // The current entry is within the same (potentially opened) folder. The
+ // previous stream has to be fully decoded before we can start reading
+ // but don't do it eagerly -- if the user skips over the entire folder nothing
+ // is effectively decompressed.
+
// need to advance the folder input stream past the current file
- drainPreviousEntry();
file.setContentMethods(archive.files[currentEntryIndex - 1].getContentMethods());
} else {
+ // We're opening a new folder. Discard any queued streams/ folder stream.
currentFolderIndex = folderIndex;
+ deferredBlockStreams.clear();
if (currentFolderInputStream != null) {
currentFolderInputStream.close();
currentFolderInputStream = null;
@@ -831,26 +841,15 @@ public class SevenZFile implements Closeable {
archive.streamMap.packStreamOffsets[firstPackStreamIndex];
currentFolderInputStream = buildDecoderStack(folder, folderOffset, firstPackStreamIndex, file);
}
- final InputStream fileStream = new BoundedInputStream(
- currentFolderInputStream, file.getSize());
+
+ InputStream fileStream = new BoundedInputStream(currentFolderInputStream, file.getSize());
if (file.getHasCrc()) {
- currentEntryInputStream = new CRC32VerifyingInputStream(
- fileStream, file.getSize(), file.getCrcValue());
- } else {
- currentEntryInputStream = fileStream;
+ fileStream = new CRC32VerifyingInputStream(fileStream, file.getSize(), file.getCrcValue());
}
+ deferredBlockStreams.add(fileStream);
}
-
- private void drainPreviousEntry() throws IOException {
- if (currentEntryInputStream != null) {
- // return value ignored as IOUtils.skip ensures the stream is drained completely
- IOUtils.skip(currentEntryInputStream, Long.MAX_VALUE);
- currentEntryInputStream.close();
- currentEntryInputStream = null;
- }
- }
-
+
private InputStream buildDecoderStack(final Folder folder, final long folderOffset,
final int firstPackStreamIndex, SevenZArchiveEntry entry) throws IOException {
file.seek(folderOffset);
@@ -886,13 +885,27 @@ public class SevenZFile implements Closeable {
* if an I/O error has occurred
*/
public int read() throws IOException {
- if (currentEntryInputStream == null) {
- throw new IllegalStateException("No current 7z entry");
- }
- return currentEntryInputStream.read();
+ return getCurrentStream().read();
}
- /**
+ private InputStream getCurrentStream() throws IOException {
+ if (deferredBlockStreams.isEmpty()) {
+ throw new IllegalStateException("No current 7z entry (call getNextEntry() first).");
+ }
+
+ while (deferredBlockStreams.size() > 1) {
+ // In solid compression mode we need to decompress all leading folder'
+ // streams to get access to an entry. We defer this until really needed
+ // so that entire blocks can be skipped without wasting time for decompression.
+ InputStream stream = deferredBlockStreams.remove(0);
+ IOUtils.skip(stream, Long.MAX_VALUE);
+ stream.close();
+ }
+
+ return deferredBlockStreams.get(0);
+ }
+
+ /**
* Reads data into an array of bytes.
*
* @param b the array to write data to
@@ -901,7 +914,7 @@ public class SevenZFile implements Closeable {
* if an I/O error has occurred
*/
public int read(byte[] b) throws IOException {
- return read(b, 0, b.length);
+ return read(b, 0, b.length);
}
/**
@@ -915,10 +928,7 @@ public class SevenZFile implements Closeable {
* if an I/O error has occurred
*/
public int read(byte[] b, int off, int len) throws IOException {
- if (currentEntryInputStream == null) {
- throw new IllegalStateException("No current 7z entry");
- }
- return currentEntryInputStream.read(b, off, len);
+ return getCurrentStream().read(b, off, len);
}
private static long readUint64(final DataInput in) throws IOException {
[5/6] commons-compress git commit: whitespace
Posted by bo...@apache.org.
whitespace
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/5457e1a2
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/5457e1a2
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/5457e1a2
Branch: refs/heads/master
Commit: 5457e1a23693695c3023a7416b2f60aabb299430
Parents: a53ab17
Author: Stefan Bodewig <bo...@apache.org>
Authored: Wed Feb 24 15:48:35 2016 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Wed Feb 24 15:48:35 2016 +0100
----------------------------------------------------------------------
.../compress/archivers/sevenz/SevenZFile.java | 41 ++++---
.../archivers/sevenz/SevenZFileTest.java | 106 +++++++++----------
2 files changed, 73 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/5457e1a2/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
index 60ffea8..4a86dd2 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
@@ -811,25 +811,24 @@ public class SevenZFile implements Closeable {
private void buildDecodingStream() throws IOException {
final int folderIndex = archive.streamMap.fileFolderIndex[currentEntryIndex];
if (folderIndex < 0) {
- deferredBlockStreams.clear();
+ deferredBlockStreams.clear();
// TODO: previously it'd return an empty stream?
- // new BoundedInputStream(new ByteArrayInputStream(new byte[0]), 0);
+ // new BoundedInputStream(new ByteArrayInputStream(new byte[0]), 0);
return;
}
final SevenZArchiveEntry file = archive.files[currentEntryIndex];
if (currentFolderIndex == folderIndex) {
- // (COMPRESS-320).
- // The current entry is within the same (potentially opened) folder. The
- // previous stream has to be fully decoded before we can start reading
- // but don't do it eagerly -- if the user skips over the entire folder nothing
- // is effectively decompressed.
+ // (COMPRESS-320).
+ // The current entry is within the same (potentially opened) folder. The
+ // previous stream has to be fully decoded before we can start reading
+ // but don't do it eagerly -- if the user skips over the entire folder nothing
+ // is effectively decompressed.
- // need to advance the folder input stream past the current file
file.setContentMethods(archive.files[currentEntryIndex - 1].getContentMethods());
} else {
- // We're opening a new folder. Discard any queued streams/ folder stream.
+ // We're opening a new folder. Discard any queued streams/ folder stream.
currentFolderIndex = folderIndex;
- deferredBlockStreams.clear();
+ deferredBlockStreams.clear();
if (currentFolderInputStream != null) {
currentFolderInputStream.close();
currentFolderInputStream = null;
@@ -885,7 +884,7 @@ public class SevenZFile implements Closeable {
* if an I/O error has occurred
*/
public int read() throws IOException {
- return getCurrentStream().read();
+ return getCurrentStream().read();
}
private InputStream getCurrentStream() throws IOException {
@@ -894,18 +893,18 @@ public class SevenZFile implements Closeable {
}
while (deferredBlockStreams.size() > 1) {
- // In solid compression mode we need to decompress all leading folder'
- // streams to get access to an entry. We defer this until really needed
- // so that entire blocks can be skipped without wasting time for decompression.
- InputStream stream = deferredBlockStreams.remove(0);
- IOUtils.skip(stream, Long.MAX_VALUE);
- stream.close();
+ // In solid compression mode we need to decompress all leading folder'
+ // streams to get access to an entry. We defer this until really needed
+ // so that entire blocks can be skipped without wasting time for decompression.
+ InputStream stream = deferredBlockStreams.remove(0);
+ IOUtils.skip(stream, Long.MAX_VALUE);
+ stream.close();
}
- return deferredBlockStreams.get(0);
- }
+ return deferredBlockStreams.get(0);
+ }
- /**
+ /**
* Reads data into an array of bytes.
*
* @param b the array to write data to
@@ -914,7 +913,7 @@ public class SevenZFile implements Closeable {
* if an I/O error has occurred
*/
public int read(byte[] b) throws IOException {
- return read(b, 0, b.length);
+ return read(b, 0, b.length);
}
/**
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/5457e1a2/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
index fe47652..a57d4cb 100644
--- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
@@ -41,64 +41,64 @@ public class SevenZFileTest extends AbstractTestCase {
// https://issues.apache.org/jira/browse/COMPRESS-320
@Test
public void testRandomlySkippingEntries() throws Exception {
- // Read sequential reference.
- Map<String, byte[]> entriesByName = new HashMap<String, byte[]>();
- SevenZFile archive = new SevenZFile(getFile("COMPRESS-320/Copy.7z"));
- SevenZArchiveEntry entry;
- while ((entry = archive.getNextEntry()) != null) {
- if (entry.hasStream()) {
- entriesByName.put(entry.getName(), readFully(archive));
- }
- }
- archive.close();
+ // Read sequential reference.
+ Map<String, byte[]> entriesByName = new HashMap<String, byte[]>();
+ SevenZFile archive = new SevenZFile(getFile("COMPRESS-320/Copy.7z"));
+ SevenZArchiveEntry entry;
+ while ((entry = archive.getNextEntry()) != null) {
+ if (entry.hasStream()) {
+ entriesByName.put(entry.getName(), readFully(archive));
+ }
+ }
+ archive.close();
- String[] variants = {
- "BZip2-solid.7z",
- "BZip2.7z",
- "Copy-solid.7z",
- "Copy.7z",
- "Deflate-solid.7z",
- "Deflate.7z",
- "LZMA-solid.7z",
- "LZMA.7z",
- "LZMA2-solid.7z",
- "LZMA2.7z",
- // TODO: unsupported compression method.
- // "PPMd-solid.7z",
- // "PPMd.7z",
- };
+ String[] variants = {
+ "BZip2-solid.7z",
+ "BZip2.7z",
+ "Copy-solid.7z",
+ "Copy.7z",
+ "Deflate-solid.7z",
+ "Deflate.7z",
+ "LZMA-solid.7z",
+ "LZMA.7z",
+ "LZMA2-solid.7z",
+ "LZMA2.7z",
+ // TODO: unsupported compression method.
+ // "PPMd-solid.7z",
+ // "PPMd.7z",
+ };
- // TODO: use randomizedtesting for predictable, but different, randomness.
- Random rnd = new Random(0xdeadbeef);
- for (String fileName : variants) {
- archive = new SevenZFile(getFile("COMPRESS-320/" + fileName));
+ // TODO: use randomizedtesting for predictable, but different, randomness.
+ Random rnd = new Random(0xdeadbeef);
+ for (String fileName : variants) {
+ archive = new SevenZFile(getFile("COMPRESS-320/" + fileName));
- while ((entry = archive.getNextEntry()) != null) {
- // Sometimes skip reading entries.
- if (rnd.nextBoolean()) {
- continue;
- }
+ while ((entry = archive.getNextEntry()) != null) {
+ // Sometimes skip reading entries.
+ if (rnd.nextBoolean()) {
+ continue;
+ }
- if (entry.hasStream()) {
- assertTrue(entriesByName.containsKey(entry.getName()));
- byte [] content = readFully(archive);
- assertTrue("Content mismatch on: " + fileName + "!" + entry.getName(),
- Arrays.equals(content, entriesByName.get(entry.getName())));
- }
- }
-
- archive.close();
- }
+ if (entry.hasStream()) {
+ assertTrue(entriesByName.containsKey(entry.getName()));
+ byte [] content = readFully(archive);
+ assertTrue("Content mismatch on: " + fileName + "!" + entry.getName(),
+ Arrays.equals(content, entriesByName.get(entry.getName())));
+ }
+ }
+
+ archive.close();
+ }
}
- private byte [] readFully(SevenZFile archive) throws IOException {
- byte [] buf = new byte [1024];
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- for (int len = 0; (len = archive.read(buf)) > 0;) {
- baos.write(buf, 0, len);
- }
- return baos.toByteArray();
- }
+ private byte[] readFully(SevenZFile archive) throws IOException {
+ byte [] buf = new byte [1024];
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ for (int len = 0; (len = archive.read(buf)) > 0;) {
+ baos.write(buf, 0, len);
+ }
+ return baos.toByteArray();
+ }
@Test
public void testAllEmptyFilesArchive() throws Exception {
@@ -109,7 +109,7 @@ public class SevenZFileTest extends AbstractTestCase {
archive.close();
}
}
-
+
@Test
public void testHelloWorldHeaderCompressionOffCopy() throws Exception {
checkHelloWorld("7z-hello-mhc-off-copy.7z");
[4/6] commons-compress git commit: Adding a batch of decompression
tests.
Posted by bo...@apache.org.
Adding a batch of decompression tests.
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/617860eb
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/617860eb
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/617860eb
Branch: refs/heads/master
Commit: 617860eb422480c46f74b3c1fa6b1087f491db38
Parents: ebeb53d
Author: Dawid Weiss <da...@carrotsearch.com>
Authored: Tue Feb 23 15:52:15 2016 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Wed Feb 24 15:42:19 2016 +0100
----------------------------------------------------------------------
.../archivers/sevenz/SevenZFileTest.java | 63 +++++++++++++++++++
src/test/resources/COMPRESS-320/BZip2-solid.7z | Bin 0 -> 66992 bytes
src/test/resources/COMPRESS-320/BZip2.7z | Bin 0 -> 98148 bytes
src/test/resources/COMPRESS-320/Copy-solid.7z | Bin 0 -> 325679 bytes
src/test/resources/COMPRESS-320/Copy.7z | Bin 0 -> 325669 bytes
.../resources/COMPRESS-320/Deflate-solid.7z | Bin 0 -> 73730 bytes
src/test/resources/COMPRESS-320/Deflate.7z | Bin 0 -> 97803 bytes
src/test/resources/COMPRESS-320/LZMA-solid.7z | Bin 0 -> 64813 bytes
src/test/resources/COMPRESS-320/LZMA.7z | Bin 0 -> 95391 bytes
src/test/resources/COMPRESS-320/LZMA2-solid.7z | Bin 0 -> 64845 bytes
src/test/resources/COMPRESS-320/LZMA2.7z | Bin 0 -> 95705 bytes
src/test/resources/COMPRESS-320/PPMd-solid.7z | Bin 0 -> 61452 bytes
src/test/resources/COMPRESS-320/PPMd.7z | Bin 0 -> 86170 bytes
src/test/resources/COMPRESS-320/recreate.sh | 9 +++
14 files changed, 72 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/617860eb/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
index 196d040..ce17218 100644
--- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
@@ -19,10 +19,16 @@ package org.apache.commons.compress.archivers.sevenz;
import static org.junit.Assert.*;
+import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.crypto.Cipher;
+
import org.apache.commons.compress.AbstractTestCase;
import org.apache.commons.compress.PasswordRequiredException;
import org.junit.Test;
@@ -31,6 +37,63 @@ public class SevenZFileTest extends AbstractTestCase {
private static final String TEST2_CONTENT = "<?xml version = '1.0'?>\r\n<!DOCTYPE"
+ " connections>\r\n<meinxml>\r\n\t<leer />\r\n</meinxml>\n";
+ // https://issues.apache.org/jira/browse/COMPRESS-320
+ @Test
+ public void testRandomlySkippingEntries() throws Exception {
+ // Read sequential reference.
+ Map<String, byte[]> entriesByName = new HashMap<String, byte[]>();
+ SevenZFile archive = new SevenZFile(getFile("COMPRESS-320/Copy.7z"));
+ SevenZArchiveEntry entry;
+ while ((entry = archive.getNextEntry()) != null) {
+ if (entry.hasStream()) {
+ entriesByName.put(entry.getName(), readFully(archive));
+ }
+ }
+ archive.close();
+
+ String[] variants = {
+ "BZip2-solid.7z",
+ "BZip2.7z",
+ "Copy-solid.7z",
+ "Copy.7z",
+ "Deflate-solid.7z",
+ "Deflate.7z",
+ "LZMA-solid.7z",
+ "LZMA.7z",
+ "LZMA2-solid.7z",
+ "LZMA2.7z",
+ // TODO: unsupported compression method.
+ // "PPMd-solid.7z",
+ // "PPMd.7z",
+ };
+
+ for (String fileName : variants) {
+ archive = new SevenZFile(getFile("COMPRESS-320/" + fileName));
+
+ while ((entry = archive.getNextEntry()) != null) {
+ // TODO: randomly skip reading entries.
+
+ if (entry.hasStream()) {
+ assertTrue(entriesByName.containsKey(entry.getName()));
+ byte [] content = readFully(archive);
+ assertTrue("Content mismatch on: " + fileName + "!" + entry.getName(),
+ Arrays.equals(content, entriesByName.get(entry.getName())));
+ }
+ }
+
+ archive.close();
+ }
+ }
+
+ private byte [] readFully(SevenZFile archive) throws IOException {
+ byte [] buf = new byte [1024];
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ for (int len = 0; (len = archive.read(buf)) > 0;) {
+ baos.write(buf, 0, len);
+ }
+ return baos.toByteArray();
+ }
+
@Test
public void testAllEmptyFilesArchive() throws Exception {
SevenZFile archive = new SevenZFile(getFile("7z-empty-mhc-off.7z"));
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/617860eb/src/test/resources/COMPRESS-320/BZip2-solid.7z
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-320/BZip2-solid.7z b/src/test/resources/COMPRESS-320/BZip2-solid.7z
new file mode 100644
index 0000000..a1ff11b
Binary files /dev/null and b/src/test/resources/COMPRESS-320/BZip2-solid.7z differ
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/617860eb/src/test/resources/COMPRESS-320/BZip2.7z
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-320/BZip2.7z b/src/test/resources/COMPRESS-320/BZip2.7z
new file mode 100644
index 0000000..3272ecd
Binary files /dev/null and b/src/test/resources/COMPRESS-320/BZip2.7z differ
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/617860eb/src/test/resources/COMPRESS-320/Copy-solid.7z
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-320/Copy-solid.7z b/src/test/resources/COMPRESS-320/Copy-solid.7z
new file mode 100644
index 0000000..008564d
Binary files /dev/null and b/src/test/resources/COMPRESS-320/Copy-solid.7z differ
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/617860eb/src/test/resources/COMPRESS-320/Copy.7z
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-320/Copy.7z b/src/test/resources/COMPRESS-320/Copy.7z
new file mode 100644
index 0000000..958cd8f
Binary files /dev/null and b/src/test/resources/COMPRESS-320/Copy.7z differ
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/617860eb/src/test/resources/COMPRESS-320/Deflate-solid.7z
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-320/Deflate-solid.7z b/src/test/resources/COMPRESS-320/Deflate-solid.7z
new file mode 100644
index 0000000..00eb84d
Binary files /dev/null and b/src/test/resources/COMPRESS-320/Deflate-solid.7z differ
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/617860eb/src/test/resources/COMPRESS-320/Deflate.7z
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-320/Deflate.7z b/src/test/resources/COMPRESS-320/Deflate.7z
new file mode 100644
index 0000000..b5e3570
Binary files /dev/null and b/src/test/resources/COMPRESS-320/Deflate.7z differ
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/617860eb/src/test/resources/COMPRESS-320/LZMA-solid.7z
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-320/LZMA-solid.7z b/src/test/resources/COMPRESS-320/LZMA-solid.7z
new file mode 100644
index 0000000..5f55993
Binary files /dev/null and b/src/test/resources/COMPRESS-320/LZMA-solid.7z differ
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/617860eb/src/test/resources/COMPRESS-320/LZMA.7z
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-320/LZMA.7z b/src/test/resources/COMPRESS-320/LZMA.7z
new file mode 100644
index 0000000..3416d11
Binary files /dev/null and b/src/test/resources/COMPRESS-320/LZMA.7z differ
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/617860eb/src/test/resources/COMPRESS-320/LZMA2-solid.7z
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-320/LZMA2-solid.7z b/src/test/resources/COMPRESS-320/LZMA2-solid.7z
new file mode 100644
index 0000000..5a9f807
Binary files /dev/null and b/src/test/resources/COMPRESS-320/LZMA2-solid.7z differ
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/617860eb/src/test/resources/COMPRESS-320/LZMA2.7z
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-320/LZMA2.7z b/src/test/resources/COMPRESS-320/LZMA2.7z
new file mode 100644
index 0000000..c6c8347
Binary files /dev/null and b/src/test/resources/COMPRESS-320/LZMA2.7z differ
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/617860eb/src/test/resources/COMPRESS-320/PPMd-solid.7z
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-320/PPMd-solid.7z b/src/test/resources/COMPRESS-320/PPMd-solid.7z
new file mode 100644
index 0000000..5a3ee0a
Binary files /dev/null and b/src/test/resources/COMPRESS-320/PPMd-solid.7z differ
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/617860eb/src/test/resources/COMPRESS-320/PPMd.7z
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-320/PPMd.7z b/src/test/resources/COMPRESS-320/PPMd.7z
new file mode 100644
index 0000000..237396a
Binary files /dev/null and b/src/test/resources/COMPRESS-320/PPMd.7z differ
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/617860eb/src/test/resources/COMPRESS-320/recreate.sh
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-320/recreate.sh b/src/test/resources/COMPRESS-320/recreate.sh
new file mode 100644
index 0000000..09bd0dc
--- /dev/null
+++ b/src/test/resources/COMPRESS-320/recreate.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+rm *.7z
+for COMPRESSION in "LZMA" "LZMA2" "PPMd" "BZip2" "Deflate" "Copy"; do
+ # New solid block every 10 files.
+ 7za a -m0=$COMPRESSION -ms10f $COMPRESSION-solid.7z ../../../../src/main/java/org/apache/commons/compress/compressors
+ # Each file in isolation
+ 7za a -m0=$COMPRESSION -ms=off $COMPRESSION.7z ../../../../src/main/java/org/apache/commons/compress/compressors
+done
[2/6] commons-compress git commit: Add toString() method on
SevenZFile to display diagnostic information.
Posted by bo...@apache.org.
Add toString() method on SevenZFile to display diagnostic information.
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/ebeb53d1
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/ebeb53d1
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/ebeb53d1
Branch: refs/heads/master
Commit: ebeb53d1ca716035748acaafffb7650a9b435678
Parents: 3baf454
Author: Dawid Weiss <da...@carrotsearch.com>
Authored: Tue Feb 23 13:52:26 2016 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Wed Feb 24 15:42:19 2016 +0100
----------------------------------------------------------------------
.../apache/commons/compress/archivers/sevenz/SevenZFile.java | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/ebeb53d1/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
index 809a9dc..90bda16 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
@@ -983,4 +983,9 @@ public class SevenZFile implements Closeable {
}
return skipped;
}
+
+ @Override
+ public String toString() {
+ return archive.toString();
+ }
}
[6/6] commons-compress git commit: document Dawid's changes
Posted by bo...@apache.org.
document Dawid's changes
closes #8
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/1d66f120
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/1d66f120
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/1d66f120
Branch: refs/heads/master
Commit: 1d66f12089aadbc90924ecad82e974d0491d62b4
Parents: 5457e1a
Author: Stefan Bodewig <bo...@apache.org>
Authored: Wed Feb 24 15:53:21 2016 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Wed Feb 24 15:53:21 2016 +0100
----------------------------------------------------------------------
src/changes/changes.xml | 7 +++++++
1 file changed, 7 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/1d66f120/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index e2a6961..1d19194 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -44,6 +44,13 @@ The <action> type attribute can be add,update,fix,remove.
<body>
<release version="1.11" date="not released, yet"
description="Release 1.11">
+ <action issue="COMPRESS-320" type="fix" date="2016-02-24"
+ due-to="Dawid Weiss">
+ SevenZFile will now only try to drain an entry's content when
+ moving on to the next entry if data is read from the next
+ entry. This should improve performance for applications that
+ try to skip over entries.
+ </action>
<action issue="COMPRESS-336" type="fix" date="2016-02-14">
file names of tar archives using the xstar format are now
parsed properly.
[3/6] commons-compress git commit: Sometimes skip entries.
Posted by bo...@apache.org.
Sometimes skip entries.
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/deb891f8
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/deb891f8
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/deb891f8
Branch: refs/heads/master
Commit: deb891f8fe6ff72cfab4c63eb975207fc359e62a
Parents: 617860e
Author: Dawid Weiss <da...@carrotsearch.com>
Authored: Tue Feb 23 15:55:26 2016 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Wed Feb 24 15:42:19 2016 +0100
----------------------------------------------------------------------
.../commons/compress/archivers/sevenz/SevenZFileTest.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/deb891f8/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
index ce17218..fe47652 100644
--- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
@@ -26,6 +26,7 @@ import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
+import java.util.Random;
import javax.crypto.Cipher;
@@ -67,11 +68,16 @@ public class SevenZFileTest extends AbstractTestCase {
// "PPMd.7z",
};
+ // TODO: use randomizedtesting for predictable, but different, randomness.
+ Random rnd = new Random(0xdeadbeef);
for (String fileName : variants) {
archive = new SevenZFile(getFile("COMPRESS-320/" + fileName));
while ((entry = archive.getNextEntry()) != null) {
- // TODO: randomly skip reading entries.
+ // Sometimes skip reading entries.
+ if (rnd.nextBoolean()) {
+ continue;
+ }
if (entry.hasStream()) {
assertTrue(entriesByName.containsKey(entry.getName()));