<commit_before>/*-------------------------------------------------------------------------
 *
 * transaction.cpp
 * file description
 *
 * Copyright(c) 2015, CMU
 *
 *-------------------------------------------------------------------------
 */

#include "backend/concurrency/transaction.h"

#include "backend/common/synch.h"
#include "backend/common/logger.h"

#include <chrono>
#include <thread>
#include <iomanip>

namespace peloton {
namespace concurrency {

void Transaction::RecordInsert(ItemPointer location) {
    auto& manager = catalog::Manager::GetInstance();
    storage::TileGroup *tile_group = static_cast<storage::TileGroup *>(manager.locator[location.block]);
    inserted_tuples[tile_group].push_back(location.offset);
}

void Transaction::RecordDelete(ItemPointer location) {
    auto& manager = catalog::Manager::GetInstance();
    storage::TileGroup *tile_group = static_cast<storage::TileGroup *>(manager.locator[location.block]);
    deleted_tuples[tile_group].push_back(location.offset);
}

bool Transaction::HasInsertedTuples(storage::TileGroup* tile_group) const {
    auto tile_group_itr = inserted_tuples.find(tile_group);
    if(tile_group_itr != inserted_tuples.end() && !tile_group_itr->second.empty())
        return true;

    return false;
}

bool Transaction::HasDeletedTuples(storage::TileGroup* tile_group) const {
    auto tile_group_itr = deleted_tuples.find(tile_group);
    if(tile_group_itr != deleted_tuples.end() && !tile_group_itr->second.empty())
        return true;

    return false;
}

const std::map<storage::TileGroup*, std::vector<oid_t> >& Transaction::GetInsertedTuples() {
    return inserted_tuples;
}

const std::map<storage::TileGroup*, std::vector<oid_t> >& Transaction::GetDeletedTuples() {
    return deleted_tuples;
}

void Transaction::IncrementRefCount() {
    ++ref_count;
}

void Transaction::DecrementRefCount() {
    assert(ref_count > 0);

    // DROP transaction when ref count reaches 1
    if (ref_count.fetch_sub(1) == 1) {
        delete this;
    }
}

void Transaction::SetResult(Result result) {
  result_ = result;
}

Result Transaction::GetResult() const {
  return result_;
}

std::ostream& operator<<(std::ostream& os, const Transaction& txn) {
<commit_msg>Disable check.<commit_after>/*-------------------------------------------------------------------------
 *
 * transaction.cpp
 * file description
 *
 * Copyright(c) 2015, CMU
 *
 *-------------------------------------------------------------------------
 */

#include "backend/concurrency/transaction.h"

#include "backend/common/synch.h"
#include "backend/common/logger.h"

#include <chrono>
#include <thread>
#include <iomanip>

namespace peloton {
namespace concurrency {

void Transaction::RecordInsert(ItemPointer location) {
    auto& manager = catalog::Manager::GetInstance();
    storage::TileGroup *tile_group = static_cast<storage::TileGroup *>(manager.locator[location.block]);
    inserted_tuples[tile_group].push_back(location.offset);
}

void Transaction::RecordDelete(ItemPointer location) {
    auto& manager = catalog::Manager::GetInstance();
    storage::TileGroup *tile_group = static_cast<storage::TileGroup *>(manager.locator[location.block]);
    deleted_tuples[tile_group].push_back(location.offset);
}

bool Transaction::HasInsertedTuples(storage::TileGroup* tile_group) const {
    auto tile_group_itr = inserted_tuples.find(tile_group);
    if(tile_group_itr != inserted_tuples.end() && !tile_group_itr->second.empty())
        return true;

    return false;
}

bool Transaction::HasDeletedTuples(storage::TileGroup* tile_group) const {
    auto tile_group_itr = deleted_tuples.find(tile_group);
    if(tile_group_itr != deleted_tuples.end() && !tile_group_itr->second.empty())
        return true;

    return false;
}

const std::map<storage::TileGroup*, std::vector<oid_t> >& Transaction::GetInsertedTuples() {
    return inserted_tuples;
}

const std::map<storage::TileGroup*, std::vector<oid_t> >& Transaction::GetDeletedTuples() {
    return deleted_tuples;
}

void Transaction::IncrementRefCount() {
    ++ref_count;
}

void Transaction::DecrementRefCount() {
    // DROP transaction when ref count reaches 1
    if (ref_count.fetch_sub(1) == 1) {
        delete this;
    }
}

void Transaction::SetResult(Result result) {
  result_ = result;
}

Result Transaction::GetResult() const {
  return result_;
}

std::ostream& operator<<(std::ostream& os, const Transaction& txn) {

{'fraction_non_alphanumeric': 0.19271418934112886, 'fraction_numerical': 0.0033730604902181245, 'mean_word_length': 3.6969376979936643, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 26, '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': '6632605', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1321, 'n_words': 239}