// A transformation method for protecting sequence functions from not // being evaluated due to short-circuit evaluation. // void ItmScalarMinMax::protectiveSequenceFunctionTransformation (Generator *generator) { // Recurse on the children // ItemExpr::protectiveSequenceFunctionTransformation(generator); // Remove the original value id from the node being transformed. // ValueId id = getValueId(); setValueId(NULL_VALUE_ID); synthTypeAndValueId(TRUE); // Construct the new subtree. // // SCALAR_MIN/MAX -- force evaluation of both children // // SCALAR(LEFT_CHILD, RIGHT_CHILD) ==> // BLOCK(BLOCK(LEFT_CHILD, RIGHT_CHILD), // SCALAR(LEFT_CHILD, RIGHT_CHILD)) // ItemExpr *block = new(generator->wHeap()) ItmBlockFunction (new(generator->wHeap()) ItmBlockFunction(child(0), child(1)), this); // Replace the old expression with the new expression for the // orginal value id // id.replaceItemExpr(block); // Run the new expression through type and value id synthesis // block->synthTypeAndValueId(TRUE); }
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)); } } } }
// A transformation method for protecting sequence functions from not // being evaluated due to short-circuit evaluation. // void BiLogic::protectiveSequenceFunctionTransformation(Generator *generator) { // Recurse on the children // ItemExpr::protectiveSequenceFunctionTransformation(generator); // Remove the original value id from the node being transformed and // assign it a new value id. // ValueId id = getValueId(); setValueId(NULL_VALUE_ID); synthTypeAndValueId(TRUE); // Construct the new subtree. // // AND/OR -- force right child evaluation // // LOGIC(LEFT_CHILD, RIGHT_CHILD) ==> // BLOCK(RIGHT_CHILD, LOGIC(LEFT_CHILD, RIGHT_CHILD)) // ItemExpr *block = new(generator->wHeap()) ItmBlockFunction(child(1), this); // Replace the old expression with the new expression for the // orginal value id // id.replaceItemExpr(block); // Run the new expression through type and value id synthesis // block->synthTypeAndValueId(TRUE); }
// A transformation method for protecting sequence functions from not // being evaluated due to short-circuit evaluation. // void Case::protectiveSequenceFunctionTransformation(Generator *generator) { // Recurse on the children // ItemExpr::protectiveSequenceFunctionTransformation(generator); // Remove the original value id from the node being transformed and // assign it a new value id. // ValueId id = getValueId(); setValueId(NULL_VALUE_ID); synthTypeAndValueId(TRUE); // Construct the new subtree. // // Case -- force evaluation of all the WHEN, THEN and ELSE parts // // CASE(IFE1(W1,T1,IFE2(W2,T2,IFE3(...)))) ==> // BLOCK(BLOCK(BLOCK(W1,T1),BLOCK(W2,T2)), CASE(...)) // // Decend the ITM_IF_THEN_ELSE tree pulling out each WHEN and THEN pair. // Mate each pair with a block and attach them to the protected block, // which contains all of the WHEN/THEN pairs for the entire tree. // Also, pull out any CASE operands and attach them to the protected // block as well. // ItemExpr *block = NULL; ItemExpr *ife = child(0); for(; (ife != NULL) && (ife->getOperatorType() == ITM_IF_THEN_ELSE); ife = ife->child(2)) { ItemExpr *sub = new(generator->wHeap()) ItmBlockFunction(ife->child(0), ife->child(1)); if(block) block = new(generator->wHeap()) ItmBlockFunction(sub, block); else block = sub; } // Add the ELSE condition, if any to the protected block // if(ife) block = new(generator->wHeap()) ItmBlockFunction(ife, block); // Construct the top-level block function. The left child is the protected // block, which contains all of the expresssions that need to be // pre-evaluated. This right child is the original case statement. // block = new(generator->wHeap()) ItmBlockFunction(block, this); // Replace the old expression with the new expression for the // original id // id.replaceItemExpr(block); // Run the new expression through type and value id synthesis // block->synthTypeAndValueId(TRUE); }
void AbstractTable::copyRowFrom(const 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 { // Copy single values for (size_t column = 0; column < source->columnCount(); column++) { setValueId(column, dst_row, source->getValueId(column, src_row)); } } }