Пример #1
0
            private Query GetType2()
            {
                string statementType2 = "INSERT INTO output2 (Type, Time, Emit, QID, Bal, RTime) VALUES('2', $0$, $5$, $2$, $3$, $4$)";
                UnaryOp.Relation relType2 = new UnaryOp.Relation(Type2Relation);
                UnaryOp.Map convType2 = new UnaryOp.Map(Type2MapConvert);
                int[] keepType2 = { 0, 1, 2, 3, 4, 5 };

                return new OpDBAccess(LINEARDATABASE, null, statementType2,
                    new OpProject(convType2, keepType2,
                        new OpRelation(relType2, accountBalances,
                            new OpServerRaw(9449))));
            }
Пример #2
0
            private List<Query> GetType3()
            {
                List<Query> type3q = new List<Query>();
                string statementType3 = "INSERT INTO output3 (Type, Time, Emit, QID, Bal) VALUES('3', $0$, $6$, $3$, $5$)";
                string queryType3 = "SELECT Toll FROM tollhistory WHERE VID = $1$ AND Xway = $2$ AND Day = $4$";
                UnaryOp.Map mapConv = new UnaryOp.Map(Type3MapConvert);
                int[] keepType3 = { 0, 1, 2, 3, 4, 5, 6 };
                UnaryOp.Relation relType3 = new UnaryOp.Relation(Type3Relation);
                OpMultiplexer omxType3 = new OpMultiplexer(new OpServerRaw(9450));
                type3q.Add(omxType3);

                OpDBAccess dbtype3 = new OpDBAccess(LINEARDATABASE, null, statementType3,
                    new OpProject(mapConv, keepType3,
                        new OpUnion(
                            new OpDBAccess(LINEARDATABASE, queryType3, null,
                                new OpSelect("$1.5 > I0",
                                    omxType3.GetQuery())),
                            new OpRelation(relType3, accountBalances,
                                new OpSelect("$1.5 = I0",
                                    omxType3.GetQuery())))));
                type3q.Add(dbtype3);
                return type3q;
            }
Пример #3
0
            private List<Query> GetType0()
            {
                List<Query> qOut = new List<Query>();
                int[] npAttrs = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; //null project attributes

                UnaryOp.Map FeedPreProcess = new UnaryOp.Map(PreProcess);
                OpMultiplexer Feeder = new OpMultiplexer(
                    new OpProject(FeedPreProcess, npAttrs,
                        new OpServerRaw(9448)));
                qOut.Add(Feeder);

                //////regions are of the form: name (# of Queries returned) - Source [-> new Source]\\\\\\

                #region SegStats (2) - Feeder
                UnaryOp.Relation ssLAVRelation = new UnaryOp.Relation(SStatsLAVInsertion);
                int[] ssAvg = { 3, 5, 6, 8 };
                int[] ssAvgMain = { 8 };
                OpRelation sStatsLAV = new OpRelation(ssLAVRelation, segStats,
                    new OpGroupByAvg(ssAvg, ssAvgMain, 2, 8,
                        new OpBucket(5 * 60, 60, 0, -1,
                            Feeder.GetQuery())));//<Time, VID, Spd, Xway, Lane, Dir, Seg, Pos>
                qOut.Add(sStatsLAV);

                UnaryOp.Map isDuplicate = new UnaryOp.Map(IsDupCheckVID);
                UnaryOp.Relation ssCountRelation = new UnaryOp.Relation(SStatsCountInsertion);
                int[] ssCount = { 3, 5, 6, 8 };
                int[] ssCountMain = { 8 };
                //int[] ssCountProject = { 1, 3, 5, 6, 8 }; //<VID, Xway, Dir, Seg, WID(List)>
                OpRelation sStatsCount = new OpRelation(ssCountRelation, segStats,
                    new OpGroupByCount(ssCount, ssCountMain, 8,
                        new OpSelect("$1.10 = I0", //<Time, VID, Spd, Xway, Lane, Dir, Seg, Pos, WID(List), ?isDup>
                            new OpProject(isDuplicate, npAttrs,
                                new OpBucket(60, 60, 0, -1,
                                    Feeder.GetQuery())))));//<Time, VID, Spd, Xway, Lane, Dir, Seg, Pos>
                qOut.Add(sStatsCount);
                #endregion

                #region Accident Detection (1) - Feeder
                int[] adGroupBy = { 1, 3, 5, 6, 7, 8}; //VID, Xway, Dir, Seg, Pos, WID
                int[] adGroupByMain = { 8 };

                UnaryOp.Relation adRelation = new UnaryOp.Relation(AccidentDetection);
                OpRelation aDetection = new OpRelation(adRelation, accidents,
                    new OpSelect("$1.7 > U1",
                        new OpGroupByCount(adGroupBy, adGroupByMain, 8,
                            new OpBucket(4 * 30, 30, 0, -1,
                                Feeder.GetQuery())))); //<Time, VID, Spd, Xway, Lane, Dir, Seg, Pos>
                qOut.Add(aDetection);
                #endregion

                #region New Segment Stream (1) - Feeder -> NSS
                UnaryOp.Map nssMap = new UnaryOp.Map(NSSCheckSeg);
                OpMultiplexer NSSFeeder = new OpMultiplexer(
                    new OpSelect("$1.7 = I1",
                            new OpProject(nssMap, npAttrs,
                                Feeder.GetQuery())));
                qOut.Add(NSSFeeder);
                #endregion

                #region Toll Charging (1) - NSS
                string Tollstatement = "INSERT INTO output0 (Type, VID, Time, Emit, Speed, Toll) VALUES('0', $1$, $0$, $9$, $8$, $7$)";
                UnaryOp.Relation chargeTollRelation = new UnaryOp.Relation(ChargeToll);
                UnaryOp.Relation findTollRelation = new UnaryOp.Relation(FindToll);
                UnaryOp.Map convertTollTimeStamp = new UnaryOp.Map(ConvertTimeStamp);
                OpDBAccess chargeTolls = new OpDBAccess(LINEARDATABASE, null, Tollstatement, //<Time, VID, Xway, Lane, Dir, Seg, Emit, ?isNSS, Toll, LAV>
                    new OpProject(convertTollTimeStamp, npAttrs,
                        new OpRelation(chargeTollRelation, accountBalances,
                            new OpSelect("$1.8 != I0", //it has a toll
                                new OpRelation(findTollRelation, tollQuotes,
                                    new OpSelect("$1.4 > I0", //not entering the expressway
                                        NSSFeeder.GetQuery()))))));
                qOut.Add(chargeTolls);
                #endregion

                #region Accident in Range Section (1) - NSS
                UnaryOp.Relation arsRelation = new UnaryOp.Relation(AccidentInRange);

                UnaryOp.Relation tqAttachStatsRelation = new UnaryOp.Relation(AttachStats);
                UnaryOp.Relation tqQuoteTollsRelation = new UnaryOp.Relation(QuoteTolls);
                OpRelation quoteTolls = new OpRelation(tqQuoteTollsRelation, tollQuotes,
                    new OpRelation(tqAttachStatsRelation, segStats,
                        new OpRelation(arsRelation, accidents, //<Time, VID, Xway, Lane, Dir, Seg, ?isNSS, ?isAIR>
                            NSSFeeder.GetQuery())));

                UnaryOp.Map accConvertTimeStamp = new UnaryOp.Map(ConvertTimeStamp);
                //<Time, VID, Xway, Lane, Dir, Seg, ?isNSS, ?isAIR, LAV, Count, Emit>
                string Accidentstatement = "INSERT INTO output1 (Type, Time, Emit, Seg) VALUES('1', $0$, $10$, $7$)";
                OpDBAccess accidentNotification = new OpDBAccess(LINEARDATABASE, null, Accidentstatement,
                    new OpProject(accConvertTimeStamp, npAttrs,
                        new OpSelect("$1.8 >= I0", //there is an accident in range
                            quoteTolls)));
                qOut.Add(accidentNotification);
                #endregion

                return qOut;
            }