Beispiel #1
0
 private long internalCreateNode(long nodeId, Map<String, Object> properties) {
   NodeRecord nodeRecord =
       new NodeRecord(
           nodeId, Record.NO_NEXT_RELATIONSHIP.intValue(), Record.NO_NEXT_PROPERTY.intValue());
   nodeRecord.setInUse(true);
   nodeRecord.setCreated();
   nodeRecord.setNextProp(createPropertyChain(properties));
   getNodeStore().updateRecord(nodeRecord);
   return nodeId;
 }
  @Test
  public void shouldNotReportMissingPropertyForDeletedNodeWithProperty() {
    // given
    PropertyRecord oldProperty = add(inUse(new PropertyRecord(10)));
    NodeRecord oldNode = add(inUse(new NodeRecord(20, false, 0, 0)));
    oldProperty.setNodeId(oldNode.getId());
    oldNode.setNextProp(oldProperty.getId());

    PropertyRecord newProperty = add(notInUse(new PropertyRecord(10)));
    NodeRecord newNode = add(notInUse(new NodeRecord(20, false, 0, 0)));
    newProperty.setNodeId(newNode.getId());
    newNode.setNextProp(newProperty.getId());

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

    // then
    verifyNoMoreInteractions(report);
  }
Beispiel #3
0
 @Override
 public void setNodeProperties(long node, Map<String, Object> properties) {
   NodeRecord record = getNodeRecord(node);
   if (record.getNextProp() != Record.NO_NEXT_PROPERTY.intValue()) {
     deletePropertyChain(record.getNextProp());
     /*
      * Batch inserter does not make any attempt to maintain the store's
      * integrity. It makes sense however to keep some things intact where
      * the cost is relatively low. So here, when we delete the property
      * chain we first make sure that the node record (or the relationship
      * record below) does not point anymore to the deleted properties. This
      * way, if during creation, something goes wrong, it will not have the properties
      * expected instead of throwing invalid record exceptions.
      */
     record.setNextProp(Record.NO_NEXT_PROPERTY.intValue());
     getNodeStore().updateRecord(record);
   }
   record.setNextProp(createPropertyChain(properties));
   getNodeStore().updateRecord(record);
 }
Beispiel #4
0
 @Override
 public void setNodeProperties(long node, Map<String, Object> properties) {
   NodeRecord record = getNodeRecord(node).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();
 }
Beispiel #5
0
  private long internalCreateNode(long nodeId, Map<String, Object> properties, Label... labels) {
    NodeRecord nodeRecord = recordAccess.getNodeRecords().create(nodeId, null).forChangingData();
    nodeRecord.setInUse(true);
    nodeRecord.setCreated();
    nodeRecord.setNextProp(
        propertyCreator.createPropertyChain(
            nodeRecord, propertiesIterator(properties), recordAccess.getPropertyRecords()));

    if (labels.length > 0) {
      setNodeLabels(nodeRecord, labels);
    }

    recordAccess.commit();
    return nodeId;
  }
 private void migrateNodes(NodeStore nodeStore, PropertyWriter propertyWriter)
     throws IOException {
   Iterable<NodeRecord> records = legacyStore.getNodeStoreReader().readNodeStore();
   // estimate total number of nodes using file size then calc number of dots or percentage
   // complete
   for (NodeRecord nodeRecord : records) {
     reportProgress(nodeRecord.getId());
     nodeStore.setHighId(nodeRecord.getId() + 1);
     if (nodeRecord.inUse()) {
       long startOfPropertyChain = nodeRecord.getNextProp();
       if (startOfPropertyChain != Record.NO_NEXT_RELATIONSHIP.intValue()) {
         long propertyRecordId = migrateProperties(startOfPropertyChain, propertyWriter);
         nodeRecord.setNextProp(propertyRecordId);
       }
       nodeStore.updateRecord(nodeRecord);
     } else {
       nodeStore.freeId(nodeRecord.getId());
     }
   }
   legacyStore.getNodeStoreReader().close();
 }