Skip to content

Commit

Permalink
Reindex test
Browse files Browse the repository at this point in the history
Signed-off-by: ntisseyre <[email protected]>
  • Loading branch information
ntisseyre committed Oct 17, 2024
1 parent ef678e2 commit b76766a
Showing 1 changed file with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import org.janusgraph.diskstorage.indexing.IndexInformation;
import org.janusgraph.diskstorage.indexing.IndexProvider;
import org.janusgraph.diskstorage.indexing.IndexTransaction;
import org.janusgraph.diskstorage.keycolumnvalue.scan.ScanJobFuture;
import org.janusgraph.diskstorage.log.kcvs.KCVSLog;
import org.janusgraph.diskstorage.util.time.TimestampProvider;
import org.janusgraph.example.GraphOfTheGodsFactory;
Expand Down Expand Up @@ -1487,6 +1488,66 @@ public void testIndexInlineProperties() throws NoSuchMethodException {
assertEquals(city, v.value("city"));
}

@Test
public void testIndexInlinePropertiesReindex() throws NoSuchMethodException, ExecutionException, InterruptedException {

clopen(option(FORCE_INDEX_USAGE), true);

PropertyKey idKey = makeKey("id", Integer.class);
PropertyKey nameKey = makeKey("name", String.class);
PropertyKey cityKey = makeKey("city", String.class);

mgmt.buildIndex("composite", Vertex.class)
.addKey(cityKey)
.buildCompositeIndex();

finishSchema();

String city = "Chicago";
for (int i = 0; i < 3; i++) {
tx.addVertex("id", i, "name", "name" + i, "city", city);
}

tx.commit();

tx = graph.buildTransaction()
.propertyPrefetching(false) //this is important
.start();

Method m = VertexCentricQueryBuilder.class.getSuperclass().getDeclaredMethod("constructQuery", RelationCategory.class);
m.setAccessible(true);

List<Vertex> vertices = tx.traversal().V().has("city", city).toList();
vertices.stream()
.map(v -> (CacheVertex) v)
.forEach(v -> verifyPropertyLoaded(v, "name", false, m));

tx.commit();

//Include inlined property and reindex
JanusGraphIndex index = mgmt.getGraphIndex("composite");
nameKey = mgmt.getPropertyKey("name");
mgmt.addInlinePropertyKey(index, nameKey);
ScanJobFuture scanJobFuture = mgmt.updateIndex(index, SchemaAction.REINDEX);
finishSchema();

while (!scanJobFuture.isDone()) {
Thread.sleep(1000);
}

//Try query now
tx = graph.buildTransaction()
.propertyPrefetching(false) //this is important
.start();

List<Vertex> vertices2 = tx.traversal().V().has("city", city).toList();
vertices2.stream()
.map(v -> (CacheVertex) v)
.forEach(v -> verifyPropertyLoaded(v, "name", true, m));

tx.commit();
}

@Test
public void testIndexInlinePropertiesUpdate() {

Expand Down

0 comments on commit b76766a

Please sign in to comment.