Search in sources :

Example 1 with AbstractIndexPartition

use of org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition in project neo4j by neo4j.

the class LuceneLabelScanIndex method createSimpleReader.

private LabelScanReader createSimpleReader(List<AbstractIndexPartition> partitions) throws IOException {
    AbstractIndexPartition partition = getFirstPartition(partitions);
    PartitionSearcher searcher = partition.acquireSearcher();
    return new SimpleLuceneLabelScanStoreReader(searcher, storageStrategy);
}
Also used : PartitionSearcher(org.neo4j.kernel.api.impl.index.partition.PartitionSearcher) AbstractIndexPartition(org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition) SimpleLuceneLabelScanStoreReader(org.neo4j.kernel.api.impl.labelscan.reader.SimpleLuceneLabelScanStoreReader)

Example 2 with AbstractIndexPartition

use of org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition in project neo4j by neo4j.

the class LuceneSchemaIndex method isOnline.

/**
     * Check if this index is marked as online.
     *
     * @return <code>true</code> if index is online, <code>false</code> otherwise
     * @throws IOException
     */
public boolean isOnline() throws IOException {
    ensureOpen();
    AbstractIndexPartition partition = getFirstPartition(getPartitions());
    Directory directory = partition.getDirectory();
    try (DirectoryReader reader = DirectoryReader.open(directory)) {
        Map<String, String> userData = reader.getIndexCommit().getUserData();
        return ONLINE.equals(userData.get(KEY_STATUS));
    }
}
Also used : DirectoryReader(org.apache.lucene.index.DirectoryReader) AbstractIndexPartition(org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition) Directory(org.apache.lucene.store.Directory)

Example 3 with AbstractIndexPartition

use of org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition in project neo4j by neo4j.

the class LuceneSchemaIndex method markAsOnline.

/**
     * Marks index as online by including "status" -> "online" map into commit metadata of the first partition.
     *
     * @throws IOException
     */
public void markAsOnline() throws IOException {
    ensureOpen();
    AbstractIndexPartition partition = getFirstPartition(getPartitions());
    IndexWriter indexWriter = partition.getIndexWriter();
    indexWriter.setCommitData(ONLINE_COMMIT_USER_DATA);
    flush(false);
}
Also used : LuceneIndexWriter(org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter) PartitionedIndexWriter(org.neo4j.kernel.api.impl.schema.writer.PartitionedIndexWriter) IndexWriter(org.apache.lucene.index.IndexWriter) AbstractIndexPartition(org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition)

Example 4 with AbstractIndexPartition

use of org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition in project neo4j by neo4j.

the class LuceneSchemaIndex method createSimpleUniquenessVerifier.

private static UniquenessVerifier createSimpleUniquenessVerifier(List<AbstractIndexPartition> partitions) throws IOException {
    AbstractIndexPartition singlePartition = getFirstPartition(partitions);
    SearcherReference partitionSearcher = singlePartition.acquireSearcher();
    return new SimpleUniquenessVerifier(partitionSearcher);
}
Also used : SimpleUniquenessVerifier(org.neo4j.kernel.api.impl.schema.verification.SimpleUniquenessVerifier) AbstractIndexPartition(org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition) SearcherReference(org.neo4j.kernel.api.impl.index.SearcherReference)

Example 5 with AbstractIndexPartition

use of org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition in project neo4j by neo4j.

the class AbstractLuceneIndex method flush.

/**
 * Commits all index partitions.
 *
 * @param merge also merge all segments together. This should be done before reading term frequencies.
 * @throws IOException on Lucene I/O error.
 */
public void flush(boolean merge) throws IOException {
    List<AbstractIndexPartition> partitions = getPartitions();
    for (AbstractIndexPartition partition : partitions) {
        IndexWriter writer = partition.getIndexWriter();
        writer.commit();
        if (merge) {
            writer.forceMerge(1);
        }
    }
}
Also used : LuceneIndexWriter(org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter) PartitionedIndexWriter(org.neo4j.kernel.api.impl.schema.writer.PartitionedIndexWriter) IndexWriter(org.apache.lucene.index.IndexWriter) AbstractIndexPartition(org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition)

Aggregations

AbstractIndexPartition (org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition)13 IndexWriter (org.apache.lucene.index.IndexWriter)3 Directory (org.apache.lucene.store.Directory)3 LuceneIndexWriter (org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter)3 PartitionedIndexWriter (org.neo4j.kernel.api.impl.schema.writer.PartitionedIndexWriter)3 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 DirectoryReader (org.apache.lucene.index.DirectoryReader)2 PartitionSearcher (org.neo4j.kernel.api.impl.index.partition.PartitionSearcher)2 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Document (org.apache.lucene.document.Document)1 IndexSearcher (org.apache.lucene.search.IndexSearcher)1 ResourceIterator (org.neo4j.graphdb.ResourceIterator)1 SearcherReference (org.neo4j.kernel.api.impl.index.SearcherReference)1 Bitmap (org.neo4j.kernel.api.impl.labelscan.bitmaps.Bitmap)1 SimpleLuceneLabelScanStoreReader (org.neo4j.kernel.api.impl.labelscan.reader.SimpleLuceneLabelScanStoreReader)1