<commit_before><?php


trait pudlTransaction {


	public function inTransaction() {
		return is_array($this->transaction);
	}



	public function begin() {
		if ($this->inTransaction()) return $this;
		$this->transaction = [];
		$this->_inserted = 0;
		$this('START TRANSACTION');
		return $this;
	}



	public function commit($sync=false) {
		if (!$this->inTransaction()) return $this;
		$this('COMMIT');
		$this->transaction = false;
		return $sync ? $this->sync() : $this;
	}



	public function chunk($size=1000, $sync=false) {
		return (++$this->_inserted % $size === 0)
			 ? $this->commit($sync)->begin()
			 : $this;
	}



	public function rollback() {
		if (!$this->inTransaction()) return $this;
		$this->transaction = false;
		$this('ROLLBACK');
		return $this;
	}



	protected function retryTransaction() {
		if (!$this->inTransaction()) return;

		$list = $this->transaction;
		$this->transaction = [];
<commit_msg>Do not execute "chunk" if we're not actively within a transaction.<commit_after><?php


trait pudlTransaction {


	public function inTransaction() {
		return is_array($this->transaction);
	}



	public function begin() {
		if ($this->inTransaction()) return $this;
		$this->transaction = [];
		$this->_inserted = 0;
		$this('START TRANSACTION');
		return $this;
	}



	public function commit($sync=false) {
		if (!$this->inTransaction()) return $this;
		$this('COMMIT');
		$this->transaction = false;
		return $sync ? $this->sync() : $this;
	}



	public function chunk($size=1000, $sync=false) {
		if (!$this->inTransaction()) return $this;
		return (++$this->_inserted % $size === 0)
			 ? $this->commit($sync)->begin()
			 : $this;
	}



	public function rollback() {
		if (!$this->inTransaction()) return $this;
		$this->transaction = false;
		$this('ROLLBACK');
		return $this;
	}



	protected function retryTransaction() {
		if (!$this->inTransaction()) return;

		$list = $this->transaction;
		$this->transaction = [];

{'fraction_non_alphanumeric': 0.18404907975460122, 'fraction_numerical': 0.006134969325153374, 'mean_word_length': 4.083116883116883, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, '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': '3682094', 'n_tokens_mistral': 711, 'n_tokens_neox': 619, 'n_words': 148}