MCPcopy Create free account
hub / github.com/e2wugui/zeze / tryAdd

Method tryAdd

ZezeJava/ZezeJava/src/main/java/Zeze/Transaction/TableX.java:669–685  ·  view source on GitHub ↗
(@NotNull K key, @NotNull V value)

Source from the content-addressed store, hash-verified

667 }
668
669 public final boolean tryAdd(@NotNull K key, @NotNull V value) {
670 //noinspection ConstantValue
671 if (value == null)
672 throw new IllegalArgumentException("value is null");
673 if (get(key) != null)
674 return false;
675
676 var currentT = Transaction.getCurrent();
677 assert currentT != null;
678
679 var tkey = new TableKey(getId(), key);
680 var cr = currentT.getRecordAccessed(tkey);
681 //noinspection DataFlowIssue
682 value.initRootInfoWithRedo(cr.atomicTupleRecord.record.createRootInfoIfNeed(tkey), null);
683 cr.put(currentT, value);
684 return true;
685 }
686
687 public final void insert(@NotNull K key, @NotNull V value) {
688 if (!tryAdd(key, value)) {

Callers 5

insertMethod · 0.95
testMemoryCacheMethod · 0.45
addMethod · 0.45
scheduleMethod · 0.45

Calls 7

getMethod · 0.95
getCurrentMethod · 0.95
getIdMethod · 0.65
putMethod · 0.65
getRecordAccessedMethod · 0.45
initRootInfoWithRedoMethod · 0.45
createRootInfoIfNeedMethod · 0.45

Tested by 1

testMemoryCacheMethod · 0.36