<commit_before>package gov.nih.nci.ncia.gridzip;

import gov.nih.nci.ivi.utils.ZipEntryOutputStream;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import org.apache.log4j.Logger;

public class ZipWorker implements Runnable {
	public ZipWorker(OutputStream outputStream,
			         Map<String, String> fileNames) {
		this.outputStream = outputStream;
		this.fileNames = fileNames;
	}

	public void run() {
        // now write to the output stream. for this test, use a zip
        // stream.
        // this is really to deal with the fact that we don't have a
        // good way to delimit the files.

        ZipEntryOutputStream zeos = null;
        BufferedInputStream dicomIn = null;
        ZipOutputStream zos = new ZipOutputStream(
                new BufferedOutputStream(outputStream));

        Set<String> keyset = fileNames.keySet();
        Iterator<String> iter = keyset.iterator();
        long start = System.currentTimeMillis();
        while (iter.hasNext()) {
            String sop =  iter.next();
             //System.out.println("sop: " + sop);
            String filePath = fileNames.get(sop);
             //System.out.println("filePath: " + filePath);
            try {
                zeos = new ZipEntryOutputStream(zos, sop,
                        ZipEntry.DEFLATED, -1);
                dicomIn = new BufferedInputStream(
                        new FileInputStream(filePath));

                byte[] data = new byte[BUFFER];
                int bytesRead = 0;
                while ((bytesRead = (dicomIn.read(data, 0, data.length))) > 0) {
                    zeos.write(data, 0, bytesRead);
                }
                
            } catch (IOException e1) {
                System.err.println("ERROR writing to zip entry "
                        + e1.getMessage());
                logger.error("Error writing to zip entry: ", e1);
                throw new RuntimeException(e1);
            } finally {
                try {
                	dicomIn.close();
                    zeos.flush();
                    zeos.close();                   
                } catch (IOException e) {                    <commit_msg>if file not found, ignore it<commit_after>package gov.nih.nci.ncia.gridzip;

import gov.nih.nci.ivi.utils.ZipEntryOutputStream;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import org.apache.log4j.Logger;

public class ZipWorker implements Runnable {
	public ZipWorker(OutputStream outputStream,
			         Map<String, String> fileNames) {
		this.outputStream = outputStream;
		this.fileNames = fileNames;
	}

	public void run() {
        // now write to the output stream. for this test, use a zip
        // stream.
        // this is really to deal with the fact that we don't have a
        // good way to delimit the files.

        ZipEntryOutputStream zeos = null;
        BufferedInputStream dicomIn = null;
        ZipOutputStream zos = new ZipOutputStream(
                new BufferedOutputStream(outputStream));

        Set<String> keyset = fileNames.keySet();
        Iterator<String> iter = keyset.iterator();
        long start = System.currentTimeMillis();
        while (iter.hasNext()) {
            String sop =  iter.next();
             //System.out.println("sop: " + sop);
            String filePath = fileNames.get(sop);
             //System.out.println("filePath: " + filePath);
            try {
                zeos = new ZipEntryOutputStream(zos, sop,
                        ZipEntry.DEFLATED, -1);
                dicomIn = new BufferedInputStream(
                        new FileInputStream(filePath));

                byte[] data = new byte[BUFFER];
                int bytesRead = 0;
                while ((bytesRead = (dicomIn.read(data, 0, data.length))) > 0) {
                    zeos.write(data, 0, bytesRead);
                }
                
            } catch (IOException e1) {
                System.err.println("ERROR writing to zip entry "
                        + e1.getMessage());
                logger.error("Error writing to zip entry: ", e1);
                //throw new RuntimeException(e1);
            } finally {
                try {
                	dicomIn.close();
                    zeos.flush();
                    zeos.close();                   
                } catch (IOException e) {                    
{'fraction_non_alphanumeric': 0.09886947584789312, 'fraction_numerical': 0.0041109969167523125, 'mean_word_length': 1.7647727272727274, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '985014', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1259, 'n_words': 331}