terrabl
terrabl
ATApache TinkerPop
Created by terrabl on 8/3/2023 in #questions
Getting Property Out of a Variable in Python Gremlin Query
But yeah if performance is bad here, when i scale up it's only going to get worse.
20 replies
ATApache TinkerPop
Created by terrabl on 8/3/2023 in #questions
Getting Property Out of a Variable in Python Gremlin Query
Yes I believe so. Mostly just for ease, and if performance is good enough here then I can build it out in my eventual solution
20 replies
ATApache TinkerPop
Created by terrabl on 8/3/2023 in #questions
Getting Property Out of a Variable in Python Gremlin Query
The binaries are from apache-tinkerpop-gremlin-servier-3.5.2
20 replies
ATApache TinkerPop
Created by terrabl on 8/3/2023 in #questions
Getting Property Out of a Variable in Python Gremlin Query
just trying to build out potential models and performance test them
20 replies
ATApache TinkerPop
Created by terrabl on 8/3/2023 in #questions
Getting Property Out of a Variable in Python Gremlin Query
tinkerpop right now, i'll eventually move it to neptune
20 replies
ATApache TinkerPop
Created by terrabl on 8/3/2023 in #questions
Getting Property Out of a Variable in Python Gremlin Query
Does saving the edges / vertices as variables have a big performance impact?
20 replies
ATApache TinkerPop
Created by terrabl on 8/3/2023 in #questions
Getting Property Out of a Variable in Python Gremlin Query
damn performance is still not where i would expect it to be...
20 replies
ATApache TinkerPop
Created by terrabl on 8/3/2023 in #questions
Getting Property Out of a Variable in Python Gremlin Query
yup that was it, i was creating duplicate has_flights_on which caused it to print duplicate paths.
20 replies
ATApache TinkerPop
Created by terrabl on 8/3/2023 in #questions
Getting Property Out of a Variable in Python Gremlin Query
Hmm I'm going to spend some more time trying to troubleshoot this. I might be creating duplicate has_flights_on
20 replies
ATApache TinkerPop
Created by terrabl on 8/3/2023 in #questions
Getting Property Out of a Variable in Python Gremlin Query
I could kiss you!
paths2 = (
g.V().has('Airport', 'airport', origin) # find origin airport
.as_('current_airport')
.repeat(
__.out('has_flights_on') # Go to the corresponding Day vertex
.has('date', gte(start_datestamp))
.has('date', lte(end_datestamp))
.outE('flight') # Go to the Flight edge
.as_('f')
.where('f', eq('current_airport')).by('origin').by('airport')
# .where(__.values('origin').is_(origin))
.inV().hasLabel('Airport') # Go to the destination Airport vertex
.as_('current_airport') # Update the current airport alias
.simplePath() # Ensure that the path doesn't contain cycles
)
.until(__.has('airport', destination).or_().loops().is_(3)) # Finish when destination is reached or max hops exceeded
.has('airport', destination)
.path()
.by(__.valueMap('airport', 'flight_id', 'start_timestamp', 'end_timestamp'))
.toList()
)
paths2 = (
g.V().has('Airport', 'airport', origin) # find origin airport
.as_('current_airport')
.repeat(
__.out('has_flights_on') # Go to the corresponding Day vertex
.has('date', gte(start_datestamp))
.has('date', lte(end_datestamp))
.outE('flight') # Go to the Flight edge
.as_('f')
.where('f', eq('current_airport')).by('origin').by('airport')
# .where(__.values('origin').is_(origin))
.inV().hasLabel('Airport') # Go to the destination Airport vertex
.as_('current_airport') # Update the current airport alias
.simplePath() # Ensure that the path doesn't contain cycles
)
.until(__.has('airport', destination).or_().loops().is_(3)) # Finish when destination is reached or max hops exceeded
.has('airport', destination)
.path()
.by(__.valueMap('airport', 'flight_id', 'start_timestamp', 'end_timestamp'))
.toList()
)
It seems to be printing out duplicate paths though, trying to figure that out now.
path[{'airport': ['MIA']}, {}, {'end_timestamp': 1686567600, 'start_timestamp': 1686561000, 'flight_id': '1912MIA20230612'}, {'airport': ['ATL']}]
path[{'airport': ['MIA']}, {}, {'end_timestamp': 1686567600, 'start_timestamp': 1686561000, 'flight_id': '1912MIA20230612'}, {'airport': ['ATL']}]
path[{'airport': ['MIA']}, {}, {'end_timestamp': 1686621960, 'start_timestamp': 1686613560, 'flight_id': '0191MIA20230612'}, {'airport': ['BWI']}, {}, {'end_timestamp': 1686774840, 'start_timestamp': 1686763260, 'flight_id': '3002BWI20230614'}, {'airport': ['ATL']}]
path[{'airport': ['MIA']}, {}, {'end_timestamp': 1686621960, 'start_timestamp': 1686613560, 'flight_id': '0191MIA20230612'}, {'airport': ['BWI']}, {}, {'end_timestamp': 1686774840, 'start_timestamp': 1686763260, 'flight_id': '3002BWI20230614'}, {'airport': ['ATL']}]
path[{'airport': ['MIA']}, {}, {'end_timestamp': 1686567600, 'start_timestamp': 1686561000, 'flight_id': '1912MIA20230612'}, {'airport': ['ATL']}]
path[{'airport': ['MIA']}, {}, {'end_timestamp': 1686567600, 'start_timestamp': 1686561000, 'flight_id': '1912MIA20230612'}, {'airport': ['ATL']}]
path[{'airport': ['MIA']}, {}, {'end_timestamp': 1686621960, 'start_timestamp': 1686613560, 'flight_id': '0191MIA20230612'}, {'airport': ['BWI']}, {}, {'end_timestamp': 1686774840, 'start_timestamp': 1686763260, 'flight_id': '3002BWI20230614'}, {'airport': ['ATL']}]
path[{'airport': ['MIA']}, {}, {'end_timestamp': 1686621960, 'start_timestamp': 1686613560, 'flight_id': '0191MIA20230612'}, {'airport': ['BWI']}, {}, {'end_timestamp': 1686774840, 'start_timestamp': 1686763260, 'flight_id': '3002BWI20230614'}, {'airport': ['ATL']}]
20 replies
ATApache TinkerPop
Created by terrabl on 8/3/2023 in #questions
Getting Property Out of a Variable in Python Gremlin Query
Basically I'm not sure I'm grabbing the airport out correctly from the where step, when I do something like .where(__.values('origin').is_(origin)) instead, it will print out paths (obviously not the correct paths but it does print some). I'm basically trying to figure out how to grab the string value out of the current_airport variable and compare that to the origin of the flight edge...
20 replies
ATApache TinkerPop
Created by terrabl on 7/24/2023 in #questions
Route from origin to destination between two datetimes
Anyone know why this query
paths = (g.V().hasLabel('Flight').has('origin', origin).has('start_timestamp', gte(start_timestamp))
.emit(__.has('destination', destination).has('end_timestamp', lte(end_timestamp)))
.repeat(
__.outE('connects_to').inV().has('end_timestamp', lte(end_timestamp)).simplePath()
)
.until(__.has('destination', destination).has('end_timestamp', lte(end_timestamp)).or_().loops().is_(3))
.has('destination', destination).has('end_timestamp', lte(end_timestamp))
.path().by(T.id)
.toList())
paths = (g.V().hasLabel('Flight').has('origin', origin).has('start_timestamp', gte(start_timestamp))
.emit(__.has('destination', destination).has('end_timestamp', lte(end_timestamp)))
.repeat(
__.outE('connects_to').inV().has('end_timestamp', lte(end_timestamp)).simplePath()
)
.until(__.has('destination', destination).has('end_timestamp', lte(end_timestamp)).or_().loops().is_(3))
.has('destination', destination).has('end_timestamp', lte(end_timestamp))
.path().by(T.id)
.toList())
Would return a path that goes through the destinaton? and then back to the destination?
5 replies
ATApache TinkerPop
Created by terrabl on 7/24/2023 in #questions
Route from origin to destination between two datetimes
Here is my query for each one AirportDay + Flight
paths = (g.V().hasLabel('AirportDay').has('airport', origin).has('date', gte(start_datestamp))
.as_('a')
.repeat(
__.outE('flight').as_('fl')
.inV().hasLabel('AirportDay').has('date', lte(end_datestamp))
.where(P.gte('a')).by('date')
.simplePath()
)
.until(
__.has('airport', destination).has('date', lte(end_datestamp)).or_().loops().is_(4)
)
.has('airport', destination).has('date', lte(end_datestamp)) # ensure the destination is reached
.path()
.by('airport')
.by(
__.valueMap('flight_id', 'start_timestamp', 'end_timestamp')) # Retrieve flight_id, start_timestamp and end_timestamp
.toList())
paths = (g.V().hasLabel('AirportDay').has('airport', origin).has('date', gte(start_datestamp))
.as_('a')
.repeat(
__.outE('flight').as_('fl')
.inV().hasLabel('AirportDay').has('date', lte(end_datestamp))
.where(P.gte('a')).by('date')
.simplePath()
)
.until(
__.has('airport', destination).has('date', lte(end_datestamp)).or_().loops().is_(4)
)
.has('airport', destination).has('date', lte(end_datestamp)) # ensure the destination is reached
.path()
.by('airport')
.by(
__.valueMap('flight_id', 'start_timestamp', 'end_timestamp')) # Retrieve flight_id, start_timestamp and end_timestamp
.toList())
Flights + connect_to
paths = (g.V().hasLabel('Flight').has('origin', origin).has('start_timestamp', gte(start_timestamp))
.emit(__.has('destination', destination).has('end_timestamp', lte(end_timestamp)))
.repeat(
__.outE('connects_to').inV().has('end_timestamp', lte(end_timestamp)).simplePath()
)
.until(__.has('destination', destination).has('end_timestamp', lte(end_timestamp)).or_().loops().is_(3))
.has('destination', destination).has('end_timestamp', lte(end_timestamp))
.path().by(T.id)
.toList())
paths = (g.V().hasLabel('Flight').has('origin', origin).has('start_timestamp', gte(start_timestamp))
.emit(__.has('destination', destination).has('end_timestamp', lte(end_timestamp)))
.repeat(
__.outE('connects_to').inV().has('end_timestamp', lte(end_timestamp)).simplePath()
)
.until(__.has('destination', destination).has('end_timestamp', lte(end_timestamp)).or_().loops().is_(3))
.has('destination', destination).has('end_timestamp', lte(end_timestamp))
.path().by(T.id)
.toList())
5 replies