<commit_before>package com.sysiq.tools.zkcopy.writer;

import java.io.IOException;
import java.util.List;

import org.apache.log4j.Logger;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.ZooDefs.Ids;
import org.apache.zookeeper.data.Stat;

import com.sysiq.tools.zkcopy.Node;

public class Writer implements Watcher
{
    private static Logger logger = Logger.getLogger(Writer.class);
    private Node sourceRoot;
    private String addr;
    private String server;
    private String path;
    private ZooKeeper zk;
    private boolean removeDeprecated;
    
    public Writer(String addr, Node znode, boolean removeDeprecatedNodes) {
        this.addr = addr;
        sourceRoot = znode;
        this.removeDeprecated = removeDeprecatedNodes;
        parseAddr();        
    }
    
    private final void parseAddr() {
        int p = addr.indexOf('/');
        server = addr.substring(0, p);
        path = addr.substring(p);
    }
    
    public void write() {
        try
        {
            zk = new ZooKeeper(server, 3000, this);
            checkCreatePath(path);
            Node dest = sourceRoot;
            dest.setPath(path);
            logger.info("Writing data...");
            update(dest);
            logger.info("Writing data completed.");
        }
        catch(IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        catch(KeeperException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        catch(InterruptedException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    public void checkCreatePath(String path) throws KeeperException, InterruptedException {
        logger.info("Checking path " + path);
        String[] l = path.split("/");
        StringBuffer b = new StringBuffer();
        for(int i=1; i<l.length; i++) {            
            b.append('/');
            b.append(l[i]);
            System.out.println("CCP: " + b.toString());
            Stat stat = zk.exists(b.toString(), false);
            if (stat == null) {
                zk.create(b.toString(), null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
                logger.info("Created " + b.toString());
            }
        }
    }
<commit_msg>Removed System.out.println call<commit_after>package com.sysiq.tools.zkcopy.writer;

import java.io.IOException;
import java.util.List;

import org.apache.log4j.Logger;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.ZooDefs.Ids;
import org.apache.zookeeper.data.Stat;

import com.sysiq.tools.zkcopy.Node;

public class Writer implements Watcher
{
    private static Logger logger = Logger.getLogger(Writer.class);
    private Node sourceRoot;
    private String addr;
    private String server;
    private String path;
    private ZooKeeper zk;
    private boolean removeDeprecated;
    
    public Writer(String addr, Node znode, boolean removeDeprecatedNodes) {
        this.addr = addr;
        sourceRoot = znode;
        this.removeDeprecated = removeDeprecatedNodes;
        parseAddr();        
    }
    
    private final void parseAddr() {
        int p = addr.indexOf('/');
        server = addr.substring(0, p);
        path = addr.substring(p);
    }
    
    public void write() {
        try
        {
            zk = new ZooKeeper(server, 3000, this);
            checkCreatePath(path);
            Node dest = sourceRoot;
            dest.setPath(path);
            logger.info("Writing data...");
            update(dest);
            logger.info("Writing data completed.");
        }
        catch(IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        catch(KeeperException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        catch(InterruptedException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    public void checkCreatePath(String path) throws KeeperException, InterruptedException {
        logger.info("Checking path " + path);
        String[] l = path.split("/");
        StringBuffer b = new StringBuffer();
        for(int i=1; i<l.length; i++) {            
            b.append('/');
            b.append(l[i]);
            Stat stat = zk.exists(b.toString(), false);
            if (stat == null) {
                zk.create(b.toString(), null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
                logger.info("Created " + b.toString());
            }
        }
    }

{'fraction_non_alphanumeric': 0.10867834394904459, 'fraction_numerical': 0.002786624203821656, 'mean_word_length': 2.019831730769231, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5517589', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1390, 'n_words': 314}