Пример #1
0
void SchemaExtractor::addToMap(SchemaMap &map, const char *key, const long value) {
    SchemaMap::iterator itr = map.find(key);
    if (itr == map.end()) {
        vector<long> newVector;
        newVector.push_back(value);
        map.insert(make_pair(supportSubclasses.addNew(key, Utils::decode_short(key) + 2),
                             newVector));
    } else {
        if (!isPresent(value, itr->second)) {
            (itr->second).push_back(value);
        }
    }
}
Пример #2
0
std::vector<std::string> DebuggerVisitor::perform(DatabaseModel* m) {
    std::vector<std::string> buf;
    buf.push_back("DBM: " + m->name());
    
    DataTypeMap dtm = m->dataTypes();
    for (DataTypeMapConstIterator i = dtm.begin(); i != dtm.end(); ++i) {
        std::vector<std::string> b = i->second->visit(this);
        buf.insert(buf.end(), b.begin(), b.end());
    }
    DatabaseConstantMap dbcm = m->databaseConstants();
    for (DatabaseConstantMapConstIterator i = dbcm.begin(); i != dbcm.end(); ++i) {
        std::vector<std::string> b = i->second->visit(this);
        buf.insert(buf.end(), b.begin(), b.end());
    }
    SchemaMap schemata = m->schemata();
    for (SchemaMapConstIterator i = schemata.begin(); i != schemata.end(); ++i) {
        std::vector<std::string> b = i->second->visit(this);
        buf.insert(buf.end(), b.begin(), b.end());
    }
    return buf;
}
Пример #3
0
	void end() { 
		xform_map.clear();
		xform_schema_map.clear();
		mesh_map.clear();
		schema_map.clear();
		camera_map.clear();
		camera_schema_map.clear();
		face_to_vertex_index_map.clear();
		trivi_to_vertex_index_map.clear();
		quadvi_count_map.clear();
		surface_size_map.clear();
		temporary_uv_list.clear();
		temporary_normal_list.clear();
		temporary_vertex_list.clear();
		{
			delete archive; archive = NULL;
		}
	}
Пример #4
0
void SchemaExtractor::processClasses(SchemaMap &map, NumericNPSchemaMap &omap) {
    //Translate the keys into numbers and build the inverse  "superclass" map
    NumericSchemaMap tmpMap;
    tmpMap.set_empty_key(-1);
    NumericNPSchemaMap inverseTmpMap;
    inverseTmpMap.set_empty_key(-1);
    for (SchemaMap::iterator itr = map.begin(); itr
            != map.end(); itr++) {
        long ks = Hashes::murmur3_56(itr->first + 2,
                                     Utils::decode_short(itr->first));
        tmpMap.insert(make_pair(ks, &(itr->second)));
        for (vector<long>::iterator itr2 = itr->second.begin();
                itr2 != itr->second.end(); ++itr2) {
            addToMap(inverseTmpMap, *itr2, ks);
        }
        //Add a mapping between the hashes and the textual strings
        hashMappings.insert(make_pair(ks, string(itr->first + 2,
                                      Utils::decode_short(itr->first))));
    }



    //Determine all roots
    google::dense_hash_set<long> roots;
    roots.set_empty_key(-1);
    for (NumericNPSchemaMap::iterator itr = inverseTmpMap.begin();
            itr != inverseTmpMap.end(); itr++) {
        NumericSchemaMap::iterator itr2 = tmpMap.find(itr->first);
        if (itr2 == tmpMap.end() || ((itr2->second)->size() == 1
                                     && (itr2->second)->at(0) == itr->first)) {
            roots.insert(itr->first);
        }
    }

    //There should be only one root: <Class>. If there are more then issue a
    //warning
    if (roots.size() > 1) {
        BOOST_LOG_TRIVIAL(error) << "There should be only one root! Found (" << roots.size() << ")";
        throw 10;
    }

    //Build the trees from the roots
    root = buildTreeFromRoot(inverseTmpMap, tmpMap, *roots.begin());

    //Rearrange tree by depth
    rearrangeTreeByDepth(root);

    //Assign a number to all the terms in the tree
    omap.clear();
    long counterID = 0;
    assignID(root, counterID);
    //printTree(0,root);

    //Compute the transitive closure
    transitiveClosure(omap, root);
    //Sort the values
    for(auto itr = omap.begin(); itr != omap.end(); itr++) {
        std::sort(itr->second.begin(), itr->second.end());
    }

    BOOST_LOG_TRIVIAL(debug) << "Members of " << omap.size() <<
                             " classes have a clustering ID";
}
Пример #5
0
bool SchemaManager::reload() {
  ServiceI& service = ServiceI::instance();
  Ice::PropertiesPtr props = service.getCommunicator()->getProperties();
  int load_hidden = props->getPropertyAsIntWithDefault("Service."
      + service.getName() + ".LoadHidden", 0);

  // TODO : template表很大的时候,只加载最新更新的template
  SchemaMap schemas;
  set<int> merge_types;
  map<int, int> type2bigtype;
  map<int, vector<int> > bigtype2types;
  // 加载 data_schemas 表信息
  {
    Statement sql;
    sql << "SELECT id, name, display, home_visible, key_list, type,merge,bigtype FROM data_schemas";
    MCE_DEBUG("schema load hidden : " << load_hidden);
    if (!load_hidden)
      sql << " WHERE display > 0";

    try {
      mysqlpp::StoreQueryResult res = QueryRunner("notify", CDbRServer).store(sql);
      if (!res) {
        MCE_WARN("select table data_schemas error.");
        return false;
      }
      MCE_DEBUG("load schema size : " << res.num_rows());
      for (size_t i = 0; i < res.num_rows(); ++i) {
        mysqlpp::Row row = res.at(i);
        int id = (int) row["id"];
        schemas[id].id = id;
        schemas[id].name = row["name"].c_str();
        schemas[id].display = (int)row["display"];
        schemas[id].is_reply = (int)row["home_visible"];
        schemas[id].bigtype= (int)row["bigtype"];
        ParseSchemaKeys(row["key_list"].c_str(), schemas[id].keys);

        int type = (int) row["type"];
        bool merge = (int)row["merge"];

        MCE_DEBUG("schema id ------>" << id << " bigtype " << schemas[id].bigtype << " type:" << type);
        type2bigtype[type] = schemas[id].bigtype;

        map<int,vector<int> >::iterator bit = bigtype2types.find(schemas[id].bigtype);
        if(bit == bigtype2types.end()){
          vector<int> v;
          bigtype2types.insert(make_pair<int, vector<int> >(schemas[id].bigtype, v));
        }

        bigtype2types[schemas[id].bigtype].push_back(type);
        if(merge){
          merge_types.insert(type);
        }
      }
    } catch (std::exception& e) {
      MCE_WARN("load table data_schemas err : " << e.what());
      return false;
    } catch (...) {
      MCE_WARN("load table data_schemas unknown exception");
      return false;
    }
  }
  // 加载 template 表信息
  {
    Statement sql;
    sql << "select id, schema_id, view, template, update_time from template";

    try {
      mysqlpp::StoreQueryResult res =
          QueryRunner("notify", CDbRServer).store(sql);
      if (!res) {
        MCE_WARN("select table 'template' error ");
        return false;
      }

      time_t update_time;
      MCE_DEBUG("load template size : " << res.num_rows());

      for (size_t i = 0; i < res.num_rows(); ++i) {
        mysqlpp::Row row = res.at(i);
        int schema_id = (int) row["schema_id"];
        if (schemas.find(schema_id) == schemas.end()) {
          MCE_DEBUG("inconsistent template item : schema id "
              << schema_id << " doesn't exist.");
          continue;
        }
        int view = (int) row["view"];
        schemas[schema_id].templates[view] = 
          ctemplate::Template::StringToTemplate( row["template"].c_str(), DO_NOT_STRIP);

        if(!ctemplate::Template::StringToTemplate(row["template"].c_str(), 
              DO_NOT_STRIP)){
          MCE_INFO("NULL return. schema_id:"<< schema_id << " view:" 
              << view << " << content:" << row["template"]);
        }
        MCE_DEBUG("load template (" << schema_id << ',' << view
            << ") = " << row["template"].c_str());
        update_time = (time_t) mysqlpp::DateTime(row["update_time"]);
        if (_load_time < update_time) {
          _load_time = update_time;
        }
      }
    } catch (std::exception& e) {
      MCE_WARN("load table template err : " << e.what());
      return false;
    } catch (...) {
      MCE_WARN("load table template unknown exception");
      return false;
    }
  }
  for(map<int, int>::iterator logit = type2bigtype.begin(); 
      logit != type2bigtype.end(); ++logit) {
    MCE_DEBUG("Reload schema--> type2bigtype info:type=" << logit->first 
        << " bigtype=" << logit->second); 
  }
  {
    IceUtil::RWRecMutex::WLock lock(_mutex);
    _schema_map.swap(schemas);
    _type2bigtype.swap(type2bigtype);
    _bigtype2types.swap(bigtype2types);
    merge_types_.swap(merge_types);
  }
  MCE_INFO("Reload schema. merge_types size:" << merge_types_.size() 
      << "," << PrintHelper::Print(merge_types_,10000));

  for (SchemaMap::iterator i1 = schemas.begin(); i1 != schemas.end(); ++i1) {
    map<int, ctemplate::Template*>::iterator i2 =
        i1->second.templates.begin(), end = i1->second.templates.end();
    for (; i2 != end; ++i2) {
      delete i2->second;
    }
  }
  return true;
}