bool FileSystemZip::Init_unzMemory(unsigned char* buf, int size) { assert(!m_unzf && "We don't handle calling this twice yet"); m_unzf = UnZipOpen_Memory(buf, size); if (!m_unzf) { LogError("Cannot mount memory using"); return false; } LogMsg("Mounted zip as memory"); //m_zipFileName = zipFileName; //save it in case we need to spawn more zip readers for streaming operations CacheIndex(); return true; //success }
bool FileSystemZip::Init_unz(std::string zipFileName) { assert(!m_unzf && "We don't handle calling this twice yet"); m_unzf = unzOpen(zipFileName.c_str()); if (!m_unzf) { LogError("Cannot mount virtual file system using %s",zipFileName.c_str()); return false; } LogMsg("Mounted zip as file system: %s", zipFileName.c_str()); m_zipFileName = zipFileName; //save it in case we need to spawn more zip readers for streaming operations CacheIndex(); return true; //success }
bool zzhang::CBPDualSolver::Init() { srand(456); clock_t init_start = clock(); std::vector<std::vector<int> > TNodeToEclusterIdx(m_NodeSize); std::vector<int> HasSuperSet(m_EClusterVec.size()); std::map<std::pair<int, int>, bool> IsVisited; for (int i = 0; i < m_EClusterVec.size(); i++) { HasSuperSet[i] = 0; for (int j = 0; j < m_EClusterVec[i].size(); j++) { TNodeToEclusterIdx[m_EClusterVec[i][j]].push_back(i); } } for (int i = 0; i < m_NodeSize; i++) { for (int j = 0; j < TNodeToEclusterIdx[i].size(); j++) { int cj = TNodeToEclusterIdx[i][j]; for (int k = j + 1; k < TNodeToEclusterIdx[i].size(); k++) { int ck = TNodeToEclusterIdx[i][k]; if (cj == ck) continue; std::pair<int, int> currentjk(cj, ck); if (IsVisited.find(currentjk) != IsVisited.end()) continue; IsVisited[currentjk] = true; IsVisited[std::pair<int, int>(ck, cj)] = true; if (m_EClusterSet[cj].size() == m_EClusterSet[ck].size()) continue; if (m_EClusterSet[cj].size() < m_EClusterSet[ck].size()) { int temp = cj; cj = ck; ck = temp; } if (std::includes(m_EClusterSet[cj].begin(), m_EClusterSet[cj].end(), m_EClusterSet[ck].begin(), m_EClusterSet[ck].end())) { HasSuperSet[ck] = 1; } } } } IsVisited.clear(); int maxsize = HasSuperSet.size(); for (int i = 0; i < maxsize; i++) { if (HasSuperSet[i]) { m_SubEClusters[i].clear(); continue; } for (int ni = 0; ni < m_EClusterVec[i].size(); ni++) { int nidx = m_EClusterVec[i][ni]; for (int k = 0; k < TNodeToEclusterIdx[nidx].size(); k++) { int cj = i, ck = TNodeToEclusterIdx[nidx][k]; if (cj == ck) continue; if (HasSuperSet[ck]) continue; std::pair<int, int> currentjk(cj, ck); if (IsVisited.find(currentjk) != IsVisited.end()) continue; IsVisited[currentjk] = true; IsVisited[std::pair<int, int>(ck, cj)] = true; std::set<int> intersection; std::set_intersection(m_EClusterSet[cj].begin(), m_EClusterSet[cj].end(), m_EClusterSet[ck].begin(), m_EClusterSet[ck].end(), std::inserter(intersection, intersection.begin())); if (m_EClusterIdx.find(intersection) != m_EClusterIdx.end()) continue; std::vector<int> intvec(intersection.begin(), intersection.end()); AddECluster(intvec, -1); //std::cout << "Added New intersection\n"; for (int j = 0; j < intvec.size(); j++) { TNodeToEclusterIdx[intvec[j]].push_back( m_EClusterVec.size() - 1); } HasSuperSet.push_back(1); } } } IsVisited.clear(); for (int i = 0; i < m_EClusterSet.size(); i++) { if (HasSuperSet[i]) continue; std::map<int, bool> isvisited; for (int ni = 0; ni < m_EClusterSet[i].size(); ni++) { int nidx = m_EClusterVec[i][ni]; for (int k = 0; k < TNodeToEclusterIdx[nidx].size(); k++) { int cj = i, ck = TNodeToEclusterIdx[nidx][k]; if (cj == ck) continue; if (isvisited.find(ck) != isvisited.end()) continue; isvisited[ck] = true; if (m_EClusterSet[cj].size() == m_EClusterSet[ck].size()) continue; if (std::includes(m_EClusterSet[cj].begin(), m_EClusterSet[cj].end(), m_EClusterSet[ck].begin(), m_EClusterSet[ck].end())) { m_SubEClusters[cj].push_back(ck); } } } } clock_t time_explore_graph_end = clock(); // printf("Explore Graph Structure Spends: %f seconds\n", // (time_explore_graph_end - init_start) * 1.0 / CLOCKS_PER_SEC); CacheIndex(); m_Potentials.clear(); m_LocalMaximum = std::vector<int>(m_EClusterVec.size()); m_DecodedSolution = boost::shared_array<int>(new int[m_NodeSize]); m_NodeToECluIdx = TNodeToEclusterIdx; clock_t cache_idx_cvt = clock(); printf("Cache index converting table spends: %f seconds\n", (cache_idx_cvt - time_explore_graph_end) * 1.0 / CLOCKS_PER_SEC); return true; }