From c84aa6844f600382f63d9f3d3a562ac9fee11781 Mon Sep 17 00:00:00 2001 From: Pontus Melke Date: Sun, 11 Jun 2017 19:47:21 +0200 Subject: [PATCH] Changed method to mode=READ It is important that a read-only user can use the index for reading. --- .../NotificationAcceptanceTest.java | 114 ++++++++++-------- .../builtinprocs/BuiltInProcedures.java | 99 ++++++++++----- .../builtinprocs/BuiltInProceduresTest.java | 13 ++ .../integrationtest/BuiltInProceduresIT.java | 79 ++++++++---- 4 files changed, 199 insertions(+), 106 deletions(-) diff --git a/community/cypher/cypher/src/test/java/org/neo4j/cypher/internal/javacompat/NotificationAcceptanceTest.java b/community/cypher/cypher/src/test/java/org/neo4j/cypher/internal/javacompat/NotificationAcceptanceTest.java index 4dd1b01288afb..269a1beb94fd7 100644 --- a/community/cypher/cypher/src/test/java/org/neo4j/cypher/internal/javacompat/NotificationAcceptanceTest.java +++ b/community/cypher/cypher/src/test/java/org/neo4j/cypher/internal/javacompat/NotificationAcceptanceTest.java @@ -111,7 +111,7 @@ public void shouldNotNotifyWhenUsingTheRulePlannerWhenCypherVersionIsNot3_2() th assertThat( arguments.get( "version" ), equalTo( version ) ); assertThat( arguments.get( "planner" ), equalTo( "RULE" ) ); result.close(); - }); + } ); } @Test @@ -122,7 +122,8 @@ public void shouldNotifyWhenUsingCreateUniqueWhenCypherVersionIsDefault() throws InputPosition position = new InputPosition( 25, 1, 26 ); // then - assertThat( result.getNotifications(), contains( CREATE_UNIQUE_UNAVAILABLE_FALLBACK.notification( position ) ) ); + assertThat( result.getNotifications(), + contains( CREATE_UNIQUE_UNAVAILABLE_FALLBACK.notification( position ) ) ); Map arguments = result.getExecutionPlanDescription().getArguments(); assertThat( arguments.get( "version" ), equalTo( "CYPHER 3.1" ) ); result.close(); @@ -136,7 +137,8 @@ public void shouldNotifyWhenUsingCreateUniqueWhenCypherVersionIs3_3() throws Exc InputPosition position = new InputPosition( 36, 1, 37 ); // then - assertThat( result.getNotifications(), contains( CREATE_UNIQUE_UNAVAILABLE_FALLBACK.notification( position ) ) ); + assertThat( result.getNotifications(), + contains( CREATE_UNIQUE_UNAVAILABLE_FALLBACK.notification( position ) ) ); Map arguments = result.getExecutionPlanDescription().getArguments(); assertThat( arguments.get( "version" ), equalTo( "CYPHER 3.1" ) ); result.close(); @@ -150,7 +152,8 @@ public void shouldNotifyWhenUsingCreateUniqueWhenCypherVersionIs3_2() throws Exc InputPosition position = new InputPosition( 36, 1, 37 ); // then - assertThat( result.getNotifications(), contains( CREATE_UNIQUE_UNAVAILABLE_FALLBACK.notification( position ) ) ); + assertThat( result.getNotifications(), + contains( CREATE_UNIQUE_UNAVAILABLE_FALLBACK.notification( position ) ) ); Map arguments = result.getExecutionPlanDescription().getArguments(); assertThat( arguments.get( "version" ), equalTo( "CYPHER 3.1" ) ); result.close(); @@ -169,31 +172,31 @@ public void shouldNotNotifyWhenUsingCreateUniqueWhenCypherVersionIsNot3_2() thro Map arguments = result.getExecutionPlanDescription().getArguments(); assertThat( arguments.get( "version" ), equalTo( version ) ); result.close(); - }); + } ); } @Test public void shouldWarnOnFutureAmbiguousRelTypeSeparator() throws Exception { - for ( String pattern : Arrays.asList("[:A|:B|:C {foo:'bar'}]", "[:A|:B|:C*]", "[x:A|:B|:C]") ) + for ( String pattern : Arrays.asList( "[:A|:B|:C {foo:'bar'}]", "[:A|:B|:C*]", "[x:A|:B|:C]" ) ) { - assertNotifications("CYPHER 3.3 explain MATCH (a)-" + pattern + "-(b) RETURN a,b", - containsItem(notification( + assertNotifications( "CYPHER 3.3 explain MATCH (a)-" + pattern + "-(b) RETURN a,b", + containsItem( notification( "Neo.ClientNotification.Statement.FeatureDeprecationWarning", containsString( "The semantics of using colon in the separation of alternative relationship " + - "types in conjunction with the use of variable binding, inlined property " + - "predicates, or variable length will change in a future version." + "types in conjunction with the use of variable binding, inlined property " + + "predicates, or variable length will change in a future version." ), - any(InputPosition.class), - SeverityLevel.WARNING))); + any( InputPosition.class ), + SeverityLevel.WARNING ) ) ); } } @Test public void shouldWarnOnBindingVariableLengthRelationship() throws Exception { - assertNotifications("CYPHER 3.3 explain MATCH ()-[rs*]-() RETURN rs", containsItem( notification( + assertNotifications( "CYPHER 3.3 explain MATCH ()-[rs*]-() RETURN rs", containsItem( notification( "Neo.ClientNotification.Statement.FeatureDeprecationWarning", containsString( "Binding relationships to a list in a variable length pattern is deprecated." ), any( InputPosition.class ), @@ -203,7 +206,7 @@ public void shouldWarnOnBindingVariableLengthRelationship() throws Exception @Test public void shouldWarnOnMissingLabel() throws Exception { - assertNotifications("EXPLAIN MATCH (a:NO_SUCH_THING) RETURN a", containsItem( notification( + assertNotifications( "EXPLAIN MATCH (a:NO_SUCH_THING) RETURN a", containsItem( notification( "Neo.ClientNotification.Statement.UnknownLabelWarning", containsString( "the missing label name is: NO_SUCH_THING)" ), any( InputPosition.class ), @@ -213,7 +216,7 @@ public void shouldWarnOnMissingLabel() throws Exception @Test public void shouldWarnOnMissingRelationshipType() throws Exception { - assertNotifications("EXPLAIN MATCH ()-[a:NO_SUCH_THING]->() RETURN a", containsItem( notification( + assertNotifications( "EXPLAIN MATCH ()-[a:NO_SUCH_THING]->() RETURN a", containsItem( notification( "Neo.ClientNotification.Statement.UnknownRelationshipTypeWarning", containsString( "the missing relationship type is: NO_SUCH_THING)" ), any( InputPosition.class ), @@ -223,7 +226,7 @@ public void shouldWarnOnMissingRelationshipType() throws Exception @Test public void shouldWarnOnMissingProperty() throws Exception { - assertNotifications("EXPLAIN MATCH (a {NO_SUCH_THING: 1337}) RETURN a", containsItem( notification( + assertNotifications( "EXPLAIN MATCH (a {NO_SUCH_THING: 1337}) RETURN a", containsItem( notification( "Neo.ClientNotification.Statement.UnknownPropertyKeyWarning", containsString( "the missing property name is: NO_SUCH_THING)" ), any( InputPosition.class ), @@ -233,21 +236,25 @@ public void shouldWarnOnMissingProperty() throws Exception @Test public void shouldWarnThatStartIsDeprecatedForAllNodeScan() { - assertNotifications("EXPLAIN START n=node(*) RETURN n", + assertNotifications( "EXPLAIN START n=node(*) RETURN n", containsItem( notification( - "Neo.ClientNotification.Statement.FeatureDeprecationWarning", - containsString( "START has been deprecated and will be removed in a future version. (START is deprecated, use: `MATCH (n)`" ), - any( InputPosition.class ), - SeverityLevel.WARNING ) ) ); + "Neo.ClientNotification.Statement.FeatureDeprecationWarning", + containsString( + "START has been deprecated and will be removed in a future version. (START is " + + "deprecated, use: `MATCH (n)`" ), + any( InputPosition.class ), + SeverityLevel.WARNING ) ) ); } @Test public void shouldWarnThatStartIsDeprecatedForNodeById() { - assertNotifications("EXPLAIN START n=node(1337) RETURN n", + assertNotifications( "EXPLAIN START n=node(1337) RETURN n", containsItem( notification( "Neo.ClientNotification.Statement.FeatureDeprecationWarning", - containsString( "START has been deprecated and will be removed in a future version. (START is deprecated, use: `MATCH (n) WHERE id(n) = 1337`" ), + containsString( + "START has been deprecated and will be removed in a future version. (START is " + + "deprecated, use: `MATCH (n) WHERE id(n) = 1337`" ), any( InputPosition.class ), SeverityLevel.WARNING ) ) ); } @@ -255,10 +262,12 @@ public void shouldWarnThatStartIsDeprecatedForNodeById() @Test public void shouldWarnThatStartIsDeprecatedForNodeByIds() { - assertNotifications("EXPLAIN START n=node(42,1337) RETURN n", + assertNotifications( "EXPLAIN START n=node(42,1337) RETURN n", containsItem( notification( "Neo.ClientNotification.Statement.FeatureDeprecationWarning", - containsString( "START has been deprecated and will be removed in a future version. (START is deprecated, use: `MATCH (n) WHERE id(n) IN [42, 1337]`" ), + containsString( + "START has been deprecated and will be removed in a future version. (START is " + + "deprecated, use: `MATCH (n) WHERE id(n) IN [42, 1337]`" ), any( InputPosition.class ), SeverityLevel.WARNING ) ) ); } @@ -266,16 +275,17 @@ public void shouldWarnThatStartIsDeprecatedForNodeByIds() @Test public void shouldWarnThatStartIsDeprecatedForNodeIndexSeek() { - try (Transaction ignore = db().beginTx()) + try ( Transaction ignore = db().beginTx() ) { db().index().forNodes( "index" ); } - assertNotifications("EXPLAIN START n=node:index(key = 'value') RETURN n", + assertNotifications( "EXPLAIN START n=node:index(key = 'value') RETURN n", containsItem( notification( "Neo.ClientNotification.Statement.FeatureDeprecationWarning", containsString( "START has been deprecated and will be removed in a future version. " + "(START is deprecated, use: " + - "`CALL db.nodeLegacyIndexSeek('index', 'key', 'value') YIELD node AS n` instead." ), + "`CALL db.nodeLegacyIndexSeek('index', 'key', 'value') YIELD node AS n` " + + "instead." ), any( InputPosition.class ), SeverityLevel.WARNING ) ) ); } @@ -283,30 +293,30 @@ public void shouldWarnThatStartIsDeprecatedForNodeIndexSeek() @Test public void shouldWarnThatStartIsDeprecatedForNodeIndexSearch() { - try (Transaction ignore = db().beginTx()) + try ( Transaction ignore = db().beginTx() ) { db().index().forNodes( "index" ); } - assertNotifications("EXPLAIN START n=node:index('key:value*') RETURN n", + assertNotifications( "EXPLAIN START n=node:index('key:value*') RETURN n", containsItem( notification( "Neo.ClientNotification.Statement.FeatureDeprecationWarning", containsString( "START has been deprecated and will be removed in a future version. " + "(START is deprecated, use: " + - "`CALL db.nodeLegacyIndexSearch('index', 'key:value*') YIELD node AS n` instead." ), + "`CALL db.nodeLegacyIndexSearch('index', 'key:value*') YIELD node AS n` " + + "instead." ), any( InputPosition.class ), SeverityLevel.WARNING ) ) ); } - - - @Test public void shouldWarnThatStartIsDeprecatedForAllRelScan() { - assertNotifications("EXPLAIN START r=relationship(*) RETURN r", + assertNotifications( "EXPLAIN START r=relationship(*) RETURN r", containsItem( notification( "Neo.ClientNotification.Statement.FeatureDeprecationWarning", - containsString( "START has been deprecated and will be removed in a future version. (START is deprecated, use: `MATCH ()-[r]->()`" ), + containsString( + "START has been deprecated and will be removed in a future version. (START is " + + "deprecated, use: `MATCH ()-[r]->()`" ), any( InputPosition.class ), SeverityLevel.WARNING ) ) ); } @@ -314,10 +324,12 @@ public void shouldWarnThatStartIsDeprecatedForAllRelScan() @Test public void shouldWarnThatStartIsDeprecatedForRelById() { - assertNotifications("EXPLAIN START r=relationship(1337) RETURN r", + assertNotifications( "EXPLAIN START r=relationship(1337) RETURN r", containsItem( notification( "Neo.ClientNotification.Statement.FeatureDeprecationWarning", - containsString( "START has been deprecated and will be removed in a future version. (START is deprecated, use: `MATCH ()-[r]->() WHERE id(r) = 1337`" ), + containsString( + "START has been deprecated and will be removed in a future version. (START is " + + "deprecated, use: `MATCH ()-[r]->() WHERE id(r) = 1337`" ), any( InputPosition.class ), SeverityLevel.WARNING ) ) ); } @@ -325,10 +337,12 @@ public void shouldWarnThatStartIsDeprecatedForRelById() @Test public void shouldWarnThatStartIsDeprecatedForRelByIds() { - assertNotifications("EXPLAIN START r=relationship(42,1337) RETURN r", + assertNotifications( "EXPLAIN START r=relationship(42,1337) RETURN r", containsItem( notification( "Neo.ClientNotification.Statement.FeatureDeprecationWarning", - containsString( "START has been deprecated and will be removed in a future version. (START is deprecated, use: `MATCH ()-[r]->() WHERE id(r) IN [42, 1337]`" ), + containsString( + "START has been deprecated and will be removed in a future version. (START is " + + "deprecated, use: `MATCH ()-[r]->() WHERE id(r) IN [42, 1337]`" ), any( InputPosition.class ), SeverityLevel.WARNING ) ) ); } @@ -336,16 +350,17 @@ public void shouldWarnThatStartIsDeprecatedForRelByIds() @Test public void shouldWarnThatStartIsDeprecatedForRelIndexSeek() { - try (Transaction ignore = db().beginTx()) + try ( Transaction ignore = db().beginTx() ) { db().index().forRelationships( "index" ); } - assertNotifications("EXPLAIN START r=relationship:index(key = 'value') RETURN r", + assertNotifications( "EXPLAIN START r=relationship:index(key = 'value') RETURN r", containsItem( notification( "Neo.ClientNotification.Statement.FeatureDeprecationWarning", containsString( "START has been deprecated and will be removed in a future version. " + "(START is deprecated, use: " + - "`CALL db.relationshipLegacyIndexSeek('index', 'key', 'value') YIELD relationship AS r` instead." ), + "`CALL db.relationshipLegacyIndexSeek('index', 'key', 'value') YIELD " + + "relationship AS r` instead." ), any( InputPosition.class ), SeverityLevel.WARNING ) ) ); } @@ -353,16 +368,17 @@ public void shouldWarnThatStartIsDeprecatedForRelIndexSeek() @Test public void shouldWarnThatStartIsDeprecatedForRelIndexSearch() { - try (Transaction ignore = db().beginTx()) + try ( Transaction ignore = db().beginTx() ) { db().index().forRelationships( "index" ); } - assertNotifications("EXPLAIN START r=relationship:index('key:value*') RETURN r", + assertNotifications( "EXPLAIN START r=relationship:index('key:value*') RETURN r", containsItem( notification( "Neo.ClientNotification.Statement.FeatureDeprecationWarning", containsString( "START has been deprecated and will be removed in a future version. " + "(START is deprecated, use: " + - "`CALL db.relationshipLegacyIndexSearch('index', 'key:value*') YIELD relationship AS r` instead." ), + "`CALL db.relationshipLegacyIndexSearch('index', 'key:value*') YIELD " + + "relationship AS r` instead." ), any( InputPosition.class ), SeverityLevel.WARNING ) ) ); } @@ -387,9 +403,9 @@ private Matcher notification( protected boolean matchesSafely( Notification item ) { return code.equals( item.getCode() ) && - description.matches( item.getDescription() ) && - position.matches( item.getPosition() ) && - severity.equals( item.getSeverity() ); + description.matches( item.getDescription() ) && + position.matches( item.getPosition() ) && + severity.equals( item.getSeverity() ); } @Override diff --git a/community/kernel/src/main/java/org/neo4j/kernel/builtinprocs/BuiltInProcedures.java b/community/kernel/src/main/java/org/neo4j/kernel/builtinprocs/BuiltInProcedures.java index 0f34af6efa1d9..65bfba7a187a3 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/builtinprocs/BuiltInProcedures.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/builtinprocs/BuiltInProcedures.java @@ -21,18 +21,23 @@ import java.util.ArrayList; import java.util.Comparator; +import java.util.Iterator; import java.util.List; +import java.util.Spliterator; +import java.util.Spliterators; import java.util.concurrent.TimeUnit; +import java.util.function.Function; import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import org.neo4j.collection.primitive.PrimitiveLongResourceIterator; import org.neo4j.graphdb.DependencyResolver; import org.neo4j.graphdb.Label; import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Relationship; import org.neo4j.graphdb.RelationshipType; -import org.neo4j.graphdb.index.IndexHits; -import org.neo4j.graphdb.index.IndexManager; import org.neo4j.kernel.api.KernelTransaction; +import org.neo4j.kernel.api.LegacyIndexHits; import org.neo4j.kernel.api.ReadOperations; import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.StatementTokenNameLookup; @@ -40,6 +45,7 @@ import org.neo4j.kernel.api.exceptions.ProcedureException; import org.neo4j.kernel.api.exceptions.Status; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; +import org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.impl.api.TokenAccess; import org.neo4j.kernel.impl.api.index.IndexingService; @@ -52,7 +58,6 @@ import static org.neo4j.helpers.collection.Iterators.asList; import static org.neo4j.kernel.api.schema.index.IndexDescriptor.Type.UNIQUE; import static org.neo4j.procedure.Mode.READ; -import static org.neo4j.procedure.Mode.SCHEMA; @SuppressWarnings( {"unused", "WeakerAccess"} ) public class BuiltInProcedures @@ -139,7 +144,7 @@ public Stream listIndexes() throws ProcedureException @Description( "Wait for an index to come online (for example: CALL db.awaitIndex(\":Person(name)\"))." ) @Procedure( name = "db.awaitIndex", mode = READ ) public void awaitIndex( @Name( "index" ) String index, - @Name( value = "timeOutSeconds", defaultValue = "300" ) long timeout ) + @Name( value = "timeOutSeconds", defaultValue = "300" ) long timeout ) throws ProcedureException { try ( IndexProcedures indexProcedures = indexProcedures() ) @@ -192,69 +197,101 @@ public Stream listConstraints() } @Description( "Get node from legacy index. Replaces `START n=node:nodes(key = 'A')`" ) - @Procedure( name = "db.nodeLegacyIndexSeek", mode = SCHEMA ) + @Procedure( name = "db.nodeLegacyIndexSeek", mode = READ ) public Stream nodeLegacyIndexSeek( @Name( "indexName" ) String legacyIndexName, - @Name("key") String key, - @Name("value") Object value ) + @Name( "key" ) String key, + @Name( "value" ) Object value ) throws ProcedureException { - IndexManager index = graphDatabaseAPI.index(); - if ( !index.existsForNodes( legacyIndexName ) ) + try ( Statement statement = tx.acquireStatement() ) + { + ReadOperations readOperations = statement.readOperations(); + LegacyIndexHits hits = readOperations.nodeLegacyIndexGet( legacyIndexName, key, value ); + return toStream( hits, ( id ) -> new NodeResult( graphDatabaseAPI.getNodeById( id ) ) ); + } + catch ( LegacyIndexNotFoundKernelException e ) { throw new ProcedureException( Status.LegacyIndex.LegacyIndexNotFound, "Node index %s not found", legacyIndexName ); } - IndexHits nodes = index.forNodes( legacyIndexName ).query( key, value ); - return nodes.stream().map( NodeResult::new ); } @Description( "Search nodes from legacy index. Replaces `START n=node:nodes('key:foo*')`" ) - @Procedure( name = "db.nodeLegacyIndexSearch", mode = SCHEMA ) - public Stream nodeLegacyIndexSearch( @Name("indexName") String legacyIndexName, - @Name("query") Object query ) + @Procedure( name = "db.nodeLegacyIndexSearch", mode = READ ) + public Stream nodeLegacyIndexSearch( @Name( "indexName" ) String legacyIndexName, + @Name( "query" ) Object query ) throws ProcedureException { - IndexManager index = graphDatabaseAPI.index(); - if ( !index.existsForNodes( legacyIndexName ) ) + try ( Statement statement = tx.acquireStatement() ) + { + ReadOperations readOperations = statement.readOperations(); + LegacyIndexHits hits = readOperations.nodeLegacyIndexQuery( legacyIndexName, query ); + return toStream( hits, ( id ) -> new NodeResult( graphDatabaseAPI.getNodeById( id ) ) ); + } + catch ( LegacyIndexNotFoundKernelException e ) { throw new ProcedureException( Status.LegacyIndex.LegacyIndexNotFound, "Node index %s not found", legacyIndexName ); } - IndexHits nodes = index.forNodes( legacyIndexName ).query( query ); - return nodes.stream().map( NodeResult::new ); } @Description( "Get relationship from legacy index. Replaces `START r=relationship:relIndex(key = 'A')`" ) - @Procedure( name = "db.relationshipLegacyIndexSeek", mode = SCHEMA ) + @Procedure( name = "db.relationshipLegacyIndexSeek", mode = READ ) public Stream relationshipLegacyIndexSeek( @Name( "indexName" ) String legacyIndexName, - @Name("key") String key, - @Name("value") Object value ) + @Name( "key" ) String key, + @Name( "value" ) Object value ) throws ProcedureException { - IndexManager index = graphDatabaseAPI.index(); - if ( !index.existsForRelationships( legacyIndexName ) ) + try ( Statement statement = tx.acquireStatement() ) + { + ReadOperations readOperations = statement.readOperations(); + LegacyIndexHits hits = readOperations.relationshipLegacyIndexGet( legacyIndexName, key, value, -1, -1 ); + return toStream( hits, ( id ) -> new RelationshipResult( graphDatabaseAPI.getRelationshipById( id ) ) ); + } + catch ( LegacyIndexNotFoundKernelException e ) { throw new ProcedureException( Status.LegacyIndex.LegacyIndexNotFound, "Node index %s not found", legacyIndexName ); } - IndexHits relationships = index.forRelationships( legacyIndexName ).query( key, value ); - return relationships.stream().map( RelationshipResult::new ); } @Description( "Search relationship from legacy index. Replaces `START r=relationship:relIndex('key:foo*')`" ) - @Procedure( name = "db.relationshipLegacyIndexSearch", mode = SCHEMA ) + @Procedure( name = "db.relationshipLegacyIndexSearch", mode = READ ) public Stream relationshipLegacyIndexSearch( @Name( "indexName" ) String legacyIndexName, - @Name("query") Object query ) + @Name( "query" ) Object query ) throws ProcedureException { - IndexManager index = graphDatabaseAPI.index(); - if ( !index.existsForRelationships( legacyIndexName ) ) + try ( Statement statement = tx.acquireStatement() ) + { + ReadOperations readOperations = statement.readOperations(); + LegacyIndexHits hits = readOperations.relationshipLegacyIndexQuery( legacyIndexName, query, -1, -1 ); + return toStream( hits, ( id ) -> new RelationshipResult( graphDatabaseAPI.getRelationshipById( id ) ) ); + } + catch ( LegacyIndexNotFoundKernelException e ) { throw new ProcedureException( Status.LegacyIndex.LegacyIndexNotFound, "Node index %s not found", legacyIndexName ); } - IndexHits relationships = index.forRelationships( legacyIndexName ).query( query ); - return relationships.stream().map( RelationshipResult::new ); + } + + private Stream toStream( PrimitiveLongResourceIterator iterator, Function mapper ) + { + Iterator it = new Iterator() + { + @Override + public boolean hasNext() + { + return iterator.hasNext(); + } + + @Override + public T next() + { + return mapper.apply( iterator.next() ); + } + }; + + return StreamSupport.stream( Spliterators.spliteratorUnknownSize( it, Spliterator.ORDERED ), false ); } private IndexProcedures indexProcedures() diff --git a/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java b/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java index f3b6f70786b38..c1f7fb05e7bb3 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java @@ -206,6 +206,19 @@ public void shouldListCorrectBuiltinProcedures() throws Throwable record( "db.schema", "db.schema() :: (nodes :: LIST? OF NODE?, relationships :: LIST? OF RELATIONSHIP?)", "Show the schema of the data." ), + record( "db.nodeLegacyIndexSearch", + "db.nodeLegacyIndexSearch(indexName :: STRING?, query :: ANY?) :: (node :: NODE?)", + "Search nodes from legacy index. Replaces `START n=node:nodes('key:foo*')`"), + record( "db.nodeLegacyIndexSeek", + "db.nodeLegacyIndexSeek(indexName :: STRING?, key :: STRING?, value :: ANY?) :: (node :: NODE?)", + "Get node from legacy index. Replaces `START n=node:nodes(key = 'A')`"), + record( "db.relationshipLegacyIndexSearch", + "db.relationshipLegacyIndexSearch(indexName :: STRING?, query :: ANY?) :: (relationship :: RELATIONSHIP?)", + "Search relationship from legacy index. Replaces `START r=relationship:relIndex('key:foo*')`"), + record( "db.relationshipLegacyIndexSeek", + "db.relationshipLegacyIndexSeek(indexName :: STRING?, key :: STRING?, value :: ANY?) :: " + + "(relationship :: RELATIONSHIP?)", + "Get relationship from legacy index. Replaces `START r=relationship:relIndex(key = 'A')`"), record( "dbms.components", "dbms.components() :: (name :: STRING?, versions :: LIST? OF STRING?, edition :: STRING?)", "List DBMS components and their versions." ), diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/BuiltInProceduresIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/BuiltInProceduresIT.java index bac51d750c7cb..c713b0d396e88 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/BuiltInProceduresIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/BuiltInProceduresIT.java @@ -63,7 +63,7 @@ public void listAllLabels() throws Throwable commit(); // When - RawIterator stream = + RawIterator stream = procedureCallOpsInNewTx().procedureCallRead( procedureName( "db", "labels" ), new Object[0] ); // Then @@ -79,7 +79,7 @@ public void listPropertyKeys() throws Throwable commit(); // When - RawIterator stream = procedureCallOpsInNewTx() + RawIterator stream = procedureCallOpsInNewTx() .procedureCallRead( procedureName( "db", "propertyKeys" ), new Object[0] ); // Then @@ -98,7 +98,7 @@ public void listRelationshipTypes() throws Throwable commit(); // When - RawIterator stream = procedureCallOpsInNewTx() + RawIterator stream = procedureCallOpsInNewTx() .procedureCallRead( procedureName( "db", "relationshipTypes" ), new Object[0] ); // Then @@ -109,20 +109,22 @@ public void listRelationshipTypes() throws Throwable public void listProcedures() throws Throwable { // When - RawIterator stream = procedureCallOpsInNewTx() + RawIterator stream = procedureCallOpsInNewTx() .procedureCallRead( procedureName( "dbms", "procedures" ), new Object[0] ); // Then assertThat( asList( stream ), containsInAnyOrder( - equalTo( new Object[]{ "dbms.listConfig", + equalTo( new Object[]{"dbms.listConfig", "dbms.listConfig(searchString = :: STRING?) :: (name :: STRING?, description :: STRING?, " + - "value :: STRING?)", - "List the currently active config of Neo4j." } ), + "value :: STRING?)", + "List the currently active config of Neo4j."} ), equalTo( new Object[]{"db.constraints", "db.constraints() :: (description :: STRING?)", "List all constraints in the database."} ), - equalTo( new Object[]{"db.indexes", "db.indexes() :: (description :: STRING?, state :: STRING?, type :: STRING?)", + equalTo( new Object[]{"db.indexes", + "db.indexes() :: (description :: STRING?, state :: STRING?, type :: STRING?)", "List all indexes in the database."} ), - equalTo( new Object[]{"db.awaitIndex", "db.awaitIndex(index :: STRING?, timeOutSeconds = 300 :: INTEGER?) :: VOID", + equalTo( new Object[]{"db.awaitIndex", + "db.awaitIndex(index :: STRING?, timeOutSeconds = 300 :: INTEGER?) :: VOID", "Wait for an index to come online (for example: CALL db.awaitIndex(\":Person(name)\"))."} ), equalTo( new Object[]{"db.resampleIndex", "db.resampleIndex(index :: STRING?) :: VOID", "Schedule resampling of an index (for example: CALL db.resampleIndex(\":Person(name)\"))."} ), @@ -130,30 +132,55 @@ public void listProcedures() throws Throwable "Schedule resampling of all outdated indexes."} ), equalTo( new Object[]{"db.propertyKeys", "db.propertyKeys() :: (propertyKey :: STRING?)", "List all property keys in the database."} ), - equalTo( new Object[]{"db.labels", "db.labels() :: (label :: STRING?)", "List all labels in the database."} ), + equalTo( new Object[]{"db.labels", "db.labels() :: (label :: STRING?)", + "List all labels in the database."} ), equalTo( new Object[]{"db.schema", "db.schema() :: (nodes :: LIST? OF NODE?, relationships :: LIST? " + - "OF " + - "RELATIONSHIP?)", "Show the schema of the data."} ), + "OF " + + "RELATIONSHIP?)", "Show the schema of the data."} ), equalTo( new Object[]{"db.relationshipTypes", "db.relationshipTypes() :: (relationshipType :: " + - "STRING?)", "List all relationship types in the database."} ), + "STRING?)", + "List all relationship types in the database."} ), equalTo( new Object[]{"dbms.procedures", "dbms.procedures() :: (name :: STRING?, signature :: " + - "STRING?, description :: STRING?)", "List all procedures in the DBMS."} ), + "STRING?, description :: STRING?)", + "List all procedures in the DBMS."} ), equalTo( new Object[]{"dbms.functions", "dbms.functions() :: (name :: STRING?, signature :: " + - "STRING?, description :: STRING?)", "List all user functions in the DBMS."} ), + "STRING?, description :: STRING?)", + "List all user functions in the DBMS."} ), equalTo( new Object[]{"dbms.components", "dbms.components() :: (name :: STRING?, versions :: LIST? OF" + - " STRING?, edition :: STRING?)", "List DBMS components and their versions."} ), + " STRING?, edition :: STRING?)", + "List DBMS components and their versions."} ), equalTo( new Object[]{"dbms.queryJmx", "dbms.queryJmx(query :: STRING?) :: (name :: STRING?, " + - "description :: STRING?, attributes :: MAP?)", "Query JMX management data by domain and name." + - " For instance, \"org.neo4j:*\""} ), - equalTo(new Object[]{"db.createLabel","db.createLabel(newLabel :: STRING?) :: VOID", "Create a label" - }), - equalTo(new Object[]{"db.createProperty","db.createProperty(newProperty :: STRING?) :: VOID", + "description :: STRING?, attributes :: MAP?)", + "Query JMX management data by domain and name." + + " For instance, \"org.neo4j:*\""} ), + equalTo( new Object[]{"db.createLabel", "db.createLabel(newLabel :: STRING?) :: VOID", "Create a label" + } ), + equalTo( new Object[]{"db.createProperty", "db.createProperty(newProperty :: STRING?) :: VOID", "Create a Property" - }), - equalTo(new Object[]{"db.createRelationshipType", + } ), + equalTo( new Object[]{"db.createRelationshipType", "db.createRelationshipType(newRelationshipType :: STRING?) :: VOID", "Create a RelationshipType" - }) + } ), + equalTo( new Object[]{"db.nodeLegacyIndexSearch", + "db.nodeLegacyIndexSearch(indexName :: STRING?, query :: ANY?) :: (node :: NODE?)", + "Search nodes from legacy index. Replaces `START n=node:nodes('key:foo*')`" + } ), + equalTo( new Object[]{"db.nodeLegacyIndexSeek", + "db.nodeLegacyIndexSeek(indexName :: STRING?, key :: STRING?, value :: ANY?) :: (node :: " + + "NODE?)", + "Get node from legacy index. Replaces `START n=node:nodes(key = 'A')`" + } ), + equalTo( new Object[]{"db.relationshipLegacyIndexSearch", + "db.relationshipLegacyIndexSearch(indexName :: STRING?, query :: ANY?) :: (relationship :: " + + "RELATIONSHIP?)", + "Search relationship from legacy index. Replaces `START r=relationship:relIndex('key:foo*')`" + } ), + equalTo( new Object[]{"db.relationshipLegacyIndexSeek", + "db.relationshipLegacyIndexSeek(indexName :: STRING?, key :: STRING?, value :: ANY?) :: " + + "(relationship :: RELATIONSHIP?)", + "Get relationship from legacy index. Replaces `START r=relationship:relIndex(key = 'A')`" + } ) ) ); } @@ -180,7 +207,7 @@ public void listAllComponents() throws Throwable // Given a running database // When - RawIterator stream = procedureCallOpsInNewTx() + RawIterator stream = procedureCallOpsInNewTx() .procedureCallRead( procedureName( "dbms", "components" ), new Object[0] ); // Then @@ -222,6 +249,6 @@ public void listAllIndexes() throws Throwable assertThat( result, containsInAnyOrder( new Object[]{"INDEX ON :Age(foo)", "ONLINE", "node_unique_property"}, new Object[]{"INDEX ON :Person(foo)", "ONLINE", "node_label_property"} - ) ); + ) ); } }