@Override public NodeRecord clone() { NodeRecord clone = new NodeRecord( getId() ).initialize( inUse(), nextProp, dense, nextRel, labels ); clone.isLight = isLight; if ( dynamicLabelRecords.size() > 0 ) { List<DynamicRecord> clonedLabelRecords = new ArrayList<>( dynamicLabelRecords.size() ); for ( DynamicRecord labelRecord : dynamicLabelRecords ) { clonedLabelRecords.add( labelRecord.clone() ); } clone.dynamicLabelRecords = clonedLabelRecords; } clone.setSecondaryUnitId( getSecondaryUnitId() ); return clone; } }
@Test public void shouldSerializeSecondaryUnitUsage() throws Exception { // Given // a record that is changed to include a secondary unit NodeRecord before = new NodeRecord( 13, false, 1, 2 ); before.setInUse( true ); before.setRequiresSecondaryUnit( false ); before.setSecondaryUnitId( NO_ID ); // this and the previous line set the defaults, they are here for clarity NodeRecord after = new NodeRecord( 13, false, 1, 2 ); after.setInUse( true ); after.setRequiresSecondaryUnit( true ); after.setSecondaryUnitId( 14L ); Command.NodeCommand command = new Command.NodeCommand( before, after ); // Then assertSerializationWorksFor( command ); }
@Test public void shouldFreeSecondaryUnitIdOfShrunkRecord() throws Exception { // GIVEN EphemeralFileSystemAbstraction fs = efs.get(); nodeStore = newNodeStore( fs ); NodeRecord record = new NodeRecord( 5L ); record.setRequiresSecondaryUnit( true ); record.setSecondaryUnitId( 10L ); record.setInUse( true ); nodeStore.updateRecord( record ); nodeStore.setHighestPossibleIdInUse( 10L ); // WHEN record.setRequiresSecondaryUnit( false ); nodeStore.updateRecord( record ); // THEN IdGenerator idGenerator = idGeneratorFactory.get( IdType.NODE ); verify( idGenerator, never() ).freeId( 5L ); verify( idGenerator ).freeId( 10L ); }
@Test public void shouldFreeSecondaryUnitIdOfDeletedRecord() throws Exception { // GIVEN EphemeralFileSystemAbstraction fs = efs.get(); nodeStore = newNodeStore( fs ); NodeRecord record = new NodeRecord( 5L ); record.setRequiresSecondaryUnit( true ); record.setSecondaryUnitId( 10L ); record.setInUse( true ); nodeStore.updateRecord( record ); nodeStore.setHighestPossibleIdInUse( 10L ); // WHEN record.setInUse( false ); nodeStore.updateRecord( record ); // THEN IdGenerator idGenerator = idGeneratorFactory.get( IdType.NODE ); verify( idGenerator ).freeId( 5L ); verify( idGenerator ).freeId( 10L ); }
if ( hasSecondaryUnit ) record.setSecondaryUnitId( channel.getLong() );
if ( hasSecondaryUnit ) record.setSecondaryUnitId( channel.getLong() );
node.setSecondaryUnitId( 6 ); node.setRequiresSecondaryUnit( true );
@Override public NodeRecord clone() { NodeRecord clone = new NodeRecord( getId() ).initialize( inUse(), nextProp, dense, nextRel, labels ); clone.isLight = isLight; if ( dynamicLabelRecords.size() > 0 ) { List<DynamicRecord> clonedLabelRecords = new ArrayList<>( dynamicLabelRecords.size() ); for ( DynamicRecord labelRecord : dynamicLabelRecords ) { clonedLabelRecords.add( labelRecord.clone() ); } clone.dynamicLabelRecords = clonedLabelRecords; } clone.setSecondaryUnitId( getSecondaryUnitId() ); return clone; } }
if ( hasSecondaryUnit ) record.setSecondaryUnitId( channel.getLong() );
if ( hasSecondaryUnit ) record.setSecondaryUnitId( channel.getLong() );