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 PrimitiveIntIterator nodeGetLabels(KernelStatement state, long nodeId)
      throws EntityNotFoundException {
    if (state.hasTxStateWithChanges()) {
      if (state.txState().nodeIsDeletedInThisTx(nodeId)) {
        return PrimitiveIntCollections.emptyIterator();
      }

      if (state.txState().nodeIsAddedInThisTx(nodeId)) {
        return PrimitiveIntCollections.toPrimitiveIterator(
            state.txState().nodeStateLabelDiffSets(nodeId).getAdded().iterator());
      }

      return state
          .txState()
          .nodeStateLabelDiffSets(nodeId)
          .augment(storeLayer.nodeGetLabels(nodeId));
    }

    return storeLayer.nodeGetLabels(nodeId);
  }
  @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);
    }
  }
Esempio n. 4
0
 public PrimitiveIntIterator nodeGetRelationshipTypes(long nodeId) throws EntityNotFoundException {
   return PrimitiveIntCollections.toPrimitiveIterator(
       getNode(nodeId).getRelationshipTypes(relationshipLoader, NODE_CACHE_SIZE_LISTENER));
 }