[ 
https://issues.apache.org/jira/browse/KYLIN-3295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16495339#comment-16495339
 ] 

ASF GitHub Bot commented on KYLIN-3295:
---------------------------------------

yiming187 closed pull request #145: KYLIN-3295, clean unused class:SQLDigestUtil
URL: https://github.com/apache/kylin/pull/145
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/core-metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigestUtil.java
 
b/core-metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigestUtil.java
deleted file mode 100644
index a70a17eef5..0000000000
--- 
a/core-metadata/src/main/java/org/apache/kylin/metadata/realization/SQLDigestUtil.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.realization;
-
-import org.apache.kylin.common.util.DateFormat;
-import org.apache.kylin.metadata.datatype.DataType;
-import org.apache.kylin.metadata.filter.ColumnTupleFilter;
-import org.apache.kylin.metadata.filter.CompareTupleFilter;
-import org.apache.kylin.metadata.filter.ConstantTupleFilter;
-import org.apache.kylin.metadata.filter.LogicalTupleFilter;
-import org.apache.kylin.metadata.filter.TupleFilter;
-import org.apache.kylin.metadata.model.TblColRef;
-
-import com.google.common.base.Function;
-import com.google.common.collect.BoundType;
-import com.google.common.collect.Range;
-
-/**
- */
-public class SQLDigestUtil {
-
-    public static <F, T> T appendTsFilterToExecute(SQLDigest sqlDigest, 
TblColRef partitionColRef, Range<Long> tsRange, Function<F, T> action) {
-
-        // add the boundary condition to query real-time
-        TupleFilter originalFilter = sqlDigest.filter;
-        sqlDigest.filter = createFilterForRealtime(originalFilter, 
partitionColRef, tsRange);
-
-        boolean addFilterColumn = false, addAllColumn = false;
-
-        if (!sqlDigest.filterColumns.contains(partitionColRef)) {
-            sqlDigest.filterColumns.add(partitionColRef);
-            addFilterColumn = true;
-        }
-
-        if (!sqlDigest.allColumns.contains(partitionColRef)) {
-            sqlDigest.allColumns.add(partitionColRef);
-            addAllColumn = true;
-        }
-
-        T ret = action.apply(null);
-
-        // restore the sqlDigest
-        sqlDigest.filter = originalFilter;
-
-        if (addFilterColumn)
-            sqlDigest.filterColumns.remove(partitionColRef);
-
-        if (addAllColumn)
-            sqlDigest.allColumns.remove(partitionColRef);
-
-        return ret;
-    }
-
-    //ts column type differentiate
-    private static String formatTimeStr(DataType type, long ts) {
-        String ret;
-        if (type == DataType.getType("date")) {
-            ret = DateFormat.formatToDateStr(ts);
-        } else if (type == DataType.getType("long")) {
-            ret = String.valueOf(ts);
-        } else {
-            throw new IllegalArgumentException("Illegal type for partition 
column " + type);
-        }
-        return ret;
-    }
-
-    private static TupleFilter createFilterForRealtime(TupleFilter 
originFilter, TblColRef partitionColRef, Range<Long> tsRange) {
-        DataType type = partitionColRef.getColumnDesc().getType();
-
-        String startTimeStr, endTimeStr;
-        CompareTupleFilter startFilter = null, endFilter = null;
-        if (tsRange.hasLowerBound()) {
-            startTimeStr = formatTimeStr(type, tsRange.lowerEndpoint());
-            if (tsRange.lowerBoundType() == BoundType.CLOSED) {
-                startFilter = new 
CompareTupleFilter(TupleFilter.FilterOperatorEnum.GTE);
-            } else {
-                startFilter = new 
CompareTupleFilter(TupleFilter.FilterOperatorEnum.GT);
-            }
-            ColumnTupleFilter columnTupleFilter = new 
ColumnTupleFilter(partitionColRef);
-            ConstantTupleFilter constantTupleFilter = new 
ConstantTupleFilter(startTimeStr);
-            startFilter.addChild(columnTupleFilter);
-            startFilter.addChild(constantTupleFilter);
-        }
-
-        if (tsRange.hasUpperBound()) {
-            endTimeStr = formatTimeStr(type, tsRange.upperEndpoint());
-            if (tsRange.upperBoundType() == BoundType.CLOSED) {
-                endFilter = new 
CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
-            } else {
-                endFilter = new 
CompareTupleFilter(TupleFilter.FilterOperatorEnum.LT);
-            }
-            ColumnTupleFilter columnTupleFilter = new 
ColumnTupleFilter(partitionColRef);
-            ConstantTupleFilter constantTupleFilter = new 
ConstantTupleFilter(endTimeStr);
-            endFilter.addChild(columnTupleFilter);
-            endFilter.addChild(constantTupleFilter);
-        }
-
-        if (originFilter == null) {
-            if (endFilter == null) {
-                return startFilter;
-            }
-            if (startFilter == null) {
-                return endFilter;
-            }
-        }
-
-        LogicalTupleFilter logicalTupleFilter = new 
LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND);
-
-        if (originFilter != null) {
-            logicalTupleFilter.addChild(originFilter);
-        }
-        if (startFilter != null) {
-            logicalTupleFilter.addChild(startFilter);
-        }
-        if (endFilter != null) {
-            logicalTupleFilter.addChild(endFilter);
-        }
-
-        return logicalTupleFilter;
-    }
-}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Unused method SQLDigestUtil#appendTsFilterToExecute
> ---------------------------------------------------
>
>                 Key: KYLIN-3295
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3295
>             Project: Kylin
>          Issue Type: Bug
>            Reporter: Ted Yu
>            Assignee: jiatao.tao
>            Priority: Minor
>             Fix For: v2.4.0
>
>
> SQLDigestUtil#appendTsFilterToExecute is not called anywhere.
> {code}
>        T ret = action.apply(null);
> {code}
> Passing null to {{apply}} seems incorrect.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to