kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject [2/2] kylin git commit: KYLIN-2245 code review
Date Mon, 05 Dec 2016 13:20:29 GMT
KYLIN-2245 code review


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/fc1e11aa
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/fc1e11aa
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/fc1e11aa

Branch: refs/heads/master
Commit: fc1e11aa8a2d20add72e382396787d9cb09771da
Parents: 0a441c3
Author: Yang Li <liyang@apache.org>
Authored: Mon Dec 5 21:20:21 2016 +0800
Committer: Yang Li <liyang@apache.org>
Committed: Mon Dec 5 21:20:21 2016 +0800

----------------------------------------------------------------------
 .../src/main/java/org/apache/kylin/cube/CubeInstance.java    | 4 ----
 .../src/main/java/org/apache/kylin/cube/CubeManager.java     | 2 +-
 .../main/java/org/apache/kylin/metadata/model/ISegment.java  | 4 ++--
 .../main/java/org/apache/kylin/metadata/model/Segments.java  | 8 ++++----
 4 files changed, 7 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/fc1e11aa/core-cube/src/main/java/org/apache/kylin/cube/CubeInstance.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/CubeInstance.java b/core-cube/src/main/java/org/apache/kylin/cube/CubeInstance.java
index ecbb437..a3665f5 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/CubeInstance.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/CubeInstance.java
@@ -371,10 +371,6 @@ public class CubeInstance extends RootPersistentEntity implements IRealization,
         return segments.calculateToBeSegments(newSegment, getModel().getPartitionDesc().isPartitioned());
     }
 
-    public Pair<CubeSegment, CubeSegment> findMergeOffsetsByDateRange(Segments<CubeSegment>
segs, long startDate, long endDate, long skipSegDateRangeCap) {
-        return this.segments.findMergeOffsetsByDateRange(segs, startDate, endDate, skipSegDateRangeCap);
-    }
-
     public CubeSegment getLastSegment() {
         List<CubeSegment> existing = getSegments();
         if (existing.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/kylin/blob/fc1e11aa/core-cube/src/main/java/org/apache/kylin/cube/CubeManager.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/CubeManager.java b/core-cube/src/main/java/org/apache/kylin/cube/CubeManager.java
index 296a4e7..0c80c07 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/CubeManager.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/CubeManager.java
@@ -519,7 +519,7 @@ public class CubeManager implements IRealizationProvider {
         if (isOffsetsOn) {
             // offset cube, merge by date range?
             if (startOffset == endOffset) {
-                Pair<CubeSegment, CubeSegment> pair = cube.findMergeOffsetsByDateRange(cube.getSegments(SegmentStatusEnum.READY),
startDate, endDate, Long.MAX_VALUE);
+                Pair<CubeSegment, CubeSegment> pair = cube.getSegments(SegmentStatusEnum.READY).findMergeOffsetsByDateRange(startDate,
endDate, Long.MAX_VALUE);
                 if (pair == null)
                     throw new IllegalArgumentException("Find no segments to merge by date
range " + startDate + "-" + endDate + " for cube " + cube);
                 startOffset = pair.getFirst().getSourceOffsetStart();

http://git-wip-us.apache.org/repos/asf/kylin/blob/fc1e11aa/core-metadata/src/main/java/org/apache/kylin/metadata/model/ISegment.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/model/ISegment.java b/core-metadata/src/main/java/org/apache/kylin/metadata/model/ISegment.java
index 9d26927..f006613 100644
--- a/core-metadata/src/main/java/org/apache/kylin/metadata/model/ISegment.java
+++ b/core-metadata/src/main/java/org/apache/kylin/metadata/model/ISegment.java
@@ -26,6 +26,8 @@ public interface ISegment {
 
     public long getDateRangeEnd();
 
+    public boolean isSourceOffsetsOn();
+
     public long getSourceOffsetStart();
 
     public long getSourceOffsetEnd();
@@ -35,6 +37,4 @@ public interface ISegment {
     public SegmentStatusEnum getStatus();
 
     public long getLastBuildTime();
-
-    public boolean isSourceOffsetsOn();
 }

http://git-wip-us.apache.org/repos/asf/kylin/blob/fc1e11aa/core-metadata/src/main/java/org/apache/kylin/metadata/model/Segments.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/model/Segments.java b/core-metadata/src/main/java/org/apache/kylin/metadata/model/Segments.java
index bc115cc..5198dc7 100644
--- a/core-metadata/src/main/java/org/apache/kylin/metadata/model/Segments.java
+++ b/core-metadata/src/main/java/org/apache/kylin/metadata/model/Segments.java
@@ -187,8 +187,8 @@ public class Segments<T extends ISegment> extends ArrayList<T>
{
 
             for (int s = 0; s < readySegs.size(); s++) {
                 ISegment seg = readySegs.get(s);
-                Pair<T, T> p = findMergeOffsetsByDateRange(readySegs.getSubList(s,
readySegs.size()), //
-                        seg.getDateRangeStart(), seg.getDateRangeStart() + toMergeRange,
toMergeRange);
+                Pair<T, T> p = readySegs.getSubList(s, readySegs.size()) //
+                        .findMergeOffsetsByDateRange(seg.getDateRangeStart(), seg.getDateRangeStart()
+ toMergeRange, toMergeRange);
                 if (p != null && p.getSecond().getDateRangeEnd() - p.getFirst().getDateRangeStart()
>= toMergeRange)
                     return Pair.newPair(p.getFirst().getSourceOffsetStart(), p.getSecond().getSourceOffsetEnd());
             }
@@ -197,10 +197,10 @@ public class Segments<T extends ISegment> extends ArrayList<T>
{
         return null;
     }
 
-    public Pair<T, T> findMergeOffsetsByDateRange(Segments<T> segments, long
startDate, long endDate, long skipSegDateRangeCap) {
+    public Pair<T, T> findMergeOffsetsByDateRange(long startDate, long endDate, long
skipSegDateRangeCap) {
         // must be offset cube
         Segments result = new Segments();
-        for (ISegment seg : segments) {
+        for (ISegment seg : this) {
 
             // include if date range overlaps
             if (startDate < seg.getDateRangeEnd() && seg.getDateRangeStart() <
endDate) {


Mime
View raw message