Skip to content

Commit

Permalink
Make setConstraintIndexOwner use RecordAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
ragadeeshu committed Jul 4, 2017
1 parent b3c4390 commit ad909d3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
Expand Up @@ -38,7 +38,7 @@ public interface RecordAccess<KEY,RECORD,ADDITIONAL>

RecordProxy<KEY, RECORD, ADDITIONAL> getIfLoaded( KEY key );

void setTo( KEY key, RECORD newRecord, ADDITIONAL additionalData );
RecordProxy<KEY,RECORD,ADDITIONAL> setTo( KEY key, RECORD newRecord, ADDITIONAL additionalData );

/**
* Creates a new record with the given {@code key}. Any {@code additionalData} is set in the
Expand Down
Expand Up @@ -76,12 +76,12 @@ public RecordProxy<KEY, RECORD, ADDITIONAL> getOrLoad( KEY key, ADDITIONAL addit
}

@Override
public void setTo( KEY key, RECORD newRecord, ADDITIONAL additionalData )
public RecordProxy<KEY,RECORD,ADDITIONAL> setTo( KEY key, RECORD newRecord, ADDITIONAL additionalData )
{
RecordChange<KEY, RECORD, ADDITIONAL> recordChange =
new RecordChange<>( recordChanges, changeCounter, key, newRecord, loader, false, additionalData );
recordChanges.put( key, recordChange );
recordChange.forChangingData();
return recordChange;
}

@Override
Expand Down
Expand Up @@ -605,6 +605,22 @@ public void dropSchemaRule( SchemaRule rule )
}
}

public void changeSchemaRule( SchemaRule rule, SchemaRule updatedRule )
{
//Read the current record
RecordProxy<Long,SchemaRecord,SchemaRule> change = recordChangeSet.getSchemaRuleChanges()
.getOrLoad( rule.getId(), rule );
SchemaRecord records = change.forReadingData();

//Register the change of the record
RecordProxy<Long,SchemaRecord,SchemaRule> recordChange = recordChangeSet.getSchemaRuleChanges()
.setTo( rule.getId(), records, updatedRule );
SchemaRecord dynamicRecords = recordChange.forChangingData();

//Update the record
dynamicRecords.setDynamicRecords( schemaStore.allocateFrom( updatedRule ) );
}

public void addLabelToNode( int labelId, long nodeId )
{
NodeRecord nodeRecord = recordChangeSet.getNodeRecords().getOrLoad( nodeId, null ).forChangingData();
Expand All @@ -619,13 +635,8 @@ public void removeLabelFromNode( int labelId, long nodeId )

public void setConstraintIndexOwner( IndexRule indexRule, long constraintId )
{
RecordProxy<Long, SchemaRecord, SchemaRule> change =
recordChangeSet.getSchemaRuleChanges().getOrLoad( indexRule.getId(), indexRule );
SchemaRecord records = change.forChangingData();

indexRule = indexRule.withOwningConstraint( constraintId );

records.setDynamicRecords( schemaStore.allocateFrom( indexRule ) );
IndexRule updatedIndexRule = indexRule.withOwningConstraint( constraintId );
changeSchemaRule( indexRule, updatedIndexRule );
}

public interface PropertyReceiver<P extends StorageProperty>
Expand Down
Expand Up @@ -30,6 +30,7 @@
import org.neo4j.kernel.impl.store.RecordStore;
import org.neo4j.kernel.impl.store.record.AbstractBaseRecord;
import org.neo4j.kernel.impl.transaction.state.RecordAccess;
import org.neo4j.kernel.impl.transaction.state.RecordChanges;
import org.neo4j.kernel.impl.util.statistics.IntCounter;

/**
Expand Down Expand Up @@ -82,7 +83,7 @@ public RecordProxy<KEY,RECORD,ADDITIONAL> getIfLoaded( KEY key )
}

@Override
public void setTo( KEY key, RECORD newRecord, ADDITIONAL additionalData )
public RecordProxy<KEY,RECORD,ADDITIONAL> setTo( KEY key, RECORD newRecord, ADDITIONAL additionalData )
{
throw new UnsupportedOperationException( "Not supported" );
}
Expand Down
Expand Up @@ -23,6 +23,7 @@

import org.neo4j.helpers.collection.IterableWrapper;
import org.neo4j.kernel.impl.transaction.state.RecordAccess;
import org.neo4j.kernel.impl.transaction.state.RecordChanges;
import org.neo4j.kernel.impl.transaction.state.TransactionRecordState;
import org.neo4j.kernel.impl.util.collection.ArrayCollection;

Expand Down Expand Up @@ -71,7 +72,7 @@ public RecordProxy<KEY,RECORD,ADDITIONAL> getIfLoaded( KEY key )
}

@Override
public void setTo( KEY key, RECORD newRecord, ADDITIONAL additionalData )
public RecordProxy<KEY,RECORD,ADDITIONAL> setTo( KEY key, RECORD newRecord, ADDITIONAL additionalData )
{
throw new UnsupportedOperationException( "Not supported" );
}
Expand Down
Expand Up @@ -59,9 +59,9 @@ public RecordProxy<Long,RECORD,ADDITIONAL> getIfLoaded( Long key )
}

@Override
public void setTo( Long key, RECORD newRecord, ADDITIONAL additionalData )
public RecordProxy<Long,RECORD,ADDITIONAL> setTo( Long key, RECORD newRecord, ADDITIONAL additionalData )
{
delegate.setTo( key, newRecord, additionalData );
return delegate.setTo( key, newRecord, additionalData );
}

@Override
Expand Down

0 comments on commit ad909d3

Please sign in to comment.