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);
}
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);
}
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;
}
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);
}
}
}
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);
}
Aggregations