From 859175f31a31bc4948981f40a81029181c59ccf6 Mon Sep 17 00:00:00 2001 From: Yuan Zi Date: Tue, 27 Jul 2021 15:30:08 +0800 Subject: [PATCH] fix bug --- .../iginx/split/SimplePlanGenerator.java | 110 +++++++++++++----- 1 file changed, 83 insertions(+), 27 deletions(-) diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/split/SimplePlanGenerator.java b/core/src/main/java/cn/edu/tsinghua/iginx/split/SimplePlanGenerator.java index d8986c18e..243d2b154 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/split/SimplePlanGenerator.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/split/SimplePlanGenerator.java @@ -285,8 +285,12 @@ public List generateSubPlans(RequestContext requestContext) public List splitDeleteColumnsPlan(DeleteColumnsPlan plan, List infoList) { List plans = new ArrayList<>(); for (SplitInfo info : infoList) { + List paths = plan.getPathsByInterval(info.getTimeSeriesInterval()); + if (paths.size() == 0) { + continue; + } DeleteColumnsPlan subPlan = new DeleteColumnsPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getStorageUnit() ); plans.add(subPlan); @@ -302,8 +306,12 @@ public List splitInsertColumnRecordsPlan(InsertColumnRe if (valuesAndBitmaps.k.length == 0) { continue; } + List paths = plan.getPathsByInterval(info.getTimeSeriesInterval()); + if (paths.size() == 0) { + continue; + } InsertColumnRecordsPlan subPlan = new InsertColumnRecordsPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, timestampsAndIndexes.k, valuesAndBitmaps.k, valuesAndBitmaps.v, @@ -325,8 +333,12 @@ public List splitInsertRowRecordsPlan(InsertRowRecordsPlan if (valuesAndBitmaps.k.length == 0) { continue; } + List paths = plan.getPathsByInterval(info.getTimeSeriesInterval()); + if (paths.size() == 0) { + continue; + } InsertRowRecordsPlan subPlan = new InsertRowRecordsPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, timestampsAndIndexes.k, valuesAndBitmaps.k, valuesAndBitmaps.v, @@ -343,8 +355,12 @@ public List splitInsertRowRecordsPlan(InsertRowRecordsPlan public List splitDeleteDataInColumnsPlan(DeleteDataInColumnsPlan plan, List infoList) { List plans = new ArrayList<>(); for (SplitInfo info : infoList) { + List paths = plan.getPathsByInterval(info.getTimeSeriesInterval()); + if (paths.size() == 0) { + continue; + } DeleteDataInColumnsPlan subPlan = new DeleteDataInColumnsPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, Math.max(plan.getStartTime(), info.getTimeInterval().getStartTime()), Math.min(plan.getEndTime(), info.getTimeInterval().getEndTime()), info.getStorageUnit() @@ -357,8 +373,12 @@ public List splitDeleteDataInColumnsPlan(DeleteDataInCo public List splitQueryDataPlan(QueryDataPlan plan, List infoList) { List plans = new ArrayList<>(); for (SplitInfo info : infoList) { + List paths = plan.getPathsByInterval(info.getTimeSeriesInterval()); + if (paths.size() == 0) { + continue; + } QueryDataPlan subPlan = new QueryDataPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, Math.max(plan.getStartTime(), info.getTimeInterval().getStartTime()), Math.min(plan.getEndTime(), info.getTimeInterval().getEndTime()), info.getStorageUnit() @@ -371,8 +391,12 @@ public List splitQueryDataPlan(QueryDataPlan plan, List splitValueFilterQueryPlan(ValueFilterQueryPlan plan, List infoList) { List plans = new ArrayList<>(); for (SplitInfo info : infoList) { + List paths = plan.getPathsByInterval(info.getTimeSeriesInterval()); + if (paths.size() == 0) { + continue; + } ValueFilterQueryPlan subPlan = new ValueFilterQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, Math.max(plan.getStartTime(), info.getTimeInterval().getStartTime()), Math.min(plan.getEndTime(), info.getTimeInterval().getEndTime()), plan.getBooleanExpression(), @@ -386,8 +410,12 @@ public List splitValueFilterQueryPlan(ValueFilterQueryPlan public List splitMaxQueryPlan(MaxQueryPlan plan, List infoList) { List plans = new ArrayList<>(); for (SplitInfo info : infoList) { + List paths = plan.getPathsByInterval(info.getTimeSeriesInterval()); + if (paths.size() == 0) { + continue; + } MaxQueryPlan subPlan = new MaxQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, Math.max(plan.getStartTime(), info.getTimeInterval().getStartTime()), Math.min(plan.getEndTime(), info.getTimeInterval().getEndTime()), info.getStorageUnit() @@ -400,11 +428,15 @@ public List splitMaxQueryPlan(MaxQueryPlan plan, List i private List splitDownsampleQueryPlan(DownsampleQueryPlan plan, List infoList) { List plans = new ArrayList<>(); for (SplitInfo info : infoList) { + List paths = plan.getPathsByInterval(info.getTimeSeriesInterval()); + if (paths.size() == 0) { + continue; + } IginxPlan subPlan = null; switch (info.getType()) { case MAX: subPlan = new MaxQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getTimeInterval().getStartTime(), info.getTimeInterval().getEndTime(), info.getStorageUnit() @@ -412,7 +444,7 @@ private List splitDownsampleQueryPlan(DownsampleQueryPlan plan, List< break; case MIN: subPlan = new MinQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getTimeInterval().getStartTime(), info.getTimeInterval().getEndTime(), info.getStorageUnit() @@ -420,7 +452,7 @@ private List splitDownsampleQueryPlan(DownsampleQueryPlan plan, List< break; case FIRST: subPlan = new FirstQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getTimeInterval().getStartTime(), info.getTimeInterval().getEndTime(), info.getStorageUnit() @@ -428,7 +460,7 @@ private List splitDownsampleQueryPlan(DownsampleQueryPlan plan, List< break; case LAST: subPlan = new LastQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getTimeInterval().getStartTime(), info.getTimeInterval().getEndTime(), info.getStorageUnit() @@ -436,7 +468,7 @@ private List splitDownsampleQueryPlan(DownsampleQueryPlan plan, List< break; case AVG: subPlan = new AvgQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getTimeInterval().getStartTime(), info.getTimeInterval().getEndTime(), info.getStorageUnit() @@ -444,7 +476,7 @@ private List splitDownsampleQueryPlan(DownsampleQueryPlan plan, List< break; case SUM: subPlan = new SumQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getTimeInterval().getStartTime(), info.getTimeInterval().getEndTime(), info.getStorageUnit() @@ -452,7 +484,7 @@ private List splitDownsampleQueryPlan(DownsampleQueryPlan plan, List< break; case COUNT: subPlan = new CountQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getTimeInterval().getStartTime(), info.getTimeInterval().getEndTime(), info.getStorageUnit() @@ -460,7 +492,7 @@ private List splitDownsampleQueryPlan(DownsampleQueryPlan plan, List< break; case DOWNSAMPLE_MAX: subPlan = new DownsampleMaxQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getTimeInterval().getStartTime(), info.getTimeInterval().getEndTime(), plan.getPrecision(), @@ -469,7 +501,7 @@ private List splitDownsampleQueryPlan(DownsampleQueryPlan plan, List< break; case DOWNSAMPLE_MIN: subPlan = new DownsampleMinQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getTimeInterval().getStartTime(), info.getTimeInterval().getEndTime(), plan.getPrecision(), @@ -478,7 +510,7 @@ private List splitDownsampleQueryPlan(DownsampleQueryPlan plan, List< break; case DOWNSAMPLE_FIRST: subPlan = new DownsampleFirstQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getTimeInterval().getStartTime(), info.getTimeInterval().getEndTime(), plan.getPrecision(), @@ -487,7 +519,7 @@ private List splitDownsampleQueryPlan(DownsampleQueryPlan plan, List< break; case DOWNSAMPLE_LAST: subPlan = new DownsampleLastQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getTimeInterval().getStartTime(), info.getTimeInterval().getEndTime(), plan.getPrecision(), @@ -496,7 +528,7 @@ private List splitDownsampleQueryPlan(DownsampleQueryPlan plan, List< break; case DOWNSAMPLE_AVG: subPlan = new DownsampleAvgQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getTimeInterval().getStartTime(), info.getTimeInterval().getEndTime(), plan.getPrecision(), @@ -505,7 +537,7 @@ private List splitDownsampleQueryPlan(DownsampleQueryPlan plan, List< break; case DOWNSAMPLE_SUM: subPlan = new DownsampleSumQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getTimeInterval().getStartTime(), info.getTimeInterval().getEndTime(), plan.getPrecision(), @@ -514,7 +546,7 @@ private List splitDownsampleQueryPlan(DownsampleQueryPlan plan, List< break; case DOWNSAMPLE_COUNT: subPlan = new DownsampleCountQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, info.getTimeInterval().getStartTime(), info.getTimeInterval().getEndTime(), plan.getPrecision(), @@ -537,8 +569,12 @@ public List splitDownsampleMaxQueryPlan(DownsampleMaxQueryPlan plan, public List splitMinQueryPlan(MinQueryPlan plan, List infoList) { List plans = new ArrayList<>(); for (SplitInfo info : infoList) { + List paths = plan.getPathsByInterval(info.getTimeSeriesInterval()); + if (paths.size() == 0) { + continue; + } MinQueryPlan subPlan = new MinQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, Math.max(plan.getStartTime(), info.getTimeInterval().getStartTime()), Math.min(plan.getEndTime(), info.getTimeInterval().getEndTime()), info.getStorageUnit() @@ -555,8 +591,12 @@ public List splitDownsampleMinQueryPlan(DownsampleMinQueryPlan plan, public List splitFirstQueryPlan(FirstQueryPlan plan, List infoList) { List plans = new ArrayList<>(); for (SplitInfo info : infoList) { + List paths = plan.getPathsByInterval(info.getTimeSeriesInterval()); + if (paths.size() == 0) { + continue; + } FirstQueryPlan subPlan = new FirstQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, Math.max(plan.getStartTime(), info.getTimeInterval().getStartTime()), Math.min(plan.getEndTime(), info.getTimeInterval().getEndTime()), info.getStorageUnit() @@ -573,8 +613,12 @@ public List splitDownsampleFirstQueryPlan(DownsampleFirstQueryPlan pl public List splitLastQueryPlan(LastQueryPlan plan, List infoList) { List plans = new ArrayList<>(); for (SplitInfo info : infoList) { + List paths = plan.getPathsByInterval(info.getTimeSeriesInterval()); + if (paths.size() == 0) { + continue; + } LastQueryPlan subPlan = new LastQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, Math.max(plan.getStartTime(), info.getTimeInterval().getStartTime()), Math.min(plan.getEndTime(), info.getTimeInterval().getEndTime()), info.getStorageUnit() @@ -591,8 +635,12 @@ public List splitDownsampleLastQueryPlan(DownsampleLastQueryPlan plan public List splitCountQueryPlan(CountQueryPlan plan, List infoList) { List plans = new ArrayList<>(); for (SplitInfo info : infoList) { + List paths = plan.getPathsByInterval(info.getTimeSeriesInterval()); + if (paths.size() == 0) { + continue; + } CountQueryPlan subPlan = new CountQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, Math.max(plan.getStartTime(), info.getTimeInterval().getStartTime()), Math.min(plan.getEndTime(), info.getTimeInterval().getEndTime()), info.getStorageUnit() @@ -609,8 +657,12 @@ public List splitDownsampleCountQueryPlan(DownsampleCountQueryPlan pl public List splitSumQueryPlan(SumQueryPlan plan, List infoList) { List plans = new ArrayList<>(); for (SplitInfo info : infoList) { + List paths = plan.getPathsByInterval(info.getTimeSeriesInterval()); + if (paths.size() == 0) { + continue; + } SumQueryPlan subPlan = new SumQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, Math.max(plan.getStartTime(), info.getTimeInterval().getStartTime()), Math.min(plan.getEndTime(), info.getTimeInterval().getEndTime()), info.getStorageUnit() @@ -627,8 +679,12 @@ public List splitDownsampleSumQueryPlan(DownsampleSumQueryPlan plan, public List splitAvgQueryPlan(AvgQueryPlan plan, List infoList) { List plans = new ArrayList<>(); for (SplitInfo info : infoList) { + List paths = plan.getPathsByInterval(info.getTimeSeriesInterval()); + if (paths.size() == 0) { + continue; + } AvgQueryPlan subPlan = new AvgQueryPlan( - plan.getPathsByInterval(info.getTimeSeriesInterval()), + paths, Math.max(plan.getStartTime(), info.getTimeInterval().getStartTime()), Math.min(plan.getEndTime(), info.getTimeInterval().getEndTime()), info.getStorageUnit()