<commit_before>// Copyright 2012 YDN Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Transaction queue.
 *
 * A transaction is used to crate non-overlapping transaction so that each
 * database methods are atomic and run in order.
 */


goog.provide('ydn.db.tr.Parallel');
goog.require('ydn.db.tr.IThread');
goog.require('ydn.db.tr.ParallelTxExecutor');
goog.require('ydn.debug.error.NotSupportedException');



/**
 * Create transaction queue providing methods to run in non-overlapping
 * transactions.
 *
 * @implements {ydn.db.tr.IThread}
 * @param {!ydn.db.tr.Storage} storage base storage.
 * @param {number} ptx_no transaction queue number.
 * @param {ydn.db.tr.IThread.Policy=} opt_policy
 * @param {!Array.<string>=} opt_store_names store names as scope.
 * @param {ydn.db.base.TransactionMode=} opt_mode mode as scope.
 * @param {number=} opt_max_tx_no limit number of transaction created.
 * @constructor
 * @struct
 */
ydn.db.tr.Parallel = function(storage, ptx_no, opt_policy,
                              opt_store_names, opt_mode, opt_max_tx_no) {

  /**
   * @final
   * @type {!ydn.db.tr.Storage}
   * @private
   */
  this.storage_ = storage;

  /**
   * @final
   */
  this.q_no_ = ptx_no;

  this.tx_no_ = 0;

  this.r_no_ = 0;

  this.pl_tx_ex_ = null;

  this.p_request_tx = null;

  /**
   * @final
   * @private
   */
  this.scope_store_names_ = opt_store_names;

  /**
   * @final
   * @private
   */
  this.scope_mode_ = opt_mode;

  /**
   * @final
   * @private
   */
  this.policy_ = opt_policy || ydn.db.tr.IThread.Policy.SINGLE;

  /**
   * @final
   * @private
   */
  this.max_tx_no_ = opt_max_tx_no || 0;

};


/**
 * @const
 * @type {boolean}
 */
ydn.db.tr.Parallel.DEBUG = false;


/**
 * @private
 * @type {number} request number.
 */
ydn.db.tr.Parallel.prototype.r_no_;


/**
 * @private
 * @type {number} transaction number.
 */
ydn.db.tr.Parallel.prototype.q_no_;


/**
 * @private
 * @type {number} transaction count.
 */
ydn.db.tr.Parallel.prototype.tx_no_ = 0;


/**
 * @type {number} limit number of transactions.
 * @private
 */
ydn.db.tr.Parallel.prototype.max_tx_no_ = 0;


/**
 * @type {ydn.db.base.TransactionMode|undefined}
 * @private
 */
ydn.db.tr.Parallel.prototype.scope_mode_;


/**
 * @type {ydn.db.tr.IThread.Policy}
 * @private
 */
ydn.db.tr.Parallel.prototype.policy_;


/**
 *
 * @type {ydn.db.tr.ParallelTxExecutor}
 * @private
 */
ydn.db.tr.Parallel.prototype.pl_tx_ex_ = null;


/**
 * Transaction object is sed when receiving a request before result df
 * callback and set null after that callback so that it can be aborted
 * in the callback.
 * In general, this tx may be different from running tx.
 * @type {ydn.db.base.Transaction}
 * @protected
 */
ydn.db.tr.Parallel.prototype.p_request_tx = null;


/**
 * @protected
 * @type {goog.debug.Logger} logger.
 */
ydn.db.tr.Parallel.prototype.logger =
    goog.debug.Logger.getLogger('ydn.db.tr.Parallel');


/**
* Add or update a store issuing a version change event.
* @protected
* @param {!StoreSchema|!ydn.db.schema.Store} store schema.
* @return {!goog.async.Deferred} promise.
*/
ydn.db.tr.Parallel.prototype.addStoreSchema = function(store) {
  return this.storage_.addStoreSchema(store);
};
//
//
///**
// * @inheritDoc
// */
//ydn.db.tr.Parallel.prototype.transaction = function(trFn, store_names,
//       opt_mode, completed_event_handler) {
//  this.storage_.transaction(trFn, store_names,
//      opt_mode, completed_event_handler);
//};


/**
 *
 * @return {string}  scope name.
 */
ydn.db.tr.Parallel.prototype.getThreadName = function() {
  return this.getLabel();
};


/**
 *
 * @return {number} transaction count.
 */<commit_msg>clean up<commit_after>// Copyright 2012 YDN Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Transaction queue.
 *
 * A transaction is used to crate non-overlapping transaction so that each
 * database methods are atomic and run in order.
 */


goog.provide('ydn.db.tr.Parallel');
goog.require('ydn.db.tr.IThread');
goog.require('ydn.db.tr.ParallelTxExecutor');
goog.require('ydn.debug.error.NotSupportedException');



/**
 * Create transaction queue providing methods to run in non-overlapping
 * transactions.
 *
 * @implements {ydn.db.tr.IThread}
 * @param {!ydn.db.tr.Storage} storage base storage.
 * @param {number} ptx_no transaction queue number.
 * @param {ydn.db.tr.IThread.Policy=} opt_policy
 * @param {!Array.<string>=} opt_store_names store names as scope.
 * @param {ydn.db.base.TransactionMode=} opt_mode mode as scope.
 * @param {number=} opt_max_tx_no limit number of transaction created.
 * @constructor
 * @struct
 */
ydn.db.tr.Parallel = function(storage, ptx_no, opt_policy,
                              opt_store_names, opt_mode, opt_max_tx_no) {

  /**
   * @final
   * @type {!ydn.db.tr.Storage}
   * @private
   */
  this.storage_ = storage;

  /**
   * Transaction thread number.
   * @final
   * @private
   */
  this.q_no_ = ptx_no;

  /**
   * Transaction number, increase one as a transaction created from this thread.
   * @type {number}
   * @private
   */
  this.tx_no_ = 0;

  /**
   * Request number, increase one as a request created from this thread. Reset
   * to 0 on each transaction.
   * @type {number}
   * @private
   */
  this.r_no_ = 0;

  /**
   *
   * @type {ydn.db.tr.ParallelTxExecutor}
   * @private
   */
  this.pl_tx_ex_ = null;

  /**
   * Transaction object is sed when receiving a request before result df
   * callback and set null after that callback so that it can be aborted
   * in the callback.
   * In general, this tx may be different from running tx.
   * @type {ydn.db.base.Transaction}
   * @protected
   */
  this.p_request_tx = null;

  /**
   * @final
   * @private
   */
  this.scope_store_names_ = opt_store_names;

  /**
   * @final
   * @private
   */
  this.scope_mode_ = opt_mode;

  /**
   * @final
   * @private
   */
  this.policy_ = opt_policy || ydn.db.tr.IThread.Policy.SINGLE;

  /**
   * @final
   * @private
   */
  this.max_tx_no_ = opt_max_tx_no || 0;

};


/**
 * @const
 * @type {boolean}
 */
ydn.db.tr.Parallel.DEBUG = false;


/**
 * @private
 * @type {number} request number.
 */
ydn.db.tr.Parallel.prototype.r_no_;


/**
 * @private
 * @type {number} transaction number.
 */
ydn.db.tr.Parallel.prototype.q_no_;


/**
 * @private
 * @type {number} transaction count.
 */
ydn.db.tr.Parallel.prototype.tx_no_ = 0;


/**
 * @type {number} limit number of transactions.
 * @private
 */
ydn.db.tr.Parallel.prototype.max_tx_no_ = 0;


/**
 * @type {ydn.db.base.TransactionMode|undefined}
 * @private
 */
ydn.db.tr.Parallel.prototype.scope_mode_;


/**
 * @type {ydn.db.tr.IThread.Policy}
 * @private
 */
ydn.db.tr.Parallel.prototype.policy_;


/**
 * @protected
 * @type {goog.debug.Logger} logger.
 */
ydn.db.tr.Parallel.prototype.logger =
    goog.debug.Logger.getLogger('ydn.db.tr.Parallel');


/**
* Add or update a store issuing a version change event.
* @protected
* @param {!StoreSchema|!ydn.db.schema.Store} store schema.
* @return {!goog.async.Deferred} promise.
*/
ydn.db.tr.Parallel.prototype.addStoreSchema = function(store) {
  return this.storage_.addStoreSchema(store);
};


/**
 *
 * @return {string}  scope name.
 */
ydn.db.tr.Parallel.prototype.getThreadName = function() {
  return this.getLabel();
};


/**
 *
 * @return {number} transaction count.
 */
{'fraction_non_alphanumeric': 0.1459344301100722, 'fraction_numerical': 0.003195644454965085, 'mean_word_length': 3.0979631425800194, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2101544', 'n_tokens_mistral': 2937, 'n_tokens_neox': 2872, 'n_words': 705}