You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2017/03/10 01:48:25 UTC

[1/2] kylin git commit: minor changes

Repository: kylin
Updated Branches:
  refs/heads/master 182ed0094 -> 181890e54


minor changes


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

Branch: refs/heads/master
Commit: 181890e542783e66078ad707f37dcb273abae596
Parents: 7eb9969
Author: Hongbin Ma <ma...@apache.org>
Authored: Thu Mar 9 21:19:26 2017 +0800
Committer: Hongbin Ma <ma...@apache.org>
Committed: Thu Mar 9 21:19:30 2017 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/kylin/common/QueryContext.java |  3 +++
 .../org/apache/kylin/rest/service/QueryService.java     | 12 ++++--------
 2 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/181890e5/core-common/src/main/java/org/apache/kylin/common/QueryContext.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/QueryContext.java b/core-common/src/main/java/org/apache/kylin/common/QueryContext.java
index 5457aa5..0b8d519 100644
--- a/core-common/src/main/java/org/apache/kylin/common/QueryContext.java
+++ b/core-common/src/main/java/org/apache/kylin/common/QueryContext.java
@@ -18,6 +18,7 @@
 
 package org.apache.kylin.common;
 
+import java.util.UUID;
 import java.util.concurrent.atomic.AtomicLong;
 
 /**
@@ -38,6 +39,8 @@ public class QueryContext {
 
     private QueryContext() {
         // use QueryContext.current() instead
+        
+        queryId = UUID.randomUUID().toString();
     }
 
     public static QueryContext current() {

http://git-wip-us.apache.org/repos/asf/kylin/blob/181890e5/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java b/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
index 122b823..6a38638 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
@@ -41,7 +41,6 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.UUID;
 
 import javax.annotation.PostConstruct;
 import javax.sql.DataSource;
@@ -237,7 +236,7 @@ public class QueryService extends BasicService {
 
     public void logQuery(final SQLRequest request, final SQLResponse response) {
         final String user = SecurityContextHolder.getContext().getAuthentication().getName();
-        final Set<String> realizationNames = new HashSet<String>();
+        final List<String> realizationNames = new LinkedList<>();
         final Set<Long> cuboidIds = new HashSet<Long>();
         float duration = response.getDuration() / (float) 1000;
         boolean storageCacheUsed = response.isStorageCacheUsed();
@@ -251,8 +250,7 @@ public class QueryService extends BasicService {
                 }
 
                 if (ctx.realization != null) {
-                    String realizationName = ctx.realization.getName();
-                    realizationNames.add(realizationName);
+                    realizationNames.add(ctx.realization.getCanonicalName());
                 }
 
             }
@@ -332,10 +330,8 @@ public class QueryService extends BasicService {
             BackdoorToggles.addToggles(sqlRequest.getBackdoorToggles());
 
         final QueryContext queryContext = QueryContext.current();
-        final String queryId = UUID.randomUUID().toString();
-        queryContext.setQueryId(queryId);
 
-        try (SetThreadName ignored = new SetThreadName("Query %s", queryId)) {
+        try (SetThreadName ignored = new SetThreadName("Query %s", queryContext.getQueryId())) {
             String sql = sqlRequest.getSql();
             String project = sqlRequest.getProject();
             logger.info("Using project: " + project);
@@ -431,7 +427,7 @@ public class QueryService extends BasicService {
         return response;
     }
 
-    private void checkQueryAuth(SQLResponse sqlResponse) throws AccessDeniedException {
+    protected void checkQueryAuth(SQLResponse sqlResponse) throws AccessDeniedException {
         if (!sqlResponse.getIsException() && KylinConfig.getInstanceFromEnv().isQuerySecureEnabled()) {
             checkAuthorization(sqlResponse.getCube());
         }


[2/2] kylin git commit: KYLIN-2493 Auto enlarge buffer in FactDistinctColumnsMapper

Posted by li...@apache.org.
KYLIN-2493 Auto enlarge buffer in FactDistinctColumnsMapper

Signed-off-by: Hongbin Ma <ma...@apache.org>


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

Branch: refs/heads/master
Commit: 7eb9969e1ce54cc919ad47f2589d85da44090d18
Parents: 182ed00
Author: xiefan46 <95...@qq.com>
Authored: Thu Mar 9 18:25:11 2017 +0800
Committer: Hongbin Ma <ma...@apache.org>
Committed: Thu Mar 9 21:19:30 2017 +0800

----------------------------------------------------------------------
 .../mr/steps/FactDistinctColumnsMapper.java     | 24 +++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/7eb9969e/engine-mr/src/main/java/org/apache/kylin/engine/mr/steps/FactDistinctColumnsMapper.java
----------------------------------------------------------------------
diff --git a/engine-mr/src/main/java/org/apache/kylin/engine/mr/steps/FactDistinctColumnsMapper.java b/engine-mr/src/main/java/org/apache/kylin/engine/mr/steps/FactDistinctColumnsMapper.java
index d9c1309..07e788c 100644
--- a/engine-mr/src/main/java/org/apache/kylin/engine/mr/steps/FactDistinctColumnsMapper.java
+++ b/engine-mr/src/main/java/org/apache/kylin/engine/mr/steps/FactDistinctColumnsMapper.java
@@ -48,7 +48,7 @@ public class FactDistinctColumnsMapper<KEYIN> extends FactDistinctColumnsMapperB
 
     public static enum RawDataCounter {
         BYTES
-    };
+    }
 
     protected boolean collectStatistics = false;
     protected CuboidScheduler cuboidScheduler = null;
@@ -153,8 +153,13 @@ public class FactDistinctColumnsMapper<KEYIN> extends FactDistinctColumnsMapperB
             }
 
             tmpbuf.clear();
+            byte[] valueBytes = Bytes.toBytes(fieldValue);
+            int size = valueBytes.length + 1;
+            if (size >= tmpbuf.capacity()) {
+                tmpbuf = ByteBuffer.allocate(countNewSize(tmpbuf.capacity(), size));
+            }
             tmpbuf.put(Bytes.toBytes(reducerIndex)[3]);
-            tmpbuf.put(Bytes.toBytes(fieldValue));
+            tmpbuf.put(valueBytes);
             outputKey.set(tmpbuf.array(), 0, tmpbuf.position());
             sortableKey.setText(outputKey);
             //judge type
@@ -176,8 +181,13 @@ public class FactDistinctColumnsMapper<KEYIN> extends FactDistinctColumnsMapperB
                 String fieldValue = row[partitionColumnIndex];
                 if (fieldValue != null) {
                     tmpbuf.clear();
+                    byte[] valueBytes = Bytes.toBytes(fieldValue);
+                    int size = valueBytes.length + 1;
+                    if (size >= tmpbuf.capacity()) {
+                        tmpbuf = ByteBuffer.allocate(countNewSize(tmpbuf.capacity(), size));
+                    }
                     tmpbuf.put(MARK_FOR_PARTITION_COL);
-                    tmpbuf.put(Bytes.toBytes(fieldValue));
+                    tmpbuf.put(valueBytes);
                     outputKey.set(tmpbuf.array(), 0, tmpbuf.position());
                     sortableKey.setText(outputKey);
                     sortableKey.setTypeId((byte) 0);
@@ -243,4 +253,12 @@ public class FactDistinctColumnsMapper<KEYIN> extends FactDistinctColumnsMapperB
             }
         }
     }
+
+    private int countNewSize(int oldSize, int dataSize) {
+        int newSize = oldSize * 2;
+        while (newSize < dataSize) {
+            newSize = newSize * 2;
+        }
+        return newSize;
+    }
 }