Code: Select all
}
state.unlockMinorConcurrent(); return view;
} else {
if(create>=0L) {
long slots; // Small graph, coarse-grained locking.
// Get and check state-local addresses of label source&target.
// Also allocate slots for label and if applicable secondary
// edge tree entries in the graph state vector.
if(labelTarget==labelSource) {
tAddress = state.setNodeSmall(target, labelTarget,
MBTYPE_MEMBER|MBTYPE_LABEL,
0x80000000|edgeMemState,
Double.NaN, EMPTY, -1);
sAddress = tAddress; if(tAddress==EMPTY) break retry;
slots = state.allocateRelationsSmall(target, 2, EMPTY,
labelWeight==labelWeight);
} else {
tAddress = state.setNodeSmall(target, labelTarget,
MBTYPE_MEMBER, 0x80000000|edgeMemState,
Double.NaN, EMPTY, -1);
sAddress = state.setNodeSmall(target, labelSource,
MBTYPE_LABEL, -1, Double.NaN, EMPTY, -1);
if(tAddress==EMPTY|sAddress==EMPTY) break retry;
slots = state.allocateRelationsSmall(target, 3, EMPTY,
labelWeight==labelWeight);
}
if(slots==EMPTY) break retry;
// If allocated ok, write and link label.
final long lState = state.packLabelStateSmall(labelMemState,
sAddress, tAddress, directionality);
state.writeRelationSmall(((int)slots)&SGRAPH_RELATION_ADDRESS,
labelWeight, lState|BALANCED);
final long edgePos = HIGH_WORD1+(create&0xFFFFFFFFL);
unsafe.putIntVolatile(state.graphState, edgePos,
unsafe.getIntVolatile(state.graphState, edgePos)|
(((int)slots)&SGRAPH_RELATION_ADDRESS));
// Add new edge to referenced nodes' secondary edge trees.
if(tAddress==sAddress) {
state.linkLabelSmall(tAddress, (int)create, edgeSource,
slots>>>20, 1, 1);
} else {
state.linkLabelSmall(tAddress, (int)create, edgeSource,
slots>>>20, 1, 0);
state.linkLabelSmall(sAddress, (int)create, edgeSource,
slots>>>40, 0, 1);
}
} else {
int lSlot; long slots; // Large graph, coarse-grained locking.
// Get and check state-local addresses of label source&target.
if(labelTarget==labelSource) {
tAddress = state.setNodeLarge(target, labelTarget,
MBTYPE_MEMBER|MBTYPE_LABEL,
0x80000000|edgeMemState,
Double.NaN, EMPTY, -1);
if(tAddress==EMPTY) break retry;
slots = state.allocateRelationsLarge(target, 2, lSlot,
EMPTY, labelWeight==labelWeight);
sAddress = tAddress; lSlot = (int)slots;
} else {
tAddress = state.setNodeLarge(target, labelTarget,
MBTYPE_MEMBER, 0x80000000|edgeMemState,
Double.NaN, EMPTY, -1);
sAddress = state.setNodeLarge(target, labelSource,
MBTYPE_LABEL, -1, Double.NaN, EMPTY, -1);
if(tAddress==EMPTY|sAddress==EMPTY) break retry;
lSlot = (int)state.allocateRelationsLarge(target, 1, EMPTY,
EMPTY, labelWeight==labelWeight);
slots = state.allocateRelationsLarge(target, 2, lSlot,
EMPTY, false);
}
// Allocate slot for label in the graph state vector.
if(slots==EMPTY) break retry;
// If allocated ok, write and link label.
state.writeRelationLarge(lSlot, labelWeight,
state.packLabelStateLarge1(sAddress, tAddress),
state.packLabelStateLarge2(labelMemState,
directionality)|BALANCED);
final long edgePos = (LGRAPH_ENTITY_BASE+(BIG_ENDIAN?4:0))+
(create&0xFFFFFFFFL);
unsafe.putIntVolatile(state.graphState, edgePos,
unsafe.getIntVolatile(state.graphState, edgePos)|lSlot);
// Add new edge to referenced nodes' secondary edge trees.
if(tAddress==sAddress) {
state.linkLabelLarge(tAddress, (int)create, edgeSource,
slots>>>32, 1, 1);
} else {
state.linkLabelLarge(tAddress, (int)create, edgeSource,
slots, 1, 0);
state.linkLabelLarge(sAddress, (int)create, edgeSource,
slots>>>32, 0, 1);
}
// Increment the graph's label count.
unsafe.putLongVolatile(state.graphState,
(long)LGRAPH_LABEL_COUNT_POS,
unsafe.getLong(state.graphState,
(long)LGRAPH_LABEL_COUNT_POS)+
(1<<LGRAPH_LABEL_COUNT_SHIFT));
}
state.unlockMinor(); return view;
}
}
// Failed due to state versioning, reacquire lock on new state.
if(lockMode==LOCKED_JAVA) unsafe.monitorExit(state);
do {
state = target.state;
if((state.control&HUGE_GRAPH)!=0) break hugeGraph;
lockMode = state.acquireWriteLock();
} while(lockMode==LOCKED_RETRY);
// view.control can change due to state restructuring
create = view.control;
that I currently have to get done. I would imagine by this weekend if not sooner.