You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ni...@apache.org on 2019/05/16 02:06:16 UTC

[kylin] branch master updated: Small performance improvements

This is an automated email from the ASF dual-hosted git repository.

nic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git


The following commit(s) were added to refs/heads/master by this push:
     new ee95242  Small performance improvements
ee95242 is described below

commit ee95242edff6f07b8a175049f975f062526fde25
Author: Michael Hausegger <ha...@googlemail.com>
AuthorDate: Wed May 15 19:23:07 2019 +0200

    Small performance improvements
---
 .../kylin/cache/cachemanager/MemcachedCacheManager.java      |  4 ++--
 .../src/main/java/org/apache/kylin/common/util/Bytes.java    |  2 +-
 .../java/org/apache/kylin/common/util/ClasspathScanner.java  |  6 +++---
 .../main/java/org/apache/kylin/common/util/MailService.java  |  2 +-
 .../kylin/storage/gtrecord/GTCubeStorageQueryBase.java       |  5 ++---
 .../org/apache/kylin/engine/mr/common/AbstractHadoopJob.java | 12 ++++--------
 .../kylin/engine/mr/common/HadoopJobStatusChecker.java       |  2 +-
 .../kylin/engine/mr/steps/lookup/LookupExecutableUtil.java   |  4 +---
 8 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/cache/src/main/java/org/apache/kylin/cache/cachemanager/MemcachedCacheManager.java b/cache/src/main/java/org/apache/kylin/cache/cachemanager/MemcachedCacheManager.java
index a4e1ffe..f19947b 100644
--- a/cache/src/main/java/org/apache/kylin/cache/cachemanager/MemcachedCacheManager.java
+++ b/cache/src/main/java/org/apache/kylin/cache/cachemanager/MemcachedCacheManager.java
@@ -166,7 +166,7 @@ public class MemcachedCacheManager extends AbstractCacheManager {
             MemcachedClientIF cacheClient = (MemcachedClientIF) cache.getNativeCache();
             Collection<SocketAddress> liveServers = cacheClient.getAvailableServers();
             Collection<SocketAddress> deadServers = cacheClient.getUnavailableServers();
-            if (liveServers.size() == 0) {
+            if (liveServers.isEmpty()) {
                 clusterHealth.set(false);
                 logger.error("All the servers in MemcachedCluster is down, UnavailableServers: " + deadServers);
             } else {
@@ -178,4 +178,4 @@ public class MemcachedCacheManager extends AbstractCacheManager {
             }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/core-common/src/main/java/org/apache/kylin/common/util/Bytes.java b/core-common/src/main/java/org/apache/kylin/common/util/Bytes.java
index a267921..994d734 100644
--- a/core-common/src/main/java/org/apache/kylin/common/util/Bytes.java
+++ b/core-common/src/main/java/org/apache/kylin/common/util/Bytes.java
@@ -1964,7 +1964,7 @@ public class Bytes {
      * @param hex
      */
     public static byte[] fromHex(String hex) {
-        checkArgument(hex.length() > 0, LENGTH_MUST_BE_GREATER_THAN_0);
+        checkArgument(!hex.isEmpty(), LENGTH_MUST_BE_GREATER_THAN_0);
         checkArgument(hex.length() % 2 == 0, "length must be a multiple of 2");
         // Make sure letters are upper case
         hex = hex.toUpperCase(Locale.ROOT);
diff --git a/core-common/src/main/java/org/apache/kylin/common/util/ClasspathScanner.java b/core-common/src/main/java/org/apache/kylin/common/util/ClasspathScanner.java
index be41985..039e8bb 100644
--- a/core-common/src/main/java/org/apache/kylin/common/util/ClasspathScanner.java
+++ b/core-common/src/main/java/org/apache/kylin/common/util/ClasspathScanner.java
@@ -239,11 +239,11 @@ public class ClasspathScanner {
         File[] files;
         while (!queue.isEmpty()) {
             dirPath = (String) queue.remove(queue.size() - 1);
-            dirFile = dirPath.length() == 0 ? dir : new File(dir, dirPath);
+            dirFile = dirPath.isEmpty() ? dir : new File(dir, dirPath);
             files = dirFile.listFiles();
             for (int i = 0; files != null && i < files.length; i++) {
                 f = files[i];
-                path = dirPath + (dirPath.length() == 0 ? "" : "/") + f.getName();
+                path = dirPath + (dirPath.isEmpty() ? "" : "/") + f.getName();
                 if (f.isDirectory()) {
                     // cut off excluded dir early
                     if (scanFiles_isIncluded(path, null, excludes))
@@ -336,4 +336,4 @@ public class ClasspathScanner {
         return j == slen;
     }
 
-}
\ No newline at end of file
+}
diff --git a/core-common/src/main/java/org/apache/kylin/common/util/MailService.java b/core-common/src/main/java/org/apache/kylin/common/util/MailService.java
index 44e1d9c..90b88df 100644
--- a/core-common/src/main/java/org/apache/kylin/common/util/MailService.java
+++ b/core-common/src/main/java/org/apache/kylin/common/util/MailService.java
@@ -96,7 +96,7 @@ public class MailService {
             email.setSmtpPort(Integer.parseInt(port));
         }
         
-        if (username != null && username.trim().length() > 0) {
+        if (username != null && !username.trim().isEmpty()) {
             email.setAuthentication(username, password);
         }
 
diff --git a/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/GTCubeStorageQueryBase.java b/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/GTCubeStorageQueryBase.java
index 8d82873..3c3c7ff 100644
--- a/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/GTCubeStorageQueryBase.java
+++ b/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/GTCubeStorageQueryBase.java
@@ -19,6 +19,7 @@
 package org.apache.kylin.storage.gtrecord;
 
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
@@ -266,9 +267,7 @@ public abstract class GTCubeStorageQueryBase implements IStorageQuery {
             if (cubeDesc.isDerived(compFilter.getColumn())) {
                 DeriveInfo hostInfo = cubeDesc.getHostInfo(tblColRef);
                 if (hostInfo.isOneToOne) {
-                    for (TblColRef hostCol : hostInfo.columns) {
-                        resultD.add(hostCol);
-                    }
+                    resultD.addAll(Arrays.asList(hostInfo.columns));
                 }
                 //if not one2one, it will be pruned
             } else {
diff --git a/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/AbstractHadoopJob.java b/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/AbstractHadoopJob.java
index 76286e3..5e49c76 100644
--- a/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/AbstractHadoopJob.java
+++ b/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/AbstractHadoopJob.java
@@ -544,8 +544,7 @@ public abstract class AbstractHadoopJob extends Configured implements Tool {
     }
 
     protected void attachCubeMetadataWithDict(CubeInstance cube, Configuration conf) throws IOException {
-        Set<String> dumpList = new LinkedHashSet<>();
-        dumpList.addAll(collectCubeMetadata(cube));
+        Set<String> dumpList = new LinkedHashSet<>(collectCubeMetadata(cube));
         for (CubeSegment segment : cube.getSegments()) {
             dumpList.addAll(segment.getDictionaryPaths());
         }
@@ -553,9 +552,8 @@ public abstract class AbstractHadoopJob extends Configured implements Tool {
     }
 
     protected void attachSegmentsMetadataWithDict(List<CubeSegment> segments, Configuration conf) throws IOException {
-        Set<String> dumpList = new LinkedHashSet<>();
         CubeInstance cube = segments.get(0).getCubeInstance();
-        dumpList.addAll(collectCubeMetadata(cube));
+        Set<String> dumpList = new LinkedHashSet<>(collectCubeMetadata(cube));
         for (CubeSegment segment : segments) {
             dumpList.addAll(segment.getDictionaryPaths());
         }
@@ -563,8 +561,7 @@ public abstract class AbstractHadoopJob extends Configured implements Tool {
     }
 
     protected void attachSegmentsMetadataWithDict(List<CubeSegment> segments, String metaUrl) throws IOException {
-        Set<String> dumpList = new LinkedHashSet<>();
-        dumpList.addAll(JobRelatedMetaUtil.collectCubeMetadata(segments.get(0).getCubeInstance()));
+        Set<String> dumpList = new LinkedHashSet<>(JobRelatedMetaUtil.collectCubeMetadata(segments.get(0).getCubeInstance()));
         for (CubeSegment segment : segments) {
             dumpList.addAll(segment.getDictionaryPaths());
             dumpList.add(segment.getStatisticsResourcePath());
@@ -582,8 +579,7 @@ public abstract class AbstractHadoopJob extends Configured implements Tool {
 
     protected void attachSegmentMetadata(CubeSegment segment, Configuration conf, boolean ifDictIncluded,
             boolean ifStatsIncluded) throws IOException {
-        Set<String> dumpList = new LinkedHashSet<>();
-        dumpList.addAll(collectCubeMetadata(segment.getCubeInstance()));
+        Set<String> dumpList = new LinkedHashSet<>(collectCubeMetadata(segment.getCubeInstance()));
         if (ifDictIncluded) {
             dumpList.addAll(segment.getDictionaryPaths());
         }
diff --git a/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/HadoopJobStatusChecker.java b/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/HadoopJobStatusChecker.java
index 84fc03d..6165652 100644
--- a/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/HadoopJobStatusChecker.java
+++ b/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/HadoopJobStatusChecker.java
@@ -56,7 +56,7 @@ public class HadoopJobStatusChecker {
             }
         } catch (Exception e) {
             logger.error("error check status", e);
-            output.append("Exception: " + e.getLocalizedMessage() + "\n");
+            output.append("Exception: ").append(e.getLocalizedMessage()).append("\n");
             status = JobStepStatusEnum.ERROR;
         }
 
diff --git a/engine-mr/src/main/java/org/apache/kylin/engine/mr/steps/lookup/LookupExecutableUtil.java b/engine-mr/src/main/java/org/apache/kylin/engine/mr/steps/lookup/LookupExecutableUtil.java
index bc2aa1d..b4617d5 100644
--- a/engine-mr/src/main/java/org/apache/kylin/engine/mr/steps/lookup/LookupExecutableUtil.java
+++ b/engine-mr/src/main/java/org/apache/kylin/engine/mr/steps/lookup/LookupExecutableUtil.java
@@ -79,9 +79,7 @@ public class LookupExecutableUtil {
         if (ids != null) {
             final String[] splitted = StringUtils.split(ids, ",");
             ArrayList<String> result = Lists.newArrayListWithExpectedSize(splitted.length);
-            for (String id : splitted) {
-                result.add(id);
-            }
+            Collections.addAll(result, splitted);
             return result;
         } else {
             return Collections.emptyList();