<commit_before>package com.continuuity.data.operation.executor;

import com.continuuity.api.data.OperationException;
import com.continuuity.api.data.OperationResult;
import com.continuuity.data.operation.Increment;
import com.continuuity.data.operation.OperationContext;
import com.continuuity.data.operation.Read;
import com.continuuity.data.operation.ReadAllKeys;
import com.continuuity.data.operation.ReadColumnRange;
import com.continuuity.data.operation.StatusCode;
import com.continuuity.data.operation.WriteOperation;
import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Map;

/**
 * This transaction agent defers all operations as long as possible while
 * preserving transactional semantics:
 * <ul>
 *   <li>write operations are deferred until a read operation is executed.</li>
 *   <li>when a read operation is received, it must return a value and thus
 *     execute immediately. Because it may depend on the writes that were already
 *     submitted, all deferred write operations are executed before the read.</li>
 *   <li>An increment counts as a read because it returns a result.</li>
 *   <li>The start of the transaction is deferred until the first operation is
 *     actually executed.</li>
 *   <li>Upon finish, all outstanding operations are executed, and the transaction
 *     is committed.</li>
 * </ul>
 * This agent aborts the current transaction whenever an operation fails - even if
 * it is a read operation. After a failure, no more operations may be submitted.
 *
 * This class is not thread-safe - any synchronization is up to the caller.
<<<<<<< HEAD
=======
 *
>>>>>>> master
 */
public class SmartTransactionAgent implements TransactionAgent {

  private static final Logger Log =
    LoggerFactory.getLogger(SmartTransactionAgent.class);

  // the actual operation executor
  private final OperationExecutor opex;
  // the operation context for all operations
  private final OperationContext context;
  // the list of currently deferred operations
  private final List<WriteOperation> deferred = Lists.newLinkedList();
  // the current transaction<commit_msg>fixing overlooked artifact from git merge<commit_after>package com.continuuity.data.operation.executor;

import com.continuuity.api.data.OperationException;
import com.continuuity.api.data.OperationResult;
import com.continuuity.data.operation.Increment;
import com.continuuity.data.operation.OperationContext;
import com.continuuity.data.operation.Read;
import com.continuuity.data.operation.ReadAllKeys;
import com.continuuity.data.operation.ReadColumnRange;
import com.continuuity.data.operation.StatusCode;
import com.continuuity.data.operation.WriteOperation;
import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Map;

/**
 * This transaction agent defers all operations as long as possible while
 * preserving transactional semantics:
 * <ul>
 *   <li>write operations are deferred until a read operation is executed.</li>
 *   <li>when a read operation is received, it must return a value and thus
 *     execute immediately. Because it may depend on the writes that were already
 *     submitted, all deferred write operations are executed before the read.</li>
 *   <li>An increment counts as a read because it returns a result.</li>
 *   <li>The start of the transaction is deferred until the first operation is
 *     actually executed.</li>
 *   <li>Upon finish, all outstanding operations are executed, and the transaction
 *     is committed.</li>
 * </ul>
 * This agent aborts the current transaction whenever an operation fails - even if
 * it is a read operation. After a failure, no more operations may be submitted.
 *
 * This class is not thread-safe - any synchronization is up to the caller.
 */
public class SmartTransactionAgent implements TransactionAgent {

  private static final Logger Log =
    LoggerFactory.getLogger(SmartTransactionAgent.class);

  // the actual operation executor
  private final OperationExecutor opex;
  // the operation context for all operations
  private final OperationContext context;
  // the list of currently deferred operations
  private final List<WriteOperation> deferred = Lists.newLinkedList();
  // the current transaction
{'fraction_non_alphanumeric': 0.0803305026394308, 'fraction_numerical': 0.0009180628873077806, 'mean_word_length': 4.523447401774398, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 36, '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': '682732', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1112, 'n_words': 424}