Block MySQLBlockInputStream::readImpl() { auto row = result.fetch(); if (!row) return {}; auto block = description.sample_block.cloneEmpty(); /// cache pointers returned by the calls to getByPosition std::vector<IColumn *> columns(block.columns()); for (const auto i : ext::range(0, columns.size())) columns[i] = block.getByPosition(i).column.get(); std::size_t num_rows = 0; while (row) { for (const auto idx : ext::range(0, row.size())) { const auto value = row[idx]; if (!value.isNull()) insertValue(columns[idx], description.types[idx], value); else insertDefaultValue(columns[idx], *description.sample_columns[idx]); } ++num_rows; if (num_rows == max_block_size) break; row = result.fetch(); } return block; }
std::unique_ptr<IMergeTreeIndex> minmaxIndexCreator( const NamesAndTypesList & new_columns, std::shared_ptr<ASTIndexDeclaration> node, const Context & context) { if (node->name.empty()) throw Exception("Index must have unique name", ErrorCodes::INCORRECT_QUERY); if (node->type->arguments) throw Exception("Minmax index have not any arguments", ErrorCodes::INCORRECT_QUERY); ASTPtr expr_list = MergeTreeData::extractKeyExpressionList(node->expr->clone()); auto syntax = SyntaxAnalyzer(context, {}).analyze( expr_list, new_columns); auto minmax_expr = ExpressionAnalyzer(expr_list, syntax, context).getActions(false); auto sample = ExpressionAnalyzer(expr_list, syntax, context) .getActions(true)->getSampleBlock(); Names columns; DataTypes data_types; for (size_t i = 0; i < expr_list->children.size(); ++i) { const auto & column = sample.getByPosition(i); columns.emplace_back(column.name); data_types.emplace_back(column.type); } return std::make_unique<MergeTreeMinMaxIndex>( node->name, std::move(minmax_expr), columns, data_types, sample, node->granularity); }
LRESULT LocationsPage::onClickedRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { int i = -1; while((i = ctrlDirectories.GetNextItem(-1, LVNI_SELECTED)) != -1) { auto itemIter = getByPosition(i); if(removeDirectory(itemIter->first)) { ctrlDirectories.DeleteItem(i); i--; } } return 0; }
LRESULT LocationsPage::onClickedRename(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { int i = -1; while((i = ctrlDirectories.GetNextItem(i, LVNI_SELECTED)) != -1) { auto itemIter = getByPosition(i); LineDlg dlg; dlg.allowEmpty = false; dlg.title = TSTRING(RENAME); dlg.description = Text::toT(itemIter->first); dlg.line = Text::toT(itemIter->second); if (dlg.DoModal() == IDOK) { itemIter->second = Text::fromT(dlg.line); ctrlDirectories.SetItemText(i, 0, dlg.line.c_str()); } } return 0; }