void MergePrefixSum::executePlanOperation() { if (input.numberOfTables() == 1) { addResult(getInputTable()); return; } const auto resultSize = getInputTable()->size(); std::vector<storage::ColumnMetadata> meta {storage::ColumnMetadata::metadataFromString(types::integer_name, "count")}; auto result = std::make_shared<storage::Table>(&meta, nullptr, resultSize, true, false); result->resize(resultSize); const auto &res_vec = getDataVector(result).first; std::vector<std::shared_ptr<storage::FixedLengthVector<value_id_t>>> vecs; for(size_t i=0, stop=input.numberOfTables(); i < stop; ++i) { vecs.emplace_back(getDataVector(getInputTable(i)).first); } for(size_t i=0; i < resultSize; ++i) { value_id_t pos = std::numeric_limits<value_id_t>::max(); for(size_t j=0, stop=vecs.size(); j < stop; ++j) { auto tmp = vecs[j]->get(0,i); pos = tmp < pos ? tmp : pos; } res_vec->set(0, i, pos); } addResult(result); }
void RadixCluster2ndPass::executePlanOperation() { //ProfilerStart("RadixCluster.prof"); assert(_bits1 != 0); assert(_bits2 != 0); const auto& tab = getInputTable(); auto tableSize = getInputTable()->size(); auto result = getInputTable(1); // Get the prefix sum from the input const auto& in_data = getDataVector(getInputTable(2)).first; auto prefix = std::dynamic_pointer_cast<FixedLengthVector<value_id_t>>(in_data->copy()); // Cast the vectors to the lowest part in the hierarchy auto data_hash = getDataVector(result).first; auto data_pos = getDataVector(result, 1).first; // Get the check data const auto& rx_hashes = getDataVector(tab).first; const auto& rx_pos = getDataVector(tab, 1).first; auto mask1 = ((1 << _bits1) - 1) << _significantOffset1; auto mask2 = ((1 << _bits2) - 1) << _significantOffset2; size_t _start = 0, _stop = tableSize; if (_count > 0) { _start = (tableSize / _count) * _part; _stop = (_count -1) == _part ? tableSize : (tableSize/_count) * (_part + 1); } // Iterate over the first pass radix clustered table and write the // newly clustered results for(size_t row=_start; row < _stop; ++row) { const auto hash_value = rx_hashes->get(0, row); const auto part1 = (hash_value & mask1) >> _significantOffset1; const auto part2 = (hash_value & mask2) >> _significantOffset2; const auto lookup = part1 * (1 << _bits2) + part2; const auto pos_to_write = prefix->inc(0, lookup); data_hash->set(0, pos_to_write, hash_value); data_pos->set(0, pos_to_write, rx_pos->get(0, row)); } //ProfilerStop(); addResult(result); }
// calculates the prefix Sum for a given table void PrefixSum::executePlanOperation() { // get attribute vector of input table const auto &in = getInputTable(); const size_t table_size = in->size(); // get attribute vector of output table std::vector<storage::ColumnMetadata> metadata; metadata.push_back(in->metadataAt(0)); auto output = std::make_shared<storage::Table>(&metadata, nullptr, table_size, true, false); output->resize(table_size); const auto &oavs = output->getAttributeVectors(0); auto ovector = std::dynamic_pointer_cast<storage::FixedLengthVector<value_id_t>>(oavs.at(0).attribute_vector); // Build ivector list to avoid lock contention while getting the vectors const size_t ivec_size = input.numberOfTables(); std::vector<vec_ref_t> ivecs; for(size_t i=0; i < input.numberOfTables(); ++i) { ivecs.emplace_back(getDataVector(getInputTable(i)).first); } // calculate the prefix sum based on the index and the number of inputs // we need to look at to calculate the correct offset value_id_t sum = 0; for(size_t i=0; i < table_size; ++i) { sum += sumForIndex(ivec_size, ivecs, i); ovector->set(0, i, sum + sumForIndexPrev(ivec_size, ivecs, i)); } addResult(output); }
Datanum* Manager::getZero() { Vector<Datanum *> &vs = getDataVector(); for (Datanum* sp: vs) { if (sp->no == 0) return sp; } return NULL; }
Datanum* Manager::getZeroDown(Datanum * spZero) { int x = spZero->x+1; int y = spZero->y; Vector<Datanum *> &vs = getDataVector(); for (Datanum* sp : vs) { if (sp->x == x && sp->y == y) return sp; } return NULL; }
std::string Manager::getStr() { std::string str; int num[3][3]; Vector<Datanum *> &vs = getDataVector(); for (Datanum* sp : vs) { num[sp->x][sp->y] = sp->no; } for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { str += (num[i][j] + '0'); } } return str; }