Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-3110

Incorrect Bytecode when multiple options are used in traversal

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.7.3
    • server
    • None

    Description

      When multiple options like with("x",1).with("y",1) are used to build a traversal, the Bytecode building logic when constructing the traversal on the server keeps appending the Bytecode incrementally instead of replacing the previous Bytecode instruction.

      For a query like below:

      g
      .with('evaluationTimeout',300000L)
      .with('a', 1)
      .with('b', 2)
      .with('c', 3)
      .V()

      The Bytecode attached to traversal looks as:

      g
      .withStrategies(new org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.OptionsStrategy(evaluationTimeout: 300000L))
      .withStrategies(new org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.OptionsStrategy(evaluationTimeout: 300000L, a: (int) 1))
      .withStrategies(new org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.OptionsStrategy(evaluationTimeout: 300000L, a: (int) 1, b: (int) 2))
      .withStrategies(new org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.OptionsStrategy(evaluationTimeout: 300000L, a: (int) 1, b: (int) 2, c: (int) 3))
      .V() 

      Instead it should be just single instruction for OptionsStrategy as:

       

      g
      .withStrategies(new org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.OptionsStrategy(evaluationTimeout: 300000L, a: (int) 1, b: (int) 2, c: (int) 3))
      .V() 

       

      We always build a new OptionsStrategy here and carry over the previous options https://github.com/apache/tinkerpop/blob/master/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java#L116-L122

      as OptionsStrategy itself is immutable and we cannot add new options after creating it.

       

      We build the traversal strategies set and bytecode here:

      https://github.com/apache/tinkerpop/blob/master/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java#L132-L133

       

      The traversal strategies set itself is built correctly and we remove duplicates https://github.com/apache/tinkerpop/blob/master/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalStrategies.java#L42-L50

       

      But Bytecode just appends the new strategy as instruction https://github.com/apache/tinkerpop/blob/master/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Bytecode.java#L82-L83

       

      Attachments

        Activity

          People

            xiazcy Yang Xia
            saikiranboga Saikiran Boga
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: