Exemple #1
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));
      }
    }
  }
}
Exemple #2
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;
}
Exemple #3
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;
}