MCPcopy Create free account
hub / github.com/apple/foundationdb / getNewID

Method getNewID

recipes/java-recipes/MicroDoc.java:193–211  ·  view source on GitHub ↗
(TransactionContext tcx)

Source from the content-addressed store, hash-verified

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

Callers 1

applyMethod · 0.95

Calls 1

runMethod · 0.65

Tested by

no test coverage detected