Index: trunk/sixdeg/frag/solaris-gcc.mk |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | PLAT_CPPFLAGS = -D_REENTRANT -DSOLARIS |
3 | | -PLAT_CXXFLAGS = -O2 -g -W -Wall -Wno-non-virtual-dtor |
| 3 | +PLAT_CXXFLAGS = -O2 -g -W -Wall -Wno-non-virtual-dtor -m64 |
4 | 4 | PLAT_LIBS = -lrt -lsocket -lnsl |
5 | 5 | CC = gcc |
6 | 6 | CXX = g++ |
Index: trunk/sixdeg/mkcache/mkcache.cc |
— | — | @@ -93,9 +93,11 @@ |
94 | 94 | } |
95 | 95 | |
96 | 96 | struct page_entry { |
| 97 | + page_entry() : id(-1) {} |
| 98 | + page_id_t id; |
97 | 99 | text_id_t text; |
98 | 100 | std::string name; |
99 | | - std::set<page_id_t> adj; |
| 101 | + std::vector<page_id_t> adj; |
100 | 102 | }; |
101 | 103 | |
102 | 104 | void |
— | — | @@ -115,7 +117,8 @@ |
116 | 118 | * First we cache the data for this wiki in RAM, then commit all once. |
117 | 119 | * This avoids constantly (over)writing in the database. |
118 | 120 | */ |
119 | | - std::map<page_id_t, page_entry> cache; |
| 121 | + //std::map<page_id_t, page_entry> cache; |
| 122 | + std::vector<page_entry> cache; |
120 | 123 | MYSQL_ROW arow; |
121 | 124 | int i = 0; |
122 | 125 | std::cout << db << ": 0" << std::flush; |
— | — | @@ -125,24 +128,27 @@ |
126 | 129 | |
127 | 130 | page_id_t from = boost::lexical_cast<page_id_t>(arow[1]); |
128 | 131 | page_id_t to = boost::lexical_cast<page_id_t>(arow[0]); |
129 | | - std::map<page_id_t, page_entry>::iterator it = cache.find(from); |
130 | | - if (it == cache.end()) { |
131 | | - page_entry e; |
132 | | - e.name = arow[2]; |
133 | | - e.text = boost::lexical_cast<text_id_t>(arow[3]); |
134 | | - it = cache.insert(std::make_pair(from, e)).first; |
| 132 | + |
| 133 | + if (cache.size() <= from) |
| 134 | + cache.resize(from + 1); |
| 135 | + |
| 136 | + if (cache[from].id == -1) { |
| 137 | + cache[from].id = from; |
| 138 | + cache[from].name = arow[2]; |
| 139 | + cache[from].text = boost::lexical_cast<text_id_t>(arow[3]); |
135 | 140 | } |
136 | 141 | |
137 | | - it->second.adj.insert(to); |
| 142 | + cache[from].adj.push_back(to); |
138 | 143 | } |
139 | 144 | mysql_free_result(res); |
140 | 145 | |
141 | 146 | bdb_adjacency_transaction *trans = new bdb_adjacency_transaction(store); |
142 | 147 | std::cout << " flush to storage... " << std::flush; |
143 | 148 | i = 0; |
144 | | - for (std::map<page_id_t, page_entry>::iterator |
145 | | - it = cache.begin(), end = cache.end(); |
146 | | - it != end; ++it) { |
| 149 | + for (std::size_t s = 0, end = cache.size(); s < end; ++s) { |
| 150 | + if (cache[s].id == -1) |
| 151 | + continue; |
| 152 | + |
147 | 153 | if (++i == 10000) { |
148 | 154 | trans->commit(); |
149 | 155 | delete trans; |
— | — | @@ -151,8 +157,9 @@ |
152 | 158 | i = 0; |
153 | 159 | } |
154 | 160 | |
155 | | - trans->add_title(db, it->first, it->second.name, it->second.text); |
156 | | - trans->set_adjacencies(db, it->first, it->second.adj); |
| 161 | + std::set<page_id_t> adj(cache[s].adj.begin(), cache[s].adj.end()); |
| 162 | + trans->add_title(db, cache[s].id, cache[s].name, cache[s].text); |
| 163 | + trans->set_adjacencies(db, cache[s].id, adj); |
157 | 164 | } |
158 | 165 | trans->commit(); |
159 | 166 | delete trans; |
Index: trunk/sixdeg/solaris-gcc.mk |
— | — | @@ -1,2 +1,2 @@ |
2 | | -PLAT_FRAG = solaris.mk |
| 2 | +PLAT_FRAG = solaris-gcc.mk |
3 | 3 | include frag/setup.mk |