<commit_before>package com.splicemachine.derby.iapi.sql.execute;

import com.splicemachine.derby.hbase.SpliceDriver;
import com.splicemachine.derby.management.StatementInfo;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.List;

public class SpliceRuntimeContext<Row> implements Externalizable {
    private static final long serialVersionUID = 1l;
    private List<Path> paths = new ArrayList<Path>();
    private boolean isSink;
    private Row scanStartOverride;
    private byte[] currentTaskId;
	private transient StatementInfo statementInfo;
    private boolean firstStepInMultistep;
    /*
     * Hash bucket to use for sink operations which do not spread data themselves.
     *
     * For example, the SortOperation can't spread data around multiple buckets, so
     * it will use this hashBucket to determine which bucket to go to. The
     * bucket itself will be generated randomly, to (hopefully) spread data from multiple
     * concurrent operations across multiple buckets.
     */
    private byte hashBucket;

    public SpliceRuntimeContext() {
        this.hashBucket = SpliceDriver.driver().getTempTable().getCurrentSpread().bucket((int) System.currentTimeMillis());
    }

    public static SpliceRuntimeContext generateLeftRuntimeContext(int resultSetNumber) {
        SpliceRuntimeContext spliceRuntimeContext = new SpliceRuntimeContext();
        spliceRuntimeContext.addPath(resultSetNumber, 0);
        return spliceRuntimeContext;
    }

    public static SpliceRuntimeContext generateRightRuntimeContext(int resultSetNumber) {
        SpliceRuntimeContext spliceRuntimeContext = new SpliceRuntimeContext();
        spliceRuntimeContext.addPath(resultSetNumber, 1);
        return spliceRuntimeContext;
    }
    
    public void addLeftRuntimeContext(int resultSetNumber) {
    	this.addPath(resultSetNumber, 0);
    }

    public void addRightRuntimeContext(int resultSetNumber) {
    	this.addPath(resultSetNumber, 1);    	
    }

    public static SpliceRuntimeContext generateSinkRuntimeContext(boolean firstStepInMultistep) {
        SpliceRuntimeContext spliceRuntimeContext = new SpliceRuntimeContext();
        spliceRuntimeContext.firstStepInMultistep = firstStepInMultistep;
        return spliceRuntimeContext;
    }

    
    public SpliceRuntimeContext copy() {
        SpliceRuntimeContext copy = new SpliceRuntimeContext();
        for (Path path : paths) {
            copy.addPath(path.copy());
        }
        copy.scanStartOverride = scanStartOverride;
        copy.hashBucket = hashBucket;
        copy.isSink = isSink;
        copy.currentTaskId = currentTaskId;
				copy.statementInfo = statementInfo;
        return copy;
    }

		public void setStatementInfo(StatementInfo statementInfo){
				this.statementInfo = statementInfo;
		}

    public void addPath(Path path) {
        paths.add(0, path);
    }

    public void addPath(int resultSetNumber, int state) {
        addPath(new Path(resultSetNumber, state));
    }
<commit_msg>Adding a sinkRuntimeContext which will work with a clone<commit_after>package com.splicemachine.derby.iapi.sql.execute;

import com.splicemachine.derby.hbase.SpliceDriver;
import com.splicemachine.derby.management.StatementInfo;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.List;

public class SpliceRuntimeContext<Row> implements Externalizable {
    private static final long serialVersionUID = 1l;
    private List<Path> paths = new ArrayList<Path>();
    private boolean isSink;
    private Row scanStartOverride;
    private byte[] currentTaskId;
	private transient StatementInfo statementInfo;
    private boolean firstStepInMultistep;
    /*
     * Hash bucket to use for sink operations which do not spread data themselves.
     *
     * For example, the SortOperation can't spread data around multiple buckets, so
     * it will use this hashBucket to determine which bucket to go to. The
     * bucket itself will be generated randomly, to (hopefully) spread data from multiple
     * concurrent operations across multiple buckets.
     */
    private byte hashBucket;

    public SpliceRuntimeContext() {
        this.hashBucket = SpliceDriver.driver().getTempTable().getCurrentSpread().bucket((int) System.currentTimeMillis());
    }

    public static SpliceRuntimeContext generateLeftRuntimeContext(int resultSetNumber) {
        SpliceRuntimeContext spliceRuntimeContext = new SpliceRuntimeContext();
        spliceRuntimeContext.addPath(resultSetNumber, 0);
        return spliceRuntimeContext;
    }

    public static SpliceRuntimeContext generateRightRuntimeContext(int resultSetNumber) {
        SpliceRuntimeContext spliceRuntimeContext = new SpliceRuntimeContext();
        spliceRuntimeContext.addPath(resultSetNumber, 1);
        return spliceRuntimeContext;
    }
    
    public void addLeftRuntimeContext(int resultSetNumber) {
    	this.addPath(resultSetNumber, 0);
    }

    public void addRightRuntimeContext(int resultSetNumber) {
    	this.addPath(resultSetNumber, 1);    	
    }

    public static SpliceRuntimeContext generateSinkRuntimeContext(boolean firstStepInMultistep) {
        SpliceRuntimeContext spliceRuntimeContext = new SpliceRuntimeContext();
        spliceRuntimeContext.firstStepInMultistep = firstStepInMultistep;
        return spliceRuntimeContext;
    }

    public void addSinkRuntimeContext(boolean firstStepInMultistep) {
    	this.firstStepInMultistep = firstStepInMultistep;  	
    }

    
    public SpliceRuntimeContext copy() {
        SpliceRuntimeContext copy = new SpliceRuntimeContext();
        for (Path path : paths) {
            copy.addPath(path.copy());
        }
        copy.scanStartOverride = scanStartOverride;
        copy.hashBucket = hashBucket;
        copy.isSink = isSink;
        copy.currentTaskId = currentTaskId;
				copy.statementInfo = statementInfo;
        return copy;
    }

		public void setStatementInfo(StatementInfo statementInfo){
				this.statementInfo = statementInfo;
		}

    public void addPath(Path path) {
        paths.add(0, path);
    }

    public void addPath(int resultSetNumber, int state) {
        addPath(new Path(resultSetNumber, state));
    }

{'fraction_non_alphanumeric': 0.07066750235036039, 'fraction_numerical': 0.001880288310874334, 'mean_word_length': 3.679618768328446, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5568461', 'n_tokens_mistral': 1749, 'n_tokens_neox': 1657, 'n_words': 430}