-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests and resolve issue running SparkGraphComputer on HBase #81
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
115 changes: 115 additions & 0 deletions
115
...ent/janusgraph-hadoop-core/src/test/java/org/janusgraph/hadoop/AbstractInputFormatIT.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,115 @@ | ||
// Copyright 2017 JanusGraph Authors | ||
// | ||
// 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. | ||
|
||
package org.janusgraph.hadoop; | ||
|
||
import org.janusgraph.core.Cardinality; | ||
import org.janusgraph.core.JanusGraphVertex; | ||
import org.janusgraph.diskstorage.configuration.WriteConfiguration; | ||
import org.janusgraph.example.GraphOfTheGodsFactory; | ||
import org.janusgraph.graphdb.JanusGraphBaseTest; | ||
import org.apache.commons.configuration.ConfigurationException; | ||
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; | ||
import org.apache.tinkerpop.gremlin.spark.process.computer.SparkGraphComputer; | ||
import org.apache.tinkerpop.gremlin.structure.Direction; | ||
import org.apache.tinkerpop.gremlin.structure.Edge; | ||
import org.apache.tinkerpop.gremlin.structure.Graph; | ||
import org.apache.tinkerpop.gremlin.structure.Vertex; | ||
import org.apache.tinkerpop.gremlin.structure.util.GraphFactory; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import com.google.common.collect.Iterators; | ||
import com.google.common.collect.Lists; | ||
import com.google.common.collect.Sets; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public abstract class AbstractInputFormatIT extends JanusGraphBaseTest { | ||
|
||
@Test | ||
public void testReadGraphOfTheGods() throws Exception { | ||
GraphOfTheGodsFactory.load(graph, null, true); | ||
assertEquals(12L, (long) graph.traversal().V().count().next()); | ||
Graph g = getGraph(); | ||
GraphTraversalSource t = g.traversal(GraphTraversalSource.computer(SparkGraphComputer.class)); | ||
assertEquals(12L, (long) t.V().count().next()); | ||
} | ||
|
||
@Test | ||
public void testReadWideVertexWithManyProperties() throws Exception { | ||
int numProps = 1 << 16; | ||
|
||
long numV = 1; | ||
mgmt.makePropertyKey("p").cardinality(Cardinality.LIST).dataType(Integer.class).make(); | ||
mgmt.commit(); | ||
finishSchema(); | ||
|
||
for (int j = 0; j < numV; j++) { | ||
Vertex v = graph.addVertex(); | ||
for (int i = 0; i < numProps; i++) { | ||
v.property("p", i); | ||
} | ||
} | ||
graph.tx().commit(); | ||
|
||
assertEquals(numV, (long) graph.traversal().V().count().next()); | ||
Map<String, Object> propertiesOnVertex = graph.traversal().V().valueMap().next(); | ||
List<?> valuesOnP = (List)propertiesOnVertex.values().iterator().next(); | ||
assertEquals(numProps, valuesOnP.size()); | ||
Graph g = getGraph(); | ||
GraphTraversalSource t = g.traversal(GraphTraversalSource.computer(SparkGraphComputer.class)); | ||
assertEquals(numV, (long) t.V().count().next()); | ||
propertiesOnVertex = t.V().valueMap().next(); | ||
valuesOnP = (List)propertiesOnVertex.values().iterator().next(); | ||
assertEquals(numProps, valuesOnP.size()); | ||
} | ||
|
||
@Test | ||
public void testReadSelfEdge() throws Exception { | ||
GraphOfTheGodsFactory.load(graph, null, true); | ||
assertEquals(12L, (long) graph.traversal().V().count().next()); | ||
|
||
// Add a self-loop on sky with edge label "lives"; it's nonsense, but at least it needs no schema changes | ||
JanusGraphVertex sky = (JanusGraphVertex)graph.query().has("name", "sky").vertices().iterator().next(); | ||
assertNotNull(sky); | ||
assertEquals("sky", sky.value("name")); | ||
assertEquals(1L, sky.query().direction(Direction.IN).edgeCount()); | ||
assertEquals(0L, sky.query().direction(Direction.OUT).edgeCount()); | ||
assertEquals(1L, sky.query().direction(Direction.BOTH).edgeCount()); | ||
sky.addEdge("lives", sky, "reason", "testReadSelfEdge"); | ||
assertEquals(2L, sky.query().direction(Direction.IN).edgeCount()); | ||
assertEquals(1L, sky.query().direction(Direction.OUT).edgeCount()); | ||
assertEquals(3L, sky.query().direction(Direction.BOTH).edgeCount()); | ||
graph.tx().commit(); | ||
|
||
// Read the new edge using the inputformat | ||
Graph g = getGraph(); | ||
GraphTraversalSource t = g.traversal(GraphTraversalSource.computer(SparkGraphComputer.class)); | ||
Iterator<Object> edgeIdIter = t.V().has("name", "sky").bothE().id(); | ||
assertNotNull(edgeIdIter); | ||
assertTrue(edgeIdIter.hasNext()); | ||
Set<Object> edges = Sets.newHashSet(edgeIdIter); | ||
assertEquals(2, edges.size()); | ||
} | ||
|
||
abstract protected Graph getGraph() throws IOException, ConfigurationException; | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it enough to only check the number of properties?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the version that was in CassandraInputFormatIT and was not modified in this PR. I think changing it would be out of scope here but maybe create an issue for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please create an issue.