Search in sources :

Example 16 with PartitionedIndexStorage

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

the class AccessUniqueDatabaseIndexTest method shouldAddUniqueEntries.

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

Example 17 with PartitionedIndexStorage

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

the class AccessUniqueDatabaseIndexTest method shouldRemoveAndAddEntries.

@Test
void shouldRemoveAndAddEntries() 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, singletonList(add(3L, "value3")));
    updateAndCommit(accessor, singletonList(add(4L, "value4")));
    updateAndCommit(accessor, singletonList(remove(1L, "value1")));
    updateAndCommit(accessor, singletonList(remove(2L, "value2")));
    updateAndCommit(accessor, singletonList(remove(3L, "value3")));
    updateAndCommit(accessor, singletonList(add(1L, "value1")));
    updateAndCommit(accessor, singletonList(add(3L, "value3b")));
    accessor.close();
    // then
    assertEquals(singletonList(1L), getAllNodes(indexStorage, "value1"));
    assertEquals(emptyList(), getAllNodes(indexStorage, "value2"));
    assertEquals(emptyList(), getAllNodes(indexStorage, "value3"));
    assertEquals(singletonList(3L), getAllNodes(indexStorage, "value3b"));
    assertEquals(singletonList(4L), getAllNodes(indexStorage, "value4"));
}
Also used : PartitionedIndexStorage(org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage) Test(org.junit.jupiter.api.Test)

Example 18 with PartitionedIndexStorage

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

the class UniqueDatabaseIndexPopulatorTest method setUp.

@BeforeEach
void setUp() {
    Path folder = testDir.directory("folder");
    indexStorage = new PartitionedIndexStorage(directoryFactory, fs, folder);
    index = LuceneSchemaIndexBuilder.create(descriptor, writable(), Config.defaults()).withIndexStorage(indexStorage).build();
    schemaDescriptor = descriptor.schema();
}
Also used : Path(java.nio.file.Path) PartitionedIndexStorage(org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 19 with PartitionedIndexStorage

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

the class FulltextIndexProvider method getOnlineAccessor.

@Override
public IndexAccessor getOnlineAccessor(IndexDescriptor index, IndexSamplingConfig samplingConfig, TokenNameLookup tokenNameLookup) throws IOException {
    PartitionedIndexStorage indexStorage = getIndexStorage(index.getId());
    Analyzer analyzer = createAnalyzer(index, tokenHolders);
    String[] propertyNames = createPropertyNames(index, tokenHolders);
    FulltextIndexBuilder fulltextIndexBuilder = FulltextIndexBuilder.create(index, config, readOnlyChecker, tokenHolders.propertyKeyTokens(), analyzer, propertyNames).withFileSystem(fileSystem).withIndexStorage(indexStorage).withPopulatingMode(false);
    if (isEventuallyConsistent(index)) {
        fulltextIndexBuilder = fulltextIndexBuilder.withIndexUpdateSink(indexUpdateSink);
    }
    DatabaseIndex<FulltextIndexReader> fulltextIndex = fulltextIndexBuilder.build();
    fulltextIndex.open();
    FulltextIndexAccessor accessor = new FulltextIndexAccessor(indexUpdateSink, fulltextIndex, index, propertyNames);
    log.debug("Created online accessor for fulltext schema index %s: %s", index, accessor);
    return accessor;
}
Also used : FulltextIndexSettings.createAnalyzer(org.neo4j.kernel.api.impl.fulltext.FulltextIndexSettings.createAnalyzer) Analyzer(org.apache.lucene.analysis.Analyzer) PartitionedIndexStorage(org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage)

Example 20 with PartitionedIndexStorage

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

the class FulltextIndexProvider method getMinimalIndexAccessor.

@Override
public MinimalIndexAccessor getMinimalIndexAccessor(IndexDescriptor descriptor) {
    PartitionedIndexStorage indexStorage = getIndexStorage(descriptor.getId());
    DatabaseIndex<FulltextIndexReader> fulltextIndex = new DroppableIndex<>(new DroppableLuceneIndex<>(indexStorage, new ReadOnlyIndexPartitionFactory(), descriptor));
    log.debug("Creating dropper for fulltext schema index: %s", descriptor);
    return new LuceneMinimalIndexAccessor<>(descriptor, fulltextIndex, isReadOnly());
}
Also used : LuceneMinimalIndexAccessor(org.neo4j.kernel.api.impl.index.LuceneMinimalIndexAccessor) DroppableIndex(org.neo4j.kernel.api.impl.index.DroppableIndex) PartitionedIndexStorage(org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage) ReadOnlyIndexPartitionFactory(org.neo4j.kernel.api.impl.index.partition.ReadOnlyIndexPartitionFactory)

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