Exemplo n.º 1
0
	const catalog::IndexInfo& getIndexInfo(const std::string& index_name) const{
		try{
			return indexes.at(index_name);
		}catch(std::out_of_range e){
			throw not_exists(index_name);
		}
	}
Exemplo n.º 2
0
	const catalog::Field& getFieldInfo(const std::string& relation_name, const std::string& field_name) const{
		try{
		return getRelationInfo(relation_name).fields.at(field_name);
		}catch(std::out_of_range e){
			throw not_exists(field_name);
		}
	}
Exemplo n.º 3
0
	const catalog::MetaRelation& getRelationInfo(const std::string& name) const{
		try{
			return relations.at(name);
		}catch(std::out_of_range e){
			throw not_exists(name);
		}
	}
bool DataModelManager::setCurrentDataModelAdapter(const std::string& key) throw (not_exists)
{
    AdapterMap::iterator it = adapters_.find(key);
    if (it == adapters_.end())
	throw not_exists();

    currentAdapter_ = it->second;
    return true;
}
DataModelAdapter* DataModelManager::getDataModelAdapter(const std::string& key)
    throw (not_exists)
{
    AdapterMap::iterator it = adapters_.find(key);
    if (it == adapters_.end())
	throw not_exists();

    return it->second;
}
Exemplo n.º 6
0
	void dropIndexInfo(const std::string& index_name){
		try{
		auto &index = indexes.at(index_name);
		auto &relation = index.relation;
		(relation->indexes).erase(index_name);//remove index ref in relation
		indexes.erase(index_name); //remove index from manager
		remove((directoryName+index_name).c_str());//remove file of that index
		writeRelationData(relation->name); //update relation info
		}catch (std::out_of_range e){
			throw not_exists(index_name);
		}
	}
Exemplo n.º 7
0
	void dropRelationInfo(const std::string& name){
		try{
			auto& relation = relations.at(name);
			auto indexes = relation.indexes; //a copy of index
			for(auto &index_pair : indexes){//remove all index files of that relation
				dropIndexInfo(index_pair.second->index_name);
			}
			relations.erase(name); //remove relation
			remove((directoryName+name).c_str()); //delete file
		}catch(std::out_of_range e){
			throw not_exists(name);}
	}
Exemplo n.º 8
0
	void createIndexInfo(const std::string& index_name, const std::string& relation_name, 
		const catalog::Field *field){
		try{
			catalog::MetaRelation& relation = relations.at(relation_name);
			indexSet::iterator index_iter = indexes.insert(std::pair<std::string, catalog::IndexInfo>
				(index_name, (catalog::IndexInfo(index_name, field, &relation)))).first;
			auto res = relation.indexes.insert(
				std::pair<const std::string, const catalog::IndexInfo*>(index_name, &(*index_iter).second));//insert ref
			if(!res.second){
				throw duplicate(index_name);
			}
			writeIndexData(index_name);
		}catch(std::out_of_range e){
			throw not_exists(relation_name);
		}
	}