Skip to content

Commit

Permalink
Code cleanup, add missing headers, fix legacy names and update docume…
Browse files Browse the repository at this point in the history
…ntation

Signed-off-by: sjudeng <[email protected]>
  • Loading branch information
sjudeng committed Feb 9, 2017
1 parent a4ace7b commit c2431d5
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@
@Graph.OptOut(
test = "org.apache.tinkerpop.gremlin.structure.io.IoTest$GraphMLTest",
method = "shouldReadGraphMLWithNoEdgeLabels",
reason = "Titan does not support default edge label (edge) used when GraphML is missing edge labels.")
reason = "JanusGraph does not support default edge label (edge) used when GraphML is missing edge labels.")
@Graph.OptOut(
test = "org.apache.tinkerpop.gremlin.process.computer.GraphComputerTest",
method = "shouldSupportGraphFilter",
reason = "Titan currently does not support graph filters but does not throw proper exception because doing so breaks numerous tests in gremlin-test ProcessComputerSuite.")
reason = "JanusGraph test graph computer (FulgoraGraphComputer) " +
"currently does not support graph filters but does not throw proper exception because doing so breaks numerous " +
"tests in gremlin-test ProcessComputerSuite.")
public interface JanusGraph extends Transaction {

/* ---------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// 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.graphdb.database.serialize.attribute;

import org.janusgraph.core.attribute.AttributeSerializer;
Expand All @@ -9,8 +23,11 @@
import org.apache.commons.lang3.SerializationUtils;

import java.io.Serializable;
import java.util.HashMap;

/**
* Serializes {@link Serializable} objects.
* @param <T> Serializable type
*/
public class SerializableSerializer<T extends Serializable> implements AttributeSerializer<T>, SerializerInjected {

private Serializer serializer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class FulgoraMemory implements Memory.Admin {
public Map<String, Object> currentMap;
private final AtomicInteger iteration = new AtomicInteger(0);
private final AtomicLong runtime = new AtomicLong(0l);
private boolean inExecute = false;
private volatile boolean inExecute = false;

public FulgoraMemory(final VertexProgram<?> vertexProgram, final Set<MapReduce> mapReducers) {
this.currentMap = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -158,9 +158,7 @@ protected void attachReferenceElements(Graph graph) {
}

private static void attachReferenceElements(TraverserSet<Object> toProcessTraversers, Graph graph) {
final Iterator<Traverser.Admin<Object>> traversers = toProcessTraversers.iterator();
while (traversers.hasNext()) {
final Traverser.Admin<Object> traverser = traversers.next();
toProcessTraversers.stream().forEach(traverser -> {
Object value = traverser.get();
if (value instanceof ReferenceVertex) {
Vertex vertex = ((ReferenceVertex) value).attach(Attachable.Method.get(graph));
Expand All @@ -169,7 +167,7 @@ private static void attachReferenceElements(TraverserSet<Object> toProcessTraver
Edge edge = ((ReferenceEdge) value).attach(Attachable.Method.get(graph));
traverser.set(edge);
}
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public <V> Iterator<VertexProperty<V>> properties(String... keys) {
if (keys==null || keys.length==0) {
keys = memoryKeys.stream().filter(k -> !k.equals(TraversalVertexProgram.HALTED_TRAVERSERS)).toArray(String[]::new);
}
List<VertexProperty<V>> result = new ArrayList<>(Math.min(keys.length,memoryKeys.size()));
final List<VertexProperty<V>> result = new ArrayList<>(Math.min(keys.length,memoryKeys.size()));
for (String key : keys) {
if (!supports(key)) continue;
V value = vertexMemory.getProperty(vertexId,key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
public class JanusGraphSONModule extends TinkerPopJacksonModule {

private static final String TYPE_NAMESPACE = "titan";
private static final String TYPE_NAMESPACE = "janusgraph";

private static final Map<Class, String> TYPE_DEFINITIONS = Collections.unmodifiableMap(
new LinkedHashMap<Class, String>() {{
Expand All @@ -48,7 +48,7 @@ public class JanusGraphSONModule extends TinkerPopJacksonModule {
}});

private JanusGraphSONModule() {
super("titan");
super("janusgraph");
addSerializer(RelationIdentifier.class, new RelationIdentifierSerializer());
addSerializer(Geoshape.class, new Geoshape.GeoshapeGsonSerializer());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public void apply(final Traversal.Admin<?, ?> traversal) {
Graph graph = traversal.getGraph().get();

//If this is a compute graph then we can't apply local traversal optimisation at this stage.
StandardJanusGraph titanGraph = graph instanceof StandardJanusGraphTx ? ((StandardJanusGraphTx) graph).getGraph() : (StandardJanusGraph) graph;
final boolean useMultiQuery = !TraversalHelper.onGraphComputer(traversal) && titanGraph.getConfiguration().useMultiQuery();
StandardJanusGraph janusGraph = graph instanceof StandardJanusGraphTx ? ((StandardJanusGraphTx) graph).getGraph() : (StandardJanusGraph) graph;
final boolean useMultiQuery = !TraversalHelper.onGraphComputer(traversal) && janusGraph.getConfiguration().useMultiQuery();

/*
====== VERTEX STEP ======
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public List<HasContainer> getHasContainers() {

@Override
public void addHasContainer(final HasContainer hasContainer) {
this.addAll(Collections.singleton(hasContainer));
this.addAll(Collections.singleton(hasContainer));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public void apply(final Traversal.Admin<?, ?> traversal) {
TraversalHelper.getStepsOfClass(GraphStep.class, traversal).forEach(originalGraphStep -> {
if (originalGraphStep.getIds() == null || originalGraphStep.getIds().length == 0) {
//Try to optimize for index calls
final JanusGraphStep<?, ?> titanGraphStep = new JanusGraphStep<>(originalGraphStep);
TraversalHelper.replaceStep(originalGraphStep, (Step) titanGraphStep, traversal);
HasStepFolder.foldInHasContainer(titanGraphStep, traversal);
HasStepFolder.foldInOrder(titanGraphStep, traversal, traversal, titanGraphStep.returnsVertex());
HasStepFolder.foldInRange(titanGraphStep, traversal);
final JanusGraphStep<?, ?> janusGraphStep = new JanusGraphStep<>(originalGraphStep);
TraversalHelper.replaceStep(originalGraphStep, (Step) janusGraphStep, traversal);
HasStepFolder.foldInHasContainer(janusGraphStep, traversal);
HasStepFolder.foldInOrder(janusGraphStep, traversal, traversal, janusGraphStep.returnsVertex());
HasStepFolder.foldInRange(janusGraphStep, traversal);
} else {
//Make sure that any provided "start" elements are instantiated in the current transaction
Object[] ids = originalGraphStep.getIds();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3456,15 +3456,11 @@ public void testTinkerPopOptimizationStrategies() {
t = gts.V().has("id", sid).local(__.outE("knows").has("weight", P.between(1, 3)).order().by("weight", decr).limit(10)).profile("~metrics");
assertCount(superV * 10, t);
metrics = (TraversalMetrics) t.asAdmin().getSideEffects().get("~metrics");
//verifyMetrics(metrics.getMetrics(0), true, false);
//verifyMetrics(metrics.getMetrics(1), true, true);

//Verify that properties also use multi query
t = gts.V().has("id", sid).values("names").profile("~metrics");
assertCount(superV * numV, t);
metrics = (TraversalMetrics) t.asAdmin().getSideEffects().get("~metrics");
//verifyMetrics(metrics.getMetrics(0), true, false);
//verifyMetrics(metrics.getMetrics(1), true, true);

clopen(option(USE_MULTIQUERY), true);
gts = graph.traversal();
Expand All @@ -3473,17 +3469,11 @@ public void testTinkerPopOptimizationStrategies() {
t = gts.V().has("id", sid).local(__.outE("knows").has("weight", P.gte(1)).has("weight", P.lt(3)).order().by("weight", decr).limit(10)).profile("~metrics");
assertCount(superV * 10, t);
metrics = (TraversalMetrics) t.asAdmin().getSideEffects().get("~metrics");
// System.out.println(metrics);
//verifyMetrics(metrics.getMetrics(0), false, false);
//verifyMetrics(metrics.getMetrics(1), false, true);

//Verify that properties also use multi query [same query as above]
t = gts.V().has("id", sid).values("names").profile("~metrics");
assertCount(superV * numV, t);
metrics = (TraversalMetrics) t.asAdmin().getSideEffects().get("~metrics");
// System.out.println(metrics);
//verifyMetrics(metrics.getMetrics(0), false, false);
//verifyMetrics(metrics.getMetrics(1), false, true);

}

Expand Down

0 comments on commit c2431d5

Please sign in to comment.