diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/index/WritableAbstractDatabaseIndex.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/index/WritableAbstractDatabaseIndex.java index 695f3281e44cd..e4de6ee0dc340 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/index/WritableAbstractDatabaseIndex.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/index/WritableAbstractDatabaseIndex.java @@ -203,4 +203,14 @@ public List getPartitions() { return luceneIndex.getPartitions(); } + + public boolean hasSinglePartition( List partitions ) + { + return luceneIndex.hasSinglePartition( partitions ); + } + + public AbstractIndexPartition getFirstPartition( List partitions ) + { + return luceneIndex.getFirstPartition( partitions ); + } } diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/writer/PartitionedIndexWriter.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/writer/PartitionedIndexWriter.java index 7bc37816373a9..00ee39d462f9c 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/writer/PartitionedIndexWriter.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/writer/PartitionedIndexWriter.java @@ -27,6 +27,7 @@ import java.io.IOException; import java.util.List; +import org.neo4j.kernel.api.impl.index.WritableAbstractDatabaseIndex; import org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition; import org.neo4j.kernel.api.impl.schema.WritableDatabaseSchemaIndex; @@ -40,14 +41,14 @@ */ public class PartitionedIndexWriter implements LuceneIndexWriter { - private final WritableDatabaseSchemaIndex index; + private final WritableAbstractDatabaseIndex index; // by default we still keep a spare of 10% to the maximum partition size: During concurrent updates // it could happen that 2 threads reserve space in a partition (without claiming it by doing addDocument): private final Integer MAXIMUM_PARTITION_SIZE = Integer.getInteger( "luceneSchemaIndex.maxPartitionSize", IndexWriter.MAX_DOCS - (IndexWriter.MAX_DOCS / 10) ); - public PartitionedIndexWriter( WritableDatabaseSchemaIndex index ) throws IOException + public PartitionedIndexWriter( WritableAbstractDatabaseIndex index ) throws IOException { this.index = index; } diff --git a/enterprise/fulltext-addon/pom.xml b/enterprise/fulltext-addon/pom.xml index ebd2f75d2644f..d107a44f77dfb 100644 --- a/enterprise/fulltext-addon/pom.xml +++ b/enterprise/fulltext-addon/pom.xml @@ -10,15 +10,15 @@ ../.. - neo4j-fulltext-helper + neo4j-fulltext-addon 3.3.0-SNAPSHOT - Neo4j - Bloom index + Neo4j - Fulltext add-on Fulltext helper addon for neo4j jar - https://github.com/neo4j/neo4j/tree/3.3/enterprise/fulltext-helper + https://github.com/neo4j/neo4j/tree/3.3/enterprise/fulltext-addon diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperFactory.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextFactory.java similarity index 95% rename from enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperFactory.java rename to enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextFactory.java index 6b48210a59dda..e204cf44674bc 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperFactory.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextFactory.java @@ -36,7 +36,7 @@ import static org.neo4j.kernel.api.impl.index.LuceneKernelExtensions.directoryFactory; -public class FulltextHelperFactory +public class FulltextFactory { private final FileSystemAbstraction fileSystem; private final String[] properties; @@ -59,7 +59,7 @@ public enum FULLTEXT_HELPER_TYPE RELATIONSHIPS } - public FulltextHelperFactory( FileSystemAbstraction fileSystem, File storeDir, Config config ) throws IOException + public FulltextFactory( FileSystemAbstraction fileSystem, File storeDir, Config config ) throws IOException { this.fileSystem = fileSystem; this.properties = config.get( GraphDatabaseSettings.bloom_indexed_properties ).toArray( new String[0] ); diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperDescriptor.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperDescriptor.java deleted file mode 100644 index 7e054d9d5de09..0000000000000 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperDescriptor.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2002-2017 "Neo Technology," - * Network Engine for Objects in Lund AB [http://neotechnology.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.neo4j.kernel.api.impl.fulltext; - -public class FulltextHelperDescriptor -{ - private final String identifier; - private final FulltextHelperFactory.FULLTEXT_HELPER_TYPE type; - - public FulltextHelperDescriptor( String identifier, FulltextHelperFactory.FULLTEXT_HELPER_TYPE type ) - { - this.identifier = identifier; - this.type = type; - } - - public String getIdentifier() - { - return identifier; - } - - public FulltextHelperFactory.FULLTEXT_HELPER_TYPE getType() - { - return type; - } -} diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperProvider.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextProvider.java similarity index 75% rename from enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperProvider.java rename to enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextProvider.java index 846e0418e607c..08ee901a6fbad 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperProvider.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextProvider.java @@ -28,34 +28,34 @@ import org.neo4j.graphdb.GraphDatabaseService; -public class FulltextHelperProvider implements AutoCloseable +public class FulltextProvider implements AutoCloseable { - private static FulltextHelperProvider instance; + private static FulltextProvider instance; private final GraphDatabaseService db; - private final FulltextHelperTransactionEventUpdater fulltextHelperTransactionEventUpdater; + private final FulltextTransactionEventUpdater fulltextTransactionEventUpdater; private boolean closed; private Set nodeProperties; private Set relationshipProperties; private Map nodeIndices; private Map relationshipIndices; - private FulltextHelperProvider( GraphDatabaseService db ) + private FulltextProvider( GraphDatabaseService db ) { this.db = db; closed = false; - fulltextHelperTransactionEventUpdater = new FulltextHelperTransactionEventUpdater( this ); - db.registerTransactionEventHandler( fulltextHelperTransactionEventUpdater ); + fulltextTransactionEventUpdater = new FulltextTransactionEventUpdater( this ); + db.registerTransactionEventHandler( fulltextTransactionEventUpdater ); nodeProperties = new HashSet<>(); relationshipProperties = new HashSet<>(); nodeIndices = new HashMap<>(); relationshipIndices = new HashMap<>(); } - public static synchronized FulltextHelperProvider instance( GraphDatabaseService db ) + public static synchronized FulltextProvider instance( GraphDatabaseService db ) { if ( instance == null || instance.closed ) { - instance = new FulltextHelperProvider( db ); + instance = new FulltextProvider( db ); } return instance; } @@ -66,7 +66,7 @@ public synchronized void close() if ( !closed ) { closed = true; - db.unregisterTransactionEventHandler( fulltextHelperTransactionEventUpdater ); + db.unregisterTransactionEventHandler( fulltextTransactionEventUpdater ); nodeIndices.values().forEach( luceneFulltextHelper -> { try @@ -95,7 +95,7 @@ public synchronized void close() public synchronized void register( LuceneFulltextHelper fulltextHelper ) throws IOException { fulltextHelper.open(); - if ( fulltextHelper.getType() == FulltextHelperFactory.FULLTEXT_HELPER_TYPE.NODES ) + if ( fulltextHelper.getType() == FulltextFactory.FULLTEXT_HELPER_TYPE.NODES ) { nodeIndices.put( fulltextHelper.getIdentifier(), fulltextHelper ); nodeProperties.addAll( fulltextHelper.getProperties() ); @@ -117,19 +117,19 @@ public String[] getRelationshipProperties() return relationshipProperties.toArray( new String[0] ); } - public Set nodeIndices() + public Set nodeIndices() { - return nodeIndices.values().stream().map( WritableDatabaseBloomIndex::new ).collect( Collectors.toSet() ); + return nodeIndices.values().stream().map( WritableDatabaseFulltext::new ).collect( Collectors.toSet() ); } - public Set relationshipIndices() + public Set relationshipIndices() { - return relationshipIndices.values().stream().map( WritableDatabaseBloomIndex::new ).collect( Collectors.toSet() ); + return relationshipIndices.values().stream().map( WritableDatabaseFulltext::new ).collect( Collectors.toSet() ); } - public BloomIndexReader getReader( String identifier, FulltextHelperFactory.FULLTEXT_HELPER_TYPE type ) throws IOException + public FulltextReader getReader( String identifier, FulltextFactory.FULLTEXT_HELPER_TYPE type ) throws IOException { - if ( type == FulltextHelperFactory.FULLTEXT_HELPER_TYPE.NODES ) + if ( type == FulltextFactory.FULLTEXT_HELPER_TYPE.NODES ) { return nodeIndices.get( identifier ).getIndexReader(); } diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/BloomIndexReader.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextReader.java similarity index 94% rename from enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/BloomIndexReader.java rename to enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextReader.java index 9591537f7fad8..744627a9bd379 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/BloomIndexReader.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextReader.java @@ -21,7 +21,7 @@ import org.neo4j.collection.primitive.PrimitiveLongIterator; -public interface BloomIndexReader extends AutoCloseable +public interface FulltextReader extends AutoCloseable { PrimitiveLongIterator query( String... query ); } diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperTransactionEventUpdater.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextTransactionEventUpdater.java similarity index 81% rename from enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperTransactionEventUpdater.java rename to enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextTransactionEventUpdater.java index 11ba41981b055..6d0e662314b42 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperTransactionEventUpdater.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextTransactionEventUpdater.java @@ -34,20 +34,20 @@ import org.neo4j.graphdb.event.TransactionData; import org.neo4j.graphdb.event.TransactionEventHandler; -public class FulltextHelperTransactionEventUpdater implements TransactionEventHandler +public class FulltextTransactionEventUpdater implements TransactionEventHandler { - private FulltextHelperProvider fulltextHelperProvider; + private FulltextProvider fulltextProvider; - public FulltextHelperTransactionEventUpdater( FulltextHelperProvider fulltextHelperProvider ) + public FulltextTransactionEventUpdater( FulltextProvider fulltextProvider ) { - this.fulltextHelperProvider = fulltextHelperProvider; + this.fulltextProvider = fulltextProvider; } @Override public Object beforeCommit( TransactionData data ) throws Exception { - String[] nodeProperties = fulltextHelperProvider.getNodeProperties(); + String[] nodeProperties = fulltextProvider.getNodeProperties(); Map> nodeMap = new HashMap>(); data.removedNodeProperties().forEach( propertyEntry -> { @@ -63,7 +63,7 @@ public Object beforeCommit( TransactionData data ) throws Exception data.assignedNodeProperties().forEach( propertyEntry -> nodeMap.put( propertyEntry.entity().getId(), propertyEntry.entity().getProperties( nodeProperties ) ) ); - String[] relationshipProperties = fulltextHelperProvider.getRelationshipProperties(); + String[] relationshipProperties = fulltextProvider.getRelationshipProperties(); Map> relationshipMap = new HashMap>(); data.removedRelationshipProperties().forEach( propertyEntry -> { @@ -87,7 +87,7 @@ public void afterCommit( TransactionData data, Object state ) //update node indices try { - for ( WritableDatabaseBloomIndex nodeIndex : fulltextHelperProvider.nodeIndices() ) + for ( WritableDatabaseFulltext nodeIndex : fulltextProvider.nodeIndices() ) { Map> nodeMap = ((Map>[]) state)[0]; removePropertyData( data.removedNodeProperties(), nodeMap, nodeIndex ); @@ -95,7 +95,7 @@ public void afterCommit( TransactionData data, Object state ) refreshIndex( nodeIndex ); } //update relationship indices - for ( WritableDatabaseBloomIndex relationshipIndex : fulltextHelperProvider.relationshipIndices() ) + for ( WritableDatabaseFulltext relationshipIndex : fulltextProvider.relationshipIndices() ) { Map> relationshipMap = ((Map>[]) state)[1]; removePropertyData( data.removedRelationshipProperties(), relationshipMap, relationshipIndex ); @@ -109,7 +109,7 @@ public void afterCommit( TransactionData data, Object state ) } } - private void updatePropertyData( Map> state, WritableDatabaseBloomIndex index ) throws IOException + private void updatePropertyData( Map> state, WritableDatabaseFulltext index ) throws IOException { for ( Map.Entry> stateEntry : state.entrySet() ) { @@ -122,15 +122,15 @@ private void updatePropertyData( Map> Collectors.toMap( entry -> entry.getKey(), entry -> entry.getValue() ) ); if ( !allProperties.isEmpty() ) { - Document document = FulltextHelperDocumentStructure.documentRepresentingProperties( entityId, allProperties ); - index.getIndexWriter().updateDocument( FulltextHelperDocumentStructure.newTermForChangeOrRemove( entityId ), document ); + Document document = LuceneFulltextDocumentStructure.documentRepresentingProperties( entityId, allProperties ); + index.getIndexWriter().updateDocument( LuceneFulltextDocumentStructure.newTermForChangeOrRemove( entityId ), document ); } } } } private void removePropertyData( Iterable> propertyEntries, Map> state, - WritableDatabaseBloomIndex index ) throws IOException + WritableDatabaseFulltext index ) throws IOException { for ( PropertyEntry propertyEntry : propertyEntries ) { @@ -140,13 +140,13 @@ private void removePropertyData( Iterable> p Map allProperties = state.get( entityId ); if ( allProperties == null || allProperties.isEmpty() ) { - index.getIndexWriter().deleteDocuments( FulltextHelperDocumentStructure.newTermForChangeOrRemove( entityId ) ); + index.getIndexWriter().deleteDocuments( LuceneFulltextDocumentStructure.newTermForChangeOrRemove( entityId ) ); } } } } - private void refreshIndex( WritableDatabaseBloomIndex index ) + private void refreshIndex( WritableDatabaseFulltext index ) { try { diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperDocumentStructure.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltextDocumentStructure.java similarity index 94% rename from enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperDocumentStructure.java rename to enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltextDocumentStructure.java index 54987a7eef67c..0c36675b92277 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextHelperDocumentStructure.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltextDocumentStructure.java @@ -33,15 +33,14 @@ import org.neo4j.values.storable.Values; import static org.apache.lucene.document.Field.Store.NO; -import static org.apache.lucene.document.Field.Store.YES; -class FulltextHelperDocumentStructure +class LuceneFulltextDocumentStructure { static final String ID_KEY = "id"; private static final ThreadLocal perThreadDocument = ThreadLocal.withInitial( DocWithId::new ); - private FulltextHelperDocumentStructure() + private LuceneFulltextDocumentStructure() { } @@ -61,7 +60,7 @@ public static Document documentRepresentingProperties( long id, Map ONLINE_COMMIT_USER_DATA = singletonMap( KEY_STATUS, ONLINE ); private final Analyzer analyzer; private final String identifier; - private final FulltextHelperFactory.FULLTEXT_HELPER_TYPE type; + private final FulltextFactory.FULLTEXT_HELPER_TYPE type; private final TaskCoordinator taskCoordinator = new TaskCoordinator( 10, TimeUnit.MILLISECONDS ); - private Set properties; + private final Set properties; LuceneFulltextHelper( PartitionedIndexStorage indexStorage, IndexPartitionFactory partitionFactory, String[] properties, Analyzer analyzer, - String identifier, FulltextHelperFactory.FULLTEXT_HELPER_TYPE type ) + String identifier, FulltextFactory.FULLTEXT_HELPER_TYPE type ) { super( indexStorage, partitionFactory ); this.properties = Collections.unmodifiableSet( new HashSet<>( Arrays.asList( properties ) ) ); @@ -93,100 +91,43 @@ public int hashCode() return result; } - public PartitionedInsightBloomWriter getIndexWriter( WritableDatabaseBloomIndex writableIndex ) throws IOException + public PartitionedIndexWriter getIndexWriter( WritableDatabaseFulltext writableIndex ) throws IOException { ensureOpen(); - return new PartitionedInsightBloomWriter( writableIndex ); + return new PartitionedIndexWriter( writableIndex ); } - public BloomIndexReader getIndexReader() throws IOException + public FulltextReader getIndexReader() throws IOException { ensureOpen(); List partitions = getPartitions(); return hasSinglePartition( partitions ) ? createSimpleReader( partitions ) : createPartitionedReader( partitions ); } - public void drop() throws IOException + public FulltextFactory.FULLTEXT_HELPER_TYPE getType() { - taskCoordinator.cancel(); - try - { - taskCoordinator.awaitCompletion(); - } - catch ( InterruptedException e ) - { - throw new IOException( "Interrupted while waiting for concurrent tasks to complete.", e ); - } - super.drop(); - } - - /** - * Check if this index is marked as online. - * - * @return true if index is online, false otherwise - * @throws IOException - */ - public boolean isOnline() throws IOException - { - ensureOpen(); - AbstractIndexPartition partition = getFirstPartition( getPartitions() ); - Directory directory = partition.getDirectory(); - try ( DirectoryReader reader = DirectoryReader.open( directory ) ) - { - Map userData = reader.getIndexCommit().getUserData(); - return ONLINE.equals( userData.get( KEY_STATUS ) ); - } + return type; } - /** - * Marks index as online by including "status" -> "online" map into commit metadata of the first partition. - * - * @throws IOException - */ - public void markAsOnline() throws IOException + public Set getProperties() { - ensureOpen(); - AbstractIndexPartition partition = getFirstPartition( getPartitions() ); - IndexWriter indexWriter = partition.getIndexWriter(); - indexWriter.setCommitData( ONLINE_COMMIT_USER_DATA ); - flush( false ); + return properties; } - /** - * Writes the given failure message to the failure storage. - * - * @param failure the failure message. - * @throws IOException - */ - public void markAsFailed( String failure ) throws IOException + public String getIdentifier() { - indexStorage.storeIndexFailure( failure ); + return identifier; } - private SimpleBloomIndexReader createSimpleReader( List partitions ) throws IOException + private SimpleFulltextReader createSimpleReader( List partitions ) throws IOException { AbstractIndexPartition singlePartition = getFirstPartition( partitions ); - return new SimpleBloomIndexReader( singlePartition.acquireSearcher(), properties.toArray( new String[0] ), analyzer ); + return new SimpleFulltextReader( singlePartition.acquireSearcher(), properties.toArray( new String[0] ), analyzer ); } - private PartitionedBloomIndexReader createPartitionedReader( List partitions ) throws IOException + private PartitionedFulltextReader createPartitionedReader( List partitions ) throws IOException { List searchers = acquireSearchers( partitions ); - return new PartitionedBloomIndexReader( searchers, properties.toArray( new String[0] ), analyzer ); - } - - public FulltextHelperFactory.FULLTEXT_HELPER_TYPE getType() - { - return type; - } - - public Set getProperties() - { - return properties; - } - - public String getIdentifier() - { - return identifier; + return new PartitionedFulltextReader( searchers, properties.toArray( new String[0] ), analyzer ); } } diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/PartitionedBloomIndexReader.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/PartitionedFulltextReader.java similarity index 76% rename from enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/PartitionedBloomIndexReader.java rename to enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/PartitionedFulltextReader.java index 7fb0bb254ccb9..a8e98995dd52d 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/PartitionedBloomIndexReader.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/PartitionedFulltextReader.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.util.List; -import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; @@ -35,22 +34,22 @@ /** * Index reader that is able to read/sample multiple partitions of a partitioned Lucene index. - * Internally uses multiple {@link SimpleBloomIndexReader}s for individual partitions. + * Internally uses multiple {@link SimpleFulltextReader}s for individual partitions. * - * @see SimpleBloomIndexReader + * @see SimpleFulltextReader */ -class PartitionedBloomIndexReader implements BloomIndexReader +class PartitionedFulltextReader implements FulltextReader { - private final List indexReaders; + private final List indexReaders; - PartitionedBloomIndexReader( List partitionSearchers, String[] properties, Analyzer analyzer ) + PartitionedFulltextReader( List partitionSearchers, String[] properties, Analyzer analyzer ) { - this( partitionSearchers.stream().map( partitionSearcher -> new SimpleBloomIndexReader( partitionSearcher, properties, analyzer ) ) + this( partitionSearchers.stream().map( partitionSearcher -> new SimpleFulltextReader( partitionSearcher, properties, analyzer ) ) .collect( Collectors.toList() ) ); } - private PartitionedBloomIndexReader( List readers ) + private PartitionedFulltextReader( List readers ) { this.indexReaders = readers; } @@ -60,7 +59,7 @@ public PrimitiveLongIterator query( String... query ) return partitionedOperation( reader -> innerQuery( reader, query ) ); } - private PrimitiveLongIterator innerQuery( BloomIndexReader reader, String... query ) + private PrimitiveLongIterator innerQuery( FulltextReader reader, String... query ) { return reader.query( query ); @@ -80,7 +79,7 @@ public void close() } private PrimitiveLongIterator partitionedOperation( - Function readerFunction ) + Function readerFunction ) { return PrimitiveLongCollections .concat( indexReaders.parallelStream().map( readerFunction::apply ).collect( Collectors.toList() ) ); diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/PartitionedInsightBloomWriter.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/PartitionedInsightBloomWriter.java deleted file mode 100644 index 67551621d4af7..0000000000000 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/PartitionedInsightBloomWriter.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2002-2017 "Neo Technology," - * Network Engine for Objects in Lund AB [http://neotechnology.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.neo4j.kernel.api.impl.fulltext; - -import org.apache.lucene.document.Document; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.Term; -import org.apache.lucene.search.Query; - -import java.io.IOException; -import java.util.List; - -import org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition; - -/** - * Schema Lucene index writer implementation that supports writing into multiple partitions and creates partitions - * on-demand if needed. - *

- * Writer threats partition as writable if partition has number of live and deleted documents that is less then configured - * {@link #MAXIMUM_PARTITION_SIZE}. - * First observable partition that satisfy writer criteria is used for writing. - */ -class PartitionedInsightBloomWriter -{ - private final WritableDatabaseBloomIndex index; - - // by default we still keep a spare of 10% to the maximum partition size: During concurrent updates - // it could happen that 2 threads reserve space in a partition (without claiming it by doing addDocument): - private final Integer MAXIMUM_PARTITION_SIZE = Integer.getInteger( "luceneSchemaIndex.maxPartitionSize", - IndexWriter.MAX_DOCS - (IndexWriter.MAX_DOCS / 10) ); - - PartitionedInsightBloomWriter( WritableDatabaseBloomIndex index ) throws IOException - { - this.index = index; - } - - public void addDocument( Document doc ) throws IOException - { - IndexWriter indexWriter = getIndexWriter( 1 ); - indexWriter.addDocument( doc ); - } - - public void addDocuments( int numDocs, Iterable documents ) throws IOException - { - getIndexWriter( numDocs ).addDocuments( documents ); - } - - public void updateDocument( Term term, Document doc ) throws IOException - { - List partitions = index.getPartitions(); - if ( index.hasSinglePartition( partitions ) && writablePartition( index.getFirstPartition( partitions ), 1 ) ) - { - index.getFirstPartition( partitions ).getIndexWriter().updateDocument( term, doc ); - } - else - { - deleteDocuments( term ); - addDocument( doc ); - } - } - - public void deleteDocuments( Query query ) throws IOException - { - List partitions = index.getPartitions(); - for ( AbstractIndexPartition partition : partitions ) - { - partition.getIndexWriter().deleteDocuments( query ); - } - } - - public void deleteDocuments( Term term ) throws IOException - { - List partitions = index.getPartitions(); - for ( AbstractIndexPartition partition : partitions ) - { - partition.getIndexWriter().deleteDocuments( term ); - } - } - - private IndexWriter getIndexWriter( int numDocs ) throws IOException - { - synchronized ( index ) - { - // We synchronise on the index to coordinate with all writers about how many partitions we - // have, and when new ones are created. The discovery that a new partition needs to be added, - // and the call to index.addNewPartition() must be atomic. - return unsafeGetIndexWriter( numDocs ); - } - } - - private IndexWriter unsafeGetIndexWriter( int numDocs ) throws IOException - { - List indexPartitions = index.getPartitions(); - int size = indexPartitions.size(); - //noinspection ForLoopReplaceableByForEach - for ( int i = 0; i < size; i++ ) - { - // We should find the *first* writable partition, so we can fill holes left by index deletes, - // after they were merged away: - AbstractIndexPartition partition = indexPartitions.get( i ); - if ( writablePartition( partition, numDocs ) ) - { - return partition.getIndexWriter(); - } - } - AbstractIndexPartition indexPartition = index.addNewPartition(); - return indexPartition.getIndexWriter(); - } - - private boolean writablePartition( AbstractIndexPartition partition, int numDocs ) - { - return MAXIMUM_PARTITION_SIZE - partition.getIndexWriter().maxDoc() >= numDocs; - } -} - diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/SimpleBloomIndexReader.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/SimpleFulltextReader.java similarity index 94% rename from enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/SimpleBloomIndexReader.java rename to enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/SimpleFulltextReader.java index d0aa978af9467..262c5c2e58381 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/SimpleBloomIndexReader.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/SimpleFulltextReader.java @@ -40,15 +40,15 @@ /** * Schema index reader that is able to read/sample a single partition of a partitioned Lucene index. * - * @see PartitionedBloomIndexReader + * @see PartitionedFulltextReader */ -class SimpleBloomIndexReader implements BloomIndexReader +class SimpleFulltextReader implements FulltextReader { private final PartitionSearcher partitionSearcher; private final Analyzer analyzer; private String[] properties; - SimpleBloomIndexReader( PartitionSearcher partitionSearcher, String[] properties, Analyzer analyzer ) + SimpleFulltextReader( PartitionSearcher partitionSearcher, String[] properties, Analyzer analyzer ) { this.partitionSearcher = partitionSearcher; this.properties = properties; diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/WritableDatabaseBloomIndex.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/WritableDatabaseFulltext.java similarity index 67% rename from enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/WritableDatabaseBloomIndex.java rename to enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/WritableDatabaseFulltext.java index e070b2e6024ab..25270f189b2b7 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/WritableDatabaseBloomIndex.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/WritableDatabaseFulltext.java @@ -25,50 +25,23 @@ import org.neo4j.kernel.api.impl.index.WritableAbstractDatabaseIndex; import org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition; +import org.neo4j.kernel.api.impl.schema.writer.PartitionedIndexWriter; -class WritableDatabaseBloomIndex extends WritableAbstractDatabaseIndex +class WritableDatabaseFulltext extends WritableAbstractDatabaseIndex { private LuceneFulltextHelper luceneFulltextHelper; - WritableDatabaseBloomIndex( LuceneFulltextHelper luceneFulltextHelper ) + WritableDatabaseFulltext( LuceneFulltextHelper luceneFulltextHelper ) { super( luceneFulltextHelper ); this.luceneFulltextHelper = luceneFulltextHelper; } - public PartitionedInsightBloomWriter getIndexWriter() throws IOException + public PartitionedIndexWriter getIndexWriter() throws IOException { return luceneFulltextHelper.getIndexWriter( this ); } - public BloomIndexReader getIndexReader() throws IOException - { - return luceneIndex.getIndexReader(); - } - - public boolean isOnline() throws IOException - { - return luceneIndex.isOnline(); - } - - public void markAsOnline() throws IOException - { - commitCloseLock.lock(); - try - { - luceneIndex.markAsOnline(); - } - finally - { - commitCloseLock.unlock(); - } - } - - public void markAsFailed( String failure ) throws IOException - { - luceneIndex.markAsFailed( failure ); - } - public boolean hasSinglePartition( List partitions ) { return luceneIndex.hasSinglePartition( partitions ); diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomKernelExtension.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomKernelExtension.java index 87f0d6eb2998b..49aeca52b9f01 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomKernelExtension.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomKernelExtension.java @@ -25,8 +25,8 @@ import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.kernel.api.exceptions.ProcedureException; -import org.neo4j.kernel.api.impl.fulltext.FulltextHelperFactory; -import org.neo4j.kernel.api.impl.fulltext.FulltextHelperProvider; +import org.neo4j.kernel.api.impl.fulltext.FulltextFactory; +import org.neo4j.kernel.api.impl.fulltext.FulltextProvider; import org.neo4j.kernel.api.impl.fulltext.LuceneFulltextHelper; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.proc.Procedures; @@ -39,7 +39,7 @@ public class BloomKernelExtension extends LifecycleAdapter private final FileSystemAbstraction fileSystemAbstraction; private final GraphDatabaseService db; private final Procedures procedures; - private FulltextHelperFactory fulltextHelperFactory; + private FulltextFactory fulltextFactory; public BloomKernelExtension( FileSystemAbstraction fileSystemAbstraction, File storeDir, Config config, GraphDatabaseService db, Procedures procedures ) { @@ -53,11 +53,11 @@ public BloomKernelExtension( FileSystemAbstraction fileSystemAbstraction, File s @Override public void init() throws IOException, ProcedureException { - FulltextHelperProvider provider = FulltextHelperProvider.instance( db ); - fulltextHelperFactory = new FulltextHelperFactory( fileSystemAbstraction, storeDir, config ); - LuceneFulltextHelper nodes = fulltextHelperFactory.createFulltextHelper( "bloomNodes", FulltextHelperFactory.FULLTEXT_HELPER_TYPE.NODES ); + FulltextProvider provider = FulltextProvider.instance( db ); + fulltextFactory = new FulltextFactory( fileSystemAbstraction, storeDir, config ); + LuceneFulltextHelper nodes = fulltextFactory.createFulltextHelper( "bloomNodes", FulltextFactory.FULLTEXT_HELPER_TYPE.NODES ); LuceneFulltextHelper relationships = - fulltextHelperFactory.createFulltextHelper( "bloomRelationships", FulltextHelperFactory.FULLTEXT_HELPER_TYPE.RELATIONSHIPS ); + fulltextFactory.createFulltextHelper( "bloomRelationships", FulltextFactory.FULLTEXT_HELPER_TYPE.RELATIONSHIPS ); provider.register( nodes ); provider.register( relationships ); @@ -68,6 +68,6 @@ public void init() throws IOException, ProcedureException @Override public void shutdown() throws Exception { - FulltextHelperProvider.instance( db ).close(); + FulltextProvider.instance( db ).close(); } } diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomProcedure.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomProcedure.java index 6168cd495e9e7..c652099c0ec13 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomProcedure.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomProcedure.java @@ -25,7 +25,7 @@ import org.neo4j.collection.primitive.PrimitiveLongIterator; import org.neo4j.kernel.api.exceptions.ProcedureException; import org.neo4j.kernel.api.exceptions.Status; -import org.neo4j.kernel.api.impl.fulltext.BloomIndexReader; +import org.neo4j.kernel.api.impl.fulltext.FulltextReader; import org.neo4j.kernel.api.impl.fulltext.LuceneFulltextHelper; import org.neo4j.kernel.api.proc.CallableProcedure; import org.neo4j.kernel.api.proc.Context; @@ -55,7 +55,7 @@ public class BloomProcedure extends CallableProcedure.BasicProcedure public RawIterator apply( Context ctx, Object[] input ) throws ProcedureException { String[] query = Arrays.stream( input ).map( Object::toString ).toArray( String[]::new ); - try ( BloomIndexReader indexReader = luceneFulltextHelper.getIndexReader() ) + try ( FulltextReader indexReader = luceneFulltextHelper.getIndexReader() ) { PrimitiveLongIterator primitiveLongIterator = indexReader.query( query ); return new RawIterator() diff --git a/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltextHelperUpdaterTest.java b/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltextHelperUpdaterTest.java index ce848b3ee2d15..b1e8c1436abdd 100644 --- a/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltextHelperUpdaterTest.java +++ b/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltextHelperUpdaterTest.java @@ -40,7 +40,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.neo4j.kernel.api.impl.fulltext.FulltextHelperFactory.FULLTEXT_HELPER_TYPE; +import static org.neo4j.kernel.api.impl.fulltext.FulltextFactory.FULLTEXT_HELPER_TYPE; public class LuceneFulltextHelperUpdaterTest { @@ -60,10 +60,10 @@ public void shouldFindNodeWithString() throws Exception GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop" ).getGraphDatabaseAPI(); Config config = db.getDependencyResolver().resolveDependency( Config.class ); config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop" ); - FulltextHelperFactory fulltextHelperFactory = new FulltextHelperFactory( fileSystemRule, testDirectory.graphDbDir(), config ); - try ( FulltextHelperProvider provider = FulltextHelperProvider.instance( db ) ) + FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), config ); + try ( FulltextProvider provider = FulltextProvider.instance( db ) ) { - provider.register( fulltextHelperFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); + provider.register( fulltextFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); long firstID; long secondID; @@ -80,7 +80,7 @@ public void shouldFindNodeWithString() throws Exception tx.success(); } - try ( BloomIndexReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) + try ( FulltextReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) { assertEquals( firstID, reader.query( "hello" ).next() ); @@ -97,10 +97,10 @@ public void shouldFindNodeWithNumber() throws Exception GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop" ).getGraphDatabaseAPI(); Config config = db.getDependencyResolver().resolveDependency( Config.class ); config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop" ); - FulltextHelperFactory fulltextHelperFactory = new FulltextHelperFactory( fileSystemRule, testDirectory.graphDbDir(), config ); - try ( FulltextHelperProvider provider = FulltextHelperProvider.instance( db ) ) + FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), config ); + try ( FulltextProvider provider = FulltextProvider.instance( db ) ) { - provider.register( fulltextHelperFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); + provider.register( fulltextFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); long firstID; @@ -117,7 +117,7 @@ public void shouldFindNodeWithNumber() throws Exception tx.success(); } - try ( BloomIndexReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) + try ( FulltextReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) { PrimitiveLongIterator one = reader.query( "1" ); assertEquals( firstID, one.next() ); @@ -135,10 +135,10 @@ public void shouldFindNodeWithBoolean() throws Exception GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop" ).getGraphDatabaseAPI(); Config config = db.getDependencyResolver().resolveDependency( Config.class ); config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop" ); - FulltextHelperFactory fulltextHelperFactory = new FulltextHelperFactory( fileSystemRule, testDirectory.graphDbDir(), config ); - try ( FulltextHelperProvider provider = FulltextHelperProvider.instance( db ) ) + FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), config ); + try ( FulltextProvider provider = FulltextProvider.instance( db ) ) { - provider.register( fulltextHelperFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); + provider.register( fulltextFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); long firstID; long secondID; @@ -154,7 +154,7 @@ public void shouldFindNodeWithBoolean() throws Exception tx.success(); } - try ( BloomIndexReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) + try ( FulltextReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) { PrimitiveLongIterator sant = reader.query( "true" ); assertEquals( firstID, sant.next() ); @@ -172,10 +172,10 @@ public void shouldFindNodeWithArrays() throws Exception GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop" ).getGraphDatabaseAPI(); Config config = db.getDependencyResolver().resolveDependency( Config.class ); config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop" ); - FulltextHelperFactory fulltextHelperFactory = new FulltextHelperFactory( fileSystemRule, testDirectory.graphDbDir(), config ); - try ( FulltextHelperProvider provider = FulltextHelperProvider.instance( db ) ) + FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), config ); + try ( FulltextProvider provider = FulltextProvider.instance( db ) ) { - provider.register( fulltextHelperFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); + provider.register( fulltextFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); long firstID; long secondID; @@ -191,7 +191,7 @@ public void shouldFindNodeWithArrays() throws Exception tx.success(); } - try ( BloomIndexReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) + try ( FulltextReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) { PrimitiveLongIterator strings = reader.query( "live" ); assertEquals( firstID, strings.next() ); @@ -209,10 +209,10 @@ public void shouldRepresentPropertyChanges() throws Exception GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop" ).getGraphDatabaseAPI(); Config config = db.getDependencyResolver().resolveDependency( Config.class ); config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop" ); - FulltextHelperFactory fulltextHelperFactory = new FulltextHelperFactory( fileSystemRule, testDirectory.graphDbDir(), config ); - try ( FulltextHelperProvider provider = FulltextHelperProvider.instance( db ) ) + FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), config ); + try ( FulltextProvider provider = FulltextProvider.instance( db ) ) { - provider.register( fulltextHelperFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); + provider.register( fulltextFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); long firstID; long secondID; @@ -238,7 +238,7 @@ public void shouldRepresentPropertyChanges() throws Exception tx.success(); } - try ( BloomIndexReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) + try ( FulltextReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) { assertFalse( reader.query( "hello" ).hasNext() ); @@ -260,10 +260,10 @@ public void shouldNotFindRemovedNodes() throws Exception GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop" ).getGraphDatabaseAPI(); Config config = db.getDependencyResolver().resolveDependency( Config.class ); config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop" ); - FulltextHelperFactory fulltextHelperFactory = new FulltextHelperFactory( fileSystemRule, testDirectory.graphDbDir(), config ); - try ( FulltextHelperProvider provider = FulltextHelperProvider.instance( db ) ) + FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), config ); + try ( FulltextProvider provider = FulltextProvider.instance( db ) ) { - provider.register( fulltextHelperFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); + provider.register( fulltextFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); long firstID; long secondID; @@ -288,7 +288,7 @@ public void shouldNotFindRemovedNodes() throws Exception tx.success(); } - try ( BloomIndexReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) + try ( FulltextReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) { assertFalse( reader.query( "hello" ).hasNext() ); @@ -305,10 +305,10 @@ public void shouldNotFindRemovedProperties() throws Exception GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop, prop2" ).getGraphDatabaseAPI(); Config config = db.getDependencyResolver().resolveDependency( Config.class ); config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop, prop2" ); - FulltextHelperFactory fulltextHelperFactory = new FulltextHelperFactory( fileSystemRule, testDirectory.graphDbDir(), config ); - try ( FulltextHelperProvider provider = FulltextHelperProvider.instance( db ) ) + FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), config ); + try ( FulltextProvider provider = FulltextProvider.instance( db ) ) { - provider.register( fulltextHelperFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); + provider.register( fulltextFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); long firstID; long secondID; @@ -351,7 +351,7 @@ public void shouldNotFindRemovedProperties() throws Exception tx.success(); } - try ( BloomIndexReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) + try ( FulltextReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) { PrimitiveLongIterator hello = reader.query( "hello" ); @@ -370,10 +370,10 @@ public void shouldOnlyIndexIndexedProperties() throws Exception GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop" ).getGraphDatabaseAPI(); Config config = db.getDependencyResolver().resolveDependency( Config.class ); config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop" ); - FulltextHelperFactory fulltextHelperFactory = new FulltextHelperFactory( fileSystemRule, testDirectory.graphDbDir(), config ); - try ( FulltextHelperProvider provider = FulltextHelperProvider.instance( db ) ) + FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), config ); + try ( FulltextProvider provider = FulltextProvider.instance( db ) ) { - provider.register( fulltextHelperFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); + provider.register( fulltextFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); long firstID; long secondID; @@ -390,7 +390,7 @@ public void shouldOnlyIndexIndexedProperties() throws Exception tx.success(); } - try ( BloomIndexReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) + try ( FulltextReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) { PrimitiveLongIterator hello = reader.query( "hello" ); @@ -407,10 +407,10 @@ public void shouldSearchAcrossMultipleProperties() throws Exception GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop, prop2" ).getGraphDatabaseAPI(); Config config = db.getDependencyResolver().resolveDependency( Config.class ); config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop, prop2" ); - FulltextHelperFactory fulltextHelperFactory = new FulltextHelperFactory( fileSystemRule, testDirectory.graphDbDir(), config ); - try ( FulltextHelperProvider provider = FulltextHelperProvider.instance( db ) ) + FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), config ); + try ( FulltextProvider provider = FulltextProvider.instance( db ) ) { - provider.register( fulltextHelperFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); + provider.register( fulltextFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); long firstID; long secondID; @@ -432,7 +432,7 @@ public void shouldSearchAcrossMultipleProperties() throws Exception } PrimitiveLongIterator iterator; - try ( BloomIndexReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) + try ( FulltextReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) { iterator = reader.query( "tomtar", "karl" ); @@ -449,10 +449,10 @@ public void shouldOrderResultsBasedOnRelevance() throws Exception GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "first, last" ).getGraphDatabaseAPI(); Config config = db.getDependencyResolver().resolveDependency( Config.class ); config.augment( GraphDatabaseSettings.bloom_indexed_properties, "first, last" ); - FulltextHelperFactory fulltextHelperFactory = new FulltextHelperFactory( fileSystemRule, testDirectory.graphDbDir(), config ); - try ( FulltextHelperProvider provider = FulltextHelperProvider.instance( db ) ) + FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), config ); + try ( FulltextProvider provider = FulltextProvider.instance( db ) ) { - provider.register( fulltextHelperFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); + provider.register( fulltextFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); long firstID; long secondID; @@ -480,7 +480,7 @@ public void shouldOrderResultsBasedOnRelevance() throws Exception tx.success(); } - try ( BloomIndexReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) + try ( FulltextReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) { PrimitiveLongIterator iterator = reader.query( "Tom", "Hanks" ); @@ -498,11 +498,11 @@ public void shouldDifferentiateNodesAndRelationships() throws Exception GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop" ).getGraphDatabaseAPI(); Config config = db.getDependencyResolver().resolveDependency( Config.class ); config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop" ); - FulltextHelperFactory fulltextHelperFactory = new FulltextHelperFactory( fileSystemRule, testDirectory.graphDbDir(), config ); - try ( FulltextHelperProvider provider = FulltextHelperProvider.instance( db ) ) + FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), config ); + try ( FulltextProvider provider = FulltextProvider.instance( db ) ) { - provider.register( fulltextHelperFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); - provider.register( fulltextHelperFactory.createFulltextHelper( "bloomRelationships", FULLTEXT_HELPER_TYPE.RELATIONSHIPS ) ); + provider.register( fulltextFactory.createFulltextHelper( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ); + provider.register( fulltextFactory.createFulltextHelper( "bloomRelationships", FULLTEXT_HELPER_TYPE.RELATIONSHIPS ) ); long firstNodeID; long secondNodeID; @@ -527,7 +527,7 @@ public void shouldDifferentiateNodesAndRelationships() throws Exception tx.success(); } - try ( BloomIndexReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) + try ( FulltextReader reader = provider.getReader( "bloomNodes", FULLTEXT_HELPER_TYPE.NODES ) ) { PrimitiveLongIterator hello = reader.query( "hello" ); @@ -539,7 +539,7 @@ public void shouldDifferentiateNodesAndRelationships() throws Exception PrimitiveLongIterator different = reader.query( "different" ); assertFalse( different.hasNext() ); } - try ( BloomIndexReader reader = provider.getReader( "bloomRelationships", FULLTEXT_HELPER_TYPE.RELATIONSHIPS ) ) + try ( FulltextReader reader = provider.getReader( "bloomRelationships", FULLTEXT_HELPER_TYPE.RELATIONSHIPS ) ) { PrimitiveLongIterator hello = reader.query( "hello" );