Skip to content

Commit

Permalink
Initialize commands in construction
Browse files Browse the repository at this point in the history
Remove the init methods for setting records.
  • Loading branch information
davidegrohmann committed Dec 22, 2015
1 parent c11f63f commit ba0a422
Show file tree
Hide file tree
Showing 44 changed files with 364 additions and 620 deletions.
Expand Up @@ -62,38 +62,33 @@ public TransactionRepresentation representation( byte[] additionalHeader, int ma


public void propertyKey( int id, String key, int... dynamicIds ) public void propertyKey( int id, String key, int... dynamicIds )
{ {
Command.PropertyKeyTokenCommand command = new Command.PropertyKeyTokenCommand(); PropertyKeyTokenRecord before = new PropertyKeyTokenRecord( id );
command.init( new PropertyKeyTokenRecord( id ), withName( new PropertyKeyTokenRecord( id ), dynamicIds, key ) ); PropertyKeyTokenRecord after = withName( new PropertyKeyTokenRecord( id ), dynamicIds, key );
addCommand( command ); addCommand( new Command.PropertyKeyTokenCommand( before, after ) );
} }


public void label( int id, String name, int... dynamicIds ) public void label( int id, String name, int... dynamicIds )
{ {
Command.LabelTokenCommand command = new Command.LabelTokenCommand(); LabelTokenRecord before = new LabelTokenRecord( id );
command.init( new LabelTokenRecord( id ), withName( new LabelTokenRecord( id ), dynamicIds, name ) ); LabelTokenRecord after = withName( new LabelTokenRecord( id ), dynamicIds, name );
addCommand( command ); addCommand( new Command.LabelTokenCommand( before, after ) );
} }


public void relationshipType( int id, String label, int... dynamicIds ) public void relationshipType( int id, String label, int... dynamicIds )
{ {
Command.RelationshipTypeTokenCommand command = new Command.RelationshipTypeTokenCommand(); RelationshipTypeTokenRecord before = new RelationshipTypeTokenRecord( id );
command.init( new RelationshipTypeTokenRecord( id ), RelationshipTypeTokenRecord after = withName( new RelationshipTypeTokenRecord( id ), dynamicIds, label );
withName( new RelationshipTypeTokenRecord( id ), dynamicIds, label ) ); addCommand( new Command.RelationshipTypeTokenCommand( before, after ) );
addCommand( command );
} }


public void update( NeoStoreRecord before, NeoStoreRecord after ) public void update( NeoStoreRecord before, NeoStoreRecord after )
{ {
Command.NeoStoreCommand command = new Command.NeoStoreCommand(); addCommand( new Command.NeoStoreCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


public void update( LabelTokenRecord before, LabelTokenRecord after ) public void update( LabelTokenRecord before, LabelTokenRecord after )
{ {
Command.LabelTokenCommand command = new Command.LabelTokenCommand(); addCommand( new Command.LabelTokenCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


private void addCommand( Command command ) private void addCommand( Command command )
Expand Down Expand Up @@ -226,68 +221,52 @@ public void delete( PropertyRecord before, PropertyRecord after )
private void addSchema( Collection<DynamicRecord> beforeRecords, Collection<DynamicRecord> afterRecords, private void addSchema( Collection<DynamicRecord> beforeRecords, Collection<DynamicRecord> afterRecords,
SchemaRule rule ) SchemaRule rule )
{ {
Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(); addCommand( new Command.SchemaRuleCommand( beforeRecords, afterRecords, rule ) );
command.init( beforeRecords, afterRecords, rule );
addCommand( command );
} }


public void add( NodeRecord before, NodeRecord after ) public void add( NodeRecord before, NodeRecord after )
{ {
Command.NodeCommand command = new Command.NodeCommand(); addCommand( new Command.NodeCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


public void add( RelationshipRecord before, RelationshipRecord after ) public void add( RelationshipRecord before, RelationshipRecord after )
{ {
Command.RelationshipCommand command = new Command.RelationshipCommand(); addCommand( new Command.RelationshipCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


public void add( RelationshipGroupRecord before, RelationshipGroupRecord after ) public void add( RelationshipGroupRecord before, RelationshipGroupRecord after )
{ {
Command.RelationshipGroupCommand command = new Command.RelationshipGroupCommand(); addCommand( new Command.RelationshipGroupCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


public void add( PropertyRecord before, PropertyRecord property ) public void add( PropertyRecord before, PropertyRecord property )
{ {
Command.PropertyCommand command = new Command.PropertyCommand(); addCommand( new Command.PropertyCommand( before, property ) );
command.init( before, property );
addCommand( command );
} }


public void add( RelationshipTypeTokenRecord before, RelationshipTypeTokenRecord after ) public void add( RelationshipTypeTokenRecord before, RelationshipTypeTokenRecord after )
{ {
Command.RelationshipTypeTokenCommand command = new Command.RelationshipTypeTokenCommand(); addCommand( new Command.RelationshipTypeTokenCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


public void add( PropertyKeyTokenRecord before, PropertyKeyTokenRecord after ) public void add( PropertyKeyTokenRecord before, PropertyKeyTokenRecord after )
{ {
Command.PropertyKeyTokenCommand command = new Command.PropertyKeyTokenCommand(); addCommand( new Command.PropertyKeyTokenCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


public void add( NeoStoreRecord before, NeoStoreRecord after ) public void add( NeoStoreRecord before, NeoStoreRecord after )
{ {
Command.NeoStoreCommand command = new Command.NeoStoreCommand(); addCommand( new Command.NeoStoreCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


public void incrementNodeCount( int labelId, long delta ) public void incrementNodeCount( int labelId, long delta )
{ {
addCommand( new Command.NodeCountsCommand().init( labelId, delta ) ); addCommand( new Command.NodeCountsCommand( labelId, delta ) );
} }


public void incrementRelationshipCount( int startLabelId, int typeId, int endLabelId, long delta ) public void incrementRelationshipCount( int startLabelId, int typeId, int endLabelId, long delta )
{ {
addCommand( new Command.RelationshipCountsCommand().init( startLabelId, typeId, endLabelId, delta ) ); addCommand( new Command.RelationshipCountsCommand( startLabelId, typeId, endLabelId, delta ) );
} }


private static <T extends TokenRecord> T withName( T record, int[] dynamicIds, String name ) private static <T extends TokenRecord> T withName( T record, int[] dynamicIds, String name )
Expand Down
Expand Up @@ -62,38 +62,33 @@ public TransactionRepresentation representation( byte[] additionalHeader, int ma


public void propertyKey( int id, String key, int... dynamicIds ) public void propertyKey( int id, String key, int... dynamicIds )
{ {
Command.PropertyKeyTokenCommand command = new Command.PropertyKeyTokenCommand(); PropertyKeyTokenRecord before = new PropertyKeyTokenRecord( id );
command.init( new PropertyKeyTokenRecord( id ), withName( new PropertyKeyTokenRecord( id ), dynamicIds, key ) ); PropertyKeyTokenRecord after = withName( new PropertyKeyTokenRecord( id ), dynamicIds, key );
addCommand( command ); addCommand( new Command.PropertyKeyTokenCommand( before, after ) );
} }


public void label( int id, String name, int... dynamicIds ) public void label( int id, String name, int... dynamicIds )
{ {
Command.LabelTokenCommand command = new Command.LabelTokenCommand(); LabelTokenRecord before = new LabelTokenRecord( id );
command.init( new LabelTokenRecord( id ), withName( new LabelTokenRecord( id ), dynamicIds, name ) ); LabelTokenRecord after = withName( new LabelTokenRecord( id ), dynamicIds, name );
addCommand( command ); addCommand( new Command.LabelTokenCommand( before, after ) );
} }


public void relationshipType( int id, String label, int... dynamicIds ) public void relationshipType( int id, String label, int... dynamicIds )
{ {
Command.RelationshipTypeTokenCommand command = new Command.RelationshipTypeTokenCommand(); RelationshipTypeTokenRecord before = new RelationshipTypeTokenRecord( id );
command.init( new RelationshipTypeTokenRecord( id ), RelationshipTypeTokenRecord after = withName( new RelationshipTypeTokenRecord( id ), dynamicIds, label );
withName( new RelationshipTypeTokenRecord( id ), dynamicIds, label ) ); addCommand( new Command.RelationshipTypeTokenCommand( before, after ) );
addCommand( command );
} }


public void update( NeoStoreRecord before, NeoStoreRecord after ) public void update( NeoStoreRecord before, NeoStoreRecord after )
{ {
Command.NeoStoreCommand command = new Command.NeoStoreCommand(); addCommand( new Command.NeoStoreCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


public void update( LabelTokenRecord before, LabelTokenRecord after ) public void update( LabelTokenRecord before, LabelTokenRecord after )
{ {
Command.LabelTokenCommand command = new Command.LabelTokenCommand(); addCommand( new Command.LabelTokenCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


private void addCommand( Command command ) private void addCommand( Command command )
Expand Down Expand Up @@ -144,7 +139,7 @@ public void delete( NodeRecord node )
add( node, new NodeRecord( node.getId(), false, NO_PREV_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue() ) ); add( node, new NodeRecord( node.getId(), false, NO_PREV_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue() ) );
} }


public void create( RelationshipRecord record ) public void create( RelationshipRecord record )
{ {
record.setCreated(); record.setCreated();
update( new RelationshipRecord( record.getId() ), record ); update( new RelationshipRecord( record.getId() ), record );
Expand Down Expand Up @@ -188,7 +183,7 @@ public void update( RelationshipGroupRecord before, RelationshipGroupRecord afte
add( before, after ); add( before, after );
} }


public void delete( RelationshipRecord record ) public void delete( RelationshipRecord record )
{ {
record.setInUse( false ); record.setInUse( false );
add( record, new RelationshipRecord( record.getId() ) ); add( record, new RelationshipRecord( record.getId() ) );
Expand Down Expand Up @@ -226,68 +221,52 @@ public void delete( PropertyRecord before, PropertyRecord after )
private void addSchema( Collection<DynamicRecord> beforeRecords, Collection<DynamicRecord> afterRecords, private void addSchema( Collection<DynamicRecord> beforeRecords, Collection<DynamicRecord> afterRecords,
SchemaRule rule ) SchemaRule rule )
{ {
Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(); addCommand( new Command.SchemaRuleCommand( beforeRecords, afterRecords, rule ) );
command.init( beforeRecords, afterRecords, rule );
addCommand( command );
} }


public void add( NodeRecord before, NodeRecord after ) public void add( NodeRecord before, NodeRecord after )
{ {
Command.NodeCommand command = new Command.NodeCommand(); addCommand( new Command.NodeCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


public void add( RelationshipRecord before, RelationshipRecord after ) public void add( RelationshipRecord before, RelationshipRecord after )
{ {
Command.RelationshipCommand command = new Command.RelationshipCommand(); addCommand( new Command.RelationshipCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


public void add( RelationshipGroupRecord before, RelationshipGroupRecord after ) public void add( RelationshipGroupRecord before, RelationshipGroupRecord after )
{ {
Command.RelationshipGroupCommand command = new Command.RelationshipGroupCommand(); addCommand( new Command.RelationshipGroupCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


public void add( PropertyRecord before, PropertyRecord property ) public void add( PropertyRecord before, PropertyRecord property )
{ {
Command.PropertyCommand command = new Command.PropertyCommand(); addCommand( new Command.PropertyCommand( before, property ) );
command.init( before, property );
addCommand( command );
} }


public void add( RelationshipTypeTokenRecord before, RelationshipTypeTokenRecord after ) public void add( RelationshipTypeTokenRecord before, RelationshipTypeTokenRecord after )
{ {
Command.RelationshipTypeTokenCommand command = new Command.RelationshipTypeTokenCommand(); addCommand( new Command.RelationshipTypeTokenCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


public void add( PropertyKeyTokenRecord before, PropertyKeyTokenRecord after ) public void add( PropertyKeyTokenRecord before, PropertyKeyTokenRecord after )
{ {
Command.PropertyKeyTokenCommand command = new Command.PropertyKeyTokenCommand(); addCommand( new Command.PropertyKeyTokenCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


public void add( NeoStoreRecord before, NeoStoreRecord after ) public void add( NeoStoreRecord before, NeoStoreRecord after )
{ {
Command.NeoStoreCommand command = new Command.NeoStoreCommand(); addCommand( new Command.NeoStoreCommand( before, after ) );
command.init( before, after );
addCommand( command );
} }


public void incrementNodeCount( int labelId, long delta ) public void incrementNodeCount( int labelId, long delta )
{ {
addCommand( new Command.NodeCountsCommand().init( labelId, delta ) ); addCommand( new Command.NodeCountsCommand( labelId, delta ) );
} }


public void incrementRelationshipCount( int startLabelId, int typeId, int endLabelId, long delta ) public void incrementRelationshipCount( int startLabelId, int typeId, int endLabelId, long delta )
{ {
addCommand( new Command.RelationshipCountsCommand().init( startLabelId, typeId, endLabelId, delta ) ); addCommand( new Command.RelationshipCountsCommand( startLabelId, typeId, endLabelId, delta ) );
} }


private static <T extends TokenRecord> T withName( T record, int[] dynamicIds, String name ) private static <T extends TokenRecord> T withName( T record, int[] dynamicIds, String name )
Expand Down
Expand Up @@ -248,7 +248,7 @@ public void visitNodeCount( int labelId, long count )
{ {
if ( count != 0 ) if ( count != 0 )
{ // Only add commands for counts that actually change { // Only add commands for counts that actually change
commands.add( new Command.NodeCountsCommand().init( labelId, count ) ); commands.add( new Command.NodeCountsCommand( labelId, count ) );
} }
} }


Expand All @@ -257,7 +257,7 @@ public void visitRelationshipCount( int startLabelId, int typeId, int endLabelId
{ {
if ( count != 0 ) if ( count != 0 )
{ // Only add commands for counts that actually change { // Only add commands for counts that actually change
commands.add( new Command.RelationshipCountsCommand().init( startLabelId, typeId, endLabelId, count ) ); commands.add( new Command.RelationshipCountsCommand( startLabelId, typeId, endLabelId, count ) );
} }
} }
} }
Expand Down

0 comments on commit ba0a422

Please sign in to comment.