Beispiel #1
0
  private void createConstraintRule(UniquenessConstraint constraint) {
    // TODO: Do not create duplicate index

    SchemaStore schemaStore = getSchemaStore();

    long indexRuleId = schemaStore.nextId();
    long constraintRuleId = schemaStore.nextId();

    IndexRule indexRule =
        IndexRule.constraintIndexRule(
            indexRuleId,
            constraint.label(),
            constraint.propertyKeyId(),
            this.schemaIndexProviders.getDefaultProvider().getProviderDescriptor(),
            constraintRuleId);
    UniquenessConstraintRule constraintRule =
        UniquenessConstraintRule.uniquenessConstraintRule(
            constraintRuleId, constraint.label(), constraint.propertyKeyId(), indexRuleId);

    for (DynamicRecord record : schemaStore.allocateFrom(constraintRule)) {
      schemaStore.updateRecord(record);
    }
    schemaCache.addSchemaRule(constraintRule);
    for (DynamicRecord record : schemaStore.allocateFrom(indexRule)) {
      schemaStore.updateRecord(record);
    }
    schemaCache.addSchemaRule(indexRule);
    labelsTouched = true;
    recordAccess.commit();
  }
Beispiel #2
0
 @Override
 public void removeRelationshipProperty(long relationship, String propertyName) {
   int propertyKey = getOrCreatePropertyKeyId(propertyName);
   propertyDeletor.removeProperty(
       getRelationshipRecord(relationship), propertyKey, recordAccess.getPropertyRecords());
   recordAccess.commit();
 }
Beispiel #3
0
 @Override
 public void removeNodeProperty(long node, String propertyName) {
   int propertyKey = getOrCreatePropertyKeyId(propertyName);
   propertyDeletor.removeProperty(
       getNodeRecord(node), propertyKey, recordAccess.getPropertyRecords());
   recordAccess.commit();
 }
Beispiel #4
0
 @Override
 public void setNodeProperty(long node, String propertyName, Object newValue) {
   propertyCreator.setPrimitiveProperty(
       getNodeRecord(node),
       getOrCreatePropertyKeyId(propertyName),
       newValue,
       recordAccess.getPropertyRecords());
   recordAccess.commit();
 }
Beispiel #5
0
 @Override
 public void setRelationshipProperty(
     long relationship, String propertyName, Object propertyValue) {
   propertyCreator.setPrimitiveProperty(
       getRelationshipRecord(relationship),
       getOrCreatePropertyKeyId(propertyName),
       propertyValue,
       recordAccess.getPropertyRecords());
   recordAccess.commit();
 }
Beispiel #6
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();
 }
Beispiel #7
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 #8
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;
  }
Beispiel #9
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;
 }
Beispiel #10
0
  private void createIndexRule(Label label, String propertyKey) {
    // TODO: Do not create duplicate index

    SchemaStore schemaStore = getSchemaStore();
    IndexRule schemaRule =
        IndexRule.indexRule(
            schemaStore.nextId(),
            getOrCreateLabelId(label.name()),
            getOrCreatePropertyKeyId(propertyKey),
            this.schemaIndexProviders.getDefaultProvider().getProviderDescriptor());
    for (DynamicRecord record : schemaStore.allocateFrom(schemaRule)) {
      schemaStore.updateRecord(record);
    }
    schemaCache.addSchemaRule(schemaRule);
    labelsTouched = true;
    recordAccess.commit();
  }
Beispiel #11
0
 @Override
 public void setNodeLabels(long node, Label... labels) {
   NodeRecord record = getNodeRecord(node).forChangingData();
   setNodeLabels(record, labels);
   recordAccess.commit();
 }