Java Code Examples for org.apache.kylin.rest.response.SQLResponse#isStorageCacheUsed()
The following examples show how to use
org.apache.kylin.rest.response.SQLResponse#isStorageCacheUsed() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryMetricsFacade.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
private static void incrCacheHitCount(QueryMetrics queryMetrics, SQLResponse sqlResponse) { if (sqlResponse.isStorageCacheUsed()) { queryMetrics.addCacheHitCount(1); } }
Example 2
Source File: QueryMetrics2Facade.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
private static void incrCacheHitCount(String name, SQLResponse sqlResponse) { if (sqlResponse.isStorageCacheUsed()) { metrics.incrementCounter(MetricsNameBuilder.buildMetricName(name, MetricsConstant.QUERY_CACHE_COUNT)); } }
Example 3
Source File: QueryService.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
public void logQuery(final String queryId, final SQLRequest request, final SQLResponse response) { final String user = aclEvaluate.getCurrentUserName(); final List<String> realizationNames = new LinkedList<>(); final Set<Long> cuboidIds = new HashSet<Long>(); float duration = response.getDuration() / (float) 1000; boolean storageCacheUsed = response.isStorageCacheUsed(); boolean isPushDown = response.isPushDown(); if (!response.isHitExceptionCache() && null != OLAPContext.getThreadLocalContexts()) { for (OLAPContext ctx : OLAPContext.getThreadLocalContexts()) { Cuboid cuboid = ctx.storageContext.getCuboid(); if (cuboid != null) { //Some queries do not involve cuboid, e.g. lookup table query cuboidIds.add(cuboid.getId()); } if (ctx.realization != null) { realizationNames.add(ctx.realization.getCanonicalName()); } } } if (realizationNames.isEmpty()) { if (!Strings.isNullOrEmpty(response.getCube())) { realizationNames.addAll(Lists.newArrayList(StringUtil.splitByComma(response.getCube()))); } } int resultRowCount = 0; if (!response.getIsException() && response.getResults() != null) { resultRowCount = response.getResults().size(); } String newLine = System.getProperty("line.separator"); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(newLine); stringBuilder.append("==========================[QUERY]===============================").append(newLine); stringBuilder.append("Query Id: ").append(queryId).append(newLine); stringBuilder.append("SQL: ").append(request.getSql()).append(newLine); stringBuilder.append("User: ").append(user).append(newLine); stringBuilder.append("Success: ").append((null == response.getExceptionMessage())).append(newLine); stringBuilder.append("Duration: ").append(duration).append(newLine); stringBuilder.append("Project: ").append(request.getProject()).append(newLine); stringBuilder.append("Realization Names: ").append(realizationNames).append(newLine); stringBuilder.append("Cuboid Ids: ").append(cuboidIds).append(newLine); stringBuilder.append("Total scan count: ").append(response.getTotalScanCount()).append(newLine); stringBuilder.append("Total scan bytes: ").append(response.getTotalScanBytes()).append(newLine); stringBuilder.append("Result row count: ").append(resultRowCount).append(newLine); stringBuilder.append("Accept Partial: ").append(request.isAcceptPartial()).append(newLine); stringBuilder.append("Is Partial Result: ").append(response.isPartial()).append(newLine); stringBuilder.append("Hit Exception Cache: ").append(response.isHitExceptionCache()).append(newLine); stringBuilder.append("Storage cache used: ").append(storageCacheUsed).append(newLine); stringBuilder.append("Is Query Push-Down: ").append(isPushDown).append(newLine); stringBuilder.append("Is Prepare: ").append(BackdoorToggles.getPrepareOnly()).append(newLine); stringBuilder.append("Trace URL: ").append(response.getTraceUrl()).append(newLine); stringBuilder.append("Message: ").append(response.getExceptionMessage()).append(newLine); stringBuilder.append("==========================[QUERY]===============================").append(newLine); logger.info(stringBuilder.toString()); }
Example 4
Source File: QueryMetricsFacade.java From kylin with Apache License 2.0 | 4 votes |
private static void incrCacheHitCount(QueryMetrics queryMetrics, SQLResponse sqlResponse) { if (sqlResponse.isStorageCacheUsed()) { queryMetrics.addCacheHitCount(1); } }
Example 5
Source File: QueryMetrics2Facade.java From kylin with Apache License 2.0 | 4 votes |
private static void incrCacheHitCount(String name, SQLResponse sqlResponse) { if (sqlResponse.isStorageCacheUsed()) { metrics.incrementCounter(MetricsNameBuilder.buildMetricName(name, MetricsConstant.QUERY_CACHE_COUNT)); } }
Example 6
Source File: QueryService.java From kylin with Apache License 2.0 | 4 votes |
public void logQuery(final String queryId, final SQLRequest request, final SQLResponse response) { final String user = aclEvaluate.getCurrentUserName(); final List<String> realizationNames = new LinkedList<>(); final Set<Long> cuboidIds = new HashSet<Long>(); float duration = response.getDuration() / (float) 1000; boolean storageCacheUsed = response.isStorageCacheUsed(); boolean isPushDown = response.isPushDown(); if (!response.isHitExceptionCache() && null != OLAPContext.getThreadLocalContexts()) { for (OLAPContext ctx : OLAPContext.getThreadLocalContexts()) { Cuboid cuboid = ctx.storageContext.getCuboid(); if (cuboid != null) { //Some queries do not involve cuboid, e.g. lookup table query cuboidIds.add(cuboid.getId()); } if (ctx.realization != null) { realizationNames.add(ctx.realization.getCanonicalName()); } } } // if Realization Names is empty, get value from SQLResponse. if (realizationNames.isEmpty()) { if (!Strings.isNullOrEmpty(response.getCube())) { realizationNames.addAll(Lists.newArrayList(StringUtil.splitByComma(response.getCube()))); } } // if Cuboid Ids is empty, get value from SQLResponse. if (cuboidIds.isEmpty()) { List<QueryContext.CubeSegmentStatisticsResult> cubeSegmentStatisticsList = response.getCubeSegmentStatisticsList(); if (CollectionUtils.isNotEmpty(cubeSegmentStatisticsList)) { cubeSegmentStatisticsList.forEach(cubeSegmentStatResult -> { if (MapUtils.isNotEmpty(cubeSegmentStatResult.getCubeSegmentStatisticsMap())) { cubeSegmentStatResult.getCubeSegmentStatisticsMap().values().forEach(cubeSegmentStatMap -> { cubeSegmentStatMap.values().forEach(cubeSegmentStat -> { cuboidIds.add(cubeSegmentStat.getTargetCuboidId()); }); }); } }); } } int resultRowCount = 0; if (!response.getIsException() && response.getResults() != null) { resultRowCount = response.getResults().size(); } String newLine = System.getProperty("line.separator"); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(newLine); stringBuilder.append("==========================[QUERY]===============================").append(newLine); stringBuilder.append("Query Id: ").append(queryId).append(newLine); stringBuilder.append("SQL: ").append(request.getSql()).append(newLine); stringBuilder.append("User: ").append(user).append(newLine); stringBuilder.append("Success: ").append((null == response.getExceptionMessage())).append(newLine); stringBuilder.append("Duration: ").append(duration).append(newLine); stringBuilder.append("Project: ").append(request.getProject()).append(newLine); stringBuilder.append("Realization Names: ").append(realizationNames).append(newLine); stringBuilder.append("Cuboid Ids: ").append(cuboidIds).append(newLine); stringBuilder.append("Total scan count: ").append(response.getTotalScanCount()).append(newLine); stringBuilder.append("Total scan bytes: ").append(response.getTotalScanBytes()).append(newLine); stringBuilder.append("Result row count: ").append(resultRowCount).append(newLine); stringBuilder.append("Accept Partial: ").append(request.isAcceptPartial()).append(newLine); stringBuilder.append("Is Partial Result: ").append(response.isPartial()).append(newLine); stringBuilder.append("Hit Exception Cache: ").append(response.isHitExceptionCache()).append(newLine); stringBuilder.append("Storage cache used: ").append(storageCacheUsed).append(newLine); stringBuilder.append("Is Query Push-Down: ").append(isPushDown).append(newLine); stringBuilder.append("Is Prepare: ").append(BackdoorToggles.getPrepareOnly()).append(newLine); stringBuilder.append("Trace URL: ").append(response.getTraceUrl()).append(newLine); stringBuilder.append("Message: ").append(response.getExceptionMessage()).append(newLine); stringBuilder.append("==========================[QUERY]===============================").append(newLine); logger.info(stringBuilder.toString()); }