use of org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage in project neo4j by neo4j.
the class FulltextIndexProvider method getPopulator.
@Override
public IndexPopulator getPopulator(IndexDescriptor descriptor, IndexSamplingConfig samplingConfig, ByteBufferFactory bufferFactory, MemoryTracker memoryTracker, TokenNameLookup tokenNameLookup) {
if (isReadOnly()) {
throw new UnsupportedOperationException("Can't create populator for read only index");
}
try {
PartitionedIndexStorage indexStorage = getIndexStorage(descriptor.getId());
Analyzer analyzer = createAnalyzer(descriptor, tokenNameLookup);
String[] propertyNames = createPropertyNames(descriptor, tokenNameLookup);
DatabaseIndex<FulltextIndexReader> fulltextIndex = FulltextIndexBuilder.create(descriptor, config, readOnlyChecker, tokenHolders.propertyKeyTokens(), analyzer, propertyNames).withFileSystem(fileSystem).withIndexStorage(indexStorage).withPopulatingMode(true).build();
log.debug("Creating populator for fulltext schema index: %s", descriptor);
return new FulltextIndexPopulator(descriptor, fulltextIndex, propertyNames);
} catch (Exception e) {
PartitionedIndexStorage indexStorage = getIndexStorage(descriptor.getId());
DatabaseIndex<FulltextIndexReader> fulltextIndex = new DroppableIndex<>(new DroppableLuceneIndex<>(indexStorage, new ReadOnlyIndexPartitionFactory(), descriptor));
log.debug("Creating failed index populator for fulltext schema index: %s", descriptor, e);
return new FailedFulltextIndexPopulator(descriptor, fulltextIndex, e);
}
}
use of org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage in project neo4j by neo4j.
the class FulltextIndexProvider method getInitialState.
@Override
public InternalIndexState getInitialState(IndexDescriptor index, CursorContext cursorContext) {
PartitionedIndexStorage indexStorage = getIndexStorage(index.getId());
String failure = indexStorage.getStoredIndexFailure();
if (failure != null) {
return InternalIndexState.FAILED;
}
// For instance, that it doesn't refer to an analyzer that has since been removed.
try {
validateIndexRef(index);
} catch (Exception e) {
try {
indexStorage.storeIndexFailure(Exceptions.stringify(e));
} catch (IOException ex) {
ex.addSuppressed(e);
log.warn("Failed to persist index failure. Index failure added as suppressed exception.", ex);
}
return InternalIndexState.FAILED;
}
try {
return indexIsOnline(indexStorage, index) ? InternalIndexState.ONLINE : InternalIndexState.POPULATING;
} catch (IOException e) {
return InternalIndexState.POPULATING;
}
}
use of org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage in project neo4j by neo4j.
the class AccessUniqueDatabaseIndexTest method shouldUpdateUniqueEntries.
@Test
void shouldUpdateUniqueEntries() throws Exception {
// given
PartitionedIndexStorage indexStorage = getIndexStorage();
LuceneIndexAccessor accessor = createAccessor(indexStorage);
// when
updateAndCommit(accessor, singletonList(add(1L, "value1")));
updateAndCommit(accessor, singletonList(change(1L, "value1", "value2")));
accessor.close();
// then
assertEquals(singletonList(1L), getAllNodes(indexStorage, "value2"));
assertEquals(emptyList(), getAllNodes(indexStorage, "value1"));
}
use of org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage in project neo4j by neo4j.
the class DatabaseIndexIntegrationTest method createTestLuceneIndex.
private WritableTestDatabaseIndex createTestLuceneIndex(DirectoryFactory dirFactory, Path folder) throws IOException {
PartitionedIndexStorage indexStorage = new PartitionedIndexStorage(dirFactory, fileSystem, folder);
WritableTestDatabaseIndex index = new WritableTestDatabaseIndex(indexStorage);
index.create();
index.open();
return index;
}
use of org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage in project neo4j by neo4j.
the class LuceneSchemaIndexBuilder method build.
/**
* Build lucene schema index with specified configuration
*
* @return lucene schema index
*/
public SchemaIndex build() {
if (isReadOnly()) {
return new ReadOnlyDatabaseSchemaIndex(storageBuilder.build(), descriptor, samplingConfig, new ReadOnlyIndexPartitionFactory());
} else {
Boolean archiveFailed = getConfig(GraphDatabaseSettings.archive_failed_index);
PartitionedIndexStorage storage = storageBuilder.archivingFailed(archiveFailed).build();
return new WritableDatabaseSchemaIndex(storage, descriptor, samplingConfig, new WritableIndexPartitionFactory(writerConfigFactory));
}
}
Aggregations