コード例 #1
0
ファイル: PosUpdateScan.cpp プロジェクト: JWUST/hyrise
void PosUpdateScan::executePlanOperation() {
  auto c_pc = checked_pointer_cast<const storage::PointerCalculator>(input.getTable(0));
  auto c_store = checked_pointer_cast<const storage::Store>(c_pc->getActualTable());

  // Cast the constness away
  auto store = std::const_pointer_cast<storage::Store>(c_store);

  // Get the offset for inserts into the delta and the size of the delta that
  // we need to increase by the positions we are inserting
  auto writeArea = store->appendToDelta(c_pc->getPositions()->size());

  const size_t firstPosition = store->getMainTable()->size() + writeArea.first;

  // Get the modification record for the current transaction
  auto& txmgr = tx::TransactionManager::getInstance();
  auto& modRecord = txmgr[_txContext.tid];

  // Functor we use for updating the data
  set_json_value_functor fun(store->getDeltaTable());
  storage::type_switch<hyrise_basic_types> ts;

  size_t counter = 0;
  for(const auto& p : *(c_pc->getPositions())) {
    // First delete the old record
    bool deleteOk = store->markForDeletion(p, _txContext.tid) == tx::TX_CODE::TX_OK;
    if(!deleteOk) {
      txmgr.rollbackTransaction(_txContext);
      throw std::runtime_error("Aborted TX because TID of other TX found");
    }
    modRecord.deletePos(store, p);
    //store->setTid(p, _txContext.tid);

    // Copy the old row from the main
    store->copyRowToDelta(store, p, writeArea.first+counter, _txContext.tid);
    // Update all the necessary values
    for(const auto& kv : _raw_data) {
      const auto& fld = store->numberOfColumn(kv.first);
      fun.set(fld, writeArea.first+counter, kv.second);
      ts(store->typeOfColumn(fld), fun);
    }

    // Insert the new one
    modRecord.insertPos(store, firstPosition+counter);
    ++counter;
  }

  // Update affected rows
  auto rsp = getResponseTask();
  if (rsp != nullptr)
    rsp->incAffectedRows(counter);

  addResult(c_store);
}
コード例 #2
0
ファイル: merge_tests.cpp プロジェクト: JWUST/hyrise
TEST_F(MergeTests, simple_logarithmic_merger_test) {
  auto m = io::Loader::shortcuts::loadMainDelta("test/merge1_main.tbl", "test/merge1_delta.tbl");
  std::vector<hyrise::storage::c_atable_ptr_t > tables;
  tables.push_back(m->getMainTable());
  tables.push_back(m->getDeltaTable());
  TableMerger merger(new DefaultMergeStrategy(), new SequentialHeapMerger());
  const auto& result = merger.merge(tables);

  const auto& correct_result = io::Loader::shortcuts::load("test/merge1_result.tbl");
  ASSERT_TRUE(result[0]->contentEquals(correct_result));
  ASSERT_TRUE(result[0]->dictionaryAt(0)->size() == 7);
  ASSERT_TRUE(result[0]->dictionaryAt(1)->size() == 7);
  ASSERT_TRUE(result[0]->dictionaryAt(2)->size() == 8);

}
コード例 #3
0
TEST_F(MergeTableTests, basic_merge_table_test) {
  auto s = io::Loader::shortcuts::loadMainDelta("test/merge1_main.tbl", "test/merge1_delta.tbl");
  auto reference = io::Loader::shortcuts::load("test/merge1_result.tbl");

  ASSERT_EQ(4u, s->getMainTable()->size());
  ASSERT_EQ(5u, s->getDeltaTable()->size());

  MergeTable mt;
  mt.addInput(s);
  mt.execute();

  const auto& result = mt.getResultTable();

  ASSERT_EQ(9u, result->size());
  ASSERT_TABLE_EQUAL(result, reference);
}
コード例 #4
0
ファイル: merge_tests.cpp プロジェクト: JWUST/hyrise
TEST_F(MergeTests, store_merge_compex) {
  auto linxxxs = std::dynamic_pointer_cast<storage::Store>(io::Loader::shortcuts::load("test/lin_xxxs.tbl"));
  auto ref = std::dynamic_pointer_cast<storage::Store>(io::Loader::shortcuts::load("test/reference/lin_xxxs_update.tbl"));
  linxxxs->resizeDelta(2);
  linxxxs->copyRowToDelta(linxxxs, 0, 0, 1);
  linxxxs->copyRowToDelta(linxxxs, 4, 1, 1);

  linxxxs->getDeltaTable()->setValue<hyrise_int_t>(1,0,99);
  linxxxs->getDeltaTable()->setValue<hyrise_int_t>(1,1,99);

  TableMerger merger(new DefaultMergeStrategy(), new SequentialHeapMerger());

  std::vector<hyrise::storage::c_atable_ptr_t> tables;
  tables.push_back(linxxxs->getMainTable());
  tables.push_back(linxxxs->getDeltaTable());

  // Valid Vector
  std::vector<bool> valid = {0,1,1,1,0,1,1};
  auto result = merger.merge(tables, true, valid);
  ASSERT_EQ(5u, result[0]->size());

  EXPECT_RELATION_EQ(ref, result[0]);
}
コード例 #5
0
ファイル: shortcut_tests.cpp プロジェクト: gekkonerd/hyrise
TEST_F(LoaderShortcutTests, loadMainDelta) {
  auto s = Loader::shortcuts::loadMainDelta("test/reference/update_scan_insert_only_after_update_main.tbl",
                                            "test/reference/update_scan_insert_only_after_update_delta.tbl");
  ASSERT_EQ(3u, s->getMainTable()->size());
  ASSERT_EQ(1u, s->getDeltaTable()->size());
}