Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

order().by(key) returns the elements without the key, which TinkerPop leaves out

Chiusa
#5,107 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Una pull request collegata è già stata integrata.

  • #5108 di @porunov — integrata

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
15/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
elasticsearch, java
Ambito
databases

Direzione di ricerca

Start by running the Groovy reproduction against inmemory storage and comparing it with TinkerGraph. The fold logic is in HasStepFolder.foldInOrder and validJanusGraphOrder, which feed JanusGraphStep, GraphCentricQueryBuilder.orderBy and OrderList, and the vertex-step path through BaseVertexCentricQueryBuilder.orderBy and BasicVertexCentricQueryBuilder.loadRelationsFromCache. Done means the counts and orders match TinkerGraph for each case, and the AssertionError and IllegalArgumentException no longer occur. PR #5108 already addresses this, so coordinate with it first.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

JanusGraph folds a traversal's order().by(key) into its query, and the query returns the elements which have no value of the key as well, after the others. TinkerPop leaves such an element out: a by() modulator which yields no value filters the traverser, so TinkerGraph returns only the elements which have the key.

Reproduction (inmemory storage; the same with a mixed index on kind and name, on Lucene or Elasticsearch):

g.addV().property('kind', 'p').property('name', 'c').iterate()
g.addV().property('kind', 'p').property('name', 'a').iterate()
g.addV().property('kind', 'p').iterate()
g.addV().property('kind', 'p').property('name', 'b').iterate()

g.V().has('kind', 'p').order().by('name').count()   // TinkerGraph: 3, JanusGraph: 4
g.V().has('kind', 'p').order().by('name')           // JanusGraph: a, b, c, then the vertex without a name

The same happens wherever JanusGraph folds the order in:

  • in a query which a mixed index sorts, one whose results a composite index gives and JanusGraph sorts, and one which no index answers;
  • for the vertices and edges which a transaction added or changed;
  • in an order of the edges or properties of a vertex, such as g.V(v).local(outE('link').order().by('weight').limit(2)). Descending, the edges without a weight come first there.

Related problems in the same code

  1. order().by('name', shuffle) throws an AssertionError from Order.convert: HasStepFolder.validJanusGraphOrder lets the order through.
  2. Of several order() steps in a row, such as order().by('age').order().by('name'), JanusGraph drops all but the last. So the elements without an age stay, and the ties of name aren't ordered by age, as TinkerPop's sorts, which keep the order of ties, order them. An earlier order by a traversal, such as order().by(values('age').is(gt(2))), is dropped too.
  3. g.V(v).local(outE('link').order().by('weight').by('uid')) throws IllegalArgumentException: Only a single sort order is supported on vertex queries.
  4. With query.batch.enabled, which is the default, g.V(v).local(outE('link').order().by('weight').limit(2)) returns the edges in the order in which the storage backend holds them, rather than by weight, where no vertex-centric index sorts the label's edges by weight. An ordered JanusGraphMultiVertexQuery, such as tx.multiQuery(v).labels('link').orderBy('weight', asc).edges(), returns them in that order too.
  5. With the deprecated ProductiveByStrategy, which makes by('name') yield null where a vertex has no name, TinkerPop places those vertices first when ascending, while JanusGraph folds the order in and places them last.

Cause

  • HasStepFolder.foldInOrder folds the keys of the order into the step. JanusGraphStep passes them to GraphCentricQueryBuilder.orderBy, whose query keeps an element without a value and places it last (OrderList). JanusGraphVertexStep and JanusGraphPropertiesStep do the same for a vertex's relations, which RelationComparator places last when ascending and first when descending.
  • validJanusGraphOrder takes any Order, shuffle included, and a by(key) whose ValueTraversal has a bypass traversal.
  • foldInOrder removes every order() step before the last, whatever its modulators.
  • BaseVertexCentricQueryBuilder.orderBy takes one key, while foldInOrder folds every key of the order into a vertex step.
  • BasicVertexCentricQueryBuilder.loadRelationsFromCache returns the relations which a multi-query loaded as they are when each subquery is cached and fitted, whether or not the backend sorts it by the query's order.
Lingua principale
Java
Stelle
5.9k
Fork
1.2k
Merge medio
2g 6h
PR unite (30g)
77

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di JanusGraph/janusgraph

Tutte le issue di JanusGraph/janusgraph

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.