-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
neo4j native ids performance improvement
- Loading branch information
1 parent
86aa5e1
commit 2fede93
Showing
7 changed files
with
130 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...a/com/steelbridgelabs/oss/neo4j/structure/Neo4JVertexWhileCreatingMatchStatementTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright 2016 SteelBridge Laboratories, LLC. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* For more information: http://steelbridgelabs.com | ||
*/ | ||
|
||
package com.steelbridgelabs.oss.neo4j.structure; | ||
|
||
import org.apache.tinkerpop.gremlin.structure.Graph; | ||
import org.apache.tinkerpop.gremlin.structure.Transaction; | ||
import org.apache.tinkerpop.gremlin.structure.VertexProperty; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
import org.neo4j.driver.v1.Values; | ||
import org.neo4j.driver.v1.types.Node; | ||
|
||
import java.util.Collections; | ||
|
||
/** | ||
* @author Rogelio J. Baucells | ||
*/ | ||
@RunWith(MockitoJUnitRunner.class) | ||
public class Neo4JVertexWhileCreatingMatchStatementTest { | ||
|
||
@Mock | ||
private Neo4JGraph graph; | ||
|
||
@Mock | ||
private Transaction transaction; | ||
|
||
@Mock | ||
private Neo4JSession session; | ||
|
||
@Mock | ||
private Neo4JReadPartition partition; | ||
|
||
@Mock | ||
private Node node; | ||
|
||
@Mock | ||
private Neo4JElementIdProvider provider; | ||
|
||
@Mock | ||
private Graph.Features.VertexFeatures vertexFeatures; | ||
|
||
@Mock | ||
private Graph.Features features; | ||
|
||
@Test | ||
public void givenAliasShouldCreateMatchStatement() { | ||
// arrange | ||
Mockito.when(vertexFeatures.getCardinality(Mockito.anyString())).thenAnswer(invocation -> VertexProperty.Cardinality.single); | ||
Mockito.when(features.vertex()).thenAnswer(invocation -> vertexFeatures); | ||
Mockito.when(partition.validateLabel(Mockito.anyString())).thenAnswer(invocation -> true); | ||
Mockito.when(partition.vertexMatchPredicate(Mockito.eq("a"))).thenAnswer(invocation -> "(a:l1 OR a:l2)"); | ||
Mockito.when(graph.tx()).thenAnswer(invocation -> transaction); | ||
Mockito.when(graph.getPartition()).thenAnswer(invocation -> partition); | ||
Mockito.when(graph.features()).thenAnswer(invocation -> features); | ||
Mockito.when(node.get(Mockito.eq("id"))).thenAnswer(invocation -> Values.value(1L)); | ||
Mockito.when(node.labels()).thenAnswer(invocation -> Collections.singletonList("l1")); | ||
Mockito.when(node.keys()).thenAnswer(invocation -> Collections.singleton("key1")); | ||
Mockito.when(node.get(Mockito.eq("key1"))).thenAnswer(invocation -> Values.value("value1")); | ||
Mockito.when(provider.generate()).thenAnswer(invocation -> 2L); | ||
Mockito.when(provider.fieldName()).thenAnswer(invocation -> "id"); | ||
Mockito.when(provider.matchPredicateOperand(Mockito.anyString())).thenAnswer(invocation -> "a.id"); | ||
Neo4JVertex vertex = new Neo4JVertex(graph, session, provider, provider, node); | ||
// act | ||
String result = vertex.matchStatement("a", "id"); | ||
// assert | ||
Assert.assertNotNull("Failed to create match predicate", result); | ||
Assert.assertEquals("Invalid match predicate", result, "MATCH (a:`l1`) WHERE a.id = {id}"); | ||
} | ||
} |