use of org.neo4j.kernel.spi.legacyindex.IndexImplementation in project neo4j by neo4j.
the class LegacyIndexMigratorTest method getIndexProviders.
private HashMap<String, IndexImplementation> getIndexProviders() {
HashMap<String, IndexImplementation> indexProviders = new HashMap<>();
IndexImplementation indexImplementation = mock(IndexImplementation.class);
indexProviders.put("lucene", indexImplementation);
when(indexImplementation.getIndexImplementationDirectory(storeDir)).thenReturn(originalIndexStore);
when(indexImplementation.getIndexImplementationDirectory(migrationDir)).thenReturn(migratedIndexStore);
return indexProviders;
}
use of org.neo4j.kernel.spi.legacyindex.IndexImplementation in project neo4j by neo4j.
the class LegacyIndexTransactionStateImpl method nodeChanges.
@Override
public LegacyIndex nodeChanges(String indexName) throws LegacyIndexNotFoundKernelException {
Map<String, String> configuration = indexConfigStore.get(Node.class, indexName);
if (configuration == null) {
throw new LegacyIndexNotFoundKernelException("Node index '" + indexName + " not found");
}
String providerName = configuration.get(IndexManager.PROVIDER);
IndexImplementation provider = providerLookup.apply(providerName);
LegacyIndexProviderTransaction transaction = transactions.get(providerName);
if (transaction == null) {
transactions.put(providerName, transaction = provider.newTransaction(this));
}
return transaction.nodeIndex(indexName, configuration);
}
use of org.neo4j.kernel.spi.legacyindex.IndexImplementation in project neo4j by neo4j.
the class LegacyIndexStore method findIndexConfig.
private Map<String, String> findIndexConfig(Class<? extends PropertyContainer> cls, String indexName, Map<String, String> suppliedConfig, @Nonnull Config dbConfig) {
// Check stored config (has this index been created previously?)
Map<String, String> storedConfig = indexStore.get(cls, indexName);
if (storedConfig != null && suppliedConfig == null) {
// Fill in "provider" if not already filled in, backwards compatibility issue
Map<String, String> newConfig = injectDefaultProviderIfMissing(indexName, dbConfig, storedConfig);
if (newConfig != storedConfig) {
indexStore.set(cls, indexName, newConfig);
}
return newConfig;
}
Map<String, String> configToUse = suppliedConfig;
// Check db config properties for provider
String provider;
IndexImplementation indexProvider;
if (configToUse == null) {
provider = getDefaultProvider(indexName, dbConfig);
configToUse = MapUtil.stringMap(PROVIDER, provider);
} else {
provider = configToUse.get(PROVIDER);
provider = provider == null ? getDefaultProvider(indexName, dbConfig) : provider;
}
indexProvider = indexProviders.apply(provider);
configToUse = indexProvider.fillInDefaults(configToUse);
configToUse = injectDefaultProviderIfMissing(indexName, dbConfig, configToUse);
// Do they match (stored vs. supplied)?
if (storedConfig != null) {
assertConfigMatches(indexProvider, indexName, storedConfig, suppliedConfig);
// Fill in "provider" if not already filled in, backwards compatibility issue
Map<String, String> newConfig = injectDefaultProviderIfMissing(indexName, dbConfig, storedConfig);
if (newConfig != storedConfig) {
indexStore.set(cls, indexName, newConfig);
}
configToUse = newConfig;
}
return Collections.unmodifiableMap(configToUse);
}
use of org.neo4j.kernel.spi.legacyindex.IndexImplementation in project neo4j by neo4j.
the class LegacyIndexMigrator method migrate.
@Override
public void migrate(File storeDir, File migrationDir, MigrationProgressMonitor.Section progressMonitor, String versionToMigrateFrom, String versionToMigrateTo) throws IOException {
IndexImplementation indexImplementation = indexProviders.get(LUCENE_LEGACY_INDEX_PROVIDER_NAME);
if (indexImplementation != null) {
RecordFormats from = RecordFormatSelector.selectForVersion(versionToMigrateFrom);
RecordFormats to = RecordFormatSelector.selectForVersion(versionToMigrateTo);
if (!from.hasSameCapabilities(to, CapabilityType.INDEX)) {
originalLegacyIndexesRoot = indexImplementation.getIndexImplementationDirectory(storeDir);
migrationLegacyIndexesRoot = indexImplementation.getIndexImplementationDirectory(migrationDir);
if (isNotEmptyDirectory(originalLegacyIndexesRoot)) {
migrateLegacyIndexes(progressMonitor);
legacyIndexMigrated = true;
}
}
} else {
log.debug("Lucene index provider not found, nothing to migrate.");
}
}
use of org.neo4j.kernel.spi.legacyindex.IndexImplementation in project neo4j by neo4j.
the class LegacyIndexTransactionStateImplTest method newLegacyIndexTxState.
private static LegacyIndexTransactionStateImpl newLegacyIndexTxState() {
IndexConfigStore indexConfigStore = mock(IndexConfigStore.class);
when(indexConfigStore.get(eq(Node.class), anyString())).thenReturn(singletonMap(IndexManager.PROVIDER, "test"));
when(indexConfigStore.get(eq(Relationship.class), anyString())).thenReturn(singletonMap(IndexManager.PROVIDER, "test"));
Function<String, IndexImplementation> providerLookup = s -> mock(IndexImplementation.class);
return new LegacyIndexTransactionStateImpl(indexConfigStore, providerLookup);
}
Aggregations