<commit_before>'use strict';

const EventEmitter = require('events').EventEmitter;

const uuid = require('uuid');

class Request extends EventEmitter {
	constructor(sql, callback) {
		super();

		this.uuid = uuid.v4();
		this.sql = sql;
		this.callback = callback;

		debug(`creating request (${ this.uuid }): ${ this.sql.length > 80 ? this.sql.slice(0, 80) + '...' : this.sql }`);
	}

	execute(context) {
		let metadata = null;
		let rowBuffer = null;
		let done = false;
		debug(`connection (${ context.uuid }): executing request (${ this.uuid })`);
		context.requests.push(this);
		let request = context.connection.queryRaw(this.sql, (err, results) => {
				if (err) {
					// HACK: Close connection because query errors can lock up the connection.
					context.removeRequest(this, err);
					context.close();
				} else if (done && typeof this.callback === 'function') {
					context.removeRequest(this);
					this.callback(err, results);
				}
			}
		});
		request.on('meta', (meta) => {
			metadata = meta;
		});
		request.on('row', () => {
			if (rowBuffer) {
				this.emit('row', rowBuffer);
			}
			rowBuffer = [];
		});
		request.on('column', (index, data) => {
			let columnMetadata = metadata[index];
			rowBuffer[index] = {
				metadata: {
					colName: columnMetadata.name,
					type: {
						id: columnMetadata.sqlType
					},
					nullable: columnMetadata.nullable,
					size: columnMetadata.size
				},
				value: data
			};
		});
		request.on('done', () => {
			done = true;
			if (rowBuffer) {
				this.emit('row', rowBuffer);
			}
		});
	}
}

module.exports = Request;
<commit_msg>lib: Fix code block<commit_after>'use strict';

const EventEmitter = require('events').EventEmitter;

const uuid = require('uuid');

class Request extends EventEmitter {
	constructor(sql, callback) {
		super();

		this.uuid = uuid.v4();
		this.sql = sql;
		this.callback = callback;

		debug(`creating request (${ this.uuid }): ${ this.sql.length > 80 ? this.sql.slice(0, 80) + '...' : this.sql }`);
	}

	execute(context) {
		let metadata = null;
		let rowBuffer = null;
		let done = false;
		debug(`connection (${ context.uuid }): executing request (${ this.uuid })`);
		context.requests.push(this);
		let request = context.connection.queryRaw(this.sql, (err, results) => {
			if (err) {
				// HACK: Close connection because query errors can lock up the connection.
				context.removeRequest(this, err);
				context.close();
			} else if (done && typeof this.callback === 'function') {
				context.removeRequest(this);
				this.callback(err, results);
			}
		});
		request.on('meta', (meta) => {
			metadata = meta;
		});
		request.on('row', () => {
			if (rowBuffer) {
				this.emit('row', rowBuffer);
			}
			rowBuffer = [];
		});
		request.on('column', (index, data) => {
			let columnMetadata = metadata[index];
			rowBuffer[index] = {
				metadata: {
					colName: columnMetadata.name,
					type: {
						id: columnMetadata.sqlType
					},
					nullable: columnMetadata.nullable,
					size: columnMetadata.size
				},
				value: data
			};
		});
		request.on('done', () => {
			done = true;
			if (rowBuffer) {
				this.emit('row', rowBuffer);
			}
		});
	}
}

module.exports = Request;

{'fraction_non_alphanumeric': 0.17214397496087636, 'fraction_numerical': 0.003755868544600939, 'mean_word_length': 3.0869565217391304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '6292800', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1043, 'n_words': 229}