Skip to content

Commit

Permalink
Draft (Inlined properties into index structure)
Browse files Browse the repository at this point in the history
Signed-off-by: ntisseyre <[email protected]>
  • Loading branch information
ntisseyre committed Oct 15, 2024
1 parent 73232fe commit e02cacf
Show file tree
Hide file tree
Showing 27 changed files with 602 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9083,6 +9083,7 @@ public void testDirectCompositeIndexEntryModification() throws BackendException
IndexRecordEntry[] record = new IndexRecordEntry[]{new IndexRecordEntry(indexedProperty)};
JanusGraphElement element = (JanusGraphElement) vertex1;
Serializer serializer = graph.getDataSerializer();
EdgeSerializer edgeSerializer = graph.getEdgeSerializer();
boolean hashKeys = graph.getIndexSerializer().isHashKeys();
HashingUtil.HashLength hashLength = graph.getIndexSerializer().getHashLength();

Expand All @@ -9092,6 +9093,8 @@ public void testDirectCompositeIndexEntryModification() throws BackendException
record,
element,
serializer,
(StandardJanusGraphTx)tx,
edgeSerializer,
hashKeys,
hashLength
);
Expand All @@ -9116,6 +9119,8 @@ public void testDirectCompositeIndexEntryModification() throws BackendException
record,
element,
serializer,
(StandardJanusGraphTx)tx,
edgeSerializer,
hashKeys,
hashLength
);
Expand Down Expand Up @@ -9150,6 +9155,8 @@ record = new IndexRecordEntry[]{new IndexRecordEntry(propertyId, "vertex2", prop
record,
element,
serializer,
(StandardJanusGraphTx)tx,
edgeSerializer,
hashKeys,
hashLength
);
Expand All @@ -9176,6 +9183,8 @@ record = new IndexRecordEntry[]{new IndexRecordEntry(propertyKey.longId(), "vert
record,
element,
serializer,
(StandardJanusGraphTx)tx,
edgeSerializer,
hashKeys,
hashLength
);
Expand Down Expand Up @@ -9218,6 +9227,7 @@ public void testStaleIndexForceRemoveVertexFromGraphIndex() throws BackendExcept
JanusGraphSchemaVertex indexChangeVertex = managementSystem.getSchemaVertex(janusGraphIndex);
CompositeIndexType index = (CompositeIndexType) indexChangeVertex.asIndexType();
Serializer serializer = graph.getDataSerializer();
EdgeSerializer edgeSerializer = graph.getEdgeSerializer();
boolean hashKeys = graph.getIndexSerializer().isHashKeys();
HashingUtil.HashLength hashLength = graph.getIndexSerializer().getHashLength();

Expand All @@ -9238,6 +9248,8 @@ public void testStaleIndexForceRemoveVertexFromGraphIndex() throws BackendExcept
record,
element,
serializer,
(StandardJanusGraphTx)tx,
edgeSerializer,
hashKeys,
hashLength
);
Expand Down Expand Up @@ -9301,6 +9313,7 @@ public void testEdgeEntryIndexForceRemoveFromGraphIndex() throws BackendExceptio
JanusGraphSchemaVertex indexChangeVertex = managementSystem.getSchemaVertex(janusGraphIndex);
CompositeIndexType index = (CompositeIndexType) indexChangeVertex.asIndexType();
Serializer serializer = graph.getDataSerializer();
EdgeSerializer edgeSerializer = graph.getEdgeSerializer();
boolean hashKeys = graph.getIndexSerializer().isHashKeys();
HashingUtil.HashLength hashLength = graph.getIndexSerializer().getHashLength();
PropertyKey propertyKey = managementSystem.getPropertyKey(namePropKeyStr);
Expand Down Expand Up @@ -9334,6 +9347,8 @@ public void testEdgeEntryIndexForceRemoveFromGraphIndex() throws BackendExceptio
record,
element,
serializer,
(StandardJanusGraphTx)tx,
edgeSerializer,
hashKeys,
hashLength
);
Expand Down Expand Up @@ -9394,6 +9409,7 @@ public void testStaleIndexForceRemoveVertexFromGraphIndexByHelperMethod(boolean
JanusGraphSchemaVertex indexChangeVertex = managementSystem.getSchemaVertex(janusGraphIndex);
CompositeIndexType index = (CompositeIndexType) indexChangeVertex.asIndexType();
Serializer serializer = graph.getDataSerializer();
EdgeSerializer edgeSerializer = graph.getEdgeSerializer();
boolean hashKeys = graph.getIndexSerializer().isHashKeys();
HashingUtil.HashLength hashLength = graph.getIndexSerializer().getHashLength();

Expand Down Expand Up @@ -9422,6 +9438,8 @@ public void testStaleIndexForceRemoveVertexFromGraphIndexByHelperMethod(boolean
record,
element,
serializer,
(StandardJanusGraphTx)tx,
edgeSerializer,
hashKeys,
hashLength
);
Expand Down Expand Up @@ -10075,28 +10093,28 @@ private void invalidateUpdatedVertexProperty(StandardJanusGraph graph, Object ve
invalidateUpdatedVertexProperty(graph, vertexIdUpdated, propertyNameUpdated, previousPropertyValue, newPropertyValue, true);
}

private void invalidateUpdatedVertexProperty(StandardJanusGraph graph, Object vertexIdUpdated, String propertyNameUpdated, Object previousPropertyValue, Object newPropertyValue, boolean withIndexConstraintsFilter){
JanusGraphTransaction tx = graph.newTransaction();
private void invalidateUpdatedVertexProperty(StandardJanusGraph graph, Object vertexIdUpdated, String propertyNameUpdated, Object previousPropertyValue, Object newPropertyValue, boolean withIndexConstraintsFilter) {
StandardJanusGraphTx tx = (StandardJanusGraphTx) graph.newTransaction();
JanusGraphManagement graphMgmt = graph.openManagement();
PropertyKey propertyKey = graphMgmt.getPropertyKey(propertyNameUpdated);
CacheVertex cacheVertex = new CacheVertex((StandardJanusGraphTx) tx, vertexIdUpdated, ElementLifeCycle.Loaded);
CacheVertex cacheVertex = new CacheVertex(tx, vertexIdUpdated, ElementLifeCycle.Loaded);
StandardVertexProperty propertyPreviousVal = new StandardVertexProperty(propertyKey.longId(), propertyKey, cacheVertex, previousPropertyValue, ElementLifeCycle.Removed);
StandardVertexProperty propertyNewVal = new StandardVertexProperty(propertyKey.longId(), propertyKey, cacheVertex, newPropertyValue, ElementLifeCycle.New);
IndexSerializer indexSerializer = graph.getIndexSerializer();

Collection<IndexUpdate> indexUpdates;
if(withIndexConstraintsFilter){
indexUpdates = indexSerializer.getIndexUpdates(cacheVertex, Arrays.asList(propertyPreviousVal, propertyNewVal));
Stream<IndexUpdate> indexUpdates;
if (withIndexConstraintsFilter) {
indexUpdates = indexSerializer.getIndexUpdates(cacheVertex, Arrays.asList(propertyPreviousVal, propertyNewVal), tx);
} else {
indexUpdates = indexSerializer.getIndexUpdatesNoConstraints(cacheVertex, Arrays.asList(propertyPreviousVal, propertyNewVal));
indexUpdates = indexSerializer.getIndexUpdatesNoConstraints(cacheVertex, Arrays.asList(propertyPreviousVal, propertyNewVal), tx);
}

CacheInvalidationService invalidationService = graph.getDBCacheInvalidationService();

for(IndexUpdate indexUpdate : indexUpdates){
indexUpdates.forEach(indexUpdate -> {
StaticBuffer keyToInvalidate = (StaticBuffer) indexUpdate.getKey();
invalidationService.markKeyAsExpiredInIndexStore(keyToInvalidate);
}
});

invalidationService.forceClearExpiredKeysInIndexStoreCache();
invalidationService.forceInvalidateVertexInEdgeStoreCache(vertexIdUpdated);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ default Object id() {
*/
PropertyKey[] getFieldKeys();

/**
* Returns the inlined keys of this index.
*
* @return
*/
String[] getInlineFieldKeys();

/**
* Returns the parameters associated with an indexed key of this index. Parameters modify the indexing
* behavior of the underlying indexing backend.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ public interface JanusGraphManagement extends JanusGraphConfiguration, SchemaMan

void addIndexKey(final JanusGraphIndex index, final PropertyKey key, Parameter... parameters);

void addInlinePropertyKey(final JanusGraphIndex index, final PropertyKey key);

/**
* Builder for {@link JanusGraphIndex}. Allows for the configuration of a graph index prior to its construction.
*/
Expand All @@ -195,6 +197,13 @@ interface IndexBuilder {
*/
IndexBuilder addKey(PropertyKey key);

/**
* Adds the given key to inline properties of the composite key of this index
* @param key
* @return this IndexBuilder
*/
IndexBuilder addInlinePropertyKey(PropertyKey key);

/**
* Adds the given key and associated parameters to the composite key of this index
*
Expand Down
Loading

0 comments on commit e02cacf

Please sign in to comment.