<commit_before>/*
 * Copyright (c) 2007 Pentaho Corporation.  All rights reserved. 
 * This software was developed by Pentaho Corporation and is provided under the terms 
 * of the GNU Lesser General Public License, Version 2.1. You may not use 
 * this file except in compliance with the license. If you need a copy of the license, 
 * please go to http://www.gnu.org/licenses/lgpl-2.1.txt. The Original Code is Pentaho 
 * Data Integration.  The Initial Developer is Pentaho Corporation.
 *
 * Software distributed under the GNU Lesser Public License is distributed on an "AS IS" 
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
 * the license for the specific language governing your rights and limitations.
*/
package org.pentaho.di.trans.step;

import org.pentaho.di.core.exception.KettleXMLException;
import org.pentaho.di.core.xml.XMLHandler;
import org.w3c.dom.Document;
import org.w3c.dom.Node;

public class StepStatus
{
    public static final String XML_TAG = "stepstatus";
    
    private String stepname;
    private int copy;
    private long linesRead;
    private long linesWritten;
    private long linesInput;
    private long linesOutput;
    private long linesUpdated;
    private long linesRejected;
    private long errors;
    private String statusDescription;
    private double seconds;
    private String speed;
    private String priority;
    private boolean stopped;
    private boolean paused;
    
    public StepStatus(BaseStep baseStep)
    {
        // Proc: nr of lines processed: input + output!
        long in_proc = Math.max(baseStep.getLinesInput(), baseStep.getLinesRead());
        long out_proc = Math.max(baseStep.getLinesOutput() + baseStep.getLinesUpdated(), baseStep.getLinesWritten() + baseStep.getLinesRejected()) ;

        float lapsed = ((float) baseStep.getRuntime()) / 1000;
        double in_speed = 0;
        double out_speed = 0;

        if (lapsed != 0)
        {
            in_speed = Math.floor(10 * (in_proc / lapsed)) / 10;
            out_speed = Math.floor(10 * (out_proc / lapsed)) / 10;
        }

        this.stepname = baseStep.getStepname();
        this.copy = baseStep.getCopy();
        this.linesRead = baseStep.getLinesRead();
        this.linesWritten = baseStep.getLinesWritten();
        this.linesInput = baseStep.getLinesInput();
        this.linesOutput = baseStep.getLinesOutput();
        this.linesUpdated = baseStep.getLinesUpdated(); 
        this.linesRejected = baseStep.getLinesRejected();
        this.errors = baseStep.getErrors();
        this.statusDescription = baseStep.getStatusDescription();
        this.seconds = Math.floor((lapsed * 10) + 0.5) / 10;
        this.speed = lapsed == 0 ? "-" : "" + (in_speed > out_speed ? in_speed : out_speed); //$NON-NLS-1$ //$NON-NLS-2$
        this.priority = baseStep.isAlive() ? "" + baseStep.rowsetInputSize() + "/" + baseStep.rowsetOutputSize() : "-"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        this.stopped = baseStep.isStopped();
        this.paused = baseStep.isPaused();
    }
    
    public String getHTMLTableRow()
    {
        return "<tr> " +
                    "<th>"+stepname+"</th> " +
                    "<th>"+copy+"</th> " +
                    "<th>"+linesRead+"</th> " +
                    "<th>"+linesWritten+"</th> " +
                    "<th>"+linesInput+"</th> " +
                    "<th>"+linesOutput+"</th> " +
                    "<th>"+linesUpdated+"</th> " +
                    "<th>"+linesRejected+"</th> " +
                    "<th>"+errors+"</th> " +
                    "<th>"+statusDescription+"</th> " +
                    "<th>"+seconds+"</th> " +
                    "<th>"+speed+"</th> " +
                    "<th>"+priority+"</th> " +
                "</tr>";
    }

    public String getXML()
    {<commit_msg>Adding a little padding to the input/output buffers field because it is frequently chopped off (at least on mac)<commit_after>/*
 * Copyright (c) 2007 Pentaho Corporation.  All rights reserved. 
 * This software was developed by Pentaho Corporation and is provided under the terms 
 * of the GNU Lesser General Public License, Version 2.1. You may not use 
 * this file except in compliance with the license. If you need a copy of the license, 
 * please go to http://www.gnu.org/licenses/lgpl-2.1.txt. The Original Code is Pentaho 
 * Data Integration.  The Initial Developer is Pentaho Corporation.
 *
 * Software distributed under the GNU Lesser Public License is distributed on an "AS IS" 
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
 * the license for the specific language governing your rights and limitations.
*/
package org.pentaho.di.trans.step;

import org.pentaho.di.core.exception.KettleXMLException;
import org.pentaho.di.core.xml.XMLHandler;
import org.w3c.dom.Document;
import org.w3c.dom.Node;

public class StepStatus
{
    public static final String XML_TAG = "stepstatus";
    
    private String stepname;
    private int copy;
    private long linesRead;
    private long linesWritten;
    private long linesInput;
    private long linesOutput;
    private long linesUpdated;
    private long linesRejected;
    private long errors;
    private String statusDescription;
    private double seconds;
    private String speed;
    private String priority;
    private boolean stopped;
    private boolean paused;
    
    public StepStatus(BaseStep baseStep)
    {
        // Proc: nr of lines processed: input + output!
        long in_proc = Math.max(baseStep.getLinesInput(), baseStep.getLinesRead());
        long out_proc = Math.max(baseStep.getLinesOutput() + baseStep.getLinesUpdated(), baseStep.getLinesWritten() + baseStep.getLinesRejected()) ;

        float lapsed = ((float) baseStep.getRuntime()) / 1000;
        double in_speed = 0;
        double out_speed = 0;

        if (lapsed != 0)
        {
            in_speed = Math.floor(10 * (in_proc / lapsed)) / 10;
            out_speed = Math.floor(10 * (out_proc / lapsed)) / 10;
        }

        this.stepname = baseStep.getStepname();
        this.copy = baseStep.getCopy();
        this.linesRead = baseStep.getLinesRead();
        this.linesWritten = baseStep.getLinesWritten();
        this.linesInput = baseStep.getLinesInput();
        this.linesOutput = baseStep.getLinesOutput();
        this.linesUpdated = baseStep.getLinesUpdated(); 
        this.linesRejected = baseStep.getLinesRejected();
        this.errors = baseStep.getErrors();
        this.statusDescription = baseStep.getStatusDescription();
        this.seconds = Math.floor((lapsed * 10) + 0.5) / 10;
        this.speed = lapsed == 0 ? "-" : "   " + (in_speed > out_speed ? in_speed : out_speed); //$NON-NLS-1$ //$NON-NLS-2$
        this.priority = baseStep.isAlive() ? "   " + baseStep.rowsetInputSize() + "/" + baseStep.rowsetOutputSize() : "-"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        this.stopped = baseStep.isStopped();
        this.paused = baseStep.isPaused();
    }
    
    public String getHTMLTableRow()
    {
        return "<tr> " +
                    "<th>"+stepname+"</th> " +
                    "<th>"+copy+"</th> " +
                    "<th>"+linesRead+"</th> " +
                    "<th>"+linesWritten+"</th> " +
                    "<th>"+linesInput+"</th> " +
                    "<th>"+linesOutput+"</th> " +
                    "<th>"+linesUpdated+"</th> " +
                    "<th>"+linesRejected+"</th> " +
                    "<th>"+errors+"</th> " +
                    "<th>"+statusDescription+"</th> " +
                    "<th>"+seconds+"</th> " +
                    "<th>"+speed+"</th> " +
                    "<th>"+priority+"</th> " +
                "</tr>";
    }

    public String getXML()
    {
{'fraction_non_alphanumeric': 0.13047923322683705, 'fraction_numerical': 0.009712460063897763, 'mean_word_length': 2.350171232876712, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6637907', 'n_tokens_mistral': 2370, 'n_tokens_neox': 2263, 'n_words': 582}