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

Method insertDoc

recipes/java-recipes/MicroDoc.java:153–166  ·  view source on GitHub ↗
(TransactionContext tcx, final Map<Object,Object> doc)

Source from the content-addressed store, hash-verified

151 }
152
153 public static Object insertDoc(TransactionContext tcx, final Map<Object,Object> doc){
154 return tcx.run(new Function<Transaction,Object>() {
155 public Object apply(Transaction tr){
156 if(!doc.containsKey("doc_id")){
157 doc.put("doc_id", getNewID(tr));
158 }
159 for(Tuple t : toTuples(doc)){
160 tr.set(docSpace.pack(Tuple.from(doc.get("doc_id")).addAll(t.popBack())),
161 Tuple.from(t.get(t.size() - 1)).pack());
162 }
163 return doc.get("doc_id");
164 }
165 });
166 }
167
168 public static Object getDoc(TransactionContext tcx, final Object ID){
169 return getDoc(tcx, ID, Tuple.from());

Callers 1

smokeTestMethod · 0.95

Calls 1

runMethod · 0.65

Tested by

no test coverage detected