diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextFactory.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextFactory.java index bd735f1004d08..0fe27129e395b 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextFactory.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextFactory.java @@ -67,7 +67,7 @@ public FulltextFactory( FileSystemAbstraction fileSystem, File storeDir, Analyze * @param provider The provider to register with * @throws IOException */ - public void createFulltextIndex( String identifier, FulltextProvider.FULLTEXT_INDEX_TYPE type, List properties, FulltextProvider provider ) + public void createFulltextIndex( String identifier, FulltextProvider.FulltextIndexType type, List properties, FulltextProvider provider ) throws IOException { LuceneIndexStorageBuilder storageBuilder = LuceneIndexStorageBuilder.create(); diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextProvider.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextProvider.java index a5e3e4307aa1a..914bed7ff63e5 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextProvider.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextProvider.java @@ -27,6 +27,8 @@ import java.util.stream.Collectors; import org.neo4j.graphdb.GraphDatabaseService; +import org.neo4j.kernel.impl.logging.LogService; +import org.neo4j.logging.Log; /** * Provider class that manages and provides fulltext indices. This is the main entry point for the fulltext addon. @@ -35,6 +37,7 @@ public class FulltextProvider implements AutoCloseable { private static FulltextProvider instance; private final GraphDatabaseService db; + private Log log; private final FulltextTransactionEventUpdater fulltextTransactionEventUpdater; private boolean closed; private Set nodeProperties; @@ -42,9 +45,10 @@ public class FulltextProvider implements AutoCloseable private Map nodeIndices; private Map relationshipIndices; - private FulltextProvider( GraphDatabaseService db ) + private FulltextProvider( GraphDatabaseService db, Log log ) { this.db = db; + this.log = log; closed = false; fulltextTransactionEventUpdater = new FulltextTransactionEventUpdater( this ); db.registerTransactionEventHandler( fulltextTransactionEventUpdater ); @@ -57,13 +61,14 @@ private FulltextProvider( GraphDatabaseService db ) /** * Fetch the current instance of the provider. If there is none, create one associated with the given database. * @param db Database used for eventual creation of the provider. + * @param logService * @return The instance for the given database. */ - public static synchronized FulltextProvider instance( GraphDatabaseService db ) + public static synchronized FulltextProvider instance( GraphDatabaseService db, LogService logService ) { if ( instance == null || instance.closed ) { - instance = new FulltextProvider( db ); + instance = new FulltextProvider( db, logService.getInternalLog( FulltextProvider.class ) ); } return instance; } @@ -86,7 +91,7 @@ public synchronized void close() } catch ( IOException e ) { - e.printStackTrace(); + log.error( "Unable to close fulltext node index.", e ); } } ); relationshipIndices.values().forEach( luceneFulltextIndex -> @@ -97,7 +102,7 @@ public synchronized void close() } catch ( IOException e ) { - e.printStackTrace(); + log.error( "Unable to close fulltext relationship index.", e ); } } ); } @@ -106,7 +111,7 @@ public synchronized void close() synchronized void register( LuceneFulltext fulltextIndex ) throws IOException { fulltextIndex.open(); - if ( fulltextIndex.getType() == FULLTEXT_INDEX_TYPE.NODES ) + if ( fulltextIndex.getType() == FulltextIndexType.NODES ) { nodeIndices.put( fulltextIndex.getIdentifier(), fulltextIndex ); nodeProperties.addAll( fulltextIndex.getProperties() ); @@ -145,9 +150,9 @@ Set writableRelationshipIndices() * @return A {@link ReadOnlyFulltext} for the index, or null if no such index is found. * @throws IOException */ - public ReadOnlyFulltext getReader( String identifier, FULLTEXT_INDEX_TYPE type ) throws IOException + public ReadOnlyFulltext getReader( String identifier, FulltextIndexType type ) throws IOException { - if ( type == FULLTEXT_INDEX_TYPE.NODES ) + if ( type == FulltextIndexType.NODES ) { return nodeIndices.get( identifier ).getIndexReader(); } @@ -160,7 +165,7 @@ public ReadOnlyFulltext getReader( String identifier, FULLTEXT_INDEX_TYPE type ) /** * Fulltext index type. */ - public enum FULLTEXT_INDEX_TYPE + public enum FulltextIndexType { NODES { diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltext.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltext.java index c5993ee3c66d2..515d4ad4424c5 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltext.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltext.java @@ -25,11 +25,8 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.concurrent.TimeUnit; -import org.neo4j.helpers.TaskCoordinator; import org.neo4j.kernel.api.impl.index.AbstractLuceneIndex; import org.neo4j.kernel.api.impl.index.partition.AbstractIndexPartition; import org.neo4j.kernel.api.impl.index.partition.IndexPartitionFactory; @@ -37,17 +34,15 @@ import org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage; import org.neo4j.kernel.api.impl.schema.writer.PartitionedIndexWriter; -import static java.util.Collections.singletonMap; - class LuceneFulltext extends AbstractLuceneIndex { private final Analyzer analyzer; private final String identifier; - private final FulltextProvider.FULLTEXT_INDEX_TYPE type; + private final FulltextProvider.FulltextIndexType type; private final Set properties; LuceneFulltext( PartitionedIndexStorage indexStorage, IndexPartitionFactory partitionFactory, List properties, Analyzer analyzer, - String identifier, FulltextProvider.FULLTEXT_INDEX_TYPE type ) + String identifier, FulltextProvider.FulltextIndexType type ) { super( indexStorage, partitionFactory ); this.properties = Collections.unmodifiableSet( new HashSet<>( properties ) ); @@ -98,7 +93,7 @@ ReadOnlyFulltext getIndexReader() throws IOException return hasSinglePartition( partitions ) ? createSimpleReader( partitions ) : createPartitionedReader( partitions ); } - FulltextProvider.FULLTEXT_INDEX_TYPE getType() + FulltextProvider.FulltextIndexType getType() { return type; } 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 c4f5cb0f3a611..39a01d32d00bf 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 @@ -31,6 +31,7 @@ import org.neo4j.kernel.api.impl.fulltext.FulltextFactory; import org.neo4j.kernel.api.impl.fulltext.FulltextProvider; import org.neo4j.kernel.configuration.Config; +import org.neo4j.kernel.impl.logging.LogService; import org.neo4j.kernel.impl.proc.Procedures; import org.neo4j.kernel.lifecycle.LifecycleAdapter; @@ -41,14 +42,17 @@ class BloomKernelExtension extends LifecycleAdapter private final FileSystemAbstraction fileSystemAbstraction; private final GraphDatabaseService db; private final Procedures procedures; + private LogService logService; - BloomKernelExtension( FileSystemAbstraction fileSystemAbstraction, File storeDir, Config config, GraphDatabaseService db, Procedures procedures ) + BloomKernelExtension( FileSystemAbstraction fileSystemAbstraction, File storeDir, Config config, GraphDatabaseService db, Procedures procedures, + LogService logService ) { this.storeDir = storeDir; this.config = config; this.fileSystemAbstraction = fileSystemAbstraction; this.db = db; this.procedures = procedures; + this.logService = logService; } @Override @@ -57,15 +61,15 @@ public void init() throws IOException, ProcedureException List properties = config.get( LoadableBloomFulltextConfig.bloom_indexed_properties ); Analyzer analyzer = getAnalyzer(); - FulltextProvider provider = FulltextProvider.instance( db ); + FulltextProvider provider = FulltextProvider.instance( db, logService ); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemAbstraction, storeDir, analyzer ); String bloomNodes = "bloomNodes"; - fulltextFactory.createFulltextIndex( bloomNodes, FulltextProvider.FULLTEXT_INDEX_TYPE.NODES, properties, provider ); + fulltextFactory.createFulltextIndex( bloomNodes, FulltextProvider.FulltextIndexType.NODES, properties, provider ); String bloomRelationships = "bloomRelationships"; - fulltextFactory.createFulltextIndex( bloomRelationships, FulltextProvider.FULLTEXT_INDEX_TYPE.RELATIONSHIPS, properties, provider ); + fulltextFactory.createFulltextIndex( bloomRelationships, FulltextProvider.FulltextIndexType.RELATIONSHIPS, properties, provider ); - procedures.register( new BloomProcedure( FulltextProvider.FULLTEXT_INDEX_TYPE.NODES, bloomNodes, provider ) ); - procedures.register( new BloomProcedure( FulltextProvider.FULLTEXT_INDEX_TYPE.RELATIONSHIPS, bloomRelationships, provider ) ); + procedures.register( new BloomProcedure( FulltextProvider.FulltextIndexType.NODES, bloomNodes, provider ) ); + procedures.register( new BloomProcedure( FulltextProvider.FulltextIndexType.RELATIONSHIPS, bloomRelationships, provider ) ); } private Analyzer getAnalyzer() @@ -86,6 +90,6 @@ private Analyzer getAnalyzer() @Override public void shutdown() throws Exception { - FulltextProvider.instance( db ).close(); + FulltextProvider.instance( db, logService ).close(); } } diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomKernelExtensionFactory.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomKernelExtensionFactory.java index 14a0195bfca32..77f7a71326ff1 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomKernelExtensionFactory.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomKernelExtensionFactory.java @@ -23,6 +23,7 @@ import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.extension.KernelExtensionFactory; +import org.neo4j.kernel.impl.logging.LogService; import org.neo4j.kernel.impl.proc.Procedures; import org.neo4j.kernel.impl.spi.KernelContext; import org.neo4j.kernel.lifecycle.Lifecycle; @@ -47,6 +48,8 @@ public interface Dependencies FileSystemAbstraction fileSystem(); Procedures procedures(); + + LogService logService(); } BloomKernelExtensionFactory() @@ -58,6 +61,6 @@ public interface Dependencies public Lifecycle newInstance( KernelContext context, Dependencies dependencies ) throws Throwable { return new BloomKernelExtension( dependencies.fileSystem(), context.storeDir(), dependencies.getConfig(), dependencies.db(), - dependencies.procedures() ); + dependencies.procedures(), dependencies.logService() ); } } 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 ab8c41992d980..19f467e4445f8 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 @@ -44,7 +44,7 @@ public class BloomProcedure extends CallableProcedure.BasicProcedure private static final String[] PROCEDURE_NAMESPACE = {"db", "fulltext"}; private final String identifier; private final FulltextProvider provider; - private final FulltextProvider.FULLTEXT_INDEX_TYPE type; + private final FulltextProvider.FulltextIndexType type; /** * Creates a procedure for querying the bloom fulltext addon. @@ -52,7 +52,7 @@ public class BloomProcedure extends CallableProcedure.BasicProcedure * @param identifier The identifier of the fulltext index. * @param provider The provider of the fulltext index. */ - public BloomProcedure( FulltextProvider.FULLTEXT_INDEX_TYPE type, String identifier, FulltextProvider provider ) + public BloomProcedure( FulltextProvider.FulltextIndexType type, String identifier, FulltextProvider provider ) { super( procedureSignature( new QualifiedName( PROCEDURE_NAMESPACE, PROCEDURE_NAME + type ) ).in( "terms", Neo4jTypes.NTList( Neo4jTypes.NTString ) ).out( OUTPUT_NAME, Neo4jTypes.NTInteger ).description( diff --git a/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/FulltextAnalyzerTest.java b/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/FulltextAnalyzerTest.java index ad546060579fe..ad9879d9277af 100644 --- a/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/FulltextAnalyzerTest.java +++ b/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/FulltextAnalyzerTest.java @@ -30,6 +30,8 @@ import org.neo4j.graphdb.Label; import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Transaction; +import org.neo4j.kernel.impl.logging.LogService; +import org.neo4j.kernel.impl.logging.NullLogService; import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.test.rule.DatabaseRule; import org.neo4j.test.rule.EmbeddedDatabaseRule; @@ -39,11 +41,12 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.neo4j.kernel.api.impl.fulltext.FulltextProvider.FULLTEXT_INDEX_TYPE; +import static org.neo4j.kernel.api.impl.fulltext.FulltextProvider.FulltextIndexType; public class FulltextAnalyzerTest { private static final Label LABEL = Label.label( "label" ); + private static final LogService LOG_SERVICE = NullLogService.getInstance(); @ClassRule public static FileSystemRule fileSystemRule = new DefaultFileSystemRule(); @ClassRule @@ -56,9 +59,9 @@ public void shouldBeAbleToSpecifyEnglishAnalyzer() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), new EnglishAnalyzer() ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "bloomNodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "bloomNodes", FulltextIndexType.NODES, Arrays.asList( "prop" ), provider ); long firstID; long secondID; @@ -74,7 +77,7 @@ public void shouldBeAbleToSpecifyEnglishAnalyzer() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "bloomNodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "bloomNodes", FulltextIndexType.NODES ) ) { assertFalse( reader.query( "and" ).hasNext() ); @@ -92,9 +95,9 @@ public void shouldBeAbleToSpecifySwedishAnalyzer() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), new SwedishAnalyzer() ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "bloomNodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "bloomNodes", FulltextIndexType.NODES, Arrays.asList( "prop" ), provider ); long firstID; long secondID; @@ -110,7 +113,7 @@ public void shouldBeAbleToSpecifySwedishAnalyzer() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "bloomNodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "bloomNodes", FulltextIndexType.NODES ) ) { assertEquals( firstID, reader.query( "and" ).next() ); assertEquals( firstID, reader.query( "in" ).next() ); diff --git a/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltextUpdaterTest.java b/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltextUpdaterTest.java index fc514352d45d1..b5b40bac8886e 100644 --- a/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltextUpdaterTest.java +++ b/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltextUpdaterTest.java @@ -32,6 +32,8 @@ import org.neo4j.graphdb.Relationship; import org.neo4j.graphdb.RelationshipType; import org.neo4j.graphdb.Transaction; +import org.neo4j.kernel.impl.logging.LogService; +import org.neo4j.kernel.impl.logging.NullLogService; import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.test.rule.DatabaseRule; import org.neo4j.test.rule.EmbeddedDatabaseRule; @@ -41,11 +43,13 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.neo4j.kernel.api.impl.fulltext.FulltextProvider.FULLTEXT_INDEX_TYPE; +import static org.neo4j.kernel.api.impl.fulltext.FulltextProvider.FulltextIndexType; public class LuceneFulltextUpdaterTest { public static final StandardAnalyzer ANALYZER = new StandardAnalyzer(); + private static final LogService LOG_SERVICE = NullLogService.getInstance(); + @ClassRule public static FileSystemRule fileSystemRule = new DefaultFileSystemRule(); @Rule @@ -61,9 +65,9 @@ public void shouldFindNodeWithString() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), ANALYZER ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "nodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "nodes", FulltextIndexType.NODES, Arrays.asList( "prop" ), provider ); long firstID; long secondID; @@ -80,7 +84,7 @@ public void shouldFindNodeWithString() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FulltextIndexType.NODES ) ) { assertEquals( firstID, reader.query( "hello" ).next() ); @@ -96,9 +100,9 @@ public void shouldFindNodeWithNumber() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), ANALYZER ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "nodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "nodes", FulltextIndexType.NODES, Arrays.asList( "prop" ), provider ); long firstID; long secondID; @@ -114,7 +118,7 @@ public void shouldFindNodeWithNumber() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FulltextIndexType.NODES ) ) { PrimitiveLongIterator node1prop = reader.query( "1" ); assertEquals( firstID, node1prop.next() ); @@ -131,9 +135,9 @@ public void shouldFindNodeWithBoolean() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), ANALYZER ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "nodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "nodes", FulltextIndexType.NODES, Arrays.asList( "prop" ), provider ); long firstID; long secondID; @@ -149,7 +153,7 @@ public void shouldFindNodeWithBoolean() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FulltextIndexType.NODES ) ) { PrimitiveLongIterator sant = reader.query( "true" ); assertEquals( firstID, sant.next() ); @@ -166,9 +170,9 @@ public void shouldFindNodeWithArrays() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), ANALYZER ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "nodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "nodes", FulltextIndexType.NODES, Arrays.asList( "prop" ), provider ); long firstID; long secondID; @@ -188,7 +192,7 @@ public void shouldFindNodeWithArrays() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FulltextIndexType.NODES ) ) { PrimitiveLongIterator strings = reader.query( "live" ); assertEquals( firstID, strings.next() ); @@ -209,9 +213,9 @@ public void shouldRepresentPropertyChanges() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), ANALYZER ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "nodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "nodes", FulltextIndexType.NODES, Arrays.asList( "prop" ), provider ); long firstID; long secondID; @@ -237,7 +241,7 @@ public void shouldRepresentPropertyChanges() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FulltextIndexType.NODES ) ) { assertFalse( reader.query( "hello" ).hasNext() ); @@ -258,9 +262,9 @@ public void shouldNotFindRemovedNodes() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), ANALYZER ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "nodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "nodes", FulltextIndexType.NODES, Arrays.asList( "prop" ), provider ); long firstID; long secondID; @@ -285,7 +289,7 @@ public void shouldNotFindRemovedNodes() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FulltextIndexType.NODES ) ) { assertFalse( reader.query( "hello" ).hasNext() ); @@ -301,9 +305,9 @@ public void shouldNotFindRemovedProperties() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), ANALYZER ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "nodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop", "prop2" ), provider ); + fulltextFactory.createFulltextIndex( "nodes", FulltextIndexType.NODES, Arrays.asList( "prop", "prop2" ), provider ); long firstID; long secondID; @@ -346,7 +350,7 @@ public void shouldNotFindRemovedProperties() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FulltextIndexType.NODES ) ) { PrimitiveLongIterator hello = reader.query( "hello" ); @@ -364,9 +368,9 @@ public void shouldOnlyIndexIndexedProperties() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), ANALYZER ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "nodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "nodes", FulltextIndexType.NODES, Arrays.asList( "prop" ), provider ); long firstID; try ( Transaction tx = db.beginTx() ) @@ -382,7 +386,7 @@ public void shouldOnlyIndexIndexedProperties() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FulltextIndexType.NODES ) ) { PrimitiveLongIterator hello = reader.query( "hello" ); @@ -398,9 +402,9 @@ public void shouldSearchAcrossMultipleProperties() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), ANALYZER ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "nodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop", "prop2" ), provider ); + fulltextFactory.createFulltextIndex( "nodes", FulltextIndexType.NODES, Arrays.asList( "prop", "prop2" ), provider ); long firstID; long secondID; @@ -422,7 +426,7 @@ public void shouldSearchAcrossMultipleProperties() throws Exception } PrimitiveLongIterator iterator; - try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FulltextIndexType.NODES ) ) { iterator = reader.query( "tomtar", "karl" ); @@ -438,9 +442,9 @@ public void shouldOrderResultsBasedOnRelevance() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), ANALYZER ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "nodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "first", "last" ), provider ); + fulltextFactory.createFulltextIndex( "nodes", FulltextIndexType.NODES, Arrays.asList( "first", "last" ), provider ); long firstID; long secondID; @@ -468,7 +472,7 @@ public void shouldOrderResultsBasedOnRelevance() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FulltextIndexType.NODES ) ) { PrimitiveLongIterator iterator = reader.query( "Tom", "Hanks" ); @@ -485,10 +489,10 @@ public void shouldDifferentiateNodesAndRelationships() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), ANALYZER ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "nodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop" ), provider ); - fulltextFactory.createFulltextIndex( "relationships", FULLTEXT_INDEX_TYPE.RELATIONSHIPS, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "nodes", FulltextIndexType.NODES, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "relationships", FulltextIndexType.RELATIONSHIPS, Arrays.asList( "prop" ), provider ); long firstNodeID; long secondNodeID; @@ -513,7 +517,7 @@ public void shouldDifferentiateNodesAndRelationships() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FulltextIndexType.NODES ) ) { PrimitiveLongIterator hello = reader.query( "hello" ); @@ -525,7 +529,7 @@ public void shouldDifferentiateNodesAndRelationships() throws Exception PrimitiveLongIterator different = reader.query( "different" ); assertFalse( different.hasNext() ); } - try ( ReadOnlyFulltext reader = provider.getReader( "relationships", FULLTEXT_INDEX_TYPE.RELATIONSHIPS ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "relationships", FulltextIndexType.RELATIONSHIPS ) ) { PrimitiveLongIterator hello = reader.query( "hello" ); @@ -545,9 +549,9 @@ public void fuzzyQueryShouldBeFuzzy() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), ANALYZER ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "nodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "nodes", FulltextIndexType.NODES, Arrays.asList( "prop" ), provider ); long firstID; long secondID; @@ -564,7 +568,7 @@ public void fuzzyQueryShouldBeFuzzy() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FulltextIndexType.NODES ) ) { assertEquals( firstID, reader.fuzzyQuery( "hella" ).next() ); @@ -584,9 +588,9 @@ public void fuzzyQueryShouldReturnExactMatchesFirst() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), ANALYZER ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "nodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "nodes", FulltextIndexType.NODES, Arrays.asList( "prop" ), provider ); long firstID; long secondID; @@ -610,7 +614,7 @@ public void fuzzyQueryShouldReturnExactMatchesFirst() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FulltextIndexType.NODES ) ) { PrimitiveLongIterator zebra = reader.fuzzyQuery( "zebra" ); @@ -628,10 +632,10 @@ public void shouldNotReturnNonMatches() throws Exception { GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); FulltextFactory fulltextFactory = new FulltextFactory( fileSystemRule, testDirectory.graphDbDir(), ANALYZER ); - try ( FulltextProvider provider = FulltextProvider.instance( db ) ) + try ( FulltextProvider provider = FulltextProvider.instance( db, LOG_SERVICE ) ) { - fulltextFactory.createFulltextIndex( "nodes", FULLTEXT_INDEX_TYPE.NODES, Arrays.asList( "prop" ), provider ); - fulltextFactory.createFulltextIndex( "relationships", FULLTEXT_INDEX_TYPE.RELATIONSHIPS, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "nodes", FulltextIndexType.NODES, Arrays.asList( "prop" ), provider ); + fulltextFactory.createFulltextIndex( "relationships", FulltextIndexType.RELATIONSHIPS, Arrays.asList( "prop" ), provider ); try ( Transaction tx = db.beginTx() ) { @@ -648,12 +652,12 @@ public void shouldNotReturnNonMatches() throws Exception tx.success(); } - try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FULLTEXT_INDEX_TYPE.NODES ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "nodes", FulltextIndexType.NODES ) ) { PrimitiveLongIterator zebra = reader.query( "zebra" ); assertFalse( zebra.hasNext() ); } - try ( ReadOnlyFulltext reader = provider.getReader( "relationships", FULLTEXT_INDEX_TYPE.RELATIONSHIPS ) ) + try ( ReadOnlyFulltext reader = provider.getReader( "relationships", FulltextIndexType.RELATIONSHIPS ) ) { PrimitiveLongIterator zebra = reader.query( "zebra" );