<commit_before>package ch.tkuhn.memetools;

import java.util.ArrayList;
import java.util.List;

public class IntStringMap {

	private static final int MAX_POS = 2000000000;

	private List<String> data = new ArrayList<String>();
	private long[] startPos;
	private int[] length;

	private StringBuilder sb = new StringBuilder();

	private boolean frozen = false;

	public IntStringMap(int size) {
		startPos = new long[size];
		length = new int[size];
		sb.append(" ");
	}

	public void put(int key, String value) {
		if (frozen) {
			throw new RuntimeException("Frozen");
		}
		int l = value.length();
		if (sb.length() + l >= MAX_POS) {
			data.add(sb.toString());
			sb = new StringBuilder();
		}
		long s = MAX_POS*data.size() + sb.length();
		sb.append(value);
		if (s < 0) {
			throw new RuntimeException("Negative start position");
		}
		if (l < 0) {
			throw new RuntimeException("Negative length");
		}
		startPos[key] = s;
		length[key] = l;
	}

	public String get(int key) {
		if (!frozen) {
			throw new RuntimeException("Not yet frozen");
		}
		long s = startPos[key];
		if (s < 0) {
			throw new RuntimeException("Negative start position");
		}
		if (s == 0) return null;
		int l = length[key];
		if (l < 0) {
			throw new RuntimeException("Negative length");
		}
		int subpos = (int) (s % MAX_POS);
		int subposEnd = subpos + l;
		if (subpos < 0) {
			throw new RuntimeException("Negative sub-position start");
		}<commit_msg>Fix bug in IntStringMap<commit_after>package ch.tkuhn.memetools;

import java.util.ArrayList;
import java.util.List;

public class IntStringMap {

	private static final int MAX_POS = 2000000000;

	private List<String> data = new ArrayList<String>();
	private long[] startPos;
	private int[] length;

	private StringBuilder sb = new StringBuilder(Integer.MAX_VALUE);

	private boolean frozen = false;

	public IntStringMap(int size) {
		startPos = new long[size];
		length = new int[size];
		sb.append(" ");
	}

	public void put(int key, String value) {
		if (frozen) {
			throw new RuntimeException("Frozen");
		}
		int l = value.length();
		if (sb.length() + l >= MAX_POS) {
			data.add(sb.toString());
			sb = new StringBuilder(Integer.MAX_VALUE);
		}
		long s = (long) MAX_POS*data.size() + sb.length();
		sb.append(value);
		if (s < 0) {
			throw new RuntimeException("Negative start position");
		}
		if (l < 0) {
			throw new RuntimeException("Negative length");
		}
		startPos[key] = s;
		length[key] = l;
	}

	public String get(int key) {
		if (!frozen) {
			throw new RuntimeException("Not yet frozen");
		}
		long s = startPos[key];
		if (s < 0) {
			throw new RuntimeException("Negative start position");
		}
		if (s == 0) return null;
		int l = length[key];
		if (l < 0) {
			throw new RuntimeException("Negative length");
		}
		int subpos = (int) (s % MAX_POS);
		int subposEnd = subpos + l;
		if (subpos < 0) {
			throw new RuntimeException("Negative sub-position start");
		}
{'fraction_non_alphanumeric': 0.1392966882895186, 'fraction_numerical': 0.010925230454079891, 'mean_word_length': 3.6287519747235386, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '5211155', 'n_tokens_mistral': 1127, 'n_tokens_neox': 973, 'n_words': 294}