by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 23 01:43

    mpollmeier on v3.4.7.2

    (compare)

  • Jul 23 01:36

    mpollmeier on master

    Handle Set properties in Marsha… Merge pull request #293 from jt… (compare)

  • Jul 23 01:36
    mpollmeier closed #293
  • Jul 23 01:36
    mpollmeier commented #293
  • Jul 22 18:30
    jtarvydas synchronize #293
  • Jul 22 17:38
    jeremysears commented #293
  • Jul 22 16:49
    jtarvydas opened #293
  • Jul 19 03:27

    mpollmeier on v3.4.7.1

    (compare)

  • Jul 19 03:20

    mpollmeier on master

    trigger release (compare)

  • Jul 19 03:20

    mpollmeier on v3.4.7.0

    (compare)

  • Jul 19 03:16

    mpollmeier on v3.4.4.7

    (compare)

  • Jul 19 03:08

    mpollmeier on master

    tinkerpop 3.4.7 (compare)

  • Jul 19 03:01

    mpollmeier on v3.4.4.6

    (compare)

  • Jul 19 02:53

    mpollmeier on master

    upgrade scala/sbt (compare)

  • Mar 20 10:24
    nilay0016 opened #292
  • Jan 31 09:24
    hubertp closed #291
  • Jan 31 09:24
    hubertp commented #291
  • Jan 29 20:31
    mpollmeier review_requested #291
  • Jan 29 20:18

    mpollmeier on v3.4.4.5

    (compare)

  • Jan 29 20:10

    mpollmeier on master

    use 2.13.0 for cross-build bac… (compare)

Haruhiko Nishi
@hanishi
This sort of worked in case when a Vertex possesses a property with List/Set cardinality, but looks very ugly. Is there a better way to write the same?
@mpollmeier
implicit class copyVertexProperties(aux: GremlinScala.Aux[Vertex, HNil]) {

    def copyProperties[A](source: Vertex, keys: Key[A]*): GremlinScala.Aux[Vertex, HNil] = {
      keys.foreach(
        key =>
          source
            .properties(key.name)
            .forEachRemaining((property: VertexProperty[A]) => setProperty(aux, key, property)))
      aux
    }

    private def setProperty[A](aux: GremlinScala.Aux[Vertex, HNil],
                               key: Key[A],
                               property: VertexProperty[A]): Unit = {
      aux.property(key, property.value)
      ()
    }
  }
Haruhiko Nishi
@hanishi

v.setPropertyList(TestProperty, List("one", "two", "three"))
This doesn't seem to be available anymore?

My build broke as 3.4.1.13 seemed to be longer available. When I fetched the latest3.4.4.3 I see those methods available. :)

Haruhiko Nishi
@hanishi

@mpollmeier

 def valueOption[A](key: Key[A]): Option[A] =
    element.property[A](key.name).toOption

This does not support retrieval of multiple properties however. Do you have any plan to support ? (If there is setPropertyListfor storing multiple values, I thought it would be nice if the reverse operation is supported as well)

Haruhiko Nishi
@hanishi
For now, I will use the following to achieve copying properties regardless of cardinality.(revised the above)
  implicit class copyVertexProperties(aux: GremlinScala.Aux[Vertex, HNil]) {

    def copyProperties[A](source: Vertex, keys: Key[A]*): GremlinScala.Aux[Vertex, HNil] = {
      keys.foreach { key =>
        values(source.properties[A](key.name), Nil) foreach { property =>
          aux.property(key, property.value)
        }
      }
      aux
    }

    private def values[A](iterator: util.Iterator[VertexProperty[A]],
                          list: List[VertexProperty[A]]): List[VertexProperty[A]] = {
      def iterate(iterator: util.Iterator[VertexProperty[A]],
                  list: List[VertexProperty[A]]): List[VertexProperty[A]] = {
        values(iterator, iterator.next :: Nil)
      }
      if (iterator.hasNext) list ::: iterate(iterator, list) else list
    }
  }
Haruhiko Nishi
@hanishi

By the way, I had to fix my insertV function to below after upgrading to 3.4.4.3 from 3.4.1.13

.where(_.outE(out).inV().is(currentV))
.sideEffect(.bothE().where(.otherV().is(currentV).drop().iterate())
to
.where(_.outE(out).inV().has(T.id, currentV.id))
.sideEffect(_.bothE().where(_.otherV().has(T.id, currentV.id)).drop().iterate())

to make my method work properly. When I was having the former with 3.4.1.13 the sideEffect clause was dropping both edges from the head of linked list after the 3 nodes.

has there been any changes made in is() operator?

    def insertV[A](currentV: Vertex, in: String, out: String): Aux[Vertex, HNil] = {
      val p = StepLabel[Vertex]()
      g.V(currentV)
        .outE(in)
        .inV()
        .where(_.outE(out).inV().has(T.id, currentV.id))
        .fold()
        .coalesce(
          _.unfold[Vertex]()
            .as(p)
            .sideEffect(_.bothE().where(_.otherV().has(T.id, currentV.id)).drop().iterate())
            .addV(currentV.label)
            .addE(out)
            .from(p)
            .inV()
            .addE(in)
            .to(p)
            .outV(),
          _.addV(currentV.label)
        )
        .addE(in)
        .from(currentV)
        .inV()
        .addE(out)
        .to(currentV)
        .outV()
    }
Bowofola
@bowofolaf
Hey all, From readme, When going from case classes to vertices, "List members will be stored as multi-properties, i.e. Cardinality.list". Is there a way to do Cardinality.set ?
Michael Pollmeier
@mpollmeier
@hanishi @bowofolaf currently i don't have capacity (and personal need) to expand the capabilities of gremlin-scala, sorry. I'm happy to help with PRs and moderation though.
Bowofola
@bowofolaf
@mpollmeier ah I wasn't asking about any extensions, just asking about current capability :)
Haruhiko Nishi
@hanishi
@bowofolaf
There is this, but I didn't find one that executesvertex.property(Cardinality.set, key, value)
  def setPropertyList[A <: AnyRef](key: String, values: List[A]): VertexProperty[A] = {
    removeProperty(Key[A](key), Cardinality.list)
    values
      .map { value =>
        vertex.property(Cardinality.list, key, value)
      }
      .lastOption
      .getOrElse(VertexProperty.empty[A])
  }
Michael Pollmeier
@mpollmeier
@bowofolaf so for case classes the capability to store them as 'set' doesn't exist - would need to be implemented in the Marshallable macro
Bowofola
@bowofolaf
@hanishi yea I think I found that, implementing my own wrapper that can do it. Thank all @mpollmeier
Haruhiko Nishi
@hanishi
スクリーンショット 2020-01-28 10.47.16.png
@mpollmeier
Hi, I have trouble understanding how select should be used. I am getting the "No implicit arguments of type: ..." as depicted in the screen capture above. What it is that I am not doing it properly?
Haruhiko Nishi
@hanishi
スクリーンショット 2020-01-28 11.29.40.png
Haruhiko Nishi
@hanishi
BTW, use of select() without specifying a tuple of StepLabeldoes not show this error and compiles fine.
Michael Pollmeier
@mpollmeier
@hanishi here's an example that works, maybe you can work your way back from there: https://github.com/mpollmeier/gremlin-scala/blob/master/gremlin-scala/src/test/scala/gremlin/scala/SelectSpec.scala#L61-L67
if not, can you share a minimal reproducable example? e.g. a small project that demonstrates your case
Haruhiko Nishi
@hanishi
@mpollmeier Thank you for your response.
I think I will clone the gremlin-scalarepo and see what the difference is. I don't know anything about shapeless so I have to study before digging into what's going on. (My Scala skill is limited) it could be my environmental setup that is causing the error.
Until I then, I have modified the code above to the following.
    .V()
        .has(`accountId`, account)
        .hasLabel("Date")
        .inE("results")
        .has(`Timestamp`)
        .order(By(Timestamp, Order.desc))
        .local(
          _.union(
            _.join(_.outV().inE("has").outV().inE("has").outV().value(`id`))
              .join(_.outV().inE("has").outV().value(`id`))
              .join(_.outV().value(`id`))
              .join(_.unionFlat(_.value(`impressions`), _.value(`clicks`), _.value(`cvs`)))))
        .toList()
I am starting to like gremlin btw.
Haruhiko Nishi
@hanishi
@mpollmeier
I have no idea, but the following compiled and ran without any problem even though the intelliJ was suggesting the error aforementioned.
スクリーンショット 2020-01-29 1.50.20.png
Haruhiko Nishi
@hanishi
By the way, would it be not a good idea to have an implicit conversion for
implicit def keyName[A](key: Key[A]): String = key.name ?
so I can just use Key[A] for ?
def values[A](key: String*)(implicit ev: End <:< Element) =
    GremlinScala[A, Labels](traversal.values[A](key: _*))
Haruhiko Nishi
@hanishi
Bowofola
@bowofolaf
@hanishi shapeless tracks the order of your aliases, that could be the problem. I think if you pass labels into select in the same order you aliased them, it should be fine.
Haruhiko Nishi
@hanishi
@bowofolaf
Thank you. I'll try and see if it works.
Michael Pollmeier
@mpollmeier
@hanishi having an implicit Key -> String is not a good idea, because String is a very basic type, so it would apply far too broadly (i.e. potentially to all functions that take a String)
Haruhiko Nishi
@hanishi

@mpollmeier
True, although I kind of did that myself in my code. Looks cleaner :)

 if (!mgmt.containsPropertyKey(name)) {
    mgmt.makePropertyKey(name).dataType(classOf[String]).cardinality(Cardinality.SINGLE).make()
  }

or this

 _.join(_.value(Timestamp))
              .join(_.constant(account))
              .join(_.outV().repeat(_.inE("has").outV()).times(2).value(`id`))
              .join(_.outV().inE("has").outV().value(`id`))
              .join(_.outV().value(`id`))
              .join(_.values[Int](
                `impressions`,
                `clicks`,
                `cvs`,
                `cost`,
                `3-second video views`,
                `Video watches at 25%`,
                `Video watches at 50%`,
                `Video watches at 75%`,
                `Video watches at 95%`,
where Video watches at 25% is Key[String]
Haruhiko Nishi
@hanishi
@mpollmeier Thank you for your insight very much appreciated
gremlin-scala has become indispensable for building our ads analyzing platform so thank you very much!
Endre Galaczi
@chiller

Hello. In the readme on gremlin-scala it says this in the section "mapping to and from case classes":

Annotating members with @id and @underlying will instruct the marshaller to set the element id and/or the underlying element in the class. Note: you cannot specify the id when adding a vertex like this.

I wonder why that is, and is there a way to get around it?

Michael Pollmeier
@mpollmeier
it's a good practice to let the graphdb assign the id rather than specifying it yourself, but other than that the reason is 'no one needed it yet'
Endre Galaczi
@chiller
Thanks
G-Ark
@G-Ark

Hello,

I am trying to merge two nodes in a graph using gremlin - Java.
Was able to generate the query using this SO answer - https://stackoverflow.com/a/46435070

g.V(parentNode).union(identity(), janusClient.g.V(aliasNode)) .unfold() .sideEffect(properties().group("p").by(T.key).by(value())) .sideEffect(__.outE().group("o").by(T.label).by(__.project("p","iv").by(__.valueMap()).by(__.inV()).fold())) .sideEffect(__.inE().group("i").by(T.label).by(__.project("p","ov").by(__.valueMap()).by(__.outV()).fold())) .sideEffect(__.drop()) .cap("p","o","i").as("poi") .addV().as("u") .sideEffect( __.select("poi").select("p").unfold().as("kv") .select("u").property(__.select("kv").select(Column.keys), __.select("kv").select(Column.values))) .sideEffect( __.select("poi").select("o").unfold().as("x").select(Column.values) .unfold().addE(__.select("x").select(Column.keys)).from(__.select("u")).to(__.select("iv"))) .sideEffect( __.select("poi").select("i").unfold().as("x").select(Column.values) .unfold().addE(__.select("x").select(Column.keys)).from(__.select("ov")).to(__.select("u"))).iterate();

The problem is with this line .addE(__.select("x").select(Column.keys)) in the last sideEffect step.

Replacing with String.valueOf(.addE(__.select("x").select(Column.keys))) does not yield the desired results.

Any help appreciated!

Nilay Gupta
@nilay0016

Hi, i am trying to make a test graph by adding vertex to it and return them while calling mock functions.

val gr = TinkerGraph.open().asScala()
val BTO_ID = Key[String](PropertyLabels.BTO_ID)
gr.addV(VertexLabels.BTO)
      .property(KeyValue(BTO_ID,id1))
      .property(KeyValue(FIRST_NAME,firstName1))
      .iterate()
println("VertexID GR -:"+gr.V(vertexId).headOption())
 Mockito.when(db.g).thenReturn(gr)

    Mockito.when(vertexIdGenerator.vertexId(VertexLabels.BTO, id1, PropertyLabels.BTO_ID)).thenReturn(vertexId)
    val result = btoService.getBTO(id1)

this println statement always returns null when i add headOptions(), The sevice class that i am testing -:

def getBTO(id: String) = {
    implicit val g = db.g
    val bto = g
    .V(
      vertexIdGenerator.vertexId(VertexLabels.BTO, id, PropertyLabels.BTO_ID))
      .headOption() match {
      case Some(value) => val x = value.getClass()
        value.toCC[BTOModel]
      case None        => throw BtoDoesNotExistException(s"BTO $id Does not exists")

    }
    println(res)
    BtoInfo(firstName = res.firstName,
            lastName = res.lastName,
            profilePic = res.profilePic)
  }

Link to stackoverflow question -:
https://stackoverflow.com/questions/60716402/how-to-test-a-dse-graph-based-scala-application

venkat125
@venkat125
hi all, i'm a newbie to gremlin,
using apache-tinkerpop-gremlin-console. Searched a lot to clear gremlin console like cls for windows cmd
Any suggestions would be helpful. Thanks!
Benoit George
@sharkgua
CTRL+L in Linux and, according to https://www.davidtan.org/how-to-clear-screen-in-groovy-console/, CTRL+W in Windows.
Ernie Makris
@emakris_twitter

I’m confused about labels. I have this code:

val a = StepLabel[Vertex]()
val baseCreateT = g.V().has(lableName, idKey, value)
      .fold()
      .coalesce(_.unfold[Vertex](),
        _.addV(labelName).property(idKey, value)).as(a)

the type of baseCreateT is Aux[Vertex, Vertex :: HNil] after the as() call.
if I don't include the as() call, it is a Aux[Vertex, HNil]. I guess I don't know enough about shapeless yet,
but I wanted to pass this tranversal to another method to add properties. Is there a generic way to reference
a traversal step that is for a vertex?

any help would be appreciated!
Ernie Makris
@emakris_twitter
well, I just realized that I can parameterize the second part of the Aux.
Ernie Makris
@emakris_twitter

@mpollmeier I’m trying what I think is a simple project operation against neptune and I’m seeing the following error:

val result = g.V().hasLabel("foo").project(_(By(Key[String]("id"))).and(By(Key[String]("cloud")))).toList()

I'm seeing an error like this:
org.apache.tinkerpop.gremlin.driver.exception.ResponseException: An error occurred during serialization of this request [RequestMessage{, requestId=bb961b69-b0c7-4f90-b928-9698590b7bb9, op='bytecode', processor='traversal', args={gremlin=[[], [V(), hasLabel(foo), project(41b7a217-91d0-4463-acf4-1c2485e74ff1, 627bd6b6-f97c-48a6-95f3-7126db4ebd0d), by(id), by(cloud), map(gremlin.scala.package$$anon$5@11ecf329)]], aliases={g=g}}}] - it could not be sent to the server - Reason: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: Serializer for type gremlin.scala.package$$anon$5 not found

I know that neptune doesn’t support lambda steps, is this the reason?
Michael Pollmeier
@mpollmeier
yes exactly. it's trying to serialize your traversal and to send it over the wire, which doesn't work because it contains lambdas
Ernie Makris
@emakris_twitter
if I use project(“a”, “b”).by(..).by(..), everything works ok, I reached for the projection builder because all the by() methods were marked as deprecated.
I’m a newbie, so I’m not sure if using the by.by syntax is going to go away in a future gremlin-scala release
vonchav
@voonchav_gitlab
Hi, any plan to upgrade to tinkerpop/gremlin-3.4.7 and/or Scala 2.13.3?
Michael Pollmeier
@mpollmeier
thanks for the reminder, i guess it's time. i just upgraded scala/sbt, will take a lot what it takes re tinkerpop version
1 reply
Michael Pollmeier
@mpollmeier
just upgrade tinkerpop to 3.4.7 as well, latest release is out as version 3.4.7.1
1 reply