Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Mar 15 12:49
    jeremysears commented #297
  • Mar 15 12:48
    jeremysears commented #297
  • Mar 15 12:12
    karlmvwaugh opened #297
  • Mar 11 23:28

    github-actions[bot] on v3.4.7.11

    (compare)

  • Mar 11 23:26

    mpollmeier on master

    add test for TextP filter, simi… (compare)

  • Feb 06 09:00

    github-actions[bot] on v3.4.7.10

    (compare)

  • Feb 06 08:58

    mpollmeier on master

    Updates ScalaVertex.addEdge to … Merge pull request #296 from jt… (compare)

  • Feb 06 08:58
    mpollmeier closed #296
  • Feb 05 19:33
    jtarvydas opened #296
  • Feb 04 03:56

    github-actions[bot] on v3.4.7.9

    (compare)

  • Feb 04 03:55

    mpollmeier on master

    .addE step doesn't need and sho… test and type arg for steplabel Merge pull request #295 from mp… (compare)

  • Feb 04 03:55
    mpollmeier closed #295
  • Feb 04 03:42
    mpollmeier synchronize #295
  • Feb 04 03:42

    mpollmeier on addE-drop-type-constraint

    test and type arg for steplabel (compare)

  • Feb 03 20:04
    jbward1 added as member
  • Feb 03 09:45
    mpollmeier opened #295
  • Feb 03 09:45

    mpollmeier on addE-drop-type-constraint

    .addE step doesn't need and sho… (compare)

  • Nov 20 2020 01:57

    github-actions[bot] on v3.4.7.8

    (compare)

  • Nov 20 2020 01:55

    mpollmeier on master

    upgrade plugin (compare)

  • Nov 20 2020 01:52

    github-actions[bot] on v3.4.7.7

    (compare)

Haruhiko Nishi
@hanishi
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
vonchav
@voonchav_gitlab

Hi @mpollmeier , how do I translate this traversal g.V().hasLabel('continent').group().by('code').by(out().count()) into gremlin-scala? I tried:

val code = Key[String]("code")
g
    .V()
    .hasLabel("country")
    .group(By(code))
    .by(__.out().count())
    .headOption()

Obviously, this doesn't compile. I know #by is mostly deprecated. But I don't know how to chain out().count() after By(count) in #group.

1 reply
vonchav
@voonchav_gitlab
Hi @mpollmeier,
How do I translate this Groovy traversal to gremlin-scala? g.V().hasLabel("foo").project('a','b','c').by('code').by('region').by(__.out().count())
Hi @emakris_twitter ,
I'm having the same problem that you asked about a few months ago, regarding the issue with project(_(By(Key[String]("id"))).and(By(Key[String]("cloud")))) not working and project.by(...) being deprecated. Did you find a solution?
Thank you in advance.
Duncan Hills Coffee Company
@DuncanHills
@voonchav_gitlab I don't recommend @ mentioning library authors repeatedly if you want support for something. Try posting on stack overflow. You're just going to burn people out like that.
Jonathan Ward
@jbward1

I'm going through the book Graph Databases in Action, but i'm using gremlin-scala to go through some of the examples. I was reading about chaining mutations and i'm a bit stumped on the best way to get this working. If I just pull the example from the book, i'm getting a compile error: No Implicits found for parameter ev: Edge <:< Vertex

implicit val graph: ScalaGraph = TinkerGraph.open().asScala()
private val g = graph.traversal

val dave = graph + (Person, FirstName -> "Dave")
val kelly = graph + (Person, FirstName -> "Kelly")
val jim = graph + (Person, FirstName -> "Jim")

g.addE(Friends).from(dave).to(jim)
//Compile Error: No Implicits found for parameter ev: Edge <:< Vertex
 .addE(Friends).from(dave).to(kelly)
 .addE(Friends).from(kelly).to(jim)

What is the best way to handle multiple mutations in a single transaction with gremlin-scala?

Michael Pollmeier
@mpollmeier
@jbward1 you're right, the constraint is not only not necessary for addE, it's also totally in the way. PR coming shortly, thanks for reporting!
Michael Pollmeier
@mpollmeier
Jonathan Ward
@jbward1
@mpollmeier thanks for the quick PR!
aparajitha-cn
@aparajitha-cn
Hi @mpollmeier , is there a way to perform wild card search in Gremlin Scala?
Michael Pollmeier
@mpollmeier

when you say 'wild card search', I presum you mean regular expressions?
No it doesn't, since Tinkerpop doesn't provide that:

TinkerPop does not support a regular expression predicate, although specific graph databases that leverage TinkerPop may provide a partial match extension.
From https://tinkerpop.apache.org/docs/current/reference/#has-step

aparajitha-cn
@aparajitha-cn
So if I want perform a search on the name field for partial matches, is there a way to do it in gremlin scala?
Michael Pollmeier
@mpollmeier
You could use TextP, I just added an example for you here: https://github.com/mpollmeier/gremlin-scala/blob/5f2b9df/gremlin-scala/src/test/scala/gremlin/scala/FilterSpec.scala#L33
Or the more flexible filterOnEnd step which is just above that.
aparajitha-cn
@aparajitha-cn
Hi @mpollmeier, I tried using TextP in my query but got a runtime exception for the same. Following is my query : db.g.V().hasLabel("business").has(Key[String]("name"), TextP.containing("net")).l()
aparajitha-cn
@aparajitha-cn
Runtime Exception which I got is :
Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: Could not read the traversal from the request sent. Cause: Could not deserialize the JSON value as required. Nested exception: org.apache.tinkerpop.shaded.jackson.databind.JsonMappingException: Could not deserialize the JSON value as required. Nested exception: org.apache.tinkerpop.shaded.jackson.data bind.exc.MismatchedInputException: Cannot deserialize instance of java.lang.String out of START_OBJECT token at [Source: (String)"{"@type":"g:Bytecode","@value":{"step":[["V"],["hasLabel","business"],["has","name",{"@type":"g:TextP","@value":{"predicateType":"P","predicate":"containing","value ":"net"}}]]}}"; line: 1, column: 113]
Could you please help me resolve it?
Michael Pollmeier
@mpollmeier
if you're using a remote database you cannot use lambdas, like TextP or filterOnEnd
i.e. unfortunately you're bound by the limits of TinkerPop here, as quoted/linked above
aparajitha-cn
@aparajitha-cn
So do you think there is a workaround for this? Or is it not possible for me to do this kind of search at all?
Michael Pollmeier
@mpollmeier
I'm not sure, sorry.