270 likes | 510 Views
Spatio-Temporal Queries and Indexing. Rui Zhang http://www.csse.unimelb.edu.au/~rui The University of Melbourne. Outline. Backgrounds Spatio-temporal queries Spatio-temporal indices Indexing historical data HR-tree Indexing current (and future) data Dual transformation TPR-tree.
E N D
Spatio-Temporal Queries and Indexing Rui Zhang http://www.csse.unimelb.edu.au/~rui The University of Melbourne
Outline • Backgrounds • Spatio-temporal queries • Spatio-temporal indices • Indexing historical data • HR-tree • Indexing current (and future) data • Dual transformation • TPR-tree
Spatio-temporal data and applications Examples: Continuously report the closest gas station on my way home? Remind me to buy drinks when I’m close to a supermarket Predict how many vehicles will be in the CBD in the next hour. In summary, queries involve spatial objects (e.g., points, lines, polygons) and time
Continuous Range Query • Range queries: find all the objects that will intersect a given range Q and the time they intersect Q Result: R={b} R={b}, [0,1]
Continuous NN Query • NN queries: find the nearest object to a given query point q at all timestamps Result: R={d} R={f} {d [0,1.5]; f (1.5, ∞]}
Spatio-temporal Aggregate Queries • Aggregate queries • Aggregate range query: find how many objects passed through a range Q during a given time interval T • Density query: find all regions whose density at t is larger than
Continuous Join Query • Join queries • given two moving object sets, find all the pairs of objects whose extents intersect for every timestamp Result: R={ ‹A1, B1› [0 , 3] , ‹A4, B3› [0 , 4] , ‹A3, B2› [1 , 3] , ‹A5, B3› [2 , 6] }
Spatio-temporal Data Indexing • Indexing historical data: store the history of a spatio-temporal evolution. • HR-tree • Indexing current data: find the current (and future) positions of moving objects. • Dual-transformation • TPR-tree
Indexing Historical data Snapshot based approach • Spatio-temporal Evolution
Historical R-tree (HR-tree) An R-tree is maintained for each timestamp in history. Trees at consecutive timestamps may share branches to save space. o4 o3 timestamp 1 o1 o6 p2 o5 p1 o2 p3 o7 timestamp 1 p1 p2 p3 M. Nascimento and M. Silva, Towards historical R-trees, in SAC, pages 234-240, 1998 o1 o2 o3 o4 o5 o6 o7
timestamp 2 p1 p2’ p3’ o3 o4 o3 o4 o5’ HR-tree o4 o3 timestamp 2 o1 o6 p2’ o5’ p1 o2 p3’ o7 timestamp 1 p1 p2 p3 o1 o2 o3 o4 o5 o6 o7
Dual transformation • Trajectories are plotted as lines in the time-location space (y, t); p(t) = vt+a trajectories o 1 o 2 o 3 o 4 • J. Patel, Y. Chen and V. Chakka, STRIPES: an efficient index for predicted trajectories, in SIGMOD, pages 635-645, 2004. (t) time
Dual space-time • Idea: map a line to a point (y) location intercept trajectories o o 1 1 o 2 o 3 o 4 o 2 o 3 (t) time slope intercept
Dual space-time indexing • Query must be transformed. [(y1q, y2q), (t1q, t2q)] • a + t2qv >= y1q and a+ t1q v <= y2q , for v>0 • a + t1qv >= y1q and a+ t2q v <= y2q , for v<0
Dual space-time indexing for 2D Objects • Map a moving point p with location (px, py) and velocity (vx, vy) to the 4D point (vx, ax, vy, ay) • Query is also transformed to a linear constraint query: Q=[(x1q, x2q), (y1q, y2q), (t1q, t2q)] • ax + t2qvx >= x1q and ax+ t1q vx <= x2q • ay + t2qvy >= y1q and ay+ t1q vy <= y2q • x1qvy - y2qvx <= axvy – ayvx<= x2qvy -y1q vx
Time-Parametrised R-tree(TPR-tree) • Store the MBRs as functions of time • MBR(t) = MBR(t0) + V(t) • The MBRs grow with time, at any time instant in the future we can compute the “MBR” • S. Saltenis, C. Jensen, S. Leutenegger, M. Lopez, Indexing the Positions of Continuously Moving Objects, in SIGMOD, pages 331-342, 2000. • Y. Tao, D. Papadias, J. Sun, The TPR*-tree: an optimized spatio-temporal access method for predictive queries, in VLDB, pages 790-801, 2003.
TPR-treeMoving Object Representation • Storing the locations of moving objects is a challenge: • Update the database with the new locations • Use a function of time f(t) to store a location • Update overhead is reduced • update the database only when velocity changes u u u u u u u
TPR-treeMotion function • For each object, the database stores • Its minimum bounding rectangle (MBR) at the reference time 0 • Its current velocity bounding rectangle (VBR) {vx1,vx2,vy1,vy2} • Examples: MBR(a)={2,4,3,4}, VBR(a)={1,1,1,1}; MBR(c)={8,9,8,9}, VBR{c}={-2,0,0,2} • An update is necessary only when an object’s VBR changes.
(a) The boundaries at current time 0 (b) The boundaries at future time 1 TPR-treeMBRs
TPR-treeInsertion and Deletion • Insertion and Deletion similar to R-tree • The only difference is that you have to compute the values overlap and volume over time • Trick: try to optimize the structure for the next T time instants • Another optimization: when you update an object, re-compute the MBR at the current time (TPR*-tree)
TPR-tree: NN Queries • Assume PNN be the current NN of query q; • The time that q’s NN changes to another data point o, TINF, equals the time q crosses the perpendicular bisector of line segment PNNo TINF(o, q)=1.5
TPR-tree: NN Queries • The time that q’ NN changes to a data object in a non-leaf entry E of the TPR-tree, TMININF(E, q), depends on mindist(E, q).
TPR-tree: Join QueriesNaiveJoin • Join nodes from two TPR-trees recursively • If intersected, check on children • Otherwise, disregard it • For an update, compute its join pairs and update the answer
TPR-tree: Join QueriesTime-constrained Join (TC-Join) R. Zhang, J. Qi, D. Lin, W. Wang, R. C. Wong. A Highly Optimized Algorithm for Continuous Intersection Join Queries over Moving Objects, VLDB Journal, 21 (4), pages 561-586, 2012. • NaiveJoin with constrained processing time range [tc, tc+TM]
Recommended Readings and References • Spatio-temporal queries • Y. Tao and D. Papadias. Time-parameterized queries in spatio-temporal databases, in SIGMOD, pages 334-345, 2002. • R. Zhang, H. V. Jagadish, B. T. Dai, K. Ramamohanarao. Optimized Algorithms for Predictive Range and KNN Queries on Moving Objects. Information Systems, 35(8): 911-932, 2010. • C. S. Jensen, D. Lin, B. C. Ooi, R. Zhang. Effective Density Queries of Continuously Moving Objects. in ICDE, 2006. • R. Zhang, J. Qi, D. Lin, W. Wang, R. C. Wong. A Highly Optimized Algorithm for Continuous Intersection Join Queries over Moving Objects, VLDB Journal, 21 (4), pages 561-586, 2012. • HR-tree • M. Nascimento and M. Silva, Towards historical R-trees, in SAC, pages 234-240, 1998. • Dual transformation • J. Patel, Y. Chen and V. Chakka, STRIPES: an efficient index for predicted trajectories, in SIGMOD, pages 635-645, 2004. • TPR-tree • S. Saltenis, C. Jensen, S. Leutenegger, M. Lopez, Indexing the Positions of Continuously Moving Objects, in SIGMOD, pages 331-342, 2000. • Y. Tao, D. Papadias, J. Sun, The TPR*-tree: an optimized spatio-temporal access method for predictive queries, in VLDB, pages 790-801, 2003. Note: some of the contents in these slides are from the Internet, e.g., http://www.cs.bu.edu/faculty/gkollios/ada02/lectnotes.html, web.cs.wpi.edu/~cs561/s04/talks/motion-databases.ppt.