Esempio n. 1
0
bool AbstractTable::contentEquals(const hyrise::storage::c_atable_ptr_t& other) const {

  if (size() != other->size()) {
    return false;
  }

  if (columnCount() != other->columnCount()) {
    return false;
  }

  for (size_t column = 0; column < columnCount(); column++) {
    auto md = metadataAt(column);
    auto md2 = other->metadataAt(column);

    if (md->getType() != md2->getType()) {
      return false;
    }

    if (md->getName() != md2->getName()) {
      return false;
    }

    for (size_t row = 0; row < size(); row++) {
      bool valueEqual = false;

      switch (md->getType()) {
        case IntegerType:
          valueEqual = getValue<hyrise_int_t>(column, row) == other->getValue<hyrise_int_t>(column,
                       row);
          break;

        case FloatType:
          valueEqual = getValue<hyrise_float_t>(column, row) == other->getValue<hyrise_float_t>(column, row);
          break;

        case StringType:
          valueEqual = getValue<std::string>(column, row).compare(other->getValue<std::string>(column, row)) == 0;
          break;

        default:
          break;
      }

      if (!valueEqual) {
        return false;
      }
    }
  }

  return true;
}
Esempio n. 2
0
::testing::AssertionResult AssertTableContentEquals(const char *left_exp,
                                                    const char *right_exp,
                                                    const hyrise::storage::c_atable_ptr_t left,
                                                    const hyrise::storage::c_atable_ptr_t right) {
  if (left->contentEquals(right)) {
    return ::testing::AssertionSuccess();
  }

  std::stringstream buf;

  PrettyPrinter::print(left.get(), buf, left_exp);
  PrettyPrinter::print(right.get(), buf, right_exp);
  return ::testing::AssertionFailure() << buf.str()
                                       << "The content of " << left_exp << " does not equal the content of " << right_exp;
}
Esempio n. 3
0
hyrise::storage::c_atable_ptr_t sortTable(hyrise::storage::c_atable_ptr_t table){
  size_t c = table->columnCount();
  for(size_t f = 0; f < c; f++){
    hyrise::access::SortScan so;
    so.addInput(table);
    so.setSortField(f);
    table = so.execute()->getResultTable();
  }
  return table;
}
Esempio n. 4
0
void AbstractTable::copyRowFrom(const hyrise::storage::c_atable_ptr_t& source, const size_t src_row, const size_t dst_row, const bool copy_values, const bool use_memcpy) {
  if (copy_values) {
    for (size_t column = 0; column < source->columnCount(); column++) {
      copyValueFrom(source, column, src_row, column, dst_row);
    }
  } else {
    if (use_memcpy) {
      // Use slices & memcpy
      // Assumes destination (this) is single row container
      assert(sliceCount() == 1);

      // this only gets the dest pointer, nothing else
      value_id_t *dst = (value_id_t *) atSlice(0, dst_row);
      size_t inc_width = 0, width = 0;

      for (size_t slice = 0; slice < source->sliceCount(); slice++) {

        // gets pointer to container at the row
        value_id_t *src = (value_id_t *) source->atSlice(slice, src_row);

        // slice width tells us how much memory we can copy
        width = source->getSliceWidth(slice);
        memcpy((char *)(dst) + inc_width, src, width);
        inc_width += width;
      }
    } else {
      // Copy single values
      for (size_t column = 0; column < source->columnCount(); column++) {
        setValueId(column, dst_row, source->getValueId(column, src_row));
      }
    }
  }
}
Esempio n. 5
0
void AbstractTable::copyValueFrom(const hyrise::storage::c_atable_ptr_t& source, const size_t src_col, const ValueId vid, const size_t dst_col, const size_t dst_row) {
  switch (source->typeOfColumn(src_col)) {
    case IntegerType:
      setValue<hyrise_int_t>(dst_col, dst_row, source->getValueForValueId<hyrise_int_t>(src_col, vid));
      break;

    case FloatType:
      setValue<hyrise_float_t>(dst_col, dst_row, source->getValueForValueId<hyrise_float_t>(src_col, vid));
      break;

    case StringType:
      setValue<hyrise_string_t>(dst_col, dst_row, source->getValueForValueId<hyrise_string_t>(src_col, vid));
      break;

    default:
      break;
  }
}
Esempio n. 6
0
  result operator()() {
    auto dict = std::dynamic_pointer_cast<OrderPreservingDictionary<R>>(_main->dictionaryAt(_column));
    std::set<R> data;

    // Build unified dictionary
    size_t deltaSize = _delta->size();
    for(size_t i=0; i < deltaSize; ++i) {
      data.insert(_delta->getValue<R>(_column, i));
    }
      

    size_t dictSize = dict->size();
    for(size_t i=0; i < dictSize; ++i)
      data.insert(dict->getValueForValueId(i));

    // Build mapping table for old dictionary
    auto start = data.cbegin();
    auto end = data.cend();
    size_t mapped = 0;
    
    std::vector<value_id_t> mapping;

    for(size_t i=0; i < dictSize; ++i) {
      auto val = dict->getValueForValueId(i);

      // Skip until we are equal
      while(start != end && *start != val) {
        ++mapped; ++start;
      }

      if (start != end)
        ++start;

      mapping.push_back(mapped++);
    }

    auto resultDict = std::make_shared<OrderPreservingDictionary<R>>(data.size());
    for(auto e : data)
      resultDict->addValue(e);

    result r = {std::move(mapping), std::move(resultDict)};
    return r;
  }
Esempio n. 7
0
size_t hash_value(const hyrise::storage::c_atable_ptr_t &source, const size_t &f, const ValueId &vid) {
  hyrise::storage::hash_functor<size_t> fun(source.get(), f, vid);
  hyrise::storage::type_switch<hyrise_basic_types> ts;
  return ts(source->typeOfColumn(f), fun);
}