Exemplo n.º 1
0
storage::c_atable_ptr_t TpccPaymentProcedure::getWarehouse() {
  auto warehouse = getTpccTable("WAREHOUSE");
  auto validated = selectAndValidate(
      warehouse,
      "WAREHOUSE",
      std::unique_ptr<SimpleExpression>(new GenericExpressionValue<hyrise_int_t, std::equal_to<hyrise_int_t>>(
          warehouse->getDeltaTable(), "W_ID", _w_id)));
  return validated;
}
Exemplo n.º 2
0
void PosUpdateScan::executePlanOperation() {
  auto c_pc = checked_pointer_cast<const 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 current maximum size
  const auto& beforSize = store->size();

  // 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());

  // 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) == hyrise::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, beforSize+counter);
    ++counter;
  }

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

  addResult(c_store);
}
Exemplo n.º 3
0
TEST_F(CopyRowFromTests, string_test) {
  std::vector<std::string> data({"123", "123", "123", "123", "123", "123", "123", "123", "123", "123"});

  auto t = io::Loader::shortcuts::load("test/lin_xxs.tbl");
  auto store = std::dynamic_pointer_cast<Store>(t);

  auto writeArea = store->appendToDelta(1);
  store->copyRowToDeltaFromStringVector(data, writeArea.first, 0);

  for (size_t i = 0; i < data.size(); i++)
    ASSERT_EQ(123, store->getDeltaTable()->getValue<int>(i, 0));
}
Exemplo n.º 4
0
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]);
}
Exemplo n.º 5
0
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);

}
Exemplo n.º 6
0
void TpccPaymentProcedure::insertHistory() {
  auto history = std::const_pointer_cast<storage::Store>(getTpccTable("HISTORY"));
  size_t row = newRow(history);
  storage::atable_ptr_t delta = history->getDeltaTable();
  delta->setValue<hyrise_int_t>("H_C_ID", row, _c_id);
  delta->setValue<hyrise_int_t>("H_C_D_ID", row, _c_d_id);
  delta->setValue<hyrise_int_t>("H_C_W_ID", row, _c_w_id);
  delta->setValue<hyrise_int_t>("H_D_ID", row, _d_id);
  delta->setValue<hyrise_int_t>("H_W_ID", row, _w_id);
  delta->setValue<hyrise_string_t>("H_DATE", row, _date);
  delta->setValue<hyrise_float_t>("H_AMOUNT", row, _h_amount);
  delta->setValue<hyrise_string_t>("H_DATA", row, _h_data);

  insert(history, row + history->deltaOffset());
}
Exemplo n.º 7
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);
}
Exemplo n.º 8
0
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());
}