コード例 #1
0
ファイル: PosUpdateScan.cpp プロジェクト: came/hyrise
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);
}
コード例 #2
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));
}
コード例 #3
0
ファイル: Store.cpp プロジェクト: JWUST/hyrise
std::pair<size_t, size_t> Store::resizeDelta(size_t num) {
  assert(num > delta->size());
  return appendToDelta(num - delta->size());
}