Search in sources :

Example 11 with DefaultIdGeneratorFactory

use of org.neo4j.internal.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class TestArrayStore method before.

@BeforeEach
void before() {
    DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fileSystem, immediate(), databaseLayout.getDatabaseName());
    StoreFactory factory = new StoreFactory(databaseLayout, Config.defaults(), idGeneratorFactory, pageCache, fileSystem, NullLogProvider.getInstance(), PageCacheTracer.NULL, writable());
    neoStores = factory.openAllNeoStores(true);
    arrayStore = neoStores.getPropertyStore().getArrayStore();
}
Also used : DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with DefaultIdGeneratorFactory

use of org.neo4j.internal.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class TestGrowingFileMemoryMapping method shouldGrowAFileWhileContinuingToMemoryMapNewRegions.

@Test
@DisabledOnOs(OS.WINDOWS)
void shouldGrowAFileWhileContinuingToMemoryMapNewRegions() {
    // given
    final int NUMBER_OF_RECORDS = 1000000;
    Config config = Config.defaults();
    DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(testDirectory.getFileSystem(), immediate(), databaseLayout.getDatabaseName());
    StoreFactory storeFactory = new StoreFactory(databaseLayout, config, idGeneratorFactory, pageCache, testDirectory.getFileSystem(), NullLogProvider.getInstance(), NULL, writable());
    NeoStores neoStores = storeFactory.openAllNeoStores(true);
    NodeStore nodeStore = neoStores.getNodeStore();
    // when
    int iterations = 2 * NUMBER_OF_RECORDS;
    long startingId = nodeStore.nextId(CursorContext.NULL);
    long nodeId = startingId;
    for (int i = 0; i < iterations; i++) {
        NodeRecord record = new NodeRecord(nodeId).initialize(false, 0, false, i, 0);
        record.setInUse(true);
        nodeStore.updateRecord(record, CursorContext.NULL);
        nodeId = nodeStore.nextId(CursorContext.NULL);
    }
    // then
    NodeRecord record = new NodeRecord(0).initialize(false, 0, false, 0, 0);
    for (int i = 0; i < iterations; i++) {
        record.setId(startingId + i);
        nodeStore.getRecord(i, record, NORMAL, CursorContext.NULL);
        assertTrue(record.inUse(), "record[" + i + "] should be in use");
        assertThat(record.getNextRel()).as("record[" + i + "] should have nextRelId of " + i).isEqualTo(i);
    }
    neoStores.close();
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Config(org.neo4j.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 13 with DefaultIdGeneratorFactory

use of org.neo4j.internal.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class TokenStoreTestTemplate method setUp.

@BeforeEach
void setUp() throws IOException {
    Path file = dir.file("label-tokens.db");
    Path idFile = dir.file("label-tokens.db.id");
    Path namesFile = dir.file("label-tokens.db.names");
    Path namesIdFile = dir.file("label-tokens.db.names.id");
    IdGeneratorFactory generatorFactory = new DefaultIdGeneratorFactory(fs, immediate(), DEFAULT_DATABASE_NAME);
    LogProvider logProvider = NullLogProvider.getInstance();
    RecordFormats formats = RecordFormatSelector.defaultFormat();
    Config config = Config.defaults();
    nameStore = new DynamicStringStore(namesFile, namesIdFile, config, IdType.LABEL_TOKEN_NAME, generatorFactory, pageCache, logProvider, TokenStore.NAME_STORE_BLOCK_SIZE, formats.dynamic(), formats.storeVersion(), writable(), DEFAULT_DATABASE_NAME, immutable.empty());
    store = instantiateStore(file, idFile, generatorFactory, pageCache, logProvider, nameStore, formats, config);
    nameStore.initialise(true, NULL);
    store.initialise(true, NULL);
    nameStore.start(NULL);
    store.start(NULL);
}
Also used : Path(java.nio.file.Path) LogProvider(org.neo4j.logging.LogProvider) NullLogProvider(org.neo4j.logging.NullLogProvider) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) Config(org.neo4j.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) IdGeneratorFactory(org.neo4j.internal.id.IdGeneratorFactory) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with DefaultIdGeneratorFactory

use of org.neo4j.internal.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class RecordStoreConsistentReadTest method setUp.

@BeforeEach
void setUp() {
    nextReadIsInconsistent = new AtomicBoolean();
    pageCache = pageCacheExtension.getPageCache(fs, config().withInconsistentReads(nextReadIsInconsistent));
    StoreFactory factory = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()), pageCache, fs, NullLogProvider.getInstance(), PageCacheTracer.NULL, writable());
    neoStores = factory.openAllNeoStores(true);
    initialiseStore(neoStores);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 15 with DefaultIdGeneratorFactory

use of org.neo4j.internal.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class AbstractDynamicStoreTest method newTestableDynamicStore.

private AbstractDynamicStore newTestableDynamicStore() {
    DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs, immediate(), DEFAULT_DATABASE_NAME);
    AbstractDynamicStore store = new AbstractDynamicStore(storeFile, idFile, Config.defaults(), IdType.ARRAY_BLOCK, idGeneratorFactory, pageCache, NullLogProvider.getInstance(), "test", BLOCK_SIZE, formats.dynamic(), formats.storeVersion(), DatabaseReadOnlyChecker.writable(), DEFAULT_DATABASE_NAME, immutable.empty()) {

        @Override
        public String getTypeDescriptor() {
            return "TestDynamicStore";
        }
    };
    store.initialise(true, NULL);
    return store;
}
Also used : DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory)

Aggregations

DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)53 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)29 BeforeEach (org.junit.jupiter.api.BeforeEach)20 Config (org.neo4j.configuration.Config)18 Test (org.junit.jupiter.api.Test)15 NeoStores (org.neo4j.kernel.impl.store.NeoStores)14 Path (java.nio.file.Path)10 PageCache (org.neo4j.io.pagecache.PageCache)10 NullLogProvider (org.neo4j.logging.NullLogProvider)10 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)9 CursorContext (org.neo4j.io.pagecache.context.CursorContext)9 IdGeneratorFactory (org.neo4j.internal.id.IdGeneratorFactory)8 IOException (java.io.IOException)7 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)6 RecordFormats (org.neo4j.kernel.impl.store.format.RecordFormats)6 TokenHolders (org.neo4j.token.TokenHolders)6 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)5 DatabaseReadOnlyChecker.writable (org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.writable)5 RecoveryCleanupWorkCollector.immediate (org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.immediate)5 ArrayList (java.util.ArrayList)4