| 191 | } |
| 192 | |
| 193 | private static int getNewID(TransactionContext tcx){ |
| 194 | return tcx.run(new Function<Transaction,Integer>() { |
| 195 | @SuppressWarnings("unused") |
| 196 | public Integer apply(Transaction tr){ |
| 197 | boolean found = false; |
| 198 | int newID; |
| 199 | do { |
| 200 | newID = (int)(Math.random()*100000000); |
| 201 | found = true; |
| 202 | for(KeyValue kv : tr.getRange(docSpace.range(Tuple.from(newID)))){ |
| 203 | // If not empty, this is false. |
| 204 | found = false; |
| 205 | break; |
| 206 | } |
| 207 | } while(!found); |
| 208 | return newID; |
| 209 | } |
| 210 | }); |
| 211 | } |
| 212 | |
| 213 | //TODO Everything in this class before here is in the doc. |
| 214 | |