Multi -dimensional Data and Spatial Range Query in Sensor Networks

40
1 Multi Multi - - dimensional Data and dimensional Data and Spatial Range Spatial Range Query in Sensor Networks Query in Sensor Networks Jie Gao Computer Science Department Stony Brook University

Transcript of Multi -dimensional Data and Spatial Range Query in Sensor Networks

Page 1: Multi -dimensional Data and Spatial Range Query in Sensor Networks

1

MultiMulti--dimensional Data and dimensional Data and Spatial Range Spatial Range

Query in Sensor NetworksQuery in Sensor Networks

Jie GaoComputer Science Department

Stony Brook University

Page 2: Multi -dimensional Data and Spatial Range Query in Sensor Networks

2

PapersPapers

• [Li03a] X. Li, Y. J. Kim, R. Govindan, W. Hong, Multi-dimensional Range Queries in Sensor Networks, Proc. ACM SenSys 2003.

• [Gao04] J. Gao, L. Guibas, J. Hershberger, L. Zhang, Fractional Cascaded information in a sensor network, IPSN’04.

Page 3: Multi -dimensional Data and Spatial Range Query in Sensor Networks

3

Orthogonal range searchOrthogonal range search

• Find all the sensors inside a rectangular box.

• Find all the sensors with temperature readings

above 70F.

Page 4: Multi -dimensional Data and Spatial Range Query in Sensor Networks

4

MultiMulti--dimensional datadimensional data

• Monitor environments.

• Multiple sensors, multiple attributes.

• Query might be multi-dimensional as well.

List all sensors with temperature value

70-80 and light level 10-20.

Page 5: Multi -dimensional Data and Spatial Range Query in Sensor Networks

5

Sensor network as a databaseSensor network as a database

• Need an indexing scheme.

• …. In addition, a storage scheme.

• First we look at range query in a centralized setting.

Page 6: Multi -dimensional Data and Spatial Range Query in Sensor Networks

6

1D range search1D range search

• Find the data inside a query interval [x, x’]

• 1D range tree: a balanced partitioning tree on a

sorted list.

– Each leaf stores an input value.

– Each internal node stores the splitting value.

3 10 19 23 30

3 19

37 49 59

30 49

10 37

23

Page 7: Multi -dimensional Data and Spatial Range Query in Sensor Networks

7

1D range search1D range search

• Find the data inside a query interval [x, x’]– Start from the root and descend the tree to find the interval

where x and x’ stays.

– Include all the leaves in the sub-trees between the two traversing paths from the root.

• Example [9, 33].

3 10 19 23 30

3 19

37 49 59

30 49

10 37

23

Page 8: Multi -dimensional Data and Spatial Range Query in Sensor Networks

8

1D range search1D range search

• Storage: n+n/2+n/4+…+1=2n=O(n)

• Height of the tree: O(logn)

• Query time: O(logn+k), where k is the output size.

3 10 19 23 30

3 19

37 49 59

30 49

10 37

23

Page 9: Multi -dimensional Data and Spatial Range Query in Sensor Networks

9

KdKd--treetree

• A recursive space partitioning tree.

– Partition along x and y axis in an alternating fashion.

– Each internal node stores the splitting node along x (or y).

x

x

y

y

x

Page 10: Multi -dimensional Data and Spatial Range Query in Sensor Networks

10

KdKd--treetree

• 2D query R=[x, x’]×[y, y’].

– Check with each internal node whether the cutting line intersects R.

• If yes, recurse on both.

• If no, only recurse on the half plane that intersects R.

x

x

y

y

x

Page 11: Multi -dimensional Data and Spatial Range Query in Sensor Networks

11

KdKd--treetree

• Storage: O(n)

• Height of the tree: O(logn)

• Query cost? O(n1/2+k), where k is the output size.

Page 12: Multi -dimensional Data and Spatial Range Query in Sensor Networks

12

r(v)

KdKd--treetree

• Query cost? O(n1/2+k), where k is the output size.

• Intuition: we visit 2 types of nodes:

– r(v) is fully contained in R (this is counted in k).

– r(v) is not fully contained in R – intersected by boundaries of R.

• Thus we bound the number of nodes intersected by a vertical line, denoted by Q(n).

Page 13: Multi -dimensional Data and Spatial Range Query in Sensor Networks

13

KdKd--treetree

• Thus we bound the number of nodes intersected by a vertical line, denoted by Q(n).

• Look at the 4 grandchildren, the line intersects at most 2 of them.

• Thus Q(n)=2Q(n/4)+O(1)= O(n1/2).

• The query cost is O(k)+4Q(n)= O(n1/2+k).

Page 14: Multi -dimensional Data and Spatial Range Query in Sensor Networks

14

KdKd--tree in Rtree in Rdd

• High dimensional kd-tree.

• If the dimension is d, we can build a kd-tree with

O(n) size, and query cost O(n1-1/d+k), where k is the output size.

• Query cost is too high.

• We can get it down if we sacrifice on space.

• Range tree: O(nlogd-1n) space and O(logdn+k)

query cost.

Page 15: Multi -dimensional Data and Spatial Range Query in Sensor Networks

15

Range treeRange tree

• Recall the 1d range tree.

• 2D range tree:

– First build a 1D range tree on x-coordinates

– For each internal node, take all the nodes in its subtree, build a 1D range tree on y-coordinates.

• Total space: O(nlogn)

Range tree on x-corodinates

Range tree on y-corodinates

Page 16: Multi -dimensional Data and Spatial Range Query in Sensor Networks

16

Range treeRange tree

• Query:– First search the 1D range tree on the x-coordinates– For each node on the traversal path, search on the y-

coordinates.

• Query cost: O(log2n+k)

Range tree on x-corodinates

Range tree on y-corodinates

Page 17: Multi -dimensional Data and Spatial Range Query in Sensor Networks

17

QuadQuad--treetree

• A recursive space partitioning tree.

• The depth might be as high as Ω(n).

• Worst-case query cost is not bounded. For uniform sensor distribution the depth is O(logn).

Page 18: Multi -dimensional Data and Spatial Range Query in Sensor Networks

18

Indexing in a sensor network?Indexing in a sensor network?

• Where is the index stored?

• How to traverse the tree?

• 1st approach: map a quad-tree to the sensor field.

• 2nd approach: distributed storage and indexing.

Page 19: Multi -dimensional Data and Spatial Range Query in Sensor Networks

19

DIMENSIONS: summariesDIMENSIONS: summaries

• Use a quad-tree partitioning.

Page 20: Multi -dimensional Data and Spatial Range Query in Sensor Networks

20

DIMENSIONS: queryDIMENSIONS: query

• Top-down query processing

Page 21: Multi -dimensional Data and Spatial Range Query in Sensor Networks

21

Issues with Issues with DIMENSIONsDIMENSIONs

• Uneven load: nodes holding coarse data are visited more often.

• Root becomes traffic bottleneck.

Page 22: Multi -dimensional Data and Spatial Range Query in Sensor Networks

22

Distributed index for multiDistributed index for multi--dimensional datadimensional data

• Construct the distributed indices.

• Locality preserving geographic hash: events

with close attributes values are likely to be

stored close.

• Kd-tree partitioning.

Page 23: Multi -dimensional Data and Spatial Range Query in Sensor Networks

23

ZonesZones

• The sensor network is partitioned to equal (geographical) size regions along x and y directions alternatively.

• Each cell is given a zone code – left (bottom) is 0, right (top) is 1.

Page 24: Multi -dimensional Data and Spatial Range Query in Sensor Networks

24

ZoneZone--treetree

• Each node x owns a zone – the largest one that contains x only.

• If a zone is empty, it is owned by the backup node – the rightmost zone in the left sibling tree, or the leftmost zone inthe right sibling tree.

Page 25: Multi -dimensional Data and Spatial Range Query in Sensor Networks

25

DataData--centric hashingcentric hashing

• Hash a multi-dimensional event to a zone.

• A multi-dimensional event Ai, i=1, …, m, Ai ∈[0, 1].

• Suppose the zone code has k bits, k is a multiple of m.

• For i=1 to m, if Ai<0.5, the i-th bit is assigned 0, otherwise 1.

• For i=m+1 to 2m, if Ai-m<0.25 or 0.5 ≤ Ai-m<0.75, the i-th bit is assigned 0, otherwise 1.

For example: [0.3, 0.8] is stored at 5-bit zone code 01110.

The event is hashed to the node that owns the zone.

A1<0.5

A1<0.5, A2<0.5

A1<0.25 or 0.5 ≤ A1<0.75, A2<0.5

Page 26: Multi -dimensional Data and Spatial Range Query in Sensor Networks

26

DataData--centric routingcentric routing

• The encoding node (where the event E is generated) may not know the # bits of the hashed

zone.

• Node A encodes the node by using the length of its

own code and generates the zone code c(E).

• Node A routes by GPSR to the centroid of the zone c(E).

• Intermediate nodes may refine code c(E).

• If the current node B finds a match of its own code

and the event code c(E), then B stores the event.

Page 27: Multi -dimensional Data and Spatial Range Query in Sensor Networks

27

Routing queriesRouting queries

• Looking for a point event is the same as routing an event.

• A range query is routed to a zone corresponding to the entire range, and then progressively split into

smaller sub-queries.

Page 28: Multi -dimensional Data and Spatial Range Query in Sensor Networks

28

Event routing helps resolving undecided zonesEvent routing helps resolving undecided zones

• How does each node knows its own zone code?

• Assume that every node knows the outer boundary.

• A node checks its 1-hop

neighbors and decides on the largest zone that only

contains itself.

• This may not fully resolve all

the boundaries.

Page 29: Multi -dimensional Data and Spatial Range Query in Sensor Networks

29

Event routing helps resolving undecided zonesEvent routing helps resolving undecided zones

• A claims the ownership of event E.

• But A is not sure of its upper boundary. So A sends

out the event E by GPSR (face routing) with a destination near A.

• Node B that receives this message shrink its zone.

Page 30: Multi -dimensional Data and Spatial Range Query in Sensor Networks

30

DIM summaryDIM summary

• Data storage explores query locality. Range query can be supported.

• Events are not necessarily stored close to where

they are generated.

• Each event costs about O(n1/2) communication

cost.

• When data is highly skewed, most data are

handled by a small number of sensors which become bottleneck.

Page 31: Multi -dimensional Data and Spatial Range Query in Sensor Networks

31

Major problem: data storageMajor problem: data storage

• Similar data (in attribute space) should be stored close.

• Data should be stored close to where they were generated. --- location is an important attribute of the data.

• The two considerations may be in conflict.

Page 32: Multi -dimensional Data and Spatial Range Query in Sensor Networks

32

Fractional cascading in sensor networkFractional cascading in sensor network

• Geographical range query (q, R, T): q is where the query is generated, R is the rectangular range, T is

a temperature range or other aggregates.

• Aggregates about region R should be returned to

query node.

q

R

Page 33: Multi -dimensional Data and Spatial Range Query in Sensor Networks

33

Storage schemeStorage scheme

• The aggregated value of a quad node is stored in all the sensors in the parent subtree.

• Each node stores O(logn) data.

• Construction: bottom up. Cost O(n logn).

Page 34: Multi -dimensional Data and Spatial Range Query in Sensor Networks

34

Query schemeQuery scheme

• The query region R is partitioned into canonical regions – the maximal quads completely inside R.

• Use a spiral routing to visit a sensor in each canonical regions.

• Recurse on each canonical piece.

Page 35: Multi -dimensional Data and Spatial Range Query in Sensor Networks

35

Query costQuery cost

• The query cost for (q, R, [T, ∞)) is

• A is the area, P is the perimeter, k is the output size.

• Cost 1: spiral visit: O(PlogP)

Page 36: Multi -dimensional Data and Spatial Range Query in Sensor Networks

36

Query costQuery cost

• Cost 2: the communication cost of recursion in each canonical piece with side length L(u) and output k(u) is

• The total recursion cost is

Page 37: Multi -dimensional Data and Spatial Range Query in Sensor Networks

37

SummarySummary

• Store similar data close

– Work in the space of the data field

– Bring all similar data together

– May need to travel far

• Store data nearby

– Respect space locality for geographical range query.

– Communication cost is low.

– Range search in data space is challenging.

• Can you get the best of both worlds?

Page 38: Multi -dimensional Data and Spatial Range Query in Sensor Networks

38

The remaining classesThe remaining classes

• Coding theory with applications in routing (network coding) and storage.

• Percolation theory and connectivity.

• Synchronization.

• Gossip algorithms.

• Anything you want to suggest?

• Reminder: work on your project! Come to discuss with me if you want guidance and suggestions.

Page 39: Multi -dimensional Data and Spatial Range Query in Sensor Networks

39

Lower bound on query costLower bound on query cost

• Assume sensors are on a regular grid with n sensors. Each sensor has a value 0 or 1. Now we want to report “hot”sensors in a range R. Assume each sensor stores m=polylogn data.

Type I query: the range is a single sensor r, (q, r).

# sensors in Q1: D2

# storage in Q2: at most D2

Thus no matter how we store data in the network, a type I query has to go outside Q2 to look for the data.

The query cost is

Page 40: Multi -dimensional Data and Spatial Range Query in Sensor Networks

40

Lower bound on query costLower bound on query cost

• Type II query (q, R(q, r)).

• Suppose t1 and t2 are two different assignments of values in the region R(q, r), I.e., at least one sensor has different value.

Suppose R(q, r) has area A = # sensors inside R.

There are total 2A different assignments.

We need at least A storage to different two different assignments.

# sensors in Q3: A

Thus a type II query has to go outside Q3 to look for the data.

The query cost is