Search in sources :

Example 6 with INSTANCE

use of org.neo4j.memory.EmptyMemoryTracker.INSTANCE in project neo4j by neo4j.

the class RelationshipChangesForNodeTest method shouldVisitRelationshipIds.

@Test
void shouldVisitRelationshipIds() {
    // given
    RelationshipChangesForNode changes = createRelationshipChangesForNode(REMOVE, INSTANCE);
    MutableIntObjectMap<Map<RelationshipDirection, MutableLongSet>> expected = IntObjectMaps.mutable.empty();
    MutableLongSet allExpected = LongSets.mutable.empty();
    for (int id = 0; id < 100; id++) {
        int type = random.nextInt(5);
        RelationshipDirection direction = random.nextBoolean() ? random.nextBoolean() ? OUTGOING : INCOMING : LOOP;
        changes.addRelationship(id, type, direction);
        expected.getIfAbsentPut(type, HashMap::new).computeIfAbsent(direction, d -> LongSets.mutable.empty()).add(id);
        allExpected.add(id);
    }
    // when
    MutableLongSet allChangedIds = LongSets.mutable.empty();
    changes.visitIds(allChangedIds::add);
    // then
    assertThat(allChangedIds).isEqualTo(allExpected);
    // and when
    changes.visitIdsSplit(typeIds -> {
        Map<RelationshipDirection, MutableLongSet> dirMap = expected.remove(typeIds.type());
        visitExpectedIds(typeIds, dirMap, OUTGOING, RelationshipModifications.NodeRelationshipTypeIds::out);
        visitExpectedIds(typeIds, dirMap, INCOMING, RelationshipModifications.NodeRelationshipTypeIds::in);
        visitExpectedIds(typeIds, dirMap, LOOP, RelationshipModifications.NodeRelationshipTypeIds::loop);
        assertThat(dirMap).isEmpty();
        return false;
    }, RelationshipModifications.noAdditionalDataDecorator());
    assertThat(expected).isEmpty();
}
Also used : RelationshipModifications(org.neo4j.storageengine.api.txstate.RelationshipModifications) RandomExtension(org.neo4j.test.extension.RandomExtension) OUTGOING(org.neo4j.storageengine.api.RelationshipDirection.OUTGOING) Direction(org.neo4j.graphdb.Direction) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) PrimitiveLongCollections.asArray(org.neo4j.collection.PrimitiveLongCollections.asArray) MutableIntObjectMap(org.eclipse.collections.api.map.primitive.MutableIntObjectMap) HashMap(java.util.HashMap) Function(java.util.function.Function) RelationshipDirection(org.neo4j.storageengine.api.RelationshipDirection) IntObjectMaps(org.eclipse.collections.impl.factory.primitive.IntObjectMaps) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Inject(org.neo4j.test.extension.Inject) RandomRule(org.neo4j.test.rule.RandomRule) Map(java.util.Map) ADD(org.neo4j.kernel.impl.api.state.RelationshipChangesForNode.DiffStrategy.ADD) INCOMING(org.neo4j.storageengine.api.RelationshipDirection.INCOMING) LOOP(org.neo4j.storageengine.api.RelationshipDirection.LOOP) REMOVE(org.neo4j.kernel.impl.api.state.RelationshipChangesForNode.DiffStrategy.REMOVE) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) Test(org.junit.jupiter.api.Test) LongIterator(org.eclipse.collections.api.iterator.LongIterator) RelationshipChangesForNode.createRelationshipChangesForNode(org.neo4j.kernel.impl.api.state.RelationshipChangesForNode.createRelationshipChangesForNode) INSTANCE(org.neo4j.memory.EmptyMemoryTracker.INSTANCE) LongSets(org.eclipse.collections.impl.factory.primitive.LongSets) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) RelationshipDirection(org.neo4j.storageengine.api.RelationshipDirection) HashMap(java.util.HashMap) RelationshipChangesForNode.createRelationshipChangesForNode(org.neo4j.kernel.impl.api.state.RelationshipChangesForNode.createRelationshipChangesForNode) MutableIntObjectMap(org.eclipse.collections.api.map.primitive.MutableIntObjectMap) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 7 with INSTANCE

use of org.neo4j.memory.EmptyMemoryTracker.INSTANCE in project neo4j by neo4j.

the class TransactionLogsRecoveryTest method writeSomeDataWithVersion.

private void writeSomeDataWithVersion(Path file, Visitor<Pair<LogEntryWriter, Consumer<LogPositionMarker>>, IOException> visitor, KernelVersion version) throws IOException {
    try (LogVersionedStoreChannel versionedStoreChannel = new PhysicalLogVersionedStoreChannel(fileSystem.write(file), logVersion, CURRENT_LOG_FORMAT_VERSION, file, EMPTY_ACCESSOR);
        PositionAwarePhysicalFlushableChecksumChannel writableLogChannel = new PositionAwarePhysicalFlushableChecksumChannel(versionedStoreChannel, new HeapScopedBuffer(1, KibiByte, INSTANCE))) {
        writeLogHeader(writableLogChannel, new LogHeader(logVersion, 2L, StoreId.UNKNOWN));
        writableLogChannel.beginChecksum();
        Consumer<LogPositionMarker> consumer = marker -> {
            try {
                writableLogChannel.getCurrentPosition(marker);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        };
        LogEntryWriter first = new LogEntryWriter(writableLogChannel, version);
        visitor.visit(Pair.of(first, consumer));
    }
}
Also used : HeapScopedBuffer(org.neo4j.io.memory.HeapScopedBuffer) Visitor(org.neo4j.internal.helpers.collection.Visitor) BeforeEach(org.junit.jupiter.api.BeforeEach) LifecycleAdapter(org.neo4j.kernel.lifecycle.LifecycleAdapter) MutableInt(org.apache.commons.lang3.mutable.MutableInt) Log(org.neo4j.logging.Log) DatabaseIdFactory.from(org.neo4j.kernel.database.DatabaseIdFactory.from) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LogFilesBuilder(org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder) Config(org.neo4j.configuration.Config) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) LogHeaderWriter.writeLogHeader(org.neo4j.kernel.impl.transaction.log.entry.LogHeaderWriter.writeLogHeader) LogEntryWriter(org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter) LogCheckPointEvent(org.neo4j.kernel.impl.transaction.tracing.LogCheckPointEvent) LogHeader(org.neo4j.kernel.impl.transaction.log.entry.LogHeader) Monitors(org.neo4j.monitoring.Monitors) BASE_TX_CHECKSUM(org.neo4j.storageengine.api.TransactionIdStore.BASE_TX_CHECKSUM) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) LogVersionRepository(org.neo4j.storageengine.api.LogVersionRepository) PositionAwarePhysicalFlushableChecksumChannel(org.neo4j.kernel.impl.transaction.log.PositionAwarePhysicalFlushableChecksumChannel) Path(java.nio.file.Path) EMPTY_CHECKER(org.neo4j.kernel.recovery.RecoveryStartupChecker.EMPTY_CHECKER) StorageEngine(org.neo4j.storageengine.api.StorageEngine) NO_RECOVERY_REQUIRED(org.neo4j.kernel.recovery.RecoveryStartInformation.NO_RECOVERY_REQUIRED) TestDirectory(org.neo4j.test.rule.TestDirectory) BASE_TX_COMMIT_TIMESTAMP(org.neo4j.storageengine.api.TransactionIdStore.BASE_TX_COMMIT_TIMESTAMP) LogPositionMarker(org.neo4j.kernel.impl.transaction.log.LogPositionMarker) LogEntryStart(org.neo4j.kernel.impl.transaction.log.entry.LogEntryStart) Instant(java.time.Instant) Neo4jLayoutExtension(org.neo4j.test.extension.Neo4jLayoutExtension) Test(org.junit.jupiter.api.Test) CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) INSTANCE(org.neo4j.memory.EmptyMemoryTracker.INSTANCE) TestLogEntryReader.logEntryReader(org.neo4j.kernel.impl.transaction.log.TestLogEntryReader.logEntryReader) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) LogEntry(org.neo4j.kernel.impl.transaction.log.entry.LogEntry) DatabaseStartAbortedException(org.neo4j.dbms.database.DatabaseStartAbortedException) Mockito.mock(org.mockito.Mockito.mock) PhysicalLogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.PhysicalLogicalTransactionStore) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) CsvSource(org.junit.jupiter.params.provider.CsvSource) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) LogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore) ProgressReporter(org.neo4j.common.ProgressReporter) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) KernelVersion(org.neo4j.kernel.KernelVersion) ArrayUtils(org.apache.commons.lang3.ArrayUtils) NULL(org.neo4j.io.pagecache.tracing.PageCacheTracer.NULL) DatabaseStartupController(org.neo4j.kernel.database.DatabaseStartupController) LogFile(org.neo4j.kernel.impl.transaction.log.files.LogFile) EMPTY_ACCESSOR(org.neo4j.kernel.impl.transaction.log.files.ChannelNativeAccessor.EMPTY_ACCESSOR) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Inject(org.neo4j.test.extension.Inject) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) StoreId(org.neo4j.storageengine.api.StoreId) TransactionApplicationMode(org.neo4j.storageengine.api.TransactionApplicationMode) GraphDatabaseInternalSettings(org.neo4j.configuration.GraphDatabaseInternalSettings) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) Lifecycle(org.neo4j.kernel.lifecycle.Lifecycle) LogEntryCommit(org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommit) Files(java.nio.file.Files) LogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader) TransactionMetadataCache(org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache) ExceptionUtils.getRootCause(org.apache.commons.lang3.exception.ExceptionUtils.getRootCause) IOException(java.io.IOException) Mockito.when(org.mockito.Mockito.when) CURRENT_LOG_FORMAT_VERSION(org.neo4j.kernel.impl.transaction.log.entry.LogVersions.CURRENT_LOG_FORMAT_VERSION) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) Mockito.verify(org.mockito.Mockito.verify) Consumer(java.util.function.Consumer) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) UUID.randomUUID(java.util.UUID.randomUUID) Mockito.never(org.mockito.Mockito.never) CURRENT_FORMAT_LOG_HEADER_SIZE(org.neo4j.kernel.impl.transaction.log.entry.LogVersions.CURRENT_FORMAT_LOG_HEADER_SIZE) NO_MONITOR(org.neo4j.kernel.recovery.RecoveryStartInformationProvider.NO_MONITOR) HeapScopedBuffer(org.neo4j.io.memory.HeapScopedBuffer) Pair(org.neo4j.internal.helpers.collection.Pair) KibiByte(org.neo4j.io.ByteUnit.KibiByte) TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) PositionAwarePhysicalFlushableChecksumChannel(org.neo4j.kernel.impl.transaction.log.PositionAwarePhysicalFlushableChecksumChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) LogEntryWriter(org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter) IOException(java.io.IOException) LogHeaderWriter.writeLogHeader(org.neo4j.kernel.impl.transaction.log.entry.LogHeaderWriter.writeLogHeader) LogHeader(org.neo4j.kernel.impl.transaction.log.entry.LogHeader) LogPositionMarker(org.neo4j.kernel.impl.transaction.log.LogPositionMarker)

Example 8 with INSTANCE

use of org.neo4j.memory.EmptyMemoryTracker.INSTANCE in project neo4j by neo4j.

the class DynamicIndexStoreViewTest method shouldVisitAllRelationshipsWithoutTokenIndexes.

@Test
void shouldVisitAllRelationshipsWithoutTokenIndexes() {
    StubStorageCursors cursors = new StubStorageCursors().withoutTokenIndexes();
    IndexProxyProvider indexProxies = mock(IndexProxyProvider.class);
    int targetType = 1;
    int notTargetType = 2;
    int[] targetTypeArray = { targetType };
    String targetPropertyKey = "key";
    Value propertyValue = Values.stringValue("value");
    MutableLongList relationshipsWithTargetType = LongLists.mutable.empty();
    long id = 0;
    int wantedPropertyUpdates = 5;
    for (int i = 0; i < wantedPropertyUpdates; i++) {
        // Relationship fitting our target
        cursors.withRelationship(id, 1, targetType, 3).properties(targetPropertyKey, propertyValue);
        relationshipsWithTargetType.add(id++);
        // Relationship with different type
        cursors.withRelationship(id, 1, notTargetType, 3).properties(targetPropertyKey, propertyValue);
        relationshipsWithTargetType.add(id++);
    }
    int targetPropertyKeyId = cursors.propertyKeyTokenHolder().getIdByName(targetPropertyKey);
    IntPredicate propertyKeyIdFilter = value -> value == targetPropertyKeyId;
    DynamicIndexStoreView storeView = dynamicIndexStoreView(cursors, indexProxies);
    TestTokenScanConsumer tokenConsumer = new TestTokenScanConsumer();
    TestPropertyScanConsumer propertyScanConsumer = new TestPropertyScanConsumer();
    StoreScan storeScan = storeView.visitRelationships(targetTypeArray, propertyKeyIdFilter, propertyScanConsumer, tokenConsumer, false, true, NULL, INSTANCE);
    storeScan.run(StoreScan.NO_EXTERNAL_UPDATES);
    assertThat(tokenConsumer.batches.size()).isEqualTo(1);
    assertThat(tokenConsumer.batches.get(0).size()).isEqualTo(relationshipsWithTargetType.size());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) IndexProxy(org.neo4j.kernel.impl.api.index.IndexProxy) IndexPrototype.forSchema(org.neo4j.internal.schema.IndexPrototype.forSchema) InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) IndexProxyProvider(org.neo4j.kernel.impl.api.index.IndexingService.IndexProxyProvider) Predicates(org.neo4j.function.Predicates) LongLists(org.eclipse.collections.impl.factory.primitive.LongLists) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Config(org.neo4j.configuration.Config) StoreScan(org.neo4j.kernel.impl.api.index.StoreScan) Value(org.neo4j.values.storable.Value) NULL(org.neo4j.io.pagecache.tracing.PageCacheTracer.NULL) MutableLongList(org.eclipse.collections.api.list.primitive.MutableLongList) NullLogProvider(org.neo4j.logging.NullLogProvider) IntPredicate(java.util.function.IntPredicate) Supplier(java.util.function.Supplier) Values(org.neo4j.values.storable.Values) StorageReader(org.neo4j.storageengine.api.StorageReader) JobSchedulerFactory(org.neo4j.kernel.impl.scheduler.JobSchedulerFactory) JobScheduler(org.neo4j.scheduler.JobScheduler) Mockito.when(org.mockito.Mockito.when) RELATIONSHIP(org.neo4j.common.EntityType.RELATIONSHIP) NO_LOCKS(org.neo4j.kernel.impl.locking.Locks.NO_LOCKS) Test(org.junit.jupiter.api.Test) AfterEach(org.junit.jupiter.api.AfterEach) INSTANCE(org.neo4j.memory.EmptyMemoryTracker.INSTANCE) StubStorageCursors(org.neo4j.storageengine.api.StubStorageCursors) NO_LOCK_SERVICE(org.neo4j.lock.LockService.NO_LOCK_SERVICE) DESCRIPTOR(org.neo4j.kernel.impl.index.schema.TokenIndexProvider.DESCRIPTOR) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) NODE(org.neo4j.common.EntityType.NODE) SchemaDescriptor.forAnyEntityTokens(org.neo4j.internal.schema.SchemaDescriptor.forAnyEntityTokens) Mockito.mock(org.mockito.Mockito.mock) MutableLongList(org.eclipse.collections.api.list.primitive.MutableLongList) IntPredicate(java.util.function.IntPredicate) StoreScan(org.neo4j.kernel.impl.api.index.StoreScan) Value(org.neo4j.values.storable.Value) IndexProxyProvider(org.neo4j.kernel.impl.api.index.IndexingService.IndexProxyProvider) StubStorageCursors(org.neo4j.storageengine.api.StubStorageCursors) Test(org.junit.jupiter.api.Test)

Example 9 with INSTANCE

use of org.neo4j.memory.EmptyMemoryTracker.INSTANCE in project neo4j by neo4j.

the class NeoStoresTest method reinitializeStores.

private void reinitializeStores(DatabaseLayout databaseLayout) {
    Dependencies dependencies = new Dependencies();
    Config config = Config.defaults(GraphDatabaseSettings.fail_on_missing_files, false);
    dependencies.satisfyDependency(config);
    closeStorageEngine();
    IdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName());
    TokenHolders tokenHolders = new TokenHolders(createReadOnlyTokenHolder(TokenHolder.TYPE_PROPERTY_KEY), createReadOnlyTokenHolder(TokenHolder.TYPE_LABEL), createReadOnlyTokenHolder(TokenHolder.TYPE_RELATIONSHIP_TYPE));
    storageEngine = new RecordStorageEngine(databaseLayout, config, pageCache, fs, nullLogProvider(), tokenHolders, new DatabaseSchemaState(nullLogProvider()), new StandardConstraintRuleAccessor(), i -> i, NO_LOCK_SERVICE, mock(Health.class), idGeneratorFactory, new DefaultIdController(), immediate(), PageCacheTracer.NULL, true, INSTANCE, writable(), CommandLockVerification.Factory.IGNORE, LockVerificationMonitor.Factory.IGNORE);
    life = new LifeSupport();
    life.add(storageEngine);
    life.add(storageEngine.schemaAndTokensLifecycle());
    life.start();
    NeoStores neoStores = storageEngine.testAccessNeoStores();
    pStore = neoStores.getPropertyStore();
    nodeStore = neoStores.getNodeStore();
    storageReader = storageEngine.newReader();
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) Sets.immutable(org.eclipse.collections.api.factory.Sets.immutable) LongSupplier(java.util.function.LongSupplier) DefaultIdController(org.neo4j.internal.id.DefaultIdController) CursorContext(org.neo4j.io.pagecache.context.CursorContext) NORMAL(org.neo4j.kernel.impl.store.record.RecordLoad.NORMAL) Config(org.neo4j.configuration.Config) Value(org.neo4j.values.storable.Value) NullLogProvider(org.neo4j.logging.NullLogProvider) INTERNAL(org.neo4j.storageengine.api.TransactionApplicationMode.INTERNAL) EMPTY_BYTE_ARRAY(org.apache.commons.lang3.ArrayUtils.EMPTY_BYTE_ARRAY) StorageNodeCursor(org.neo4j.storageengine.api.StorageNodeCursor) DEFAULT_DATABASE_NAME(org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME) StorageRelationshipScanCursor(org.neo4j.storageengine.api.StorageRelationshipScanCursor) Duration(java.time.Duration) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) NULL(org.neo4j.io.pagecache.context.CursorContext.NULL) RecoveryCleanupWorkCollector(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector) Path(java.nio.file.Path) PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer) StoreTokens.createReadOnlyTokenHolder(org.neo4j.internal.recordstorage.StoreTokens.createReadOnlyTokenHolder) Position(org.neo4j.kernel.impl.store.MetaDataStore.Position) Dependencies(org.neo4j.collection.Dependencies) UncloseableDelegatingFileSystemAbstraction(org.neo4j.io.fs.UncloseableDelegatingFileSystemAbstraction) PropertyKeyValue(org.neo4j.storageengine.api.PropertyKeyValue) IdType(org.neo4j.internal.id.IdType) EphemeralNeo4jLayoutExtension(org.neo4j.test.extension.EphemeralNeo4jLayoutExtension) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) RelationshipType(org.neo4j.graphdb.RelationshipType) Mockito.mock(org.mockito.Mockito.mock) AUTH_DISABLED(org.neo4j.internal.kernel.api.security.AuthSubject.AUTH_DISABLED) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) TransactionId(org.neo4j.storageengine.api.TransactionId) RecordFormatSelector(org.neo4j.kernel.impl.store.format.RecordFormatSelector) Node(org.neo4j.graphdb.Node) ArrayList(java.util.ArrayList) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DelegatingTokenHolder(org.neo4j.token.DelegatingTokenHolder) StorageReader(org.neo4j.storageengine.api.StorageReader) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NONE(org.neo4j.lock.LockTracer.NONE) NullLogProvider.nullLogProvider(org.neo4j.logging.NullLogProvider.nullLogProvider) UTF8(org.neo4j.string.UTF8) IOException(java.io.IOException) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) RecoveryCleanupWorkCollector.immediate(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.immediate) AfterEach(org.junit.jupiter.api.AfterEach) KernelException(org.neo4j.exceptions.KernelException) TokenHolders(org.neo4j.token.TokenHolders) CURRENT_FORMAT_LOG_HEADER_SIZE(org.neo4j.kernel.impl.transaction.log.entry.LogVersions.CURRENT_FORMAT_LOG_HEADER_SIZE) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) IndexedIdGenerator(org.neo4j.internal.id.indexed.IndexedIdGenerator) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) LockVerificationMonitor(org.neo4j.internal.recordstorage.LockVerificationMonitor) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) ByteBuffer(java.nio.ByteBuffer) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) UnderlyingStorageException(org.neo4j.exceptions.UnderlyingStorageException) StoreChannel(org.neo4j.io.fs.StoreChannel) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) StorageRelationshipTraversalCursor(org.neo4j.storageengine.api.StorageRelationshipTraversalCursor) DatabaseSchemaState(org.neo4j.kernel.impl.api.DatabaseSchemaState) Record(org.neo4j.kernel.impl.store.record.Record) PageCache(org.neo4j.io.pagecache.PageCache) DatabaseReadOnlyChecker.writable(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.writable) TestDirectory(org.neo4j.test.rule.TestDirectory) BASE_TX_COMMIT_TIMESTAMP(org.neo4j.storageengine.api.TransactionIdStore.BASE_TX_COMMIT_TIMESTAMP) RecordStorageEngine(org.neo4j.internal.recordstorage.RecordStorageEngine) StoragePropertyCursor(org.neo4j.storageengine.api.StoragePropertyCursor) Test(org.junit.jupiter.api.Test) List(java.util.List) CommandCreationContext(org.neo4j.storageengine.api.CommandCreationContext) INSTANCE(org.neo4j.memory.EmptyMemoryTracker.INSTANCE) NO_LOCK_SERVICE(org.neo4j.lock.LockService.NO_LOCK_SERVICE) StorageProperty(org.neo4j.storageengine.api.StorageProperty) DatabaseReadOnlyChecker(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) RelationshipVisitor(org.neo4j.storageengine.api.RelationshipVisitor) IdGeneratorFactory(org.neo4j.internal.id.IdGeneratorFactory) GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) TxState(org.neo4j.kernel.impl.api.state.TxState) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) StorageCommand(org.neo4j.storageengine.api.StorageCommand) Values(org.neo4j.values.storable.Values) StandardConstraintRuleAccessor(org.neo4j.storageengine.api.StandardConstraintRuleAccessor) TokenHolder(org.neo4j.token.api.TokenHolder) PropertyReceiver(org.neo4j.internal.recordstorage.TransactionRecordState.PropertyReceiver) Inject(org.neo4j.test.extension.Inject) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) ALL_RELATIONSHIPS(org.neo4j.storageengine.api.RelationshipSelection.ALL_RELATIONSHIPS) GraphDatabaseInternalSettings.counts_store_rotation_timeout(org.neo4j.configuration.GraphDatabaseInternalSettings.counts_store_rotation_timeout) OpenOption(java.nio.file.OpenOption) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) IGNORE(org.neo4j.lock.ResourceLocker.IGNORE) TransactionState(org.neo4j.kernel.api.txstate.TransactionState) CommandLockVerification(org.neo4j.internal.recordstorage.CommandLockVerification) Health(org.neo4j.monitoring.Health) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) EphemeralPageCacheExtension(org.neo4j.test.extension.pagecache.EphemeralPageCacheExtension) FIELD_NOT_PRESENT(org.neo4j.kernel.impl.store.format.standard.MetaDataRecordFormat.FIELD_NOT_PRESENT) Relationship(org.neo4j.graphdb.Relationship) ImmutableSet(org.eclipse.collections.api.set.ImmutableSet) TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultIdController(org.neo4j.internal.id.DefaultIdController) DatabaseSchemaState(org.neo4j.kernel.impl.api.DatabaseSchemaState) Config(org.neo4j.configuration.Config) RecordStorageEngine(org.neo4j.internal.recordstorage.RecordStorageEngine) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) IdGeneratorFactory(org.neo4j.internal.id.IdGeneratorFactory) Dependencies(org.neo4j.collection.Dependencies) TokenHolders(org.neo4j.token.TokenHolders) StandardConstraintRuleAccessor(org.neo4j.storageengine.api.StandardConstraintRuleAccessor)

Example 10 with INSTANCE

use of org.neo4j.memory.EmptyMemoryTracker.INSTANCE in project neo4j by neo4j.

the class OnlineIndexUpdatesTest method setUp.

@BeforeEach
void setUp() throws IOException {
    life = new LifeSupport();
    Config config = Config.defaults();
    NullLogProvider nullLogProvider = NullLogProvider.getInstance();
    StoreFactory storeFactory = new StoreFactory(databaseLayout, config, new DefaultIdGeneratorFactory(fileSystem, immediate(), databaseLayout.getDatabaseName()), pageCache, fileSystem, nullLogProvider, NULL, writable());
    neoStores = storeFactory.openAllNeoStores(true);
    GBPTreeCountsStore counts = new GBPTreeCountsStore(pageCache, databaseLayout.countStore(), fileSystem, immediate(), new CountsComputer(neoStores, pageCache, NULL, databaseLayout, INSTANCE, NullLog.getInstance()), writable(), NULL, GBPTreeCountsStore.NO_MONITOR, databaseLayout.getDatabaseName(), 1_000);
    life.add(wrapInLifecycle(counts));
    nodeStore = neoStores.getNodeStore();
    relationshipStore = neoStores.getRelationshipStore();
    PropertyStore propertyStore = neoStores.getPropertyStore();
    schemaCache = new SchemaCache(new StandardConstraintRuleAccessor(), index -> index);
    propertyPhysicalToLogicalConverter = new PropertyPhysicalToLogicalConverter(neoStores.getPropertyStore(), CursorContext.NULL);
    life.start();
    propertyCreator = new PropertyCreator(neoStores.getPropertyStore(), new PropertyTraverser(CursorContext.NULL), CursorContext.NULL, INSTANCE);
    recordAccess = new DirectRecordAccess<>(neoStores.getPropertyStore(), Loaders.propertyLoader(propertyStore, CursorContext.NULL));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) LifecycleAdapter(org.neo4j.kernel.lifecycle.LifecycleAdapter) NodeCommand(org.neo4j.internal.recordstorage.Command.NodeCommand) CursorContext(org.neo4j.io.pagecache.context.CursorContext) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Config(org.neo4j.configuration.Config) Value(org.neo4j.values.storable.Value) NO_NEXT_RELATIONSHIP(org.neo4j.kernel.impl.store.record.Record.NO_NEXT_RELATIONSHIP) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) NullLogProvider(org.neo4j.logging.NullLogProvider) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) Collections.singletonList(java.util.Collections.singletonList) NO_LABELS_FIELD(org.neo4j.kernel.impl.store.record.Record.NO_LABELS_FIELD) InlineNodeLabels(org.neo4j.kernel.impl.store.InlineNodeLabels) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) CountsComputer(org.neo4j.kernel.impl.store.CountsComputer) NullLog(org.neo4j.logging.NullLog) PageCache(org.neo4j.io.pagecache.PageCache) DatabaseReadOnlyChecker.writable(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.writable) IndexEntryUpdate(org.neo4j.storageengine.api.IndexEntryUpdate) Neo4jLayoutExtension(org.neo4j.test.extension.Neo4jLayoutExtension) Test(org.junit.jupiter.api.Test) INSTANCE(org.neo4j.memory.EmptyMemoryTracker.INSTANCE) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) IndexPrototype(org.neo4j.internal.schema.IndexPrototype) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) NodeStore(org.neo4j.kernel.impl.store.NodeStore) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) NODE(org.neo4j.common.EntityType.NODE) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) CountsStore(org.neo4j.counts.CountsStore) NULL(org.neo4j.io.pagecache.tracing.PageCacheTracer.NULL) Values(org.neo4j.values.storable.Values) StandardConstraintRuleAccessor(org.neo4j.storageengine.api.StandardConstraintRuleAccessor) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) NeoStores(org.neo4j.kernel.impl.store.NeoStores) Inject(org.neo4j.test.extension.Inject) GBPTreeCountsStore(org.neo4j.internal.counts.GBPTreeCountsStore) NO_NEXT_PROPERTY(org.neo4j.kernel.impl.store.record.Record.NO_NEXT_PROPERTY) PropertyCommand(org.neo4j.internal.recordstorage.Command.PropertyCommand) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SchemaDescriptor.fulltext(org.neo4j.internal.schema.SchemaDescriptor.fulltext) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore) Lifecycle(org.neo4j.kernel.lifecycle.Lifecycle) PageCacheExtension(org.neo4j.test.extension.pagecache.PageCacheExtension) Iterator(java.util.Iterator) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) IOException(java.io.IOException) RELATIONSHIP(org.neo4j.common.EntityType.RELATIONSHIP) RecoveryCleanupWorkCollector.immediate(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.immediate) AfterEach(org.junit.jupiter.api.AfterEach) PrimitiveRecord(org.neo4j.kernel.impl.store.record.PrimitiveRecord) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) Config(org.neo4j.configuration.Config) CountsComputer(org.neo4j.kernel.impl.store.CountsComputer) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) GBPTreeCountsStore(org.neo4j.internal.counts.GBPTreeCountsStore) NullLogProvider(org.neo4j.logging.NullLogProvider) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore) StandardConstraintRuleAccessor(org.neo4j.storageengine.api.StandardConstraintRuleAccessor) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

INSTANCE (org.neo4j.memory.EmptyMemoryTracker.INSTANCE)10 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 Test (org.junit.jupiter.api.Test)7 IOException (java.io.IOException)6 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)6 Mockito.mock (org.mockito.Mockito.mock)6 Inject (org.neo4j.test.extension.Inject)6 ArrayList (java.util.ArrayList)5 Mockito.when (org.mockito.Mockito.when)5 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)5 PageCache (org.neo4j.io.pagecache.PageCache)5 Values (org.neo4j.values.storable.Values)5 Path (java.nio.file.Path)4 List (java.util.List)4 AfterEach (org.junit.jupiter.api.AfterEach)4 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)4 Mockito.verify (org.mockito.Mockito.verify)4 Config (org.neo4j.configuration.Config)4 NULL (org.neo4j.io.pagecache.tracing.PageCacheTracer.NULL)4 Arrays (java.util.Arrays)3