Search in sources :

Example 11 with PartitionedIndexStorage

use of org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage in project neo4j by neo4j.

the class LuceneSchemaIndexProvider method getInitialState.

@Override
public InternalIndexState getInitialState(long indexId, NewIndexDescriptor descriptor) {
    PartitionedIndexStorage indexStorage = getIndexStorage(indexId);
    String failure = indexStorage.getStoredIndexFailure();
    if (failure != null) {
        return InternalIndexState.FAILED;
    }
    try {
        return indexIsOnline(indexStorage, descriptor) ? InternalIndexState.ONLINE : InternalIndexState.POPULATING;
    } catch (IOException e) {
        log.error("Failed to open index:" + indexId + ", requesting re-population.", e);
        return InternalIndexState.POPULATING;
    }
}
Also used : IOException(java.io.IOException) PartitionedIndexStorage(org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage)

Example 12 with PartitionedIndexStorage

use of org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage in project neo4j by neo4j.

the class LuceneLabelScanStoreTest method createLabelScanStore.

@Override
protected LabelScanStore createLabelScanStore(FileSystemAbstraction fs, File rootFolder, List<NodeLabelUpdate> existingData, boolean usePersistentStore, boolean readOnly, LabelScanStore.Monitor monitor) {
    DirectoryFactory directoryFactory = usePersistentStore ? DirectoryFactory.PERSISTENT : inMemoryDirectoryFactory;
    indexStorage = new PartitionedIndexStorage(directoryFactory, fs, rootFolder, LuceneLabelScanIndexBuilder.DEFAULT_INDEX_IDENTIFIER, false);
    Config config = Config.defaults().with(MapUtil.stringMap(GraphDatabaseSettings.read_only.name(), String.valueOf(readOnly)));
    LuceneLabelScanIndexBuilder indexBuilder = LuceneLabelScanIndexBuilder.create().withDirectoryFactory(directoryFactory).withIndexStorage(indexStorage).withOperationalMode(OperationalMode.single).withConfig(config).withDocumentFormat(documentFormat);
    return new LuceneLabelScanStore(indexBuilder, asStream(existingData), monitor);
}
Also used : Config(org.neo4j.kernel.configuration.Config) DirectoryFactory(org.neo4j.kernel.api.impl.index.storage.DirectoryFactory) PartitionedIndexStorage(org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage)

Example 13 with PartitionedIndexStorage

use of org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage in project neo4j by neo4j.

the class ConstraintIndexFailureIT method storeIndexFailure.

private void storeIndexFailure(String failure) throws IOException {
    File luceneRootDirectory = new File(storeDir.directory(), "schema/index/lucene");
    PartitionedIndexStorage indexStorage = LuceneIndexStorageBuilder.create().withFileSystem(fileSystemRule.get()).withIndexRootFolder(luceneRootDirectory).withIndexIdentifier("1").build();
    indexStorage.storeIndexFailure(failure);
}
Also used : File(java.io.File) PartitionedIndexStorage(org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage)

Example 14 with PartitionedIndexStorage

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, File folder) throws IOException {
    PartitionedIndexStorage indexStorage = new PartitionedIndexStorage(dirFactory, fileSystemRule.get(), folder, "test", false);
    WritableTestDatabaseIndex index = new WritableTestDatabaseIndex(indexStorage);
    index.create();
    index.open();
    return index;
}
Also used : PartitionedIndexStorage(org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage)

Example 15 with PartitionedIndexStorage

use of org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage in project neo4j by neo4j.

the class AccessUniqueDatabaseIndexTest method shouldConsiderWholeTransactionForValidatingUniqueness.

@Test
void shouldConsiderWholeTransactionForValidatingUniqueness() throws Exception {
    // given
    PartitionedIndexStorage indexStorage = getIndexStorage();
    LuceneIndexAccessor accessor = createAccessor(indexStorage);
    // when
    updateAndCommit(accessor, singletonList(add(1L, "value1")));
    updateAndCommit(accessor, singletonList(add(2L, "value2")));
    updateAndCommit(accessor, asList(change(1L, "value1", "value2"), change(2L, "value2", "value1")));
    accessor.close();
    // then
    assertEquals(singletonList(2L), getAllNodes(indexStorage, "value1"));
    assertEquals(singletonList(1L), getAllNodes(indexStorage, "value2"));
}
Also used : PartitionedIndexStorage(org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage) Test(org.junit.jupiter.api.Test)

Aggregations

PartitionedIndexStorage (org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage)21 ReadOnlyIndexPartitionFactory (org.neo4j.kernel.api.impl.index.partition.ReadOnlyIndexPartitionFactory)5 IOException (java.io.IOException)4 Test (org.junit.jupiter.api.Test)4 Path (java.nio.file.Path)2 Analyzer (org.apache.lucene.analysis.Analyzer)2 Before (org.junit.Before)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 FulltextIndexSettings.createAnalyzer (org.neo4j.kernel.api.impl.fulltext.FulltextIndexSettings.createAnalyzer)2 DroppableIndex (org.neo4j.kernel.api.impl.index.DroppableIndex)2 LuceneMinimalIndexAccessor (org.neo4j.kernel.api.impl.index.LuceneMinimalIndexAccessor)2 Config (org.neo4j.kernel.configuration.Config)2 TokenNotFoundException (org.neo4j.token.api.TokenNotFoundException)2 File (java.io.File)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 DatabaseIndex (org.neo4j.kernel.api.impl.index.DatabaseIndex)1 DroppableLuceneIndex (org.neo4j.kernel.api.impl.index.DroppableLuceneIndex)1 WritableIndexPartitionFactory (org.neo4j.kernel.api.impl.index.partition.WritableIndexPartitionFactory)1 DirectoryFactory (org.neo4j.kernel.api.impl.index.storage.DirectoryFactory)1 ValueIndexReader (org.neo4j.kernel.api.index.ValueIndexReader)1