Repository navigation
Conversation
An edge of a MULTI label with a sort key is stored under the column [type+dir][sortKey][adjacentVertex][relationId], but RelationIdentifier carries only relationId, outVertexId, typeId and inVertexId. Resolving an identifier (g.E(id), mixed and composite edge index hits) could therefore only slice [type+dir] and read every edge of the label on the vertex. With the new option graph.relation-id-sort-key (MASKABLE, default false), identifiers of such edges carry their encoded sort-key values, and resolving them reads a single column. A lookup that misses falls back to the scan. The string form gains an optional fifth token K<hex> and GraphBinary two new in-vertex markers; ids without a sort key keep their exact format, and equals/hashCode are unchanged. Mixed index deletes and reindex remove documents under either id form, and composite edge index entries append the sort key after the in-vertex id. Also fixes EdgeSerializer.getQuery reassigning keyEndPos on every implicit-key position, which flipped the adjacent vertex bytes for DESC labels when the sort key, adjacent vertex and relation id were all constrained, so the query never matched the stored column. Fixes JanusGraph#4923 Signed-off-by: Balmukund Trivedi <btrivedipublic@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 of 9 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4923.
For a
MULTIlabel with a sort key, the edge column is[type+dir][sortKey][adjacent][relationId], butRelationIdentifierhas no sort-key values. So resolving an edge id (g.E(id), mixed and composite edge index hits) slices only[type+dir]and reads every edge of the label on the vertex.Change
graph.relation-id-sort-key(MASKABLE, defaultfalse; nothing changes unless enabled). With it on, ids of such edges carry their encoded sort-key values and resolve with a single-column read. A miss falls back to the scan, so a wrong sort key cannot hide an edge.K<hex>, and two new GraphBinary in-vertex markers. Both are written only when a sort key is present.equals/hashCodeare unchanged. Gryo/Java serialization keep their format.FORKlabels, sort keys over 64 encoded bytes, and ids taken after the edge's transaction closed keep the old form.EdgeSerializer.getQueryreassignedkeyEndPosper implicit key. With sort key + adjacent + relation id constrained on aDESClabel, that flipped the adjacent vertex bytes and the slice never matched. Happy to split this into its own PR.Tests
JanusGraphOperationCountingTest: with 100 edges of one label on a vertex, resolving one edge reads 1 edgestore entry with the sort key and ≥100 without. Covered for ASC, DESC and a two-key sort key, viag.E(id), the string form and composite index hits.JanusGraphIndexTest: mixed index hits (ASC/DESC) read one column; delete and reindex remove either doc id form.EdgeSerializerTestfor the DESC query (fails without the fix).For all changes:
master)?For code changes:
For documentation related changes:
🤖 Generated with Claude Code