blacklight
blacklight
ATApache TinkerPop
Created by blacklight on 11/25/2024 in #questions
mergeV with onMerge when extra properties are unknown
I'm in the following situation:
jobId = "spark:bdx_job_1"

// Initial vertices
vertices = [
[
(T.id): "spark:bdx_job_1",
(T.label): "job",
"url": single("spark://some/url"),
"status": single("running"),
],
]

// First insertion
g.inject(vertices) \
.unfold() \
.mergeV() \
.iterate()

// Updated vertices
updatedVertices = vertices = [
[
(T.id): jobId,
(T.label): "job",
"url": "spark://another/url",
"status": "completed"
}
]
]
jobId = "spark:bdx_job_1"

// Initial vertices
vertices = [
[
(T.id): "spark:bdx_job_1",
(T.label): "job",
"url": single("spark://some/url"),
"status": single("running"),
],
]

// First insertion
g.inject(vertices) \
.unfold() \
.mergeV() \
.iterate()

// Updated vertices
updatedVertices = vertices = [
[
(T.id): jobId,
(T.label): "job",
"url": "spark://another/url",
"status": "completed"
}
]
]
I want to inject updatedVertices in such a way that the node is created if it doesn't exist, and its properties (excluding id and label) are updated if a match is found on <id, label>. I tried this approach, but I'm in a situation where the extra properties are not known upfront, so the range/tail approach probably isn't feasible. I've tried ti tinker with sideEffect, but any attempts resulted in a serialization error through the JDK proxy. I've also tried some of the solutions suggested here, but I haven't had much luck either.
3 replies