You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by Stephen Mallette <sp...@gmail.com> on 2018/10/03 09:01:24 UTC
[DISCUSS] Modulated valueMap()
valueMap() is a really convenient step:
gremlin> g.V().has('person','name','marko').valueMap()
==>[name:[marko],age:[29]]
or perhaps more preferably:
gremlin> g.V().has('person','name','marko').valueMap('name','age')
==>[name:[marko],age:[29]]
but argh - multiproperties ruin everything. so then we're forced into
Gremlin acrobatics:
gremlin> g.V().has('name','marko').
......1> valueMap('name','age').
......2> unfold().
......3> group().
......4> by(keys).
......5> by(select(values).unfold())
==>[name:marko,age:29]
or as I usually recommend, use project():
gremlin>
g.V().has('person','name','marko').project('name','age').by('name').by('age')
==>[name:marko,age:29]
which is fine, but you pretty much have to type a lot more especially if
there are a lot of properties to contend with. What if we were to modulate
valueMap() with by(Traversal) so that:
g.V().has('person','name','marko').
valueMap('name','age').
by(unfold())
and the by() are just applied round-robin on the keys? Thoughts?
Re: [DISCUSS] Modulated valueMap()
Posted by Stephen Mallette <sp...@gmail.com>.
Created this for tracking and additional discussion:
https://issues.apache.org/jira/browse/TINKERPOP-2059
On Wed, Oct 3, 2018 at 1:19 PM Daniel Kuppitz <me...@gremlin.guru> wrote:
> Yea, that's weird. My code was actually pseudo-code, I wasn't referring to
> T.id and T.label, we would have String some constants as we do for other
> with() modulations. Perhaps:
>
> valueMap().with(Tokens.all)
> valueMap().with(Tokens.label)
> valueMap().with(Tokens.id)
>
>
> Cheers,
> Daniel
>
> On Wed, Oct 3, 2018 at 10:14 AM Stephen Mallette <sp...@gmail.com>
> wrote:
>
> > I thought about using with() for this in some way but figured by() was
> the
> > right direction. i like your idea, but with(String) won't take
> with(label)
> > or with(id) right? can we use by() again? We already have by(T) as a
> > modulator:
> >
> > g.V().
> > valueMap().
> > by(id).
> > by(label).
> > by(unfold())
> >
> > Looks a little weird though...maybe?
> >
> >
> > On Wed, Oct 3, 2018 at 10:19 AM Daniel Kuppitz <me...@gremlin.guru> wrote:
> >
> > > Good idea! Also, when I saw the subject of your email, I thought you
> were
> > > about to propose something like .with(label), .with(id) or
> .with(tokens)
> > -
> > > I would like that too as valueMap is the only step that takes a boolean
> > > parameter that changes its behavior.
> > >
> > > Cheers,
> > > Daniel
> > >
> > >
> > > On Wed, Oct 3, 2018, 2:01 AM Stephen Mallette <sp...@gmail.com>
> > > wrote:
> > >
> > > > valueMap() is a really convenient step:
> > > >
> > > > gremlin> g.V().has('person','name','marko').valueMap()
> > > > ==>[name:[marko],age:[29]]
> > > >
> > > > or perhaps more preferably:
> > > >
> > > > gremlin> g.V().has('person','name','marko').valueMap('name','age')
> > > > ==>[name:[marko],age:[29]]
> > > >
> > > > but argh - multiproperties ruin everything. so then we're forced into
> > > > Gremlin acrobatics:
> > > >
> > > > gremlin> g.V().has('name','marko').
> > > > ......1> valueMap('name','age').
> > > > ......2> unfold().
> > > > ......3> group().
> > > > ......4> by(keys).
> > > > ......5> by(select(values).unfold())
> > > > ==>[name:marko,age:29]
> > > >
> > > > or as I usually recommend, use project():
> > > >
> > > > gremlin>
> > > >
> > > >
> > >
> >
> g.V().has('person','name','marko').project('name','age').by('name').by('age')
> > > > ==>[name:marko,age:29]
> > > >
> > > > which is fine, but you pretty much have to type a lot more especially
> > if
> > > > there are a lot of properties to contend with. What if we were to
> > > modulate
> > > > valueMap() with by(Traversal) so that:
> > > >
> > > > g.V().has('person','name','marko').
> > > > valueMap('name','age').
> > > > by(unfold())
> > > >
> > > > and the by() are just applied round-robin on the keys? Thoughts?
> > > >
> > >
> >
>
Re: [DISCUSS] Modulated valueMap()
Posted by Daniel Kuppitz <me...@gremlin.guru>.
Yea, that's weird. My code was actually pseudo-code, I wasn't referring to
T.id and T.label, we would have String some constants as we do for other
with() modulations. Perhaps:
valueMap().with(Tokens.all)
valueMap().with(Tokens.label)
valueMap().with(Tokens.id)
Cheers,
Daniel
On Wed, Oct 3, 2018 at 10:14 AM Stephen Mallette <sp...@gmail.com>
wrote:
> I thought about using with() for this in some way but figured by() was the
> right direction. i like your idea, but with(String) won't take with(label)
> or with(id) right? can we use by() again? We already have by(T) as a
> modulator:
>
> g.V().
> valueMap().
> by(id).
> by(label).
> by(unfold())
>
> Looks a little weird though...maybe?
>
>
> On Wed, Oct 3, 2018 at 10:19 AM Daniel Kuppitz <me...@gremlin.guru> wrote:
>
> > Good idea! Also, when I saw the subject of your email, I thought you were
> > about to propose something like .with(label), .with(id) or .with(tokens)
> -
> > I would like that too as valueMap is the only step that takes a boolean
> > parameter that changes its behavior.
> >
> > Cheers,
> > Daniel
> >
> >
> > On Wed, Oct 3, 2018, 2:01 AM Stephen Mallette <sp...@gmail.com>
> > wrote:
> >
> > > valueMap() is a really convenient step:
> > >
> > > gremlin> g.V().has('person','name','marko').valueMap()
> > > ==>[name:[marko],age:[29]]
> > >
> > > or perhaps more preferably:
> > >
> > > gremlin> g.V().has('person','name','marko').valueMap('name','age')
> > > ==>[name:[marko],age:[29]]
> > >
> > > but argh - multiproperties ruin everything. so then we're forced into
> > > Gremlin acrobatics:
> > >
> > > gremlin> g.V().has('name','marko').
> > > ......1> valueMap('name','age').
> > > ......2> unfold().
> > > ......3> group().
> > > ......4> by(keys).
> > > ......5> by(select(values).unfold())
> > > ==>[name:marko,age:29]
> > >
> > > or as I usually recommend, use project():
> > >
> > > gremlin>
> > >
> > >
> >
> g.V().has('person','name','marko').project('name','age').by('name').by('age')
> > > ==>[name:marko,age:29]
> > >
> > > which is fine, but you pretty much have to type a lot more especially
> if
> > > there are a lot of properties to contend with. What if we were to
> > modulate
> > > valueMap() with by(Traversal) so that:
> > >
> > > g.V().has('person','name','marko').
> > > valueMap('name','age').
> > > by(unfold())
> > >
> > > and the by() are just applied round-robin on the keys? Thoughts?
> > >
> >
>
Re: [DISCUSS] Modulated valueMap()
Posted by Stephen Mallette <sp...@gmail.com>.
I thought about using with() for this in some way but figured by() was the
right direction. i like your idea, but with(String) won't take with(label)
or with(id) right? can we use by() again? We already have by(T) as a
modulator:
g.V().
valueMap().
by(id).
by(label).
by(unfold())
Looks a little weird though...maybe?
On Wed, Oct 3, 2018 at 10:19 AM Daniel Kuppitz <me...@gremlin.guru> wrote:
> Good idea! Also, when I saw the subject of your email, I thought you were
> about to propose something like .with(label), .with(id) or .with(tokens) -
> I would like that too as valueMap is the only step that takes a boolean
> parameter that changes its behavior.
>
> Cheers,
> Daniel
>
>
> On Wed, Oct 3, 2018, 2:01 AM Stephen Mallette <sp...@gmail.com>
> wrote:
>
> > valueMap() is a really convenient step:
> >
> > gremlin> g.V().has('person','name','marko').valueMap()
> > ==>[name:[marko],age:[29]]
> >
> > or perhaps more preferably:
> >
> > gremlin> g.V().has('person','name','marko').valueMap('name','age')
> > ==>[name:[marko],age:[29]]
> >
> > but argh - multiproperties ruin everything. so then we're forced into
> > Gremlin acrobatics:
> >
> > gremlin> g.V().has('name','marko').
> > ......1> valueMap('name','age').
> > ......2> unfold().
> > ......3> group().
> > ......4> by(keys).
> > ......5> by(select(values).unfold())
> > ==>[name:marko,age:29]
> >
> > or as I usually recommend, use project():
> >
> > gremlin>
> >
> >
> g.V().has('person','name','marko').project('name','age').by('name').by('age')
> > ==>[name:marko,age:29]
> >
> > which is fine, but you pretty much have to type a lot more especially if
> > there are a lot of properties to contend with. What if we were to
> modulate
> > valueMap() with by(Traversal) so that:
> >
> > g.V().has('person','name','marko').
> > valueMap('name','age').
> > by(unfold())
> >
> > and the by() are just applied round-robin on the keys? Thoughts?
> >
>
Re: [DISCUSS] Modulated valueMap()
Posted by Daniel Kuppitz <me...@gremlin.guru>.
Good idea! Also, when I saw the subject of your email, I thought you were
about to propose something like .with(label), .with(id) or .with(tokens) -
I would like that too as valueMap is the only step that takes a boolean
parameter that changes its behavior.
Cheers,
Daniel
On Wed, Oct 3, 2018, 2:01 AM Stephen Mallette <sp...@gmail.com> wrote:
> valueMap() is a really convenient step:
>
> gremlin> g.V().has('person','name','marko').valueMap()
> ==>[name:[marko],age:[29]]
>
> or perhaps more preferably:
>
> gremlin> g.V().has('person','name','marko').valueMap('name','age')
> ==>[name:[marko],age:[29]]
>
> but argh - multiproperties ruin everything. so then we're forced into
> Gremlin acrobatics:
>
> gremlin> g.V().has('name','marko').
> ......1> valueMap('name','age').
> ......2> unfold().
> ......3> group().
> ......4> by(keys).
> ......5> by(select(values).unfold())
> ==>[name:marko,age:29]
>
> or as I usually recommend, use project():
>
> gremlin>
>
> g.V().has('person','name','marko').project('name','age').by('name').by('age')
> ==>[name:marko,age:29]
>
> which is fine, but you pretty much have to type a lot more especially if
> there are a lot of properties to contend with. What if we were to modulate
> valueMap() with by(Traversal) so that:
>
> g.V().has('person','name','marko').
> valueMap('name','age').
> by(unfold())
>
> and the by() are just applied round-robin on the keys? Thoughts?
>