Skip to content

Commit

Permalink
Making lazy-load relations TRUE by default
Browse files Browse the repository at this point in the history
Signed-off-by: ntisseyre <ntisseyre@apple.com>
[cql-tests][tp-tests]
  • Loading branch information
ntisseyre committed Apr 14, 2024
1 parent d725e10 commit 55bcad2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,14 @@ public void testKCVSAccess1() {
v = getV(tx,v);
assertCount(2, v.properties());
verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 2L)); //1 verify vertex existence, 1 for query
verifyTypeCacheMetrics(3, 4);
verifyTypeCacheMetrics(3, 2);
tx.commit();

tx = graph.buildTransaction().groupName(metricsPrefix).start();
v = getV(tx,v);
assertCount(2, v.properties());
verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 4L)); //1 verify vertex existence, 1 for query
verifyTypeCacheMetrics(3, 4);
verifyTypeCacheMetrics(3, 2);
tx.commit();

//Check type index lookup caching
Expand All @@ -343,7 +343,7 @@ public void testKCVSAccess1() {
assertNotNull(v.value("name"));
assertCount(1, v.query().direction(Direction.BOTH).edges());
verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 11L)); //1 verify vertex existence, 3 for query
verifyTypeCacheMetrics(5, 10);
verifyTypeCacheMetrics(5, 9);
tx.commit();

verifyLockingOverwrite(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
import org.janusgraph.testutil.TestGraphConfigs;
import org.janusgraph.util.IDUtils;
import org.janusgraph.util.stats.MetricManager;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -2644,7 +2645,8 @@ public void testPropertyIdAccessInDifferentTransaction() {

// access property id in new transaction
graph.tx().commit();
assertEquals(expectedId, p.id());
Exception exception = Assert.assertThrows(IllegalStateException.class, p::id);
assertEquals(exception.getMessage(), "Any lazy load operation is not supported when transaction is already closed.");
}

/**
Expand Down Expand Up @@ -6286,10 +6288,15 @@ protected TraversalMetrics testLimitedBatch(Supplier<GraphTraversal<?, ?>> trave
}

private void assertEqualResultWithAndWithoutLimitBatchSize(Supplier<GraphTraversal<?, ?>> traversal) {
boolean isLazyLoad = ((StandardJanusGraphTx) tx).getConfiguration().isLazyLoadRelations();
clopen(option(USE_MULTIQUERY), true, option(LIMITED_BATCH), true);
final List<?> resultLimitedBatch = traversal.get().toList();
if (isLazyLoad) resultLimitedBatch.forEach(Object::hashCode);

clopen(option(USE_MULTIQUERY), true, option(LIMITED_BATCH), false);
final List<?> resultUnimitedBatch = traversal.get().toList();
if (isLazyLoad) resultUnimitedBatch.forEach(Object::hashCode);

clopen(option(USE_MULTIQUERY), false);
final List<?> resultNoMultiQuery = traversal.get().toList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public class StandardTransactionBuilder implements TransactionConfiguration, Tra

private boolean skipDBCacheRead;

private boolean isLazyLoadRelations;
private boolean isLazyLoadRelations = true;

private MultiQueryHasStepStrategyMode hasStepStrategyMode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@

package org.janusgraph.graphdb.inmemory;

import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.janusgraph.core.JanusGraphVertex;
import org.janusgraph.diskstorage.configuration.WriteConfiguration;
import org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder;
import org.janusgraph.graphdb.database.LazyLoadGraphTest;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertThrows;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* @author Matthias Broecheler (me@matthiasb.com)
Expand All @@ -36,18 +30,4 @@ public void open(WriteConfiguration config) {
tx = graph.buildTransaction().start();
mgmt = graph.openManagement();
}

@Override @Test
public void testPropertyIdAccessInDifferentTransaction() {
JanusGraphVertex v1 = graph.addVertex();
Object expectedId = v1.property("name", "foo").id();
graph.tx().commit();

VertexProperty p = getOnlyElement(v1.properties("name"));

// access property id in new transaction
graph.tx().commit();
Exception exception = assertThrows(IllegalStateException.class, p::id);
assertEquals(exception.getMessage(), "Any lazy load operation is not supported when transaction is already closed.");
}
}

0 comments on commit 55bcad2

Please sign in to comment.