Exemplo n.º 1
0
void SimpleTableDump::dumpHeader(std::string name, atable_ptr_t table) {
  std::stringstream header;
  std::vector<std::string> names, types;
  std::vector<uint32_t> parts;

  // Get names and types
  for (size_t i = 0; i < table->columnCount(); ++i) {
    names.push_back(table->nameOfColumn(i));
    types.push_back(data_type_to_string(table->typeOfColumn(i)));
  }

  // This calculation will break if the width of the value_id changes
  // or someone forgets to simply update the width accordingly in the
  // constructor of the table
  for (size_t i = 0; i < table->partitionCount(); ++i) {
    parts.push_back(table->partitionWidth(i));
  }

  // Dump and join
  header << std::accumulate(names.begin(), names.end(), std::string(), infix(" | ")) << "\n";
  header << std::accumulate(types.begin(), types.end(), std::string(), infix(" | ")) << "\n";
  std::vector<std::string> allParts;
  for (size_t i = 0; i < parts.size(); ++i) {
    auto p = parts[i];
    auto tmp = std::vector<std::string>(p, std::to_string(i) + "_R");
    allParts.insert(allParts.end(), tmp.begin(), tmp.end());
  }
  header << std::accumulate(allParts.begin(), allParts.end(), std::string(), infix(" | ")) << "\n";
  header << "===";

  std::string fullPath = _baseDirectory + "/" + name + "/header.dat";
  std::ofstream data(fullPath, std::ios::out | std::ios::binary);
  data << header.str();
  data.close();
}
Exemplo n.º 2
0
column_mapping_t identityMap(atable_ptr_t input) {
  column_mapping_t map;
  for (size_t column_index = 0; column_index < input->columnCount(); ++column_index)
    map[column_index] = column_index;
  return map;
}