List of usage examples for java.util.zip ZipEntry getCompressedSize
public long getCompressedSize()
From source file:reconcile.hbase.mapreduce.ZipInputFormat.java
private List<ZipEntrySplit> getZipFileEntries(JobContext context, FileSystem fs, Path[] zipFiles, Integer maxEntryFiles, Integer ignoreFilesLargerThanMB, List<String> processMimeTypes) throws IOException { ArrayList<ZipEntrySplit> splits = new ArrayList<ZipEntrySplit>(); ZipInputStream zis = null;/*from ww w . j a v a 2 s .c om*/ ZipEntry zipEntry = null; for (int i = 0; i < zipFiles.length; i++) { Path file = zipFiles[i]; LOG.debug("Opening zip file: " + file.toString()); try { zis = new ZipInputStream(fs.open(file)); while ((zipEntry = zis.getNextEntry()) != null) { if (maxEntryFiles != null && splits.size() == maxEntryFiles.intValue()) { LOG.debug("Exceeded maximum number of splits. End getSplits()"); return splits; } boolean processFile = true; if (processMimeTypes.size() > 0) { // Ensure that if process mime types were specified, that entry // mime type meets that criteria String mimeType = fileNameMap.getContentTypeFor(zipEntry.getName()); if (mimeType == null || (!processMimeTypes.contains(mimeType.toLowerCase()))) { processFile = false; LOG.debug("Ignoring entry file (" + zipEntry.getName() + " mimeType(" + mimeType + ") not in process list"); } } long byteCount = zipEntry.getSize(); /* if (byteCount <= 0) { // Read entry and figure out size for ourselves byteCount = 0; while (zis.available()==1) { zis.read(); ++byteCount; } } */ if (ignoreFilesLargerThanMB != null && byteCount > ignoreFilesLargerThanMB.intValue()) { processFile = false; LOG.debug("Ignoring entry file (" + zipEntry.getName() + ") which exceeds size limit"); } if (processFile) { LOG.debug("Creating split for zip entry: " + zipEntry.getName() + " Size: " + byteCount + " Method: " + (ZipEntry.DEFLATED == zipEntry.getMethod() ? "DEFLATED" : "STORED") + " Compressed Size: " + zipEntry.getCompressedSize()); ZipEntrySplit zipSplit = new ZipEntrySplit(file, zipEntry.getName(), zipEntry.getSize(), context); splits.add(zipSplit); } zis.closeEntry(); } } finally { IOUtils.closeQuietly(zis); } } return splits; }