Exemple #1
0
  void SetUp() {

    hyrise::tx::TransactionManager::getInstance().reset();

    TableBuilder::param_list list;
    list.append().set_type("INTEGER").set_name("a");
    list.append().set_type("FLOAT").set_name("b");
    list.append().set_type("STRING").set_name("c");

    list.appendGroup(1).appendGroup(1).appendGroup(1);

    TableBuilder::param_list list2;
    list2.append().set_type("INTEGER").set_name("col_0");
    list2.append().set_type("INTEGER").set_name("col_1");

    one_row = TableBuilder::build(list2);
    one_row->resize(1);
    one_row->setValue<hyrise_int_t>(0, 0, 99);
    one_row->setValue<hyrise_int_t>(1, 0, 999);

    second_row = TableBuilder::build(list2);
    second_row->resize(1);
    second_row->setValue<hyrise_int_t>(0, 0, 22);
    second_row->setValue<hyrise_int_t>(1, 0, 222);

    // Convert to store
    data = std::make_shared<storage::Store>(storage::TableBuilder::build(list));
    linxxxs = std::dynamic_pointer_cast<storage::Store>(io::Loader::shortcuts::load("test/lin_xxxs.tbl"));
    linxxxs_ref = std::dynamic_pointer_cast<storage::Store>(io::Loader::shortcuts::load("test/lin_xxxs.tbl"));
  }
void JsonTable::executePlanOperation() {

	TableBuilder::param_list list;

	for(size_t i=0, attr_size = _names.size(); i < attr_size; ++i)
		list.append().set_name(_names[i]).set_type(_types[i]);
	
	for(size_t i=0, groups_size = _groups.size(); i < groups_size; ++i)
		list.appendGroup(_groups[i]);


	hyrise::storage::atable_ptr_t result = TableBuilder::build(list);
	if (_useStoreFlag) {
		auto tmp = std::make_shared<Store>(TableBuilder::build(list));
		tmp->setDefaultMerger();
		result = tmp;
	}

	// Add the rows if any
	size_t rows = _data.size();
	if (rows > 0 ) {

		if (_useStoreFlag)
			std::dynamic_pointer_cast<Store>(result)->getDeltaTable()->resize(rows);
		else
			result->resize(rows);


		set_string_value_functor fun(_useStoreFlag ? std::dynamic_pointer_cast<Store>(result)->getDeltaTable() : result);
		hyrise::storage::type_switch<hyrise_basic_types> ts;

		for(size_t i=0; i < rows; ++i) {
			auto row = _data[i];
			if (row.size() != _names.size())
				throw std::runtime_error("Mismatch in provided data and number of columns in table!");

			for(size_t j=0, rs = row.size(); j < rs; ++j) {
				fun.set(j, i, row[j]);
				ts(result->typeOfColumn(j), fun);
			}
		}
	}

	addResult(result);
}