コード例 #1
0
  @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
ファイル: BatchInserterImpl.java プロジェクト: kov4l/neo4j
 @Override
 public void setRelationshipProperties(long rel, Map<String, Object> properties) {
   RelationshipRecord record = getRelationshipRecord(rel);
   if (record.getNextProp() != Record.NO_NEXT_PROPERTY.intValue()) {
     deletePropertyChain(record.getNextProp());
     /*
      * See setNodeProperties above for an explanation of what goes on
      * here
      */
     record.setNextProp(Record.NO_NEXT_PROPERTY.intValue());
     getRelationshipStore().updateRecord(record);
   }
   record.setNextProp(createPropertyChain(properties));
   getRelationshipStore().updateRecord(record);
 }
コード例 #3
0
 @Override
 public void setRelationshipProperties(long rel, Map<String, Object> properties) {
   RelationshipRecord record = recordAccess.getRelRecords().getOrLoad(rel, null).forChangingData();
   if (record.getNextProp() != Record.NO_NEXT_PROPERTY.intValue()) {
     propertyDeletor.getAndDeletePropertyChain(record, recordAccess.getPropertyRecords());
   }
   record.setNextProp(
       propertyCreator.createPropertyChain(
           record, propertiesIterator(properties), recordAccess.getPropertyRecords()));
   recordAccess.commit();
 }
コード例 #4
0
 @Override
 public long createRelationship(
     long node1, long node2, RelationshipType type, Map<String, Object> properties) {
   long id = neoStore.getRelationshipStore().nextId();
   int typeId = getOrCreateRelationshipTypeToken(type);
   relationshipCreator.relationshipCreate(id, typeId, node1, node2, recordAccess);
   if (properties != null && !properties.isEmpty()) {
     RelationshipRecord record =
         recordAccess.getRelRecords().getOrLoad(id, null).forChangingData();
     record.setNextProp(
         propertyCreator.createPropertyChain(
             record, propertiesIterator(properties), recordAccess.getPropertyRecords()));
   }
   recordAccess.commit();
   return id;
 }
コード例 #5
0
ファイル: BatchInserterImpl.java プロジェクト: kov4l/neo4j
 @Override
 public long createRelationship(
     long node1, long node2, RelationshipType type, Map<String, Object> properties) {
   NodeRecord firstNode = getNodeRecord(node1);
   NodeRecord secondNode = getNodeRecord(node2);
   int typeId = typeHolder.getTypeId(type.name());
   if (typeId == -1) {
     typeId = createNewRelationshipType(type.name());
   }
   long id = getRelationshipStore().nextId();
   RelationshipRecord record = new RelationshipRecord(id, node1, node2, typeId);
   record.setInUse(true);
   record.setCreated();
   connectRelationship(firstNode, secondNode, record);
   getNodeStore().updateRecord(firstNode);
   getNodeStore().updateRecord(secondNode);
   record.setNextProp(createPropertyChain(properties));
   getRelationshipStore().updateRecord(record);
   return id;
 }
コード例 #6
0
  @Test
  public void shouldReportPropertyNotReferencedFromRelationshipWithChain() throws Exception {
    // given
    PropertyRecord oldProperty = notInUse(new PropertyRecord(42));
    PropertyRecord newProperty = inUse(new PropertyRecord(42));
    RelationshipRecord rel = add(inUse(new RelationshipRecord(1, 10, 20, 0)));
    PropertyRecord a = add(inUse(new PropertyRecord(1)));
    PropertyRecord b = add(inUse(new PropertyRecord(2)));
    a.setNextProp(b.getId());
    b.setPrevProp(a.getId());
    rel.setNextProp(a.getId());
    newProperty.setRelId(rel.getId());

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

    // then
    verify(report).ownerDoesNotReferenceBack();
    verifyNoMoreInteractions(report);
  }
コード例 #7
0
    private void migrateRelationships(
        RelationshipStore relationshipStore, PropertyWriter propertyWriter) throws IOException {
      long nodeMaxId = legacyStore.getNodeStoreReader().getMaxId();

      Iterable<RelationshipRecord> records =
          legacyStore.getRelationshipStoreReader().readRelationshipStore();
      for (RelationshipRecord relationshipRecord : records) {
        reportProgress(nodeMaxId + relationshipRecord.getId());
        relationshipStore.setHighId(relationshipRecord.getId() + 1);
        if (relationshipRecord.inUse()) {
          long startOfPropertyChain = relationshipRecord.getNextProp();
          if (startOfPropertyChain != Record.NO_NEXT_RELATIONSHIP.intValue()) {
            long propertyRecordId = migrateProperties(startOfPropertyChain, propertyWriter);
            relationshipRecord.setNextProp(propertyRecordId);
          }
          relationshipStore.updateRecord(relationshipRecord);
        } else {
          relationshipStore.freeId(relationshipRecord.getId());
        }
      }
      legacyStore.getRelationshipStoreReader().close();
    }