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);
}
Esempio n. 2
0
void DataSetup::read(Names& N, bool skip_2, string dir)
{
  read_setup(skip_2, dir);

  int nn;
  string filename = dir + "/Player-FHE-Keys-P" + to_string(N.my_num());
  ifstream inpf(filename.c_str());
  if (inpf.fail()) { throw file_error(filename); }

  inpf >> nn;
  if (nn!=N.num_players())
    { cout << "KeyGen was last run with " << nn << " players." << endl;
      cout << "  - You are running Offline with " << N.num_players() << " players." << endl;
      exit(1);
    }

  /* Load in the public/private keys for this player */
  inpf >> pk_p >> sk_p;
  inpf >> pk_2 >> sk_2;

  /* Load in ciphertexts encrypting the MAC keys */
  inpf >> calphap;
  inpf >> calpha2;

  /* Loads in the players shares of the MAC keys */
  inpf >> alphapi;
  inpf >> alpha2i;

  inpf.close();

  cout << "Loaded the public keys etc" << endl;
}
DBusBrowser::DBusBrowser(::DBus::Connection &conn)
: ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME)
{
	set_title("D-Bus Browser");
	set_border_width(5);
	set_default_size(400, 500);

	typedef std::vector< std::string > Names;

	Names names = ListNames();

	for (Names::iterator it = names.begin(); it != names.end(); ++it)
	{
		_cb_busnames.append_text(*it);
	}

	_cb_busnames.signal_changed().connect(sigc::mem_fun(*this, &DBusBrowser::on_select_busname));

	_tm_inspect = Gtk::TreeStore::create(_records);
	_tv_inspect.set_model(_tm_inspect);
	_tv_inspect.append_column("Node", _records.name);

	_sc_tree.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
	_sc_tree.add(_tv_inspect);

	_vbox.pack_start(_cb_busnames, Gtk::PACK_SHRINK);
	_vbox.pack_start(_sc_tree);

	add(_vbox);

	show_all_children();
}
BlockInputStreams StorageSystemTables::read(
    const Names & column_names,
    const SelectQueryInfo & query_info,
    const Context & context,
    QueryProcessingStage::Enum /*processed_stage*/,
    const size_t max_block_size,
    const unsigned /*num_streams*/)
{
    check(column_names);

    /// Create a mask of what columns are needed in the result.

    NameSet names_set(column_names.begin(), column_names.end());

    Block sample_block = getSampleBlock();
    Block res_block;

    std::vector<UInt8> columns_mask(sample_block.columns());
    for (size_t i = 0, size = columns_mask.size(); i < size; ++i)
    {
        if (names_set.count(sample_block.getByPosition(i).name))
        {
            columns_mask[i] = 1;
            res_block.insert(sample_block.getByPosition(i));
        }
    }

    ColumnPtr filtered_databases_column = getFilteredDatabases(query_info.query, context);
    return {std::make_shared<TablesBlockInputStream>(
        std::move(columns_mask), std::move(res_block), max_block_size, std::move(filtered_databases_column), context)};
}
const synthv1widget_controls::Names& synthv1widget_controls::rpnNames (void)
{
	static struct
	{
		unsigned short param;
		const char *name;

	} s_rpns[] = {

		{  0, QT_TR_NOOP("Pitch Bend Sensitivity") },
		{  1, QT_TR_NOOP("Fine Tune") },
		{  2, QT_TR_NOOP("Coarse Tune") },
		{  3, QT_TR_NOOP("Tuning Program") },
		{  4, QT_TR_NOOP("Tuning Bank") },

		{  0, NULL }
	};

	static Names s_rpnNames;

	if (s_rpnNames.isEmpty()) {
		// Pre-load RPN-names hash table...
		for (int i = 0; s_rpns[i].name; ++i) {
			s_rpnNames.insert(s_rpns[i].param,
				QObject::tr(s_rpns[i].name, "rpnName"));
		}
	}

	return s_rpnNames;
}
Esempio n. 6
0
void Path::set( size_t begin, size_t end, const Names &names )
{
	if( begin > m_names.size() )
	{
		throw IECore::Exception( "Index out of range" );
	}

	if( end > m_names.size() )
	{
		throw IECore::Exception( "Index out of range" );
	}

	Names::difference_type sizeDifference = names.size() - (end - begin);

	if( sizeDifference == 0 )
	{
		if( equal( m_names.begin() + begin, m_names.begin() + end, names.begin() ) )
		{
			return;
		}
	}
	else if( sizeDifference > 0 )
	{
		m_names.resize( m_names.size() + sizeDifference );
		std::copy_backward( m_names.begin() + end, m_names.begin() + end + sizeDifference, m_names.end() );
	}
	else
	{
		std::copy( m_names.begin() + end, m_names.end(), m_names.begin() + end + sizeDifference );
		m_names.resize( m_names.size() + sizeDifference );
	}

	std::copy( names.begin(), names.end(), m_names.begin() + begin );
	emitPathChanged();
}
Esempio n. 7
0
Names NamesAndTypesList::getNames() const
{
    Names res;
    res.reserve(size());
    for (const NameAndTypePair & column : *this)
        res.push_back(column.name);
    return res;
}
Esempio n. 8
0
int main()
{
	Names name;
	name.setName("Dylan");
	cout << "Your new name is " << name.getName() << endl;

	system("PAUSE");
	return 0;
}
Esempio n. 9
0
NameSet MergeTreeReadPool::injectRequiredColumns(const MergeTreeData::DataPartPtr & part, Names & columns) const
{
	NameSet required_columns{std::begin(columns), std::end(columns)};
	NameSet injected_columns;

	auto all_column_files_missing = true;

	for (size_t i = 0; i < columns.size(); ++i)
	{
		const auto & column_name = columns[i];

		/// column has files and hence does not require evaluation
		if (part->hasColumnFiles(column_name))
		{
			all_column_files_missing = false;
			continue;
		}

		const auto default_it = data.column_defaults.find(column_name);
		/// columns has no explicit default expression
		if (default_it == std::end(data.column_defaults))
			continue;

		/// collect identifiers required for evaluation
		IdentifierNameSet identifiers;
		default_it->second.expression->collectIdentifierNames(identifiers);

		for (const auto & identifier : identifiers)
		{
			if (data.hasColumn(identifier))
			{
				/// ensure each column is added only once
				if (required_columns.count(identifier) == 0)
				{
					columns.emplace_back(identifier);
					required_columns.emplace(identifier);
					injected_columns.emplace(identifier);
				}
			}
		}
	}

	/** Добавить столбец минимального размера.
		* Используется в случае, когда ни один столбец не нужен или файлы отсутствуют, но нужно хотя бы знать количество строк.
		* Добавляет в columns.
		*/
	if (all_column_files_missing)
	{
		const auto minimum_size_column_name = part->getColumnNameWithMinumumCompressedSize();
		columns.push_back(minimum_size_column_name);
		/// correctly report added column
		injected_columns.insert(columns.back());
	}

	return injected_columns;
}
Esempio n. 10
0
Paving Paving::projection(const Names &names) {

  Paving result;
  NamedBox varbox;   // varbox for result, varbox_ for this paving
  Tuple varlist;   // list of variables to be retained
  varlist.resize(names.size());
  result.set_type(type_);

  // push the relevant names and intervals
  for (nat i = 0; i < names.size(); ++i) {
    nat v = varbox_.var(names[i]);
    if (v < varbox_.size()) {
      varbox.push(names[i], varbox_.val(v));
      varlist[i] = v;
    } else {
      std::ostringstream os;
      os << "Kodiak (projection): name \"" << names[i] << "\" doesn't exist in the paving.";
      throw Growl(os.str());
    }
  }
  result.set_varbox(varbox);

  // add boxes
  Box x;
  x.resize(names.size());
  if (boxes_.size() == 0) return result;
  for (nat i = 0; i < boxes_.size(); ++i) { // iterate over types
    if (boxes_[i].size() == 0) continue;
    // add the first box
    for (nat k = 0; k < names.size(); ++k) x[k] = boxes_[i][0][varlist[k]];
    result.push_box(i, x);
    if (boxes_[i].size() == 1) continue;
    // add remaining boxes where necessary
    for (nat j = 1; j < boxes_[i].size(); ++j) {
      for (nat k = 0; k < names.size(); ++k) x[k] = boxes_[i][j][varlist[k]];
      nat subset = 0;   // is the jth box a subset of any box already
      // pushed into the result paving?
      for (nat jj = 0; jj < result.boxes(i).size(); ++jj) {
        if (box_subset(result.boxes(i)[jj], x)) {
          subset = 1;
          break;
        }
      }
      if (subset == 0) result.push_box(i, x);
    }
  }

  for (nat i = 0; i < boxes_.size(); ++i) { // iterate over types
    encluster(result.boxes(i));
  }

  result.set_type(type_);
  return result;

}
Esempio n. 11
0
  string name(const char* baseName)
  {
    Names::iterator p = names_number_.find(string(baseName));
    int id = (p == names_number_.end()) ? 0 : names_number_[baseName] + 1;
    names_number_[baseName] = id;

    enum { BufferSize = 14 };
    char buffer[BufferSize];
    snprintf(buffer, BufferSize, "_%d", id);

    return (string(baseName) + buffer + ".log").c_str();
  }
Esempio n. 12
0
 static void s_add(const char * var,const char * pool) {
   char * s = new char[strlen(var)+1];
   strcpy(s,var);
   MI w = s_poolname_to_prototype_p->find(pool);
   if(w==s_poolname_to_prototype_p->end()){
     NoPoolError(pool);
   };
   if(s_vars.find(var)!=s_vars.end()) {
     VarAlreadyError(var);
   };
   Names * p = (*w).second;
   p = p->prototype();
   pair<const char *,Names *> pr(s,p);
   s_vars.insert(pr);
 };
SemanticResults::Names SemanticResults::semanticResults(const SPPHRASEPROPERTY * pProperty) {
	Names names;
	if (pProperty) {
		names.insert({ RuleName::withoutChoiceIndex(pProperty->pszName) , pProperty->pszName });
		if (pProperty->pFirstChild) {
			Names children = semanticResults(pProperty->pFirstChild);
			names.insert(children.begin(), children.end());
		}
		if (pProperty->pNextSibling) {
			Names children = semanticResults(pProperty->pNextSibling);
			names.insert(children.begin(), children.end());
		}
	}
	return names;
}
Esempio n. 14
0
void ITableDeclaration::check(const Names & column_names) const
{
	const NamesAndTypesList & available_columns = getColumnsList();

	if (column_names.empty())
		throw Exception("Empty list of columns queried. There are columns: " + listOfColumns(available_columns),
			ErrorCodes::EMPTY_LIST_OF_COLUMNS_QUERIED);

	const auto columns_map = getColumnsMap(available_columns);

	using UniqueStrings = google::dense_hash_set<StringRef, StringRefHash>;
	UniqueStrings unique_names;
	unique_names.set_empty_key(StringRef());

	for (const auto & name : column_names)
	{
		if (columns_map.end() == columns_map.find(name))
			throw Exception("There is no column with name " + name + " in table. There are columns: " + listOfColumns(available_columns),
				ErrorCodes::NO_SUCH_COLUMN_IN_TABLE);

		if (unique_names.end() != unique_names.find(name))
			throw Exception("Column " + name + " queried more than once",
				ErrorCodes::COLUMN_QUERIED_MORE_THAN_ONCE);
		unique_names.insert(name);
	}
}
Esempio n. 15
0
void ITableDeclaration::check(const NamesAndTypesList & columns, const Names & column_names) const
{
	const NamesAndTypesList & available_columns = getColumnsList();
	const auto available_columns_map = getColumnsMap(available_columns);
	const NamesAndTypesMap & provided_columns_map = getColumnsMap(columns);

	if (column_names.empty())
		throw Exception("Empty list of columns queried. There are columns: " + listOfColumns(available_columns),
			ErrorCodes::EMPTY_LIST_OF_COLUMNS_QUERIED);

	using UniqueStrings = google::dense_hash_set<StringRef, StringRefHash>;
	UniqueStrings unique_names;
	unique_names.set_empty_key(StringRef());

	for (const String & name : column_names)
	{
		NamesAndTypesMap::const_iterator it = provided_columns_map.find(name);
		if (provided_columns_map.end() == it)
			continue;

		NamesAndTypesMap::const_iterator jt = available_columns_map.find(name);
		if (available_columns_map.end() == jt)
			throw Exception("There is no column with name " + name + ". There are columns: "
				+ listOfColumns(available_columns), ErrorCodes::NO_SUCH_COLUMN_IN_TABLE);

		if (it->second->getName() != jt->second->getName())
			throw Exception("Type mismatch for column " + name + ". Column has type "
				+ jt->second->getName() + ", got type " + it->second->getName(), ErrorCodes::TYPE_MISMATCH);

		if (unique_names.end() != unique_names.find(name))
			throw Exception("Column " + name + " queried more than once",
				ErrorCodes::COLUMN_QUERIED_MORE_THAN_ONCE);
		unique_names.insert(name);
	}
}
Esempio n. 16
0
/**
 * @brief Reloads the ui scripts and reinitializes the ui
 */
static void UI_Restart_f (void)
{
	typedef std::vector<std::string> Names;
	Names names;
	for (int i = 0; i < ui_global.windowStackPos; i++) {
		names.push_back(std::string(ui_global.windowStack[i]->name));
	}

	UI_Shutdown();
	CLMN_Shutdown();
	R_FontShutdown();
	UI_Init();
	R_FontInit();
	Com_Printf("%i ui script files\n", FS_BuildFileList("ufos/ui/*.ufo"));
	FS_NextScriptHeader(nullptr, nullptr, nullptr);
	const char* type, *name, *text;
	text = nullptr;
	while ((type = FS_NextScriptHeader("ufos/*.ufo", &name, &text)) != nullptr) {
		if (Q_streq(type, "font"))
			UI_ParseFont(name, &text);
		else if (Q_streq(type, "menu_model"))
			UI_ParseUIModel(name, &text);
		else if (Q_streq(type, "sprite"))
			UI_ParseSprite(name, &text);
	}
	UI_Reinit();
	FS_NextScriptHeader(nullptr, nullptr, nullptr);
	text = nullptr;
	while ((type = FS_NextScriptHeader("ufos/ui/*.ufo", &name, &text)) != nullptr) {
		if (Q_streq(type, "window"))
			UI_ParseWindow(type, name, &text);
		else if (Q_streq(type, "component"))
			UI_ParseComponent(type, name, &text);
		else if (Q_streq(type, "menu_model"))
			UI_ParseUIModel(name, &text);
		else if (Q_streq(type, "sprite"))
			UI_ParseSprite(name, &text);
		else if (Q_streq(type, "lua"))
			UI_ParseAndLoadLuaScript(name, &text);
	}

	CLMN_Init();

	for (Names::iterator i = names.begin(); i != names.end(); ++i) {
		UI_PushWindow(i->c_str());
	}
}
Esempio n. 17
0
void Paving::save(const std::string filename, const Names &titles, const Names &names) const {
  if (empty()) return;
  Tuple vs;
  for (nat v = 0; v < names.size(); ++v) {
    nat n = varbox_.var(names[v]);
    if (n < nvars())
      vs.push_back(n);
  }
  std::ostringstream os;
  os << filename;
  for (nat i = 0; i < vs.size(); ++i)
    os << "_" << varbox_.name(vs[i]);
  os << ".dat";
  if (vs.empty()) {
    vs.resize(varbox_.size());
    for (nat v = 0; v < varbox_.size(); ++v)
      vs[v] = v;
  }
  std::ofstream f;
  f.open(os.str().c_str(), std::ofstream::out);
  f << "## File: " << os.str() << std::endl;
  f << "## Type: " << type_ << std::endl;
  f << "## Vars:" << std::endl;
  nat width = 2 * Kodiak::precision();
  for (nat i = 0; i < vs.size(); ++i)
    f << std::setw(width) << varbox_.name(vs[i]);
  f << std::endl;
  for (nat i = 0; i < vs.size(); ++i)
    f << std::setw(width) << varbox_.box()[vs[i]].inf();
  f << std::endl;
  for (nat i = 0; i < vs.size(); ++i)
    f << std::setw(width) << varbox_.box()[vs[i]].sup();
  f << std::endl;
  f << std::endl;
  for (nat i = 0; i < titles.size(); ++i) {
    f << "## " << titles[i] << ": " << size(i) << " boxes " << std::endl;
    if (i < boxes_.size() && boxes_[i].size() > 0)
      save_boxes(f, boxes_[i], vs, width);
    else
      f << std::endl;
  }
  f.close();
  std::cout << "Kodiak (save): Boxes were saved in file " << os.str() << std::endl;
}
Esempio n. 18
0
    NonJoinedBlockInputStream(const Join & parent_, const Block & left_sample_block, const Names & key_names_left, size_t max_block_size_)
        : parent(parent_), max_block_size(max_block_size_)
    {
        /** left_sample_block contains keys and "left" columns.
          * result_sample_block - keys, "left" columns, and "right" columns.
          */

        size_t num_keys = key_names_left.size();
        size_t num_columns_left = left_sample_block.columns() - num_keys;
        size_t num_columns_right = parent.sample_block_with_columns_to_add.columns();

        result_sample_block = materializeBlock(left_sample_block);

        /// Add columns from the right-side table to the block.
        for (size_t i = 0; i < num_columns_right; ++i)
        {
            const ColumnWithTypeAndName & src_column = parent.sample_block_with_columns_to_add.getByPosition(i);
            result_sample_block.insert(src_column.cloneEmpty());
        }

        column_indices_left.reserve(num_columns_left);
        column_indices_keys_and_right.reserve(num_keys + num_columns_right);
        std::vector<bool> is_key_column_in_left_block(num_keys + num_columns_left, false);

        for (const std::string & key : key_names_left)
        {
            size_t key_pos = left_sample_block.getPositionByName(key);
            is_key_column_in_left_block[key_pos] = true;
            /// Here we establish the mapping between key columns of the left- and right-side tables.
            /// key_pos index is inserted in the position corresponding to key column in parent.blocks
            /// (saved blocks of the right-side table) and points to the same key column
            /// in the left_sample_block and thus in the result_sample_block.
            column_indices_keys_and_right.push_back(key_pos);
        }

        for (size_t i = 0; i < num_keys + num_columns_left; ++i)
        {
            if (!is_key_column_in_left_block[i])
                column_indices_left.push_back(i);
        }

        for (size_t i = 0; i < num_columns_right; ++i)
            column_indices_keys_and_right.push_back(num_keys + num_columns_left + i);

        /// If use_nulls, convert left columns to Nullable.
        if (parent.use_nulls)
        {
            for (size_t i = 0; i < num_columns_left; ++i)
            {
                convertColumnToNullable(result_sample_block.getByPosition(column_indices_left[i]));
            }
        }

        columns_left.resize(num_columns_left);
        columns_keys_and_right.resize(num_keys + num_columns_right);
    }
Esempio n. 19
0
BlockInputStreams StorageStripeLog::read(
    const Names & column_names,
    const SelectQueryInfo & /*query_info*/,
    const Context & context,
    QueryProcessingStage::Enum & processed_stage,
    const size_t /*max_block_size*/,
    unsigned num_streams)
{
    std::shared_lock<std::shared_mutex> lock(rwlock);

    check(column_names);
    processed_stage = QueryProcessingStage::FetchColumns;

    NameSet column_names_set(column_names.begin(), column_names.end());

    if (!Poco::File(full_path() + "index.mrk").exists())
        return { std::make_shared<NullBlockInputStream>() };

    CompressedReadBufferFromFile index_in(full_path() + "index.mrk", 0, 0, INDEX_BUFFER_SIZE);
    std::shared_ptr<const IndexForNativeFormat> index{std::make_shared<IndexForNativeFormat>(index_in, column_names_set)};

    BlockInputStreams res;

    size_t size = index->blocks.size();
    if (num_streams > size)
        num_streams = size;

    for (size_t stream = 0; stream < num_streams; ++stream)
    {
        IndexForNativeFormat::Blocks::const_iterator begin = index->blocks.begin();
        IndexForNativeFormat::Blocks::const_iterator end = index->blocks.begin();

        std::advance(begin, stream * size / num_streams);
        std::advance(end, (stream + 1) * size / num_streams);

        res.emplace_back(std::make_shared<StripeLogBlockInputStream>(
            *this, context.getSettingsRef().max_read_buffer_size, index, begin, end));
    }

    /// We do not keep read lock directly at the time of reading, because we read ranges of data that do not change.

    return res;
}
Esempio n. 20
0
Names Macros::expand(const Names & source_names, size_t level) const
{
    Names result_names;
    result_names.reserve(source_names.size());

    for (const String & name : source_names)
        result_names.push_back(expand(name, level));

    return result_names;
}
Esempio n. 21
0
void C2Sema::analyseStructNames(const StructTypeDecl* S, Names& names) {
    typedef Names::iterator NamesIter;
    for (unsigned i=0; i<S->numMembers(); i++) {
        const Decl* member = S->getMember(i);
        const std::string& name = member->getName();
        if (name == "") {
            assert(isa<StructTypeDecl>(member));
            analyseStructNames(cast<StructTypeDecl>(member), names);
        } else {
            NamesIter iter = names.find(name);
            if (iter != names.end()) {
                const Decl* existing = iter->second;
                Diag(member->getLocation(), diag::err_duplicate_member) << name;
                Diag(existing->getLocation(), diag::note_previous_declaration);
            } else {
                names[name] = member;
            }
        }
    }
}
Esempio n. 22
0
TEST(DATASTOR,NamesImpl)
{
    FILELog::Level() = LL_INFO;

    string path = FileIo::getTempName("/tmp");
    CwseDatasetConfig cfg = Dataset::getDefaultDatasetConfig();
    Dataset::create(path.c_str(), &cfg);
    Dataset* p = Dataset::open(path.c_str(), CWSE_DATA_ACCESS_READ_ONLY);

    Names* names = p->getNames(NULL);
    string name;
    ASSERT_FALSE(names->next(name));
    delete names;

    names = p->getNames(NULL);
    NamesImpl* nimpl = static_cast<NamesImpl*>(names);
    nimpl->reserve(5);
    nimpl->add("one");
    nimpl->add("two");
    nimpl->add("three");
    ASSERT_TRUE(names->next(name));
    ASSERT_EQ(name, string("one"));
    ASSERT_TRUE(names->next(name));
    ASSERT_EQ(name, string("two"));
    ASSERT_TRUE(names->next(name));
    ASSERT_EQ(name, string("three"));
    ASSERT_FALSE(names->next(name));
    delete names;

    delete p;
    FileIo::rmdir(path.c_str());
}
Esempio n. 23
0
const synthv1widget_controls::Names& synthv1widget_controls::control14Names (void)
{
	static struct
	{
		unsigned short param;
		const char *name;

	} s_control14s[] = {

		{  1, QT_TR_NOOP("Modulation Wheel (14bit)") },
		{  2, QT_TR_NOOP("Breath Controller (14bit)") },
		{  4, QT_TR_NOOP("Foot Pedal (14bit)") },
		{  5, QT_TR_NOOP("Portamento Time (14bit)") },
		{  7, QT_TR_NOOP("Volume (14bit)") },
		{  8, QT_TR_NOOP("Balance (14bit)") },
		{ 10, QT_TR_NOOP("Pan Position (14bit)") },
		{ 11, QT_TR_NOOP("Expression (14bit)") },
		{ 12, QT_TR_NOOP("Effect Control 1 (14bit)") },
		{ 13, QT_TR_NOOP("Effect Control 2 (14bit)") },
		{ 16, QT_TR_NOOP("General Purpose Slider 1 (14bit)") },
		{ 17, QT_TR_NOOP("General Purpose Slider 2 (14bit)") },
		{ 18, QT_TR_NOOP("General Purpose Slider 3 (14bit)") },
		{ 19, QT_TR_NOOP("General Purpose Slider 4 (14bit)") },

		{  0, NULL }
	};

	static Names s_control14Names;

	if (s_control14Names.isEmpty()) {
		// Pre-load controller-names hash table...
		for (int i = 0; s_control14s[i].name; ++i) {
			s_control14Names.insert(s_control14s[i].param,
				QObject::tr(s_control14s[i].name, "control14Name"));
		}
	}

	return s_control14Names;
}
Esempio n. 24
0
void Join::checkTypesOfKeys(const Block & block_left, const Names & key_names_left, const Block & block_right) const
{
    size_t keys_size = key_names_left.size();

    for (size_t i = 0; i < keys_size; ++i)
    {
        /// Compare up to Nullability.

        DataTypePtr left_type = removeNullable(recursiveRemoveLowCardinality(block_left.getByName(key_names_left[i]).type));
        DataTypePtr right_type = removeNullable(recursiveRemoveLowCardinality(block_right.getByName(key_names_right[i]).type));

        if (!left_type->equals(*right_type))
            throw Exception("Type mismatch of columns to JOIN by: "
                + key_names_left[i] + " " + left_type->getName() + " at left, "
                + key_names_right[i] + " " + right_type->getName() + " at right",
                ErrorCodes::TYPE_MISMATCH);
    }
}
Esempio n. 25
0
Parallel_MAC_Check<T>::Parallel_MAC_Check(const T& ai, Names& Nms,
    int thread_num, int opening_sum, int max_broadcast, int base_player) :
    Separate_MAC_Check<T>(ai, Nms, thread_num, opening_sum, max_broadcast, base_player),
    send_player(Nms, mc_base_id<T>(2, thread_num)),
    send_base_player(base_player)
{
  int sum_players = Nms.num_players();
  Player* summer_send_player = &send_player;
  for (int i = 0; ; i++)
    {
      int last_sum_players = sum_players;
      sum_players = (sum_players - 2 + opening_sum) / opening_sum;
      int next_sum_players = (sum_players - 2 + opening_sum) / opening_sum;
      if (sum_players == 0)
        break;
      Player* summer_receive_player = summer_send_player;
      summer_send_player = new PlainPlayer(Nms, mc_base_id<T>(3, thread_num));
      summers.push_back(new Summer<T>(sum_players, last_sum_players, next_sum_players,
              summer_send_player, summer_receive_player, *this));
      pthread_create(&(summers[i]->thread), 0, run_summer_thread<T>, summers[i]);
    }
  receive_player = summer_send_player;
}
Esempio n. 26
0
int main(int argc, char ** argv)
{
    using namespace DB;

    try
    {

    if (argc < 2)
    {
        std::cerr << "at least 1 argument expected" << std::endl;
        return 1;
    }

    Context context;

    NamesAndTypesList columns;
    for (int i = 2; i + 1 < argc; i += 2)
    {
        NameAndTypePair col;
        col.name = argv[i];
        col.type = DataTypeFactory::instance().get(argv[i + 1]);
        columns.push_back(col);
    }

    ASTPtr root;
    ParserPtr parsers[] = {std::make_unique<ParserSelectQuery>(), std::make_unique<ParserExpressionList>(false)};
    for (size_t i = 0; i < sizeof(parsers)/sizeof(parsers[0]); ++i)
    {
        IParser & parser = *parsers[i];
        const char * pos = argv[1];
        const char * end = argv[1] + strlen(argv[1]);
        const char * max_parsed_pos = pos;
        Expected expected = "";
        if (parser.parse(pos, end, root, max_parsed_pos, expected))
            break;
        else
            root = nullptr;
    }
    if (!root)
    {
        std::cerr << "invalid expression (should be select query or expression list)" << std::endl;
        return 2;
    }

    formatAST(*root, std::cout);
    std::cout << std::endl;

    ExpressionAnalyzer analyzer(root, context, {}, columns);

    Names required = analyzer.getRequiredColumns();
    std::cout << "required columns:\n";
    for (size_t i = 0; i < required.size(); ++i)
    {
        std::cout << required[i] << "\n";
    }
    std::cout << "\n";

    std::cout << "only consts:\n\n" << analyzer.getConstActions()->dumpActions() << "\n";

    if (analyzer.hasAggregation())
    {
        Names key_names;
        AggregateDescriptions aggregates;
        analyzer.getAggregateInfo(key_names, aggregates);

        std::cout << "keys:\n";
        for (size_t i = 0; i < key_names.size(); ++i)
            std::cout << key_names[i] << "\n";
        std::cout << "\n";

        std::cout << "aggregates:\n";
        for (size_t i = 0; i < aggregates.size(); ++i)
        {
            AggregateDescription desc = aggregates[i];

            std::cout << desc.column_name << " = " << desc.function->getName() << " ( ";
            for (size_t j = 0; j < desc.argument_names.size(); ++j)
                std::cout << desc.argument_names[j] << " ";
            std::cout << ")\n";
        }
        std::cout << "\n";

        ExpressionActionsChain before;
        if (analyzer.appendWhere(before, false))
            before.addStep();
        analyzer.appendAggregateFunctionsArguments(before, false);
        analyzer.appendGroupBy(before, false);
        before.finalize();

        ExpressionActionsChain after;
        if (analyzer.appendHaving(after, false))
            after.addStep();
        analyzer.appendSelect(after, false);
        analyzer.appendOrderBy(after, false);
        after.addStep();
        analyzer.appendProjectResult(after, false);
        after.finalize();

        std::cout << "before aggregation:\n\n";
        for (size_t i = 0; i < before.steps.size(); ++i)
        {
            std::cout << before.steps[i].actions->dumpActions();
            std::cout << std::endl;
        }

        std::cout << "\nafter aggregation:\n\n";
        for (size_t i = 0; i < after.steps.size(); ++i)
        {
            std::cout << after.steps[i].actions->dumpActions();
            std::cout << std::endl;
        }
    }
    else
    {
        if (typeid_cast<ASTSelectQuery *>(&*root))
        {
            ExpressionActionsChain chain;
            if (analyzer.appendWhere(chain, false))
                chain.addStep();
            analyzer.appendSelect(chain, false);
            analyzer.appendOrderBy(chain, false);
            chain.addStep();
            analyzer.appendProjectResult(chain, false);
            chain.finalize();

            for (size_t i = 0; i < chain.steps.size(); ++i)
            {
                std::cout << chain.steps[i].actions->dumpActions();
                std::cout << std::endl;
            }
        }
        else
        {
            std::cout << "unprojected actions:\n\n" << analyzer.getActions(false)->dumpActions() << "\n";
            std::cout << "projected actions:\n\n" << analyzer.getActions(true)->dumpActions() << "\n";
        }
    }

    }
    catch (Exception & e)
    {
        std::cerr << "Exception " << e.what() << ": " << e.displayText() << "\n" << e.getStackTrace().toString();
        return 3;
    }

    return 0;
}
Esempio n. 27
0
const synthv1widget_controls::Names& synthv1widget_controls::controllerNames (void)
{
	static struct
	{
		unsigned short param;
		const char *name;

	} s_controllers[] = {

		{  0, QT_TR_NOOP("Bank Select (coarse)") },
		{  1, QT_TR_NOOP("Modulation Wheel (coarse)") },
		{  2, QT_TR_NOOP("Breath Controller (coarse)") },
		{  4, QT_TR_NOOP("Foot Pedal (coarse)") },
		{  5, QT_TR_NOOP("Portamento Time (coarse)") },
		{  6, QT_TR_NOOP("Data Entry (coarse)") },
		{  7, QT_TR_NOOP("Volume (coarse)") },
		{  8, QT_TR_NOOP("Balance (coarse)") },
		{ 10, QT_TR_NOOP("Pan Position (coarse)") },
		{ 11, QT_TR_NOOP("Expression (coarse)") },
		{ 12, QT_TR_NOOP("Effect Control 1 (coarse)") },
		{ 13, QT_TR_NOOP("Effect Control 2 (coarse)") },
		{ 16, QT_TR_NOOP("General Purpose Slider 1") },
		{ 17, QT_TR_NOOP("General Purpose Slider 2") },
		{ 18, QT_TR_NOOP("General Purpose Slider 3") },
		{ 19, QT_TR_NOOP("General Purpose Slider 4") },
		{ 32, QT_TR_NOOP("Bank Select (fine)") },
		{ 33, QT_TR_NOOP("Modulation Wheel (fine)") },
		{ 34, QT_TR_NOOP("Breath Controller (fine)") },
		{ 36, QT_TR_NOOP("Foot Pedal (fine)") },
		{ 37, QT_TR_NOOP("Portamento Time (fine)") },
		{ 38, QT_TR_NOOP("Data Entry (fine)") },
		{ 39, QT_TR_NOOP("Volume (fine)") },
		{ 40, QT_TR_NOOP("Balance (fine)") },
		{ 42, QT_TR_NOOP("Pan Position (fine)") },
		{ 43, QT_TR_NOOP("Expression (fine)") },
		{ 44, QT_TR_NOOP("Effect Control 1 (fine)") },
		{ 45, QT_TR_NOOP("Effect Control 2 (fine)") },
		{ 64, QT_TR_NOOP("Hold Pedal (on/off)") },
		{ 65, QT_TR_NOOP("Portamento (on/off)") },
		{ 66, QT_TR_NOOP("Sustenuto Pedal (on/off)") },
		{ 67, QT_TR_NOOP("Soft Pedal (on/off)") },
		{ 68, QT_TR_NOOP("Legato Pedal (on/off)") },
		{ 69, QT_TR_NOOP("Hold 2 Pedal (on/off)") },
		{ 70, QT_TR_NOOP("Sound Variation") },
		{ 71, QT_TR_NOOP("Sound Timbre") },
		{ 72, QT_TR_NOOP("Sound Release Time") },
		{ 73, QT_TR_NOOP("Sound Attack Time") },
		{ 74, QT_TR_NOOP("Sound Brightness") },
		{ 75, QT_TR_NOOP("Sound Control 6") },
		{ 76, QT_TR_NOOP("Sound Control 7") },
		{ 77, QT_TR_NOOP("Sound Control 8") },
		{ 78, QT_TR_NOOP("Sound Control 9") },
		{ 79, QT_TR_NOOP("Sound Control 10") },
		{ 80, QT_TR_NOOP("General Purpose Button 1 (on/off)") },
		{ 81, QT_TR_NOOP("General Purpose Button 2 (on/off)") },
		{ 82, QT_TR_NOOP("General Purpose Button 3 (on/off)") },
		{ 83, QT_TR_NOOP("General Purpose Button 4 (on/off)") },
		{ 91, QT_TR_NOOP("Effects Level") },
		{ 92, QT_TR_NOOP("Tremulo Level") },
		{ 93, QT_TR_NOOP("Chorus Level") },
		{ 94, QT_TR_NOOP("Celeste Level") },
		{ 95, QT_TR_NOOP("Phaser Level") },
		{ 96, QT_TR_NOOP("Data Button Increment") },
		{ 97, QT_TR_NOOP("Data Button Decrement") },
		{ 98, QT_TR_NOOP("Non-Registered Parameter (fine)") },
		{ 99, QT_TR_NOOP("Non-Registered Parameter (coarse)") },
		{100, QT_TR_NOOP("Registered Parameter (fine)") },
		{101, QT_TR_NOOP("Registered Parameter (coarse)") },
		{120, QT_TR_NOOP("All Sound Off") },
		{121, QT_TR_NOOP("All Controllers Off") },
		{122, QT_TR_NOOP("Local Keyboard (on/off)") },
		{123, QT_TR_NOOP("All Notes Off") },
		{124, QT_TR_NOOP("Omni Mode Off") },
		{125, QT_TR_NOOP("Omni Mode On") },
		{126, QT_TR_NOOP("Mono Operation") },
		{127, QT_TR_NOOP("Poly Operation") },

		{  0, NULL }
	};

	static Names s_controllerNames;

	// Pre-load controller-names hash table...
	if (s_controllerNames.isEmpty()) {
		for (int i = 0; s_controllers[i].name; ++i) {
			s_controllerNames.insert(s_controllers[i].param,
				QObject::tr(s_controllers[i].name, "controllerName"));
		}
	}

	return s_controllerNames;
}
Esempio n. 28
0
void DataSetup::write_setup(const Names& N, bool skip_2)
{
  write_setup(get_prep_dir(N.num_players()), skip_2);
}
InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(
    const ASTPtr & query_ptr_,
    const Context & context_,
    const Names & required_result_column_names,
    QueryProcessingStage::Enum to_stage_,
    size_t subquery_depth_,
    bool only_analyze,
    bool modify_inplace)
    : query_ptr(query_ptr_),
    context(context_),
    to_stage(to_stage_),
    subquery_depth(subquery_depth_)
{
    const ASTSelectWithUnionQuery & ast = typeid_cast<const ASTSelectWithUnionQuery &>(*query_ptr);

    size_t num_selects = ast.list_of_selects->children.size();

    if (!num_selects)
        throw Exception("Logical error: no children in ASTSelectWithUnionQuery", ErrorCodes::LOGICAL_ERROR);

    /// Initialize interpreters for each SELECT query.
    /// Note that we pass 'required_result_column_names' to first SELECT.
    /// And for the rest, we pass names at the corresponding positions of 'required_result_column_names' in the result of first SELECT,
    ///  because names could be different.

    nested_interpreters.reserve(num_selects);

    std::vector<Names> required_result_column_names_for_other_selects(num_selects);
    if (!required_result_column_names.empty() && num_selects > 1)
    {
        /// Result header if there are no filtering by 'required_result_column_names'.
        /// We use it to determine positions of 'required_result_column_names' in SELECT clause.

        Block full_result_header = InterpreterSelectQuery(
            ast.list_of_selects->children.at(0), context, Names(), to_stage, subquery_depth, true).getSampleBlock();

        std::vector<size_t> positions_of_required_result_columns(required_result_column_names.size());
        for (size_t required_result_num = 0, size = required_result_column_names.size(); required_result_num < size; ++required_result_num)
            positions_of_required_result_columns[required_result_num] = full_result_header.getPositionByName(required_result_column_names[required_result_num]);

        for (size_t query_num = 1; query_num < num_selects; ++query_num)
        {
            Block full_result_header_for_current_select = InterpreterSelectQuery(
                ast.list_of_selects->children.at(query_num), context, Names(), to_stage, subquery_depth, true).getSampleBlock();

            if (full_result_header_for_current_select.columns() != full_result_header.columns())
                throw Exception("Different number of columns in UNION ALL elements:\n"
                    + full_result_header.dumpNames()
                    + "\nand\n"
                    + full_result_header_for_current_select.dumpNames() + "\n",
                    ErrorCodes::UNION_ALL_RESULT_STRUCTURES_MISMATCH);

            required_result_column_names_for_other_selects[query_num].reserve(required_result_column_names.size());
            for (const auto & pos : positions_of_required_result_columns)
                required_result_column_names_for_other_selects[query_num].push_back(full_result_header_for_current_select.getByPosition(pos).name);
        }
    }

    for (size_t query_num = 0; query_num < num_selects; ++query_num)
    {
        const Names & current_required_result_column_names
            = query_num == 0 ? required_result_column_names : required_result_column_names_for_other_selects[query_num];

        nested_interpreters.emplace_back(std::make_unique<InterpreterSelectQuery>(
            ast.list_of_selects->children.at(query_num),
            context,
            current_required_result_column_names,
            to_stage,
            subquery_depth,
            only_analyze,
            modify_inplace));
    }

    /// Determine structure of the result.

    if (num_selects == 1)
    {
        result_header = nested_interpreters.front()->getSampleBlock();
    }
    else
    {
        Blocks headers(num_selects);
        for (size_t query_num = 0; query_num < num_selects; ++query_num)
            headers[query_num] = nested_interpreters[query_num]->getSampleBlock();

        result_header = headers.front();
        size_t num_columns = result_header.columns();

        for (size_t query_num = 1; query_num < num_selects; ++query_num)
            if (headers[query_num].columns() != num_columns)
                throw Exception("Different number of columns in UNION ALL elements:\n"
                    + result_header.dumpNames()
                    + "\nand\n"
                    + headers[query_num].dumpNames() + "\n",
                    ErrorCodes::UNION_ALL_RESULT_STRUCTURES_MISMATCH);

        for (size_t column_num = 0; column_num < num_columns; ++column_num)
        {
            ColumnWithTypeAndName & result_elem = result_header.getByPosition(column_num);

            /// Determine common type.

            DataTypes types(num_selects);
            for (size_t query_num = 0; query_num < num_selects; ++query_num)
                types[query_num] = headers[query_num].getByPosition(column_num).type;

            result_elem.type = getLeastSupertype(types);

            /// If there are different constness or different values of constants, the result must be non-constant.

            if (result_elem.column->isColumnConst())
            {
                bool need_materialize = false;
                for (size_t query_num = 1; query_num < num_selects; ++query_num)
                {
                    const ColumnWithTypeAndName & source_elem = headers[query_num].getByPosition(column_num);

                    if (!source_elem.column->isColumnConst()
                        || (static_cast<const ColumnConst &>(*result_elem.column).getField()
                            != static_cast<const ColumnConst &>(*source_elem.column).getField()))
                    {
                        need_materialize = true;
                        break;
                    }
                }

                if (need_materialize)
                    result_elem.column = result_elem.type->createColumn();
            }

            /// BTW, result column names are from first SELECT.
        }
    }
}
Esempio n. 30
0
NamesAndTypesList NamesAndTypesList::filter(const Names & names) const
{
    return filter(NameSet(names.begin(), names.end()));
}