- CarLocStr: Stream of car location reports.
This forms primary input to the system.
CarLocStr(car_id, /* unique car identifier */
speed, /* speed of the car */
exp_way, /* expressway: 0..10 */
lane, /* lane: 0,1,2,3 */
dir, /* direction: 0(east), 1(west) */
x-pos); /* coordinate in express way */
- AccBalQueryStr: Stream of
account-balance adhoc queries. Each query requests the current account balance
of a car.
AccBalQueryStr(car_id,
query_id);/* id used to associate
* responses with queries */
- ExpQueryStr: Stream of adhoc queries
requesting
the expenditure of a car for the current day.
ExpQueryStr(car_id,
query_id);
- TravelTimeQueryStr: Stream of
expected-travel-time adhoc queries.
TravelTimeQueryStr(query_id,
exp_way,
init_seg, /* initial segment */
fin_seg, /* final segment */
time_of_day,
day_of_week);
Currently, the format of historical data, which is required to answer the
adhoc queries above, is not specified. We have presently modeled the
historical data using an additional input stream; this modeling will be
changed when the complete specification of historical data is provided.
- AccCars (relation): Relation containing cars
currently involved in an accident, and the position of the accident. Note
that AVG(x-pos) below is just a hack to get the common location
of 4 identical location reports of a car involved in an accident.
SELECT car_id, AVG(x-pos) AS acc_loc
FROM CarLocStr [PARTITION BY car_id ROWS 4]
GROUP BY car_id
HAVING COUNT DISTINCT (x-pos) == 1;
- AccSeg (relation): Relation containing the
set of segments involved in an accident. This relation is obtained by
joining CurCarSeg relation with AccCars relation.
SELECT DISTINCT exp_way, dir, seg, acc_loc
FROM CurCarSeg, AccCars
WHERE CurCarSeg.car_id = AccCars.car_id;
- AccNotifyStr (stream): Output stream
notifying an accident to cars currently in the upstream 5 segments from
the accident segment. The ISTREAM operator streams a new
accident being inserted into AccSeg
relation; a new accident tuple is joined with
CurCarSeg relation to determine cars in the upstream 5 segments.
SELECT RSTREAM (car_id, acc_loc)
FROM (ISTREAM (AccSeg)) [NOW] AS A, CurCarSeg as S
WHERE (A.exp_way = S.exp_way and A.dir = EAST and S.dir = EAST and
S.seg < A.seg and S.seg > A.seg - 5) OR
(A.exp_way = S.exp_way and A.dir = WEST and S.dir = WEST and
S.seg > A.seg and S.seg < A.seg + 5);
- AccAffectedSeg (relation): Relation
of segments not tolled due to accidents (see
SegToll relation). The 10 upstream segments of an
accident segment are not tolled until 20 minutes after an accident is
cleared. For simplicity, the CQL specification of this relation assumes a
fixed relation AllSeg containing the set of all all segments
in all the freeways. The relation AccAffectedSeg is specified
below as a union of two
relations---the relation containing 10 upstream segments of segments
currently having an uncleared accident, and the relation containing 10
upstream
segments of segments that had an accident cleared within the last 20
minutes.
SELECT A.exp_way, A.dir, A.seg
FROM AllSeg AS A, AccSeg AS S
WHERE (A.exp_way = S.exp_way AND A.dir = EAST AND S.dir = EAST AND
A.seg < S.seg AND A.seg > S.seg - 10) OR
(A.exp_way = S.exp_way AND A.dir = WEST AND S.dir = WEST AND
A.seg > S.seg AND A.seg < S.seg + 10)
UNION
SELECT A.exp_way, A.dir, A.seg
FROM AllSeg AS A, DSTREAM ( AccSeg )[RANGE 20 MINUTES] AS S
WHERE (A.exp_way = S.exp_way AND A.dir = EAST AND S.dir = EAST AND
A.seg < S.seg AND A.seg > S.seg - 10) OR
(A.exp_way = S.exp_way AND A.dir = WEST AND S.dir = WEST AND
A.seg > S.seg AND A.seg < S.seg + 10);