Search in sources :

Example 6 with VisibleForTesting

use of org.neo4j.util.VisibleForTesting in project neo4j by neo4j.

the class MultipleIndexPopulator method newPopulatingUpdater.

@VisibleForTesting
MultipleIndexUpdater newPopulatingUpdater(NodePropertyAccessor accessor, CursorContext cursorContext) {
    Map<SchemaDescriptor, Pair<IndexPopulation, IndexUpdater>> updaters = new HashMap<>();
    forEachPopulation(population -> {
        IndexUpdater updater = population.populator.newPopulatingUpdater(accessor, cursorContext);
        updaters.put(population.schema(), Pair.of(population, updater));
    }, cursorContext);
    return new MultipleIndexUpdater(this, updaters, logProvider, cursorContext);
}
Also used : SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) HashMap(java.util.HashMap) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Pair(org.neo4j.internal.helpers.collection.Pair) VisibleForTesting(org.neo4j.util.VisibleForTesting)

Example 7 with VisibleForTesting

use of org.neo4j.util.VisibleForTesting in project neo4j by neo4j.

the class SchemaStorage method streamAllSchemaRules.

@VisibleForTesting
Stream<SchemaRule> streamAllSchemaRules(boolean ignoreMalformed, CursorContext cursorContext) {
    long startId = schemaStore.getNumberOfReservedLowIds();
    long endId = schemaStore.getHighId();
    Stream<IndexDescriptor> nli = Stream.empty();
    KernelVersion currentVersion;
    try {
        currentVersion = versionSupplier.kernelVersion();
    } catch (IllegalStateException ignored) {
        // If KernelVersion is missing we are an older store.
        currentVersion = KernelVersion.V4_2;
    }
    if (currentVersion.isLessThan(KernelVersion.VERSION_IN_WHICH_TOKEN_INDEXES_ARE_INTRODUCED)) {
        nli = Stream.of(IndexDescriptor.INJECTED_NLI);
    }
    return Stream.concat(LongStream.range(startId, endId).mapToObj(id -> schemaStore.getRecord(id, schemaStore.newRecord(), RecordLoad.LENIENT_ALWAYS, cursorContext)).filter(AbstractBaseRecord::inUse).flatMap(record -> readSchemaRuleThrowingRuntimeException(record, ignoreMalformed, cursorContext)), nli);
}
Also used : KernelVersion(org.neo4j.kernel.KernelVersion) SchemaRule(org.neo4j.internal.schema.SchemaRule) CursorContext(org.neo4j.io.pagecache.context.CursorContext) KernelVersion(org.neo4j.kernel.KernelVersion) Value(org.neo4j.values.storable.Value) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) ArrayList(java.util.ArrayList) Values(org.neo4j.values.storable.Values) IntObjectMap(org.eclipse.collections.api.map.primitive.IntObjectMap) KernelVersionRepository(org.neo4j.storageengine.api.KernelVersionRepository) IntObjectProcedure(org.eclipse.collections.api.block.procedure.primitive.IntObjectProcedure) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) AbstractBaseRecord(org.neo4j.kernel.impl.store.record.AbstractBaseRecord) VisibleForTesting(org.neo4j.util.VisibleForTesting) MalformedSchemaRuleException(org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException) SchemaRuleNotFoundException(org.neo4j.internal.kernel.api.exceptions.schema.SchemaRuleNotFoundException) MemoryTracker(org.neo4j.memory.MemoryTracker) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore) Record(org.neo4j.kernel.impl.store.record.Record) LongStream(java.util.stream.LongStream) Iterator(java.util.Iterator) Collection(java.util.Collection) SchemaStore(org.neo4j.kernel.impl.store.SchemaStore) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) DuplicateSchemaRuleException(org.neo4j.internal.kernel.api.exceptions.schema.DuplicateSchemaRuleException) Stream(java.util.stream.Stream) KernelException(org.neo4j.exceptions.KernelException) TokenHolders(org.neo4j.token.TokenHolders) SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) SchemaDescriptorSupplier(org.neo4j.internal.schema.SchemaDescriptorSupplier) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) RecordLoad(org.neo4j.kernel.impl.store.record.RecordLoad) IndexRef(org.neo4j.internal.schema.IndexRef) AbstractBaseRecord(org.neo4j.kernel.impl.store.record.AbstractBaseRecord) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) VisibleForTesting(org.neo4j.util.VisibleForTesting)

Example 8 with VisibleForTesting

use of org.neo4j.util.VisibleForTesting in project neo4j by neo4j.

the class SetDefaultAdminCommand method loadNeo4jConfig.

@VisibleForTesting
Config loadNeo4jConfig() {
    Config cfg = Config.newBuilder().fromFileNoThrow(ctx.confDir().resolve(Config.DEFAULT_CONFIG_FILE_NAME)).set(GraphDatabaseSettings.neo4j_home, ctx.homeDir().toAbsolutePath()).commandExpansion(allowCommandExpansion).build();
    ConfigUtils.disableAllConnectors(cfg);
    return cfg;
}
Also used : Config(org.neo4j.configuration.Config) VisibleForTesting(org.neo4j.util.VisibleForTesting)

Example 9 with VisibleForTesting

use of org.neo4j.util.VisibleForTesting in project neo4j by neo4j.

the class GBPTree method overwriteHeader.

@VisibleForTesting
public static void overwriteHeader(PageCache pageCache, Path indexFile, Consumer<PageCursor> headerWriter, String databaseName, CursorContext cursorContext) throws IOException {
    Header.Writer writer = replace(headerWriter);
    try (PagedFile pagedFile = openExistingIndexFile(pageCache, indexFile, cursorContext, databaseName, immutable.empty())) {
        Pair<TreeState, TreeState> states = readStatePages(pagedFile, cursorContext);
        TreeState newestValidState = TreeStatePair.selectNewestValidState(states);
        long pageToOverwrite = newestValidState.pageId();
        try (PageCursor cursor = pagedFile.io(pageToOverwrite, PagedFile.PF_SHARED_WRITE_LOCK, cursorContext)) {
            PageCursorUtil.goTo(cursor, "state page", pageToOverwrite);
            // Place cursor after state data
            TreeState.read(cursor);
            // Note offset to header
            int headerOffset = cursor.getOffset();
            int headerDataOffset = getHeaderDataOffset(headerOffset);
            // Reserve space to store length
            cursor.setOffset(headerDataOffset);
            // Write data
            writer.write(null, 0, cursor);
            // Write length
            int length = cursor.getOffset() - headerDataOffset;
            cursor.putInt(headerOffset, length);
            checkOutOfBounds(cursor);
        }
    }
}
Also used : PagedFile(org.neo4j.io.pagecache.PagedFile) PageCursor(org.neo4j.io.pagecache.PageCursor) VisibleForTesting(org.neo4j.util.VisibleForTesting)

Example 10 with VisibleForTesting

use of org.neo4j.util.VisibleForTesting in project neo4j by neo4j.

the class NativeLuceneFusionIndexProviderFactory30 method create.

@VisibleForTesting
public static FusionIndexProvider create(PageCache pageCache, Path databaseDirectory, FileSystemAbstraction fs, Monitors monitors, String monitorTag, Config config, DatabaseReadOnlyChecker readOnlyChecker, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, PageCacheTracer pageCacheTracer, String databaseName) {
    IndexDirectoryStructure.Factory childDirectoryStructure = subProviderDirectoryStructure(databaseDirectory);
    boolean archiveFailedIndex = config.get(GraphDatabaseInternalSettings.archive_failed_index);
    DatabaseIndexContext databaseIndexContext = DatabaseIndexContext.builder(pageCache, fs, databaseName).withMonitors(monitors).withTag(monitorTag).withReadOnlyChecker(readOnlyChecker).withPageCacheTracer(pageCacheTracer).build();
    GenericNativeIndexProvider generic = new GenericNativeIndexProvider(databaseIndexContext, childDirectoryStructure, recoveryCleanupWorkCollector, config);
    LuceneIndexProvider lucene = IndexProviderFactoryUtil.luceneProvider(fs, childDirectoryStructure, monitors, monitorTag, config, readOnlyChecker);
    return new FusionIndexProvider(generic, lucene, new FusionSlotSelector30(), DESCRIPTOR, directoriesByProvider(databaseDirectory), fs, archiveFailedIndex, readOnlyChecker);
}
Also used : GenericNativeIndexProvider(org.neo4j.kernel.impl.index.schema.GenericNativeIndexProvider) DatabaseIndexContext(org.neo4j.kernel.impl.index.schema.DatabaseIndexContext) IndexDirectoryStructure(org.neo4j.kernel.api.index.IndexDirectoryStructure) LuceneIndexProvider(org.neo4j.kernel.api.impl.schema.LuceneIndexProvider) VisibleForTesting(org.neo4j.util.VisibleForTesting)

Aggregations

VisibleForTesting (org.neo4j.util.VisibleForTesting)11 Config (org.neo4j.configuration.Config)3 PageCursor (org.neo4j.io.pagecache.PageCursor)3 SchemaDescriptor (org.neo4j.internal.schema.SchemaDescriptor)2 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 UncheckedIOException (java.io.UncheckedIOException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LongStream (java.util.stream.LongStream)1 Stream (java.util.stream.Stream)1 IntObjectProcedure (org.eclipse.collections.api.block.procedure.primitive.IntObjectProcedure)1 IntObjectMap (org.eclipse.collections.api.map.primitive.IntObjectMap)1 KernelException (org.neo4j.exceptions.KernelException)1 IndexConfig (org.neo4j.internal.batchimport.IndexConfig)1 Pair (org.neo4j.internal.helpers.collection.Pair)1 DuplicateSchemaRuleException (org.neo4j.internal.kernel.api.exceptions.schema.DuplicateSchemaRuleException)1 MalformedSchemaRuleException (org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException)1