Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: ntisseyre <ntisseyre@apple.com>
  • Loading branch information
ntisseyre committed Mar 20, 2024
1 parent cd91c52 commit dfbb92e
Show file tree
Hide file tree
Showing 18 changed files with 676 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
import org.janusgraph.graphdb.database.util.StaleIndexRecordUtil;
import org.janusgraph.graphdb.internal.ElementCategory;
import org.janusgraph.graphdb.internal.ElementLifeCycle;
import org.janusgraph.graphdb.internal.InternalElement;
import org.janusgraph.graphdb.internal.InternalRelationType;
import org.janusgraph.graphdb.internal.InternalVertex;
import org.janusgraph.graphdb.internal.Order;
Expand All @@ -129,7 +130,6 @@
import org.janusgraph.graphdb.query.condition.PredicateCondition;
import org.janusgraph.graphdb.query.index.IndexSelectionUtil;
import org.janusgraph.graphdb.query.profile.QueryProfiler;
import org.janusgraph.graphdb.relations.AbstractEdge;
import org.janusgraph.graphdb.relations.RelationIdentifier;
import org.janusgraph.graphdb.relations.StandardEdge;
import org.janusgraph.graphdb.relations.StandardVertexProperty;
Expand Down Expand Up @@ -425,7 +425,7 @@ public void testUpdatePropertyPropThenRemoveVertex() {
public void testUpdateEdgePropertyThenRemoveEdge() {
initializeGraphWithVerticesAndEdges();
// normal edge
AbstractEdge edge = (AbstractEdge) graph.traversal().E().has("_e", 1).next();
InternalElement edge = (InternalElement) graph.traversal().E().has("_e", 1).next();
assertTrue(ElementLifeCycle.isLoaded(edge.getLifeCycle()));
Object id = edge.id();

Expand All @@ -452,7 +452,7 @@ public void testUpdateEdgePropertyThenRemoveEdge() {
public void testUpdateForkEdgePropertyThenRemoveEdge() {
initializeGraphWithVerticesAndEdges();
// fork edge
AbstractEdge edge = (AbstractEdge) graph.traversal().E().has("_e", 2).next();
InternalElement edge = (InternalElement) graph.traversal().E().has("_e", 2).next();
assertTrue(ElementLifeCycle.isLoaded(edge.getLifeCycle()));
Object id = edge.id();

Expand Down Expand Up @@ -483,7 +483,7 @@ public void testUpdateForkEdgePropertyThenRemoveEdge() {
@Test
public void testUpdateForkEdgePropertyThenFindEdgeById() {
initializeGraphWithVerticesAndEdges();
AbstractEdge edge = (AbstractEdge) graph.traversal().E().has("_e", 2).next();
InternalElement edge = (InternalElement) graph.traversal().E().has("_e", 2).next();
Object id = edge.id();

edge.property("_e", -2);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2024 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;

import org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration;
import org.janusgraph.graphdb.transaction.StandardTransactionBuilder;

public class LazyLoadGraphTest extends StandardJanusGraph {
public LazyLoadGraphTest(GraphDatabaseConfiguration configuration) {
super(configuration);
}

@Override
public StandardTransactionBuilder buildTransaction() {
return (StandardTransactionBuilder) new StandardTransactionBuilder(getConfiguration(), this)
.lazyLoadRelations();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2024 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.core;

import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.diskstorage.Entry;
import org.janusgraph.graphdb.internal.InternalRelation;
import org.janusgraph.graphdb.internal.InternalRelationType;
import org.janusgraph.graphdb.internal.InternalVertex;
import org.janusgraph.graphdb.transaction.StandardJanusGraphTx;

public class JanusGraphLazyEdge extends JanusGraphLazyRelation implements JanusGraphEdge {

Check warning on line 25 in janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyEdge.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyEdge.java#L25

Added line #L25 was not covered by tests

public JanusGraphLazyEdge(InternalRelation janusGraphRelation,
final InternalVertex vertex,
final StandardJanusGraphTx tx,
final InternalRelationType type) {
super(janusGraphRelation, vertex, tx, type);
}

Check warning on line 32 in janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyEdge.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyEdge.java#L31-L32

Added lines #L31 - L32 were not covered by tests

public JanusGraphLazyEdge(Entry dataEntry,
final InternalVertex vertex,
final StandardJanusGraphTx tx,
final InternalRelationType type) {
super(dataEntry, vertex, tx, type);
}

Check warning on line 39 in janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyEdge.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyEdge.java#L38-L39

Added lines #L38 - L39 were not covered by tests

private JanusGraphEdge loadEdge() {
assert this.isEdge();
return (JanusGraphEdge) this.loadValue();

Check warning on line 43 in janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyEdge.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyEdge.java#L43

Added line #L43 was not covered by tests
}

@Override
public JanusGraphVertex vertex(Direction dir) {
return this.loadEdge().vertex(dir);

Check warning on line 48 in janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyEdge.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyEdge.java#L48

Added line #L48 was not covered by tests
}

@Override
public JanusGraphVertex otherVertex(Vertex vertex) {
return this.loadEdge().otherVertex(vertex);

Check warning on line 53 in janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyEdge.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyEdge.java#L53

Added line #L53 was not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2024 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.core;

import org.apache.tinkerpop.gremlin.structure.Property;
import org.janusgraph.diskstorage.Entry;
import org.janusgraph.graphdb.internal.InternalRelation;
import org.janusgraph.graphdb.internal.InternalRelationType;
import org.janusgraph.graphdb.internal.InternalVertex;
import org.janusgraph.graphdb.transaction.StandardJanusGraphTx;

import java.util.Iterator;

public class JanusGraphLazyProperty<V> extends JanusGraphLazyRelation<V> implements JanusGraphVertexProperty<V> {

Check warning on line 26 in janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyProperty.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyProperty.java#L26

Added line #L26 was not covered by tests

public JanusGraphLazyProperty(InternalRelation janusGraphRelation,
final InternalVertex vertex,
final StandardJanusGraphTx tx,
final InternalRelationType type) {
super(janusGraphRelation, vertex, tx, type);
}

Check warning on line 33 in janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyProperty.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyProperty.java#L32-L33

Added lines #L32 - L33 were not covered by tests

public JanusGraphLazyProperty(Entry dataEntry,
final InternalVertex vertex,
final StandardJanusGraphTx tx,
final InternalRelationType type) {
super(dataEntry, vertex, tx, type);
}

Check warning on line 40 in janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyProperty.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyProperty.java#L39-L40

Added lines #L39 - L40 were not covered by tests

private JanusGraphVertexProperty<V> loadProperty() {
assert this.isProperty();
return (JanusGraphVertexProperty) this.loadValue();

Check warning on line 44 in janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyProperty.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyProperty.java#L44

Added line #L44 was not covered by tests
}

@Override
public boolean isPresent() {
return loadProperty().isPresent();

Check warning on line 49 in janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyProperty.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyProperty.java#L49

Added line #L49 was not covered by tests
}

@Override
public JanusGraphVertex element() {
return loadProperty().element();

Check warning on line 54 in janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyProperty.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyProperty.java#L54

Added line #L54 was not covered by tests
}

@Override
public <V> Iterator<Property<V>> properties(String... propertyKeys) {
return this.loadProperty().properties(propertyKeys);

Check warning on line 59 in janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyProperty.java

View check run for this annotation

Codecov / codecov/patch

janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphLazyProperty.java#L59

Added line #L59 was not covered by tests
}
}
Loading

0 comments on commit dfbb92e

Please sign in to comment.