Skip to content

Commit 8141ba8

Browse files
committed
dsl: shortcut steps
1 parent 56a4bda commit 8141ba8

File tree

1 file changed

+32
-0
lines changed
  • gremlin-scala/src/main/scala/gremlin/scala/dsl

1 file changed

+32
-0
lines changed

gremlin-scala/src/main/scala/gremlin/scala/dsl/Steps.scala

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,38 @@ class Steps[EndDomain, EndGraph, Labels <: HList](val raw: GremlinScala[EndGraph
4343
def headOption(): Option[EndDomain] = raw.headOption.map(converter.toDomain)
4444
def isDefined: Boolean = headOption().isDefined
4545

46+
/**
47+
* shortcut for `toList`
48+
*/
49+
def l: List[EndDomain] = toList
50+
51+
/**
52+
Alias for `toStream`
53+
*/
54+
def s(): JStream[EndDomain] = toStream()
55+
56+
/**
57+
* print the results to stdout
58+
*/
59+
def p(): Unit = {
60+
l.foreach {
61+
case vertex: Vertex => {
62+
val label = vertex.label
63+
val id = vertex.id().toString
64+
val keyValPairs = vertex.valueMap.toList
65+
.filter(x => x._2.toString != "")
66+
.sortBy(_._1)
67+
.map(x => x._1 + ": " + x._2)
68+
println(s"($label,$id): " + keyValPairs.mkString(", "))
69+
70+
}
71+
case elem => println(elem)
72+
}
73+
}
74+
75+
def count(): Long =
76+
raw.count.head
77+
4678
override def clone() = new Steps[EndDomain, EndGraph, Labels](raw.clone())
4779

4880
def dedup(): Steps[EndDomain, EndGraph, Labels] =

0 commit comments

Comments
 (0)