Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added testing about allocating double record units in import
- Loading branch information
Showing
14 changed files
with
262 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
...ty/kernel/src/test/java/org/neo4j/unsafe/impl/batchimport/EntityStoreUpdaterStepTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Copyright (c) 2002-2017 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.unsafe.impl.batchimport; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import org.neo4j.kernel.configuration.Config; | ||
import org.neo4j.kernel.impl.store.NeoStores; | ||
import org.neo4j.kernel.impl.store.StoreFactory; | ||
import org.neo4j.kernel.impl.store.format.ForcedSecondaryUnitRecordFormats; | ||
import org.neo4j.kernel.impl.store.format.RecordFormats; | ||
import org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory; | ||
import org.neo4j.kernel.impl.store.record.PropertyRecord; | ||
import org.neo4j.kernel.impl.store.record.RelationshipRecord; | ||
import org.neo4j.logging.NullLogProvider; | ||
import org.neo4j.test.rule.PageCacheAndDependenciesRule; | ||
import org.neo4j.unsafe.impl.batchimport.input.InputRelationship; | ||
import org.neo4j.unsafe.impl.batchimport.staging.SimpleStageControl; | ||
import org.neo4j.unsafe.impl.batchimport.staging.StageControl; | ||
import org.neo4j.unsafe.impl.batchimport.store.PrepareIdSequence; | ||
import org.neo4j.unsafe.impl.batchimport.store.io.IoMonitor; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import static org.neo4j.kernel.impl.store.StoreType.PROPERTY; | ||
import static org.neo4j.kernel.impl.store.StoreType.PROPERTY_ARRAY; | ||
import static org.neo4j.kernel.impl.store.StoreType.PROPERTY_STRING; | ||
import static org.neo4j.kernel.impl.store.StoreType.RELATIONSHIP; | ||
import static org.neo4j.kernel.impl.store.format.standard.Standard.LATEST_RECORD_FORMATS; | ||
import static org.neo4j.unsafe.impl.batchimport.Configuration.DEFAULT; | ||
|
||
public class EntityStoreUpdaterStepTest | ||
{ | ||
@Rule | ||
public final PageCacheAndDependenciesRule storage = new PageCacheAndDependenciesRule(); | ||
|
||
@Test | ||
public void shouldAllocateDoubleRecordUnitsNextToRecord() throws Exception | ||
{ | ||
// given | ||
RecordFormats formats = new ForcedSecondaryUnitRecordFormats( LATEST_RECORD_FORMATS ); | ||
try ( NeoStores stores = new StoreFactory( storage.directory().absolutePath(), Config.defaults(), | ||
new DefaultIdGeneratorFactory( storage.fileSystem() ), storage.pageCache(), storage.fileSystem(), formats, | ||
NullLogProvider.getInstance() ).openNeoStores( true, RELATIONSHIP, PROPERTY, PROPERTY_ARRAY, PROPERTY_STRING ) ) | ||
{ | ||
StageControl control = new SimpleStageControl(); | ||
PrepareIdSequence idSequence = PrepareIdSequence.of( true ); | ||
int batchSize = 100; | ||
stores.getRelationshipStore().setHighId( batchSize * 10 ); | ||
Batch<InputRelationship,RelationshipRecord> batch = batchOfRelationshipsWithPreallocatedSecondaryUnits( batchSize ); | ||
try ( EntityStoreUpdaterStep<RelationshipRecord,InputRelationship> step = new EntityStoreUpdaterStep<>( control, | ||
DEFAULT, stores.getRelationshipStore(), stores.getPropertyStore(), mock( IoMonitor.class ), | ||
mock( EntityStoreUpdaterStep.Monitor.class ), idSequence ) ) | ||
{ | ||
step.start( 0 ); | ||
|
||
// when | ||
step.receive( 0, batch ); | ||
step.endOfUpstream(); | ||
while ( !step.isCompleted() ) | ||
{ | ||
Thread.sleep( 10 ); | ||
control.assertHealthy(); | ||
} | ||
} | ||
|
||
// then | ||
for ( int i = 0; i < batchSize; i++ ) | ||
{ | ||
RelationshipRecord record = batch.records[i]; | ||
assertTrue( record.hasSecondaryUnitId() ); | ||
assertEquals( record.getId() + 1, record.getSecondaryUnitId() ); | ||
} | ||
} | ||
} | ||
|
||
private Batch<InputRelationship,RelationshipRecord> batchOfRelationshipsWithPreallocatedSecondaryUnits( int batchSize ) | ||
{ | ||
Batch<InputRelationship,RelationshipRecord> batch = new Batch<>( new InputRelationship[batchSize] ); | ||
batch.records = new RelationshipRecord[batchSize]; | ||
batch.propertyRecords = new PropertyRecord[batchSize][]; | ||
for ( int i = 0; i < batchSize; i++ ) | ||
{ | ||
batch.records[i] = new RelationshipRecord( i * 2 ); | ||
batch.records[i].setInUse( true ); | ||
} | ||
return batch; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.