Scala: How to return a tuple in a function? “type mismatch”Scala type inference failure on “? extends” in Java codeParametric type + function requires a string as second parameter?Type mismatch in scala while using eclipseScala - type mismatch; found Int, required StringScala Type MisMatch Error in sparkScala mapValues() type mismatchscala mismatch & inferred type arguments with JavaHow to flatten tuples in Spark?How to use Gremlin in Scala script?Strange Scala 'Type mismatch' error for tuples
MAXDOP Settings for SQL Server 2014
We have a love-hate relationship
Should I install hardwood flooring or cabinets first?
Hot bath for aluminium engine block and heads
If a character with the Alert feat rolls a crit fail on their Perception check, are they surprised?
About a little hole in Z'ha'dum
How should I respond when I lied about my education and the company finds out through background check?
Why does Async/Await work properly when the loop is inside the async function and not the other way around?
Gibbs free energy in standard state vs. equilibrium
Flux received by a negative charge
Are lightweight LN wallets vulnerable to transaction withholding?
Why do IPv6 unique local addresses have to have a /48 prefix?
What is the grammatical term for “‑ed” words like these?
How to align and center standalone amsmath equations?
A social experiment. What is the worst that can happen?
What (else) happened July 1st 1858 in London?
Some numbers are more equivalent than others
Engineer refusing to file/disclose patents
What linear sensor for a keyboard?
When quoting, must I also copy hyphens used to divide words that continue on the next line?
Can the Supreme Court overturn an impeachment?
Folder comparison
How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?
Diode in opposite direction?
Scala: How to return a tuple in a function? “type mismatch”
Scala type inference failure on “? extends” in Java codeParametric type + function requires a string as second parameter?Type mismatch in scala while using eclipseScala - type mismatch; found Int, required StringScala Type MisMatch Error in sparkScala mapValues() type mismatchscala mismatch & inferred type arguments with JavaHow to flatten tuples in Spark?How to use Gremlin in Scala script?Strange Scala 'Type mismatch' error for tuples
I'm using the library gremlin-scala
to interact with Janusgraph.
Using the DSL, a way to insert a new vertex is by doing the following:
val Id = Key[Long]("id")
val Name = Key[String]("name")
graph + ("label", Id -> 42, Name -> "Mike")
I want to make this part into a a function ("label", Id -> 42, Name -> "Mike")
case class VertexModel(id: Long, name: String)
def toVertex: (Label, KeyValue[Long], KeyValue[String]) =
val Id = Key[Long]("id")
val Name = Key[String]("name")
("item", Id -> id, Name -> name)
val model = VertexModel(1, "Bill")
graph + model.toVertex
This fails with the following error:
Error:(26, 11) type mismatch;
found : T1
required: gremlin.scala.Label
(which expands to) String
graph + vertex
Error:(26, 11) type mismatch;
found : T2
required: gremlin.scala.KeyValue[Long]
graph + vertex
Error:(26, 11) type mismatch;
found : T3
required: gremlin.scala.KeyValue[String]
graph + vertex
Not sure how to fix this.
scala gremlin-scala
add a comment |
I'm using the library gremlin-scala
to interact with Janusgraph.
Using the DSL, a way to insert a new vertex is by doing the following:
val Id = Key[Long]("id")
val Name = Key[String]("name")
graph + ("label", Id -> 42, Name -> "Mike")
I want to make this part into a a function ("label", Id -> 42, Name -> "Mike")
case class VertexModel(id: Long, name: String)
def toVertex: (Label, KeyValue[Long], KeyValue[String]) =
val Id = Key[Long]("id")
val Name = Key[String]("name")
("item", Id -> id, Name -> name)
val model = VertexModel(1, "Bill")
graph + model.toVertex
This fails with the following error:
Error:(26, 11) type mismatch;
found : T1
required: gremlin.scala.Label
(which expands to) String
graph + vertex
Error:(26, 11) type mismatch;
found : T2
required: gremlin.scala.KeyValue[Long]
graph + vertex
Error:(26, 11) type mismatch;
found : T3
required: gremlin.scala.KeyValue[String]
graph + vertex
Not sure how to fix this.
scala gremlin-scala
Fromgremlin-scala
's source code it looks like the argument to+
on a graph isn't a tuple but just a regular argument list.
– Levi Ramsey
Mar 21 at 14:34
add a comment |
I'm using the library gremlin-scala
to interact with Janusgraph.
Using the DSL, a way to insert a new vertex is by doing the following:
val Id = Key[Long]("id")
val Name = Key[String]("name")
graph + ("label", Id -> 42, Name -> "Mike")
I want to make this part into a a function ("label", Id -> 42, Name -> "Mike")
case class VertexModel(id: Long, name: String)
def toVertex: (Label, KeyValue[Long], KeyValue[String]) =
val Id = Key[Long]("id")
val Name = Key[String]("name")
("item", Id -> id, Name -> name)
val model = VertexModel(1, "Bill")
graph + model.toVertex
This fails with the following error:
Error:(26, 11) type mismatch;
found : T1
required: gremlin.scala.Label
(which expands to) String
graph + vertex
Error:(26, 11) type mismatch;
found : T2
required: gremlin.scala.KeyValue[Long]
graph + vertex
Error:(26, 11) type mismatch;
found : T3
required: gremlin.scala.KeyValue[String]
graph + vertex
Not sure how to fix this.
scala gremlin-scala
I'm using the library gremlin-scala
to interact with Janusgraph.
Using the DSL, a way to insert a new vertex is by doing the following:
val Id = Key[Long]("id")
val Name = Key[String]("name")
graph + ("label", Id -> 42, Name -> "Mike")
I want to make this part into a a function ("label", Id -> 42, Name -> "Mike")
case class VertexModel(id: Long, name: String)
def toVertex: (Label, KeyValue[Long], KeyValue[String]) =
val Id = Key[Long]("id")
val Name = Key[String]("name")
("item", Id -> id, Name -> name)
val model = VertexModel(1, "Bill")
graph + model.toVertex
This fails with the following error:
Error:(26, 11) type mismatch;
found : T1
required: gremlin.scala.Label
(which expands to) String
graph + vertex
Error:(26, 11) type mismatch;
found : T2
required: gremlin.scala.KeyValue[Long]
graph + vertex
Error:(26, 11) type mismatch;
found : T3
required: gremlin.scala.KeyValue[String]
graph + vertex
Not sure how to fix this.
scala gremlin-scala
scala gremlin-scala
edited Mar 21 at 13:57
drum
asked Mar 21 at 13:49
drumdrum
1,78943654
1,78943654
Fromgremlin-scala
's source code it looks like the argument to+
on a graph isn't a tuple but just a regular argument list.
– Levi Ramsey
Mar 21 at 14:34
add a comment |
Fromgremlin-scala
's source code it looks like the argument to+
on a graph isn't a tuple but just a regular argument list.
– Levi Ramsey
Mar 21 at 14:34
From
gremlin-scala
's source code it looks like the argument to +
on a graph isn't a tuple but just a regular argument list.– Levi Ramsey
Mar 21 at 14:34
From
gremlin-scala
's source code it looks like the argument to +
on a graph isn't a tuple but just a regular argument list.– Levi Ramsey
Mar 21 at 14:34
add a comment |
1 Answer
1
active
oldest
votes
Why do you need extension method toVertex
?
Doesn't this work just like
import gremlin.scala._
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
object App
implicit val graph: ScalaGraph = TinkerGraph.open.asScala
case class VertexModel(id: Long, name: String)
val model = VertexModel(1, "Bill")
graph + model
?
build.sbt
scalaVersion := "2.12.8"
libraryDependencies += "com.michaelpollmeier" %% "gremlin-scala" % "3.4.0.4"
libraryDependencies += "org.apache.tinkerpop" % "tinkergraph-gremlin" % "3.4.0"
That's cool! Didn't know that was possible. 1 more question: How can I add the label to the class? Expanding on your solution:case class VertexModel(label: Label, id: Long, name: String)
, I getName cannot be in protected namespace: label
– drum
Mar 21 at 14:49
Sorry, can't reproduce.case class VertexModel(label: Label, id: Long, name: String)
val model = VertexModel("item", 1, "Bill")
graph + model
compiles for me.
– Dmytro Mitin
Mar 21 at 14:56
That's during runtime by the gremlin server
– drum
Mar 21 at 15:12
Another issue is that I cannot use differentKey
names. For example I want a keytype
but I can't docase class VertexModel(type: String, id: Long, name: String)
becausetype
is a keyword.
– drum
Mar 21 at 15:20
1
What if you trylabel, type
in backticks?
– Dmytro Mitin
Mar 21 at 15:35
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281951%2fscala-how-to-return-a-tuple-in-a-function-type-mismatch%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Why do you need extension method toVertex
?
Doesn't this work just like
import gremlin.scala._
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
object App
implicit val graph: ScalaGraph = TinkerGraph.open.asScala
case class VertexModel(id: Long, name: String)
val model = VertexModel(1, "Bill")
graph + model
?
build.sbt
scalaVersion := "2.12.8"
libraryDependencies += "com.michaelpollmeier" %% "gremlin-scala" % "3.4.0.4"
libraryDependencies += "org.apache.tinkerpop" % "tinkergraph-gremlin" % "3.4.0"
That's cool! Didn't know that was possible. 1 more question: How can I add the label to the class? Expanding on your solution:case class VertexModel(label: Label, id: Long, name: String)
, I getName cannot be in protected namespace: label
– drum
Mar 21 at 14:49
Sorry, can't reproduce.case class VertexModel(label: Label, id: Long, name: String)
val model = VertexModel("item", 1, "Bill")
graph + model
compiles for me.
– Dmytro Mitin
Mar 21 at 14:56
That's during runtime by the gremlin server
– drum
Mar 21 at 15:12
Another issue is that I cannot use differentKey
names. For example I want a keytype
but I can't docase class VertexModel(type: String, id: Long, name: String)
becausetype
is a keyword.
– drum
Mar 21 at 15:20
1
What if you trylabel, type
in backticks?
– Dmytro Mitin
Mar 21 at 15:35
add a comment |
Why do you need extension method toVertex
?
Doesn't this work just like
import gremlin.scala._
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
object App
implicit val graph: ScalaGraph = TinkerGraph.open.asScala
case class VertexModel(id: Long, name: String)
val model = VertexModel(1, "Bill")
graph + model
?
build.sbt
scalaVersion := "2.12.8"
libraryDependencies += "com.michaelpollmeier" %% "gremlin-scala" % "3.4.0.4"
libraryDependencies += "org.apache.tinkerpop" % "tinkergraph-gremlin" % "3.4.0"
That's cool! Didn't know that was possible. 1 more question: How can I add the label to the class? Expanding on your solution:case class VertexModel(label: Label, id: Long, name: String)
, I getName cannot be in protected namespace: label
– drum
Mar 21 at 14:49
Sorry, can't reproduce.case class VertexModel(label: Label, id: Long, name: String)
val model = VertexModel("item", 1, "Bill")
graph + model
compiles for me.
– Dmytro Mitin
Mar 21 at 14:56
That's during runtime by the gremlin server
– drum
Mar 21 at 15:12
Another issue is that I cannot use differentKey
names. For example I want a keytype
but I can't docase class VertexModel(type: String, id: Long, name: String)
becausetype
is a keyword.
– drum
Mar 21 at 15:20
1
What if you trylabel, type
in backticks?
– Dmytro Mitin
Mar 21 at 15:35
add a comment |
Why do you need extension method toVertex
?
Doesn't this work just like
import gremlin.scala._
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
object App
implicit val graph: ScalaGraph = TinkerGraph.open.asScala
case class VertexModel(id: Long, name: String)
val model = VertexModel(1, "Bill")
graph + model
?
build.sbt
scalaVersion := "2.12.8"
libraryDependencies += "com.michaelpollmeier" %% "gremlin-scala" % "3.4.0.4"
libraryDependencies += "org.apache.tinkerpop" % "tinkergraph-gremlin" % "3.4.0"
Why do you need extension method toVertex
?
Doesn't this work just like
import gremlin.scala._
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
object App
implicit val graph: ScalaGraph = TinkerGraph.open.asScala
case class VertexModel(id: Long, name: String)
val model = VertexModel(1, "Bill")
graph + model
?
build.sbt
scalaVersion := "2.12.8"
libraryDependencies += "com.michaelpollmeier" %% "gremlin-scala" % "3.4.0.4"
libraryDependencies += "org.apache.tinkerpop" % "tinkergraph-gremlin" % "3.4.0"
edited 2 days ago
answered Mar 21 at 14:39
Dmytro MitinDmytro Mitin
7,947619
7,947619
That's cool! Didn't know that was possible. 1 more question: How can I add the label to the class? Expanding on your solution:case class VertexModel(label: Label, id: Long, name: String)
, I getName cannot be in protected namespace: label
– drum
Mar 21 at 14:49
Sorry, can't reproduce.case class VertexModel(label: Label, id: Long, name: String)
val model = VertexModel("item", 1, "Bill")
graph + model
compiles for me.
– Dmytro Mitin
Mar 21 at 14:56
That's during runtime by the gremlin server
– drum
Mar 21 at 15:12
Another issue is that I cannot use differentKey
names. For example I want a keytype
but I can't docase class VertexModel(type: String, id: Long, name: String)
becausetype
is a keyword.
– drum
Mar 21 at 15:20
1
What if you trylabel, type
in backticks?
– Dmytro Mitin
Mar 21 at 15:35
add a comment |
That's cool! Didn't know that was possible. 1 more question: How can I add the label to the class? Expanding on your solution:case class VertexModel(label: Label, id: Long, name: String)
, I getName cannot be in protected namespace: label
– drum
Mar 21 at 14:49
Sorry, can't reproduce.case class VertexModel(label: Label, id: Long, name: String)
val model = VertexModel("item", 1, "Bill")
graph + model
compiles for me.
– Dmytro Mitin
Mar 21 at 14:56
That's during runtime by the gremlin server
– drum
Mar 21 at 15:12
Another issue is that I cannot use differentKey
names. For example I want a keytype
but I can't docase class VertexModel(type: String, id: Long, name: String)
becausetype
is a keyword.
– drum
Mar 21 at 15:20
1
What if you trylabel, type
in backticks?
– Dmytro Mitin
Mar 21 at 15:35
That's cool! Didn't know that was possible. 1 more question: How can I add the label to the class? Expanding on your solution:
case class VertexModel(label: Label, id: Long, name: String)
, I get Name cannot be in protected namespace: label
– drum
Mar 21 at 14:49
That's cool! Didn't know that was possible. 1 more question: How can I add the label to the class? Expanding on your solution:
case class VertexModel(label: Label, id: Long, name: String)
, I get Name cannot be in protected namespace: label
– drum
Mar 21 at 14:49
Sorry, can't reproduce.
case class VertexModel(label: Label, id: Long, name: String)
val model = VertexModel("item", 1, "Bill")
graph + model
compiles for me.– Dmytro Mitin
Mar 21 at 14:56
Sorry, can't reproduce.
case class VertexModel(label: Label, id: Long, name: String)
val model = VertexModel("item", 1, "Bill")
graph + model
compiles for me.– Dmytro Mitin
Mar 21 at 14:56
That's during runtime by the gremlin server
– drum
Mar 21 at 15:12
That's during runtime by the gremlin server
– drum
Mar 21 at 15:12
Another issue is that I cannot use different
Key
names. For example I want a key type
but I can't do case class VertexModel(type: String, id: Long, name: String)
because type
is a keyword.– drum
Mar 21 at 15:20
Another issue is that I cannot use different
Key
names. For example I want a key type
but I can't do case class VertexModel(type: String, id: Long, name: String)
because type
is a keyword.– drum
Mar 21 at 15:20
1
1
What if you try
label, type
in backticks?– Dmytro Mitin
Mar 21 at 15:35
What if you try
label, type
in backticks?– Dmytro Mitin
Mar 21 at 15:35
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281951%2fscala-how-to-return-a-tuple-in-a-function-type-mismatch%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
From
gremlin-scala
's source code it looks like the argument to+
on a graph isn't a tuple but just a regular argument list.– Levi Ramsey
Mar 21 at 14:34