@Test
  public void shouldNotReportMissingPropertyForDeletedRelationshipWithProperty() {
    // given
    NodeRecord oldNode1 = add(inUse(new NodeRecord(1, false, NONE, NONE)));
    NodeRecord oldNode2 = add(inUse(new NodeRecord(2, false, NONE, NONE)));

    RelationshipRecord oldRel = add(inUse(new RelationshipRecord(42, 1, 2, 7)));
    oldNode1.setNextRel(oldRel.getId());
    oldNode2.setNextRel(oldRel.getId());

    PropertyRecord oldProperty = add(inUse(new PropertyRecord(101)));
    oldProperty.setRelId(oldRel.getId());
    oldRel.setNextProp(oldProperty.getId());

    NodeRecord newNode1 = add(notInUse(new NodeRecord(1, false, NONE, NONE)));
    NodeRecord newNode2 = add(notInUse(new NodeRecord(2, false, NONE, NONE)));

    RelationshipRecord newRel = add(notInUse(new RelationshipRecord(42, 1, 2, 7)));
    newNode1.setNextRel(newRel.getId());
    newNode2.setNextRel(newRel.getId());

    PropertyRecord newProperty = add(notInUse(new PropertyRecord(101)));
    newProperty.setRelId(newRel.getId());
    newRel.setNextProp(newProperty.getId());

    // when
    ConsistencyReport.PropertyConsistencyReport report = checkChange(oldProperty, newProperty);

    // then
    verifyNoMoreInteractions(report);
  }
示例#2
0
 private void connectRelationship(
     NodeRecord firstNode, NodeRecord secondNode, RelationshipRecord rel) {
   assert firstNode.getNextRel() != rel.getId();
   assert secondNode.getNextRel() != rel.getId();
   rel.setFirstNextRel(firstNode.getNextRel());
   rel.setSecondNextRel(secondNode.getNextRel());
   connect(firstNode, rel);
   connect(secondNode, rel);
   firstNode.setNextRel(rel.getId());
   secondNode.setNextRel(rel.getId());
 }
示例#3
0
  private void connectRelationship(
      NodeRecord firstNode,
      NodeRecord secondNode,
      RelationshipRecord rel,
      RecordAccess<Long, RelationshipRecord, Void> relRecords,
      RecordAccess<Long, RelationshipGroupRecord, Integer> relGroupRecords) {
    // Assertion interpreted: if node is a normal node and we're trying to create a
    // relationship that we already have as first rel for that node --> error
    assert firstNode.getNextRel() != rel.getId() || firstNode.isDense();
    assert secondNode.getNextRel() != rel.getId() || secondNode.isDense();

    if (!firstNode.isDense()) {
      rel.setFirstNextRel(firstNode.getNextRel());
    }
    if (!secondNode.isDense()) {
      rel.setSecondNextRel(secondNode.getNextRel());
    }

    if (!firstNode.isDense()) {
      connect(firstNode, rel, relRecords);
    } else {
      connectRelationshipToDenseNode(firstNode, rel, relRecords, relGroupRecords);
    }

    if (!secondNode.isDense()) {
      if (firstNode.getId() != secondNode.getId()) {
        connect(secondNode, rel, relRecords);
      } else {
        rel.setFirstInFirstChain(true);
        rel.setSecondPrevRel(rel.getFirstPrevRel());
      }
    } else if (firstNode.getId() != secondNode.getId()) {
      connectRelationshipToDenseNode(secondNode, rel, relRecords, relGroupRecords);
    }

    if (!firstNode.isDense()) {
      firstNode.setNextRel(rel.getId());
    }
    if (!secondNode.isDense()) {
      secondNode.setNextRel(rel.getId());
    }
  }
示例#4
0
 private void convertNodeToDenseNode(
     NodeRecord node,
     RelationshipRecord firstRel,
     RecordAccess<Long, RelationshipRecord, Void> relRecords,
     RecordAccess<Long, RelationshipGroupRecord, Integer> relGroupRecords) {
   firstRel = relRecords.getOrLoad(firstRel.getId(), null).forChangingLinkage();
   node.setDense(true);
   node.setNextRel(Record.NO_NEXT_RELATIONSHIP.intValue());
   long relId = firstRel.getId();
   RelationshipRecord relRecord = firstRel;
   while (relId != Record.NO_NEXT_RELATIONSHIP.intValue()) {
     locker.getWriteLock(relId);
     relId = relChain(relRecord, node.getId()).get(relRecord);
     connectRelationshipToDenseNode(node, relRecord, relRecords, relGroupRecords);
     if (relId == Record.NO_NEXT_RELATIONSHIP.intValue()) {
       break;
     }
     relRecord = relRecords.getOrLoad(relId, null).forChangingLinkage();
   }
   if (upgradedDenseNodes == null) {
     upgradedDenseNodes = new ArrayList<>();
   }
   upgradedDenseNodes.add(node);
 }