<commit_before>package Cache;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import Util.CmdLineParser;

import Database.DatabaseManager;

public class Simulator {

	static final int BLKDEFAULT = 3;
	static final int PFDEFAULT = 3;
	static final int CSIZEDEFAULT = 10;
	static final int PRODEFAULT = 1;

	public enum FileType {
		A, M, D, V, C, R
	}

	int blocksize;
	int prefetchsize;
	int cachesize;
	int pid;
	CacheReplacement.Policy cacheRep;
	Cache cache;
	Connection conn = DatabaseManager.getConnection();
	int hit;
	int miss;
	static final String findCommit = "select id, date, is_bug_fix from scmlog " +
			"where repository_id =? and date>=? order by date ASC";
	static final String findFile = "select actions.file_id, type from actions, content_loc " +
			"where actions.file_id=content_loc.file_id and actions.commit_id=? and content_loc.commit_id=? " +
			"and actions.file_id in( select file_id from file_types where type='code') order by loc DESC";
	static final String findHunkId = "select id from hunks where file_id =? and commit_id =?";
	static final String findBugIntroCdate = "select date from hunk_blames, scmlog " +
			"where hunk_id =? and hunk_blames.bug_commit_id=scmlog.id";
	private static PreparedStatement findCommitQuery;
	private static PreparedStatement findFileQuery;
	private static PreparedStatement findHunkIdQuery;
	private static PreparedStatement findBugIntroCdateQuery;

	public Simulator(int bsize, int psize, int csize, int projid,
			CacheReplacement.Policy rep, String start) {
		blocksize = bsize;
		prefetchsize = psize;
		cachesize = csize;
		this.pid = projid;
		cacheRep = rep;
		cache = new Cache(cachesize, new CacheReplacement(rep), start, projid);
		hit = 0;
		miss = 0;

	}

	// input: initial commit ID
	// input: LOC for every file in initial commit ID
	// input: pre-fetch size
	// output: fills cache with pre-fetch size number of top-LOC files from
	// initial commit
	public void initialPreLoad() {
		String firstDate = findFirstDate();
		final String findInitialPreload = "select content_loc.file_id, content_loc.commit_id from content_loc, scmlog, actions " +
				"where repository_id=? and content_loc.commit_id = scmlog.id and date =? and content_loc.file_id=actions.file_id " +
				"and content_loc.commit_id=actions.commit_id and actions.type!='D' order by loc DESC";
		PreparedStatement findInitialPreloadQuery;
		ResultSet r = null;
		int fileId = 0;
		int commitId = 0;
		try {
			findInitialPreloadQuery = conn.prepareStatement(findInitialPreload);
			findInitialPreloadQuery.setInt(1, pid);
			findInitialPreloadQuery.setString(2, firstDate);
			r = findInitialPreloadQuery.executeQuery();
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		for (int size = 0; size < prefetchsize; size++) {
			try {
				if (r.next()) {
					fileId = r.getInt(1);
					commitId = r.getInt(2);
					cache.add(fileId, commitId, firstDate,
							CacheItem.CacheReason.Prefetch);
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	private String findFirstDate() {
		// TODO Auto-generated method stub
		String findFirstDate = "";
		PreparedStatement findFirstDateQuery;
		String firstDate = "";
		if (cache.startDate == null) {
			findFirstDate = "select min(date) from scmlog where repository_id=?";
			try {
				findFirstDateQuery = conn.prepareStatement(findFirstDate);
				findFirstDateQuery.setInt(1, pid);
				firstDate = Util.Database.getStringResult(findFirstDateQuery);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else {
			findFirstDate = "select min(date) from scmlog where repository_id=? and date >=?";
			try {
				findFirstDateQuery = conn.prepareStatement(findFirstDate);
				findFirstDateQuery.setInt(1, pid);
				findFirstDateQuery.setString(2, cache.startDate);
				firstDate = Util.Database.getStringResult(findFirstDateQuery);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		return firstDate;
	}

	private static void printUsage() {
		System.err
				.println("Example Usage: FixCache -b=10000 -c=500 -f=600 -r=\"LRU\" -p=1");
		System.err
				.println("Example Usage: FixCache --blksize=10000 --csize=500 --pfsize=600 --cacherep=\"LRU\" --pid=1");
		System.err.println("-p/--pid option is required");
	}
<commit_msg>delete some unused lines of code<commit_after>package Cache;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import Util.CmdLineParser;

import Database.DatabaseManager;

public class Simulator {

	static final int BLKDEFAULT = 3;
	static final int PFDEFAULT = 3;
	static final int CSIZEDEFAULT = 10;
	static final int PRODEFAULT = 1;

	public enum FileType {
		A, M, D, V, C, R
	}

	int blocksize;
	int prefetchsize;
	int cachesize;
	int pid;
	CacheReplacement.Policy cacheRep;
	Cache cache;
	Connection conn = DatabaseManager.getConnection();
	int hit;
	int miss;
	static final String findCommit = "select id, date, is_bug_fix from scmlog " +
			"where repository_id =? and date>=? order by date ASC";
	static final String findFile = "select actions.file_id, type from actions, content_loc " +
			"where actions.file_id=content_loc.file_id and actions.commit_id=? and content_loc.commit_id=? " +
			"and actions.file_id in( select file_id from file_types where type='code') order by loc DESC";
	static final String findHunkId = "select id from hunks where file_id =? and commit_id =?";
	static final String findBugIntroCdate = "select date from hunk_blames, scmlog " +
			"where hunk_id =? and hunk_blames.bug_commit_id=scmlog.id";
	private static PreparedStatement findCommitQuery;
	private static PreparedStatement findFileQuery;
	private static PreparedStatement findHunkIdQuery;
	private static PreparedStatement findBugIntroCdateQuery;

	public Simulator(int bsize, int psize, int csize, int projid,
			CacheReplacement.Policy rep, String start) {
		blocksize = bsize;
		prefetchsize = psize;
		cachesize = csize;
		this.pid = projid;
		cacheRep = rep;
		cache = new Cache(cachesize, new CacheReplacement(rep), start, projid);
		hit = 0;
		miss = 0;

	}

	// input: initial commit ID
	// input: LOC for every file in initial commit ID
	// input: pre-fetch size
	// output: fills cache with pre-fetch size number of top-LOC files from
	// initial commit
	public void initialPreLoad() {
		String firstDate = findFirstDate();
		final String findInitialPreload = "select content_loc.file_id, content_loc.commit_id from content_loc, scmlog, actions " +
				"where repository_id=? and content_loc.commit_id = scmlog.id and date =? and content_loc.file_id=actions.file_id " +
				"and content_loc.commit_id=actions.commit_id and actions.type!='D' order by loc DESC";
		PreparedStatement findInitialPreloadQuery;
		ResultSet r = null;
		int fileId = 0;
		int commitId = 0;
		try {
			findInitialPreloadQuery = conn.prepareStatement(findInitialPreload);
			findInitialPreloadQuery.setInt(1, pid);
			findInitialPreloadQuery.setString(2, firstDate);
			r = findInitialPreloadQuery.executeQuery();
		} catch (SQLException e1) {
			e1.printStackTrace();
		}

		for (int size = 0; size < prefetchsize; size++) {
			try {
				if (r.next()) {
					fileId = r.getInt(1);
					commitId = r.getInt(2);
					cache.add(fileId, commitId, firstDate,
							CacheItem.CacheReason.Prefetch);
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}

	private String findFirstDate() {
		String findFirstDate = "";
		PreparedStatement findFirstDateQuery;
		String firstDate = "";
		if (cache.startDate == null) {
			findFirstDate = "select min(date) from scmlog where repository_id=?";
			try {
				findFirstDateQuery = conn.prepareStatement(findFirstDate);
				findFirstDateQuery.setInt(1, pid);
				firstDate = Util.Database.getStringResult(findFirstDateQuery);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		} else {
			findFirstDate = "select min(date) from scmlog where repository_id=? and date >=?";
			try {
				findFirstDateQuery = conn.prepareStatement(findFirstDate);
				findFirstDateQuery.setInt(1, pid);
				findFirstDateQuery.setString(2, cache.startDate);
				firstDate = Util.Database.getStringResult(findFirstDateQuery);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}

		return firstDate;
	}

	private static void printUsage() {
		System.err
				.println("Example Usage: FixCache -b=10000 -c=500 -f=600 -r=\"LRU\" -p=1");
		System.err
				.println("Example Usage: FixCache --blksize=10000 --csize=500 --pfsize=600 --cacherep=\"LRU\" --pid=1");
		System.err.println("-p/--pid option is required");
	}

{'fraction_non_alphanumeric': 0.10522160821021766, 'fraction_numerical': 0.009698883500620278, 'mean_word_length': 4.123050259965338, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1274827', 'n_tokens_mistral': 3203, 'n_tokens_neox': 2844, 'n_words': 781}