Ejemplo n.º 1
0
atable_ptr_t Table::copy_structure(abstract_dictionary_callback ad, abstract_attribute_vector_callback aav) const {
  std::vector<ColumnMetadata> metadata;
  std::vector<adict_ptr_t> dicts;

  for (size_t i = 0; i < columnCount(); ++i) {
    metadata.push_back(metadataAt(i));
  }

  for (const auto& field : metadata) {
    dicts.push_back(ad(field.getType()));
  }

  return std::make_shared<Table>(
      metadata, checked_pointer_cast<BaseAttributeVector<value_id_t>>(aav(metadata.size())), dicts);
}
Ejemplo n.º 2
0
atable_ptr_t AbstractTable::copy_structure_modifiable(const field_list_t *fields, const size_t initial_size, const bool with_containers) const {
  std::vector<ColumnMetadata > metadata;
  auto dictionaries = std::unique_ptr<std::vector<AbstractTable::SharedDictionaryPtr > >(new std::vector<AbstractTable::SharedDictionaryPtr >);

  if (fields != nullptr) {
    for (const field_t & field: *fields) {
      auto m = metadataAt(field);
      m.setType(types::getUnorderedType(m.getType()));
      metadata.push_back(m);
      dictionaries->push_back(makeDictionary(m));
    }
  } else {
    for (size_t i = 0; i < columnCount(); ++i) {
      auto m = metadataAt(i);
      m.setType(types::getUnorderedType(m.getType()));
      metadata.push_back(m);
      dictionaries->push_back(makeDictionary(m));
    }
  }


  auto result = std::make_shared<Table>(&metadata, dictionaries.get(), initial_size, false);
  return result;
}
Ejemplo n.º 3
0
void SimpleRawTableScan::executePlanOperation() {
  auto table = std::dynamic_pointer_cast<const storage::RawTable>(input.getTable(0));
  if (!table)
    throw std::runtime_error("Input table is no uncompressed raw table");

  // Prepare a result that contains the result semi-compressed, and only row-wise
  storage::metadata_list meta(table->columnCount());
  for(size_t i=0; i<table->columnCount(); ++i)
    meta[i] = table->metadataAt(i);
  auto result = std::make_shared<storage::Table>(&meta,
                                                 nullptr,
                                                 1,  /* initial size */
                                                 false, /* sorted */
                                                 false /* compressed */);

  // Prepare the copy operator
  storage::copy_value_functor_raw_table fun(result, table);
  storage::type_switch<hyrise_basic_types> ts;
  auto positions = new storage::pos_list_t;

  size_t tabSize = table->size();
  for(size_t row=0; row < tabSize; ++row) {
    if ((*_comparator)(row)) {
      if (_materializing) {
        result->resize(result->size() + 1);
        for(size_t i=0; i < result->columnCount(); ++i) {
          fun.setValues(result->size() - 1, row, i);
          ts(table->typeOfColumn(i), fun);
        }
      }
      else {
        positions->push_back(row);
      }
    }
  }

  if (_materializing) {
    addResult(result);
  } else {
    addResult(storage::PointerCalculator::create(table, positions));
  }
}
Ejemplo n.º 4
0
metadata_vec_t AbstractTable::metadata() const {
  metadata_vec_t result(columnCount());
  for(size_t i=0; i < result.size(); ++i)
    result[i] = *metadataAt(i);
  return result;
}
Ejemplo n.º 5
0
std::string AbstractTable::nameOfColumn(const size_t column) const {
  return metadataAt(column)->getName();
}
Ejemplo n.º 6
0
DataType AbstractTable::typeOfColumn(const size_t column) const {
  return metadataAt(column)->getType();
}