How can I write a project using an inject that doesn't exhaust itself?

Take the following example query: g.inject("1", "2", "3").project("list").by(__.inject("b").fold()).toList() its result is [{list=[1, b]}, {list=[2]}, {list=[3]}] I'd like to see [{list=[1, b]}, {list=[2, b]}, {list=[3, b]}] instead How can I accomplish this?
4 Replies
Flynnt
Flynnt11mo ago
have you try : g.inject("1", "2", "3").project("list").by(__.union(identity(),constant("b")).fold()).toList()
spmallette
spmallette11mo ago
+1 to constant() in this case.
danielcraig23
danielcraig2311mo ago
stephen mallette
constant() Is Not inject()
The constant() step looks a bit like inject(). Both look like they take some arbitrary “constant” sort of value and “inject” it into the traversal stream.
danielcraig23
danielcraig2311mo ago
I'll try again with this pattern Thanks, I was able to get my issue sorted out with this pattern!
Want results from more Discord servers?
Add your server
More Posts
ReadOnlyStrategy for remote script execution to make a read only server instanceHi all, I am setting up a read only cluster of gremlin server, I have conifgured the initialization Pass label to coalesceWhen I want to pass a label to a `coalesce` step I get follwoing error: ``` "addE(occupied) failed Can I use a query to export data in the form of a query?In the SQL world you can use SQL Developer to generate INSERT statements from the results of a queryGremlin query to give response for 1 and 2 hops at same timeI have a graph setup with certain type of vertices like: inputFiles, outputFiles, convertors conveConnect and work with JGHi Guys. I'm looking for assistance with connecting to a JanusGraph database using Angular and TypeSAdd Multiple addV() by one IterateHello guys, I have crazy question which needs some experts to help me. I am using C# to add many nodMetricRegistry DocumentationIs there documentation anywhere on the metrics provided by the `MetricRegistry` and what their meaniHow do I enable Dynamic Graphs while using the default Docker image `janusgraph/janusgraph:latest`?With the following configuration settings and using the default `g` alias I can work with gremlin/JaEncounter strange behaviors in "match()" stepHello! Sorry for bothering you once again. When I further investigate the problem I post at https://[parameterized queries] Increased time in query evaluation when gremlin server starts/restartsHi folks, High latency observed in query evaluation time whenever janusgraph server restarts/starts