<commit_before>/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.basho.riak.presto;

// /usr/local/erlang/R16B03-1/lib/erlang/lib/jinterface-1.5.8/priv/OtpErlang.jar

import com.ericsson.otp.erlang.*;
import io.airlift.log.Logger;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

public class Coverage {
    //private final node;
    private static final Logger log = Logger.get(Coverage.class);
    private final DirectConnection conn;
    private OtpErlangTuple coveragePlan;


    public Coverage(DirectConnection conn) {
        //this.node = riakNode;
        this.conn = conn; //checkNotNull(conn);
        this.coveragePlan = null;
    }

    @NotNull
    public void plan() {
        try {
            //conn.ping();
            this.coveragePlan = conn.getCoveragePlan(9979);
            log.debug("got coverage plan; %s", coveragePlan);
        } catch (java.io.IOException e) {
            log.debug("%d\n", e);
        } catch (com.ericsson.otp.erlang.OtpAuthException e) {
            log.debug("%d\n", e);
        } catch (com.ericsson.otp.erlang.OtpErlangExit e) {
            log.debug("%d\n", e);
        }
    }

    public List<SplitTask> getSplits() {
        log.debug("%d", this.coveragePlan.toString());
        OtpErlangList vnodes = (OtpErlangList) this.coveragePlan.elementAt(0);
        OtpErlangObject filterVnodes = this.coveragePlan.elementAt(1);

        //System.out.println(vnodes);
        //System.out.println(filterVnodes);

        List<SplitTask> l = new ArrayList<SplitTask>();

        for (OtpErlangObject obj : vnodes) {

            // {Index, Node}
            OtpErlangTuple vnode = (OtpErlangTuple) obj;
            OtpErlangObject index = vnode.elementAt(0);
            String nodeName = ((OtpErlangAtom) vnode.elementAt(1)).atomValue();
            OtpErlangObject[] a = {vnode, filterVnodes};
            OtpErlangTuple t = new OtpErlangTuple(a);

            SplitTask task = new SplitTask(nodeName, t);
            l.add(task);
        }

        return l;
    }

    public String toString() {
        return coveragePlan.toString();
    }

    public void run()
            throws java.io.IOException, OtpErlangExit, OtpAuthException {
//        byte[] b = "foobartable".getBytes();
//        for(OtpErlangObject split : this.splits) {
//            OtpErlangTuple t = (OtpErlangTuple)split;
//            OtpErlangList r = conn.processSplits(b, t);
//            System.out.println(r);
//        }

    }
}<commit_msg>Fix one wrong log output<commit_after>/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.basho.riak.presto;

// /usr/local/erlang/R16B03-1/lib/erlang/lib/jinterface-1.5.8/priv/OtpErlang.jar

import com.ericsson.otp.erlang.*;
import io.airlift.log.Logger;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

public class Coverage {
    //private final node;
    private static final Logger log = Logger.get(Coverage.class);
    private final DirectConnection conn;
    private OtpErlangTuple coveragePlan;


    public Coverage(DirectConnection conn) {
        //this.node = riakNode;
        this.conn = conn; //checkNotNull(conn);
        this.coveragePlan = null;
    }

    @NotNull
    public void plan() {
        try {
            //conn.ping();
            this.coveragePlan = conn.getCoveragePlan(9979);
            log.debug("got coverage plan; %s", coveragePlan);
        } catch (java.io.IOException e) {
            log.debug("%d\n", e);
        } catch (com.ericsson.otp.erlang.OtpAuthException e) {
            log.debug("%d\n", e);
        } catch (com.ericsson.otp.erlang.OtpErlangExit e) {
            log.debug("%d\n", e);
        }
    }

    public List<SplitTask> getSplits() {
        log.debug("%s", this.coveragePlan.toString());
        OtpErlangList vnodes = (OtpErlangList) this.coveragePlan.elementAt(0);
        OtpErlangObject filterVnodes = this.coveragePlan.elementAt(1);

        //System.out.println(vnodes);
        //System.out.println(filterVnodes);

        List<SplitTask> l = new ArrayList<SplitTask>();

        for (OtpErlangObject obj : vnodes) {

            // {Index, Node}
            OtpErlangTuple vnode = (OtpErlangTuple) obj;
            OtpErlangObject index = vnode.elementAt(0);
            String nodeName = ((OtpErlangAtom) vnode.elementAt(1)).atomValue();
            OtpErlangObject[] a = {vnode, filterVnodes};
            OtpErlangTuple t = new OtpErlangTuple(a);

            SplitTask task = new SplitTask(nodeName, t);
            l.add(task);
        }

        return l;
    }

    public String toString() {
        return coveragePlan.toString();
    }

    public void run()
            throws java.io.IOException, OtpErlangExit, OtpAuthException {
//        byte[] b = "foobartable".getBytes();
//        for(OtpErlangObject split : this.splits) {
//            OtpErlangTuple t = (OtpErlangTuple)split;
//            OtpErlangList r = conn.processSplits(b, t);
//            System.out.println(r);
//        }

    }
}
{'fraction_non_alphanumeric': 0.11695331695331695, 'fraction_numerical': 0.006552006552006552, 'mean_word_length': 2.4516676088185414, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3219914', 'n_tokens_mistral': 1931, 'n_tokens_neox': 1877, 'n_words': 456}