<commit_before>package org.opencloudb.stat;

import org.apache.log4j.Logger;
import org.opencloudb.MycatServer;
import org.opencloudb.statistic.SQLRecord;
import org.opencloudb.statistic.SQLRecorder;

/**
 * 用户状态
 * 
 * @author Ben
 */
public class UserStat {
	

	private static final Logger LOGGER = Logger.getLogger(UserStat.class);
	
	private final static int SQL_SLOW_TIME = 1000;
	
	/**
	 * SQL 执行记录
	 */
	private SqlStat sqlStat = null;
	
	/**
	 * CURD 执行分布
	 */
	private RWStat rwStat = null;
	
	/**
	 * 慢查询记录器  TOP 10
	 */
	private SQLRecorder sqlRecorder;
	
	private String user;
	
	public UserStat(String user) {
		super();
		this.user = user;		
		this.rwStat = new RWStat();
		this.sqlStat = new SqlStat(10);
		this.sqlRecorder =  new SQLRecorder(MycatServer.getInstance().getConfig().getSystem().getSqlRecordCount());
	}

	public String getUser() {
		return user;
	}

	public SQLRecorder getSqlRecorder() {
		return sqlRecorder;
	}

	public RWStat getRWStat() {
		return rwStat;
	}

	public SqlStat getSqlStat() {
		return sqlStat;
	}
	
	public void reset() {
		
		this.sqlRecorder.clear();
		this.rwStat.reset();
		this.sqlStat.reset();
	}

	/**
	 * 更新状态
	 * 
	 * @param sqlType
	 * @param sql
	 * @param startTime
	 */
	public void update(int sqlType, String sql, long startTime) {	
		
		if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("System record stat: sqlType:" + sqlType + ", sql:" + sql + ", startTime:" + startTime);
		}
		
		long now = System.currentTimeMillis();
		
		//慢查询记录
		long executeTime = now - startTime;		
		if ( executeTime >= SQL_SLOW_TIME ){			
			SQLRecord record = new SQLRecord();
			record.executeTime = executeTime;
			record.statement = sql;
			record.startTime = startTime;<commit_msg>取消 DEBUG 日志<commit_after>package org.opencloudb.stat;

import org.opencloudb.MycatServer;
import org.opencloudb.statistic.SQLRecord;
import org.opencloudb.statistic.SQLRecorder;

/**
 * 用户状态
 * 
 * @author Ben
 */
public class UserStat {
	
	private final static int SQL_SLOW_TIME = 1000;
	
	/**
	 * SQL 执行记录
	 */
	private SqlStat sqlStat = null;
	
	/**
	 * CURD 执行分布
	 */
	private RWStat rwStat = null;
	
	/**
	 * 慢查询记录器  TOP 10
	 */
	private SQLRecorder sqlRecorder;
	
	private String user;
	
	public UserStat(String user) {
		super();
		this.user = user;		
		this.rwStat = new RWStat();
		this.sqlStat = new SqlStat(10);
		this.sqlRecorder =  new SQLRecorder(MycatServer.getInstance().getConfig().getSystem().getSqlRecordCount());
	}

	public String getUser() {
		return user;
	}

	public SQLRecorder getSqlRecorder() {
		return sqlRecorder;
	}

	public RWStat getRWStat() {
		return rwStat;
	}

	public SqlStat getSqlStat() {
		return sqlStat;
	}
	
	public void reset() {
		
		this.sqlRecorder.clear();
		this.rwStat.reset();
		this.sqlStat.reset();
	}

	/**
	 * 更新状态
	 * 
	 * @param sqlType
	 * @param sql
	 * @param startTime
	 */
	public void update(int sqlType, String sql, long startTime) {	
		
		long now = System.currentTimeMillis();
		
		//慢查询记录
		long executeTime = now - startTime;		
		if ( executeTime >= SQL_SLOW_TIME ){			
			SQLRecord record = new SQLRecord();
			record.executeTime = executeTime;
			record.statement = sql;
			record.startTime = startTime;
{'fraction_non_alphanumeric': 0.12117426608369769, 'fraction_numerical': 0.005309181761399126, 'mean_word_length': 3.299328859060403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7241783', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1146, 'n_words': 256}