private boolean nextFromStore() { // Get the next row from store, unless that row should not show up from the store if (!txState.nodeIsAddedInThisTx(nodeId.read())) { while (storeCursor.next()) { if (!txState.relationshipIsDeletedInThisTx(relIdFromStore.read())) { relId.write(relIdFromStore.read()); return true; } } } // The store cursor is exhausted. Move to the next input. if (inputCursor.next()) { // This will allow the next store cursor call to pick up another input row storeInputCursor.makeNextAvailable(); storeCursor.reset(); // If the next input row has local tx changes, swap to injecting those txLocalRels = txState.addedRelationships(nodeId.read(), relTypes.read(), expandDirection.read()); if (txLocalRels != null) { state = State.INJECTING_LOCAL_RELS; } return next(); } else { return false; } }
public static PrimitiveIntIterator nodeGetLabels( StoreReadLayer storeLayer, ReadableTxState txState, long nodeId) throws EntityNotFoundException { if (txState.nodeIsDeletedInThisTx(nodeId)) { return PrimitiveIntCollections.emptyIterator(); } if (txState.nodeIsAddedInThisTx(nodeId)) { return PrimitiveIntCollections.toPrimitiveIterator( txState.nodeStateLabelDiffSets(nodeId).getAdded().iterator()); } return txState.nodeStateLabelDiffSets(nodeId).augment(storeLayer.nodeGetLabels(nodeId)); }
@Override public PrimitiveLongIterator nodeGetRelationships( KernelStatement state, long nodeId, Direction direction) throws EntityNotFoundException { if (state.hasTxStateWithChanges()) { ReadableTxState txState = state.txState(); PrimitiveLongIterator stored; if (txState.nodeIsAddedInThisTx(nodeId)) { stored = PrimitiveLongCollections.emptyIterator(); } else { stored = storeLayer.nodeListRelationships(nodeId, direction); } return txState.augmentRelationships(nodeId, direction, stored); } return storeLayer.nodeListRelationships(nodeId, direction); }
private boolean nextTxLocalRel() { if (txLocalRels.hasNext()) { // Pull out the next row from local state long id = txLocalRels.next(); txState.relationshipVisit(id, neighborFetcher); return true; } else { // All added relationships have been injected, swap to returning rows from the store state = State.DELEGATING_TO_STORE; return next(); } }
@Override public PrimitiveIntIterator nodeGetRelationshipTypes(KernelStatement state, long nodeId) throws EntityNotFoundException { if (state.hasTxStateWithChanges() && state.txState().nodeModifiedInThisTx(nodeId)) { ReadableTxState tx = state.txState(); if (tx.nodeIsDeletedInThisTx(nodeId)) { return PrimitiveIntCollections.emptyIterator(); } if (tx.nodeIsAddedInThisTx(nodeId)) { return tx.nodeRelationshipTypes(nodeId); } Set<Integer> types = new HashSet<>(); // Add types in the current transaction PrimitiveIntIterator typesInTx = tx.nodeRelationshipTypes(nodeId); while (typesInTx.hasNext()) { types.add(typesInTx.next()); } // Augment with types stored on disk, minus any types where all rels of that type are deleted // in current tx. PrimitiveIntIterator committedTypes = storeLayer.nodeGetRelationshipTypes(nodeId); while (committedTypes.hasNext()) { int current = committedTypes.next(); if (!types.contains(current) && nodeGetDegree(state, nodeId, Direction.BOTH, current) > 0) { types.add(current); } } return PrimitiveIntCollections.toPrimitiveIterator(types.iterator()); } else { return storeLayer.nodeGetRelationshipTypes(nodeId); } }