本文整理汇总了C++中NValue::castAndSortAndDedupArrayForInList方法的典型用法代码示例。如果您正苦于以下问题:C++ NValue::castAndSortAndDedupArrayForInList方法的具体用法?C++ NValue::castAndSortAndDedupArrayForInList怎么用?C++ NValue::castAndSortAndDedupArrayForInList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NValue
的用法示例。
在下文中一共展示了NValue::castAndSortAndDedupArrayForInList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: p_execute
bool MaterializedScanExecutor::p_execute(const NValueArray ¶ms) {
MaterializedScanPlanNode* node = dynamic_cast<MaterializedScanPlanNode*>(m_abstractNode);
assert(node);
// output table has one column
Table* output_table = node->getOutputTable();
TableTuple& tmptup = output_table->tempTuple();
assert(output_table);
assert ((int)output_table->columnCount() == 1);
// get the output type
const TupleSchema::ColumnInfo *columnInfo = output_table->schema()->getColumnInfo(0);
ValueType outputType = columnInfo->getVoltType();
bool outputCantBeNull = !columnInfo->allowNull;
AbstractExpression* rowsExpression = node->getTableRowsExpression();
assert(rowsExpression);
// get array nvalue
NValue arrayNValue = rowsExpression->eval();
SortDirectionType sort_direction = node->getSortDirection();
// make a set to eliminate unique values in O(nlogn) time
std::vector<NValue> sortedUniques;
// iterate over the array of values and build a sorted/deduped set of
// values that don't overflow or violate unique constaints
arrayNValue.castAndSortAndDedupArrayForInList(outputType, sortedUniques);
// insert all items in the set in order
if (sort_direction != SORT_DIRECTION_TYPE_DESC) {
std::vector<NValue>::const_iterator iter;
for (iter = sortedUniques.begin(); iter != sortedUniques.end(); iter++) {
if ((*iter).isNull() && outputCantBeNull) {
continue;
}
tmptup.setNValue(0, *iter);
output_table->insertTuple(tmptup);
}
} else {
std::vector<NValue>::reverse_iterator reverse_iter;
for (reverse_iter = sortedUniques.rbegin(); reverse_iter != sortedUniques.rend(); reverse_iter++) {
if ((*reverse_iter).isNull() && outputCantBeNull) {
continue;
}
tmptup.setNValue(0, *reverse_iter);
output_table->insertTuple(tmptup);
}
}
VOLT_TRACE("\n%s\n", output_table->debug().c_str());
VOLT_DEBUG("Finished Materializing a Table");
return true;
}