You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ma...@apache.org on 2016/06/25 11:12:16 UTC
[15/18] kylin git commit: KYLIN-1821 Reformat all of the java files
and enable checkstyle to enforce code formatting
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/IKylinValidationConstants.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/IKylinValidationConstants.java b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/IKylinValidationConstants.java
deleted file mode 100644
index d0a07de..0000000
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/IKylinValidationConstants.java
+++ /dev/null
@@ -1,28 +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.cube.model.validation.rule;
-
-import org.apache.kylin.metadata.MetadataConstants;
-
-public interface IKylinValidationConstants extends MetadataConstants {
-
- public static final int DEFAULT_MAX_AGR_GROUP_SIZE = 12;
- public static final String KEY_MAX_AGR_GROUP_SIZE = "rule_max.arggregation.group.size";
-
-}
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/cube/upgrade/common/MetadataVersionRefresher.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/upgrade/common/MetadataVersionRefresher.java b/core-cube/src/main/java/org/apache/kylin/cube/upgrade/common/MetadataVersionRefresher.java
index 02f084c..4cf0584 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/upgrade/common/MetadataVersionRefresher.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/upgrade/common/MetadataVersionRefresher.java
@@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.node.ObjectNode;
+
import com.google.common.collect.Lists;
/**
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/cube/upgrade/v1_4_0/CubeMetadataUpgrade_v_1_4_0.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/upgrade/v1_4_0/CubeMetadataUpgrade_v_1_4_0.java b/core-cube/src/main/java/org/apache/kylin/cube/upgrade/v1_4_0/CubeMetadataUpgrade_v_1_4_0.java
index 007b868..ca78d68 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/upgrade/v1_4_0/CubeMetadataUpgrade_v_1_4_0.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/upgrade/v1_4_0/CubeMetadataUpgrade_v_1_4_0.java
@@ -66,8 +66,6 @@ public class CubeMetadataUpgrade_v_1_4_0 extends CubeMetadataUpgrade {
//do nothing
}
-
-
private CubeDesc loadOldCubeDesc(String path) {
CubeDesc ndesc = null;
try {
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/gridtable/GTAggregateScanner.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/gridtable/GTAggregateScanner.java b/core-cube/src/main/java/org/apache/kylin/gridtable/GTAggregateScanner.java
index 53cc387..863b958 100644
--- a/core-cube/src/main/java/org/apache/kylin/gridtable/GTAggregateScanner.java
+++ b/core-cube/src/main/java/org/apache/kylin/gridtable/GTAggregateScanner.java
@@ -193,8 +193,8 @@ public class GTAggregateScanner implements IGTScanner {
for (int i = 0; i < types.length; i++) {
types[i] = info.getColumnType(metrics.trueBitAt(i));
}
-
- BufferedMeasureEncoder result = new BufferedMeasureEncoder(types);
+
+ BufferedMeasureEncoder result = new BufferedMeasureEncoder(types);
result.setBufferSize(info.getMaxColumnLength(metrics));
return result;
}
@@ -372,7 +372,7 @@ public class GTAggregateScanner implements IGTScanner {
record.cols[c].set(key, offset, columnLength);
offset += columnLength;
}
-
+
for (int i = 0; i < value.length; i++) {
tmpValues[i] = value[i].getState();
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/gridtable/GTFilterScanner.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/gridtable/GTFilterScanner.java b/core-cube/src/main/java/org/apache/kylin/gridtable/GTFilterScanner.java
index 61129b1..a5fa808 100644
--- a/core-cube/src/main/java/org/apache/kylin/gridtable/GTFilterScanner.java
+++ b/core-cube/src/main/java/org/apache/kylin/gridtable/GTFilterScanner.java
@@ -98,12 +98,12 @@ public class GTFilterScanner implements IGTScanner {
private boolean evaluate() {
if (filter == null)
return true;
-
+
// 'next' and 'oneTuple' are referring to the same record
boolean[] cachedResult = resultCache.checkCache(next);
if (cachedResult != null)
return cachedResult[0];
-
+
boolean result = filter.evaluate(oneTuple, filterCodeSystem);
resultCache.setLastResult(result);
return result;
@@ -153,16 +153,16 @@ public class GTFilterScanner implements IGTScanner {
public boolean[] checkCache(GTRecord record) {
if (!enabled)
return null;
-
+
count++;
-
+
// disable the cache if the hit rate is bad
if (count == CHECKPOINT) {
if ((double) hit / (double) count < HIT_RATE_THRESHOLD) {
enabled = false;
}
}
-
+
boolean match = count > 1;
int p = 0;
for (int i = 0; i < colsInFilter.trueBitCount(); i++) {
@@ -176,7 +176,7 @@ public class GTFilterScanner implements IGTScanner {
}
p += col.length();
}
-
+
if (match) {
hit++;
return lastResult;
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/gridtable/GTInfo.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/gridtable/GTInfo.java b/core-cube/src/main/java/org/apache/kylin/gridtable/GTInfo.java
index 349bd3f..0571c6f 100644
--- a/core-cube/src/main/java/org/apache/kylin/gridtable/GTInfo.java
+++ b/core-cube/src/main/java/org/apache/kylin/gridtable/GTInfo.java
@@ -58,7 +58,6 @@ public class GTInfo {
private GTInfo() {
}
-
public String getTableName() {
return tableName;
}
@@ -74,7 +73,7 @@ public class GTInfo {
public int getColumnBlockCount() {
return colBlocks.length;
}
-
+
public ImmutableBitSet getColumnBlock(int i) {
return colBlocks[i];
}
@@ -82,7 +81,7 @@ public class GTInfo {
public ImmutableBitSet getPrimaryKey() {
return primaryKey;
}
-
+
public ImmutableBitSet getAllColumns() {
return colAll;
}
@@ -333,12 +332,12 @@ public class GTInfo {
int newRowBlockSize = BytesUtil.readVInt(in);
return GTInfo.builder().setCodeSystem(codeSystem).//
- setTableName(newTableName).//
- setColumns(newColTypes).//
- setColumnPreferIndex(newColPreferIndex).//
- setPrimaryKey(newPrimaryKey).//
- enableColumnBlock(newColBlocks).//
- enableRowBlock(newRowBlockSize).build();
+ setTableName(newTableName).//
+ setColumns(newColTypes).//
+ setColumnPreferIndex(newColPreferIndex).//
+ setPrimaryKey(newPrimaryKey).//
+ enableColumnBlock(newColBlocks).//
+ enableRowBlock(newRowBlockSize).build();
}
};
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/gridtable/GTInvertedIndexOfColumn.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/gridtable/GTInvertedIndexOfColumn.java b/core-cube/src/main/java/org/apache/kylin/gridtable/GTInvertedIndexOfColumn.java
index 6069e73..bfacc0f 100644
--- a/core-cube/src/main/java/org/apache/kylin/gridtable/GTInvertedIndexOfColumn.java
+++ b/core-cube/src/main/java/org/apache/kylin/gridtable/GTInvertedIndexOfColumn.java
@@ -24,6 +24,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.kylin.common.util.ByteArray;
import com.google.common.collect.Maps;
+
import it.uniroma3.mat.extendedset.intset.ConciseSet;
public class GTInvertedIndexOfColumn {
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/gridtable/GTRecord.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/gridtable/GTRecord.java b/core-cube/src/main/java/org/apache/kylin/gridtable/GTRecord.java
index 276f66e..37f42c7 100644
--- a/core-cube/src/main/java/org/apache/kylin/gridtable/GTRecord.java
+++ b/core-cube/src/main/java/org/apache/kylin/gridtable/GTRecord.java
@@ -235,8 +235,6 @@ public class GTRecord implements Comparable<GTRecord> {
buf.setLength(pos);
}
-
-
/** write data to given buffer, like serialize */
public void exportColumns(ImmutableBitSet selectedCols, ByteBuffer buf) {
for (int i = 0; i < selectedCols.trueBitCount(); i++) {
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/gridtable/GTScanRange.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/gridtable/GTScanRange.java b/core-cube/src/main/java/org/apache/kylin/gridtable/GTScanRange.java
index 0cffcd9..6f93252 100644
--- a/core-cube/src/main/java/org/apache/kylin/gridtable/GTScanRange.java
+++ b/core-cube/src/main/java/org/apache/kylin/gridtable/GTScanRange.java
@@ -48,7 +48,7 @@ public class GTScanRange {
newFuzzyKeys.add(new GTRecord(gtInfo, input.cols));
}
return new GTScanRange(new GTRecord(gtInfo, pkStart.cols), //
- new GTRecord(gtInfo, pkEnd.cols), //
+ new GTRecord(gtInfo, pkEnd.cols), //
newFuzzyKeys);
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/gridtable/GTScanRangePlanner.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/gridtable/GTScanRangePlanner.java b/core-cube/src/main/java/org/apache/kylin/gridtable/GTScanRangePlanner.java
index 5531005..17d27f9 100644
--- a/core-cube/src/main/java/org/apache/kylin/gridtable/GTScanRangePlanner.java
+++ b/core-cube/src/main/java/org/apache/kylin/gridtable/GTScanRangePlanner.java
@@ -145,7 +145,7 @@ public class GTScanRangePlanner {
this.maxScanRanges = KylinConfig.getInstanceFromEnv().getQueryStorageVisitScanRangeMax();
this.maxFuzzyKeys = KylinConfig.getInstanceFromEnv().getQueryScanFuzzyKeyMax();
-
+
this.gtInfo = info;
IGTComparator comp = gtInfo.codeSystem.getComparator();
@@ -161,7 +161,6 @@ public class GTScanRangePlanner {
this.gtPartitionCol = gtPartitionCol;
}
-
public GTScanRequest planScanRequest() {
GTScanRequest scanRequest;
List<GTScanRange> scanRanges = this.planScanRanges();
@@ -311,8 +310,8 @@ public class GTScanRangePlanner {
if (gtPartitionCol != null && range.column.equals(gtPartitionCol)) {
if (rangeStartEndComparator.comparator.compare(gtStartAndEnd.getFirst(), range.end) <= 0 //
&& (rangeStartEndComparator.comparator.compare(range.begin, gtStartAndEnd.getSecond()) < 0 //
- || rangeStartEndComparator.comparator.compare(range.begin, gtStartAndEnd.getSecond()) == 0 //
- && (range.op == FilterOperatorEnum.EQ || range.op == FilterOperatorEnum.LTE || range.op == FilterOperatorEnum.GTE || range.op == FilterOperatorEnum.IN))) {
+ || rangeStartEndComparator.comparator.compare(range.begin, gtStartAndEnd.getSecond()) == 0 //
+ && (range.op == FilterOperatorEnum.EQ || range.op == FilterOperatorEnum.LTE || range.op == FilterOperatorEnum.GTE || range.op == FilterOperatorEnum.IN))) {
//segment range is [Closed,Open), but segmentStartAndEnd.getSecond() might be rounded, so use <= when has equals in condition.
} else {
logger.debug("Pre-check partition col filter failed, partitionColRef {}, segment start {}, segment end {}, range begin {}, range end {}", //
@@ -353,10 +352,10 @@ public class GTScanRangePlanner {
for (Map<Integer, ByteArray> fuzzyValue : fuzzyValueCombinations) {
-// BitSet bitSet = new BitSet(gtInfo.getColumnCount());
-// for (Map.Entry<Integer, ByteArray> entry : fuzzyValue.entrySet()) {
-// bitSet.set(entry.getKey());
-// }
+ // BitSet bitSet = new BitSet(gtInfo.getColumnCount());
+ // for (Map.Entry<Integer, ByteArray> entry : fuzzyValue.entrySet()) {
+ // bitSet.set(entry.getKey());
+ // }
GTRecord fuzzy = new GTRecord(gtInfo);
for (Map.Entry<Integer, ByteArray> entry : fuzzyValue.entrySet()) {
fuzzy.set(entry.getKey(), entry.getValue());
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/gridtable/IGTCodeSystem.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/gridtable/IGTCodeSystem.java b/core-cube/src/main/java/org/apache/kylin/gridtable/IGTCodeSystem.java
index 7402f2f..89dfc99 100644
--- a/core-cube/src/main/java/org/apache/kylin/gridtable/IGTCodeSystem.java
+++ b/core-cube/src/main/java/org/apache/kylin/gridtable/IGTCodeSystem.java
@@ -35,7 +35,7 @@ public interface IGTCodeSystem {
/** Return the max possible length of a column */
int maxCodeLength(int col);
-
+
/** Return a DimensionEncoding if the underlying column is backed by a cube dimension, return null otherwise */
DimensionEncoding getDimEnc(int col);
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/gridtable/UnitTestSupport.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/gridtable/UnitTestSupport.java b/core-cube/src/main/java/org/apache/kylin/gridtable/UnitTestSupport.java
index c54b5be..3ec1d74 100644
--- a/core-cube/src/main/java/org/apache/kylin/gridtable/UnitTestSupport.java
+++ b/core-cube/src/main/java/org/apache/kylin/gridtable/UnitTestSupport.java
@@ -22,10 +22,10 @@ import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
-import org.apache.kylin.measure.hllc.HyperLogLogPlusCounter;
import org.apache.kylin.common.util.DateFormat;
import org.apache.kylin.common.util.ImmutableBitSet;
import org.apache.kylin.gridtable.GTInfo.Builder;
+import org.apache.kylin.measure.hllc.HyperLogLogPlusCounter;
import org.apache.kylin.metadata.datatype.DataType;
import org.apache.kylin.metadata.datatype.LongMutable;
@@ -41,14 +41,13 @@ public class UnitTestSupport {
Builder builder = infoBuilder();
builder.enableColumnBlock(new ImmutableBitSet[] { setOf(0), setOf(1, 2), setOf(3, 4) });
builder.enableRowBlock(4);
- GTInfo info = builder.build();
- return info;
+ return builder.build();
}
public static GTInfo hllInfo() {
Builder builder = GTInfo.builder();
builder.setCodeSystem(new GTSampleCodeSystem());
- builder.setColumns( //
+ builder.setColumns(//
DataType.getType("varchar(10)"), //
DataType.getType("varchar(10)"), //
DataType.getType("varchar(10)"), //
@@ -58,14 +57,13 @@ public class UnitTestSupport {
);
builder.setPrimaryKey(setOf(0));
builder.setColumnPreferIndex(setOf(0));
- GTInfo info = builder.build();
- return info;
+ return builder.build();
}
private static Builder infoBuilder() {
Builder builder = GTInfo.builder();
builder.setCodeSystem(new GTSampleCodeSystem());
- builder.setColumns( //
+ builder.setColumns(//
DataType.getType("varchar(10)"), //
DataType.getType("varchar(10)"), //
DataType.getType("varchar(10)"), //
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/GTScannerBenchmark.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/GTScannerBenchmark.java b/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/GTScannerBenchmark.java
index 0d96ac0..680ba33 100644
--- a/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/GTScannerBenchmark.java
+++ b/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/GTScannerBenchmark.java
@@ -25,11 +25,11 @@ import org.apache.kylin.common.util.ByteArray;
import org.apache.kylin.common.util.BytesUtil;
import org.apache.kylin.common.util.ImmutableBitSet;
import org.apache.kylin.gridtable.GTInfo;
+import org.apache.kylin.gridtable.GTInfo.Builder;
import org.apache.kylin.gridtable.GTRecord;
import org.apache.kylin.gridtable.GTSampleCodeSystem;
import org.apache.kylin.gridtable.GTScanRequest;
import org.apache.kylin.gridtable.IGTScanner;
-import org.apache.kylin.gridtable.GTInfo.Builder;
import org.apache.kylin.metadata.datatype.DataType;
import org.apache.kylin.metadata.filter.ColumnTupleFilter;
import org.apache.kylin.metadata.filter.CompareTupleFilter;
@@ -134,19 +134,19 @@ public class GTScannerBenchmark {
//@Test
public void testFilter2() throws IOException {
- testFilter( //
- and( //
+ testFilter(//
+ and(//
gt(col(0), 5), //
eq(col(2), 2, 4)));
}
//@Test
public void testFilter3() throws IOException {
- testFilter( //
- and( //
+ testFilter(//
+ and(//
gt(col(0), 2), //
eq(col(4), 1, 3, 5, 9, 12, 14, 23, 43, 52, 78, 92), //
- or( //
+ or(//
eq(col(1), 2, 4), //
eq(col(2), 2, 4, 5, 9))));
}
@@ -161,7 +161,7 @@ public class GTScannerBenchmark {
for (GTRecord rec : scanner) {
count++;
}
-
+
t = System.currentTimeMillis() - t;
System.out.println(N + " records filtered to " + count + ", " + calcSpeed(t) + "K rec/sec");
}
@@ -213,14 +213,14 @@ public class GTScannerBenchmark {
private ColumnTupleFilter col(int i) {
return new ColumnTupleFilter(info.colRef(i));
}
-
+
public static void main(String[] args) throws IOException {
GTScannerBenchmark benchmark = new GTScannerBenchmark();
-
+
benchmark.testFilter1();
benchmark.testFilter2();
benchmark.testFilter3();
-
+
benchmark.testAggregate2();
benchmark.testAggregate2_();
benchmark.testAggregate4();
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/GTScannerBenchmark2.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/GTScannerBenchmark2.java b/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/GTScannerBenchmark2.java
index 8a376ba..ae86e46 100644
--- a/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/GTScannerBenchmark2.java
+++ b/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/GTScannerBenchmark2.java
@@ -27,11 +27,11 @@ import org.apache.kylin.common.util.ByteArray;
import org.apache.kylin.common.util.BytesUtil;
import org.apache.kylin.common.util.ImmutableBitSet;
import org.apache.kylin.gridtable.GTInfo;
+import org.apache.kylin.gridtable.GTInfo.Builder;
import org.apache.kylin.gridtable.GTRecord;
import org.apache.kylin.gridtable.GTSampleCodeSystem;
import org.apache.kylin.gridtable.GTScanRequest;
import org.apache.kylin.gridtable.IGTScanner;
-import org.apache.kylin.gridtable.GTInfo.Builder;
import org.apache.kylin.gridtable.benchmark.SortedGTRecordGenerator.Randomizer;
import org.apache.kylin.measure.hllc.HyperLogLogPlusCounter;
import org.apache.kylin.metadata.datatype.DataType;
@@ -80,7 +80,7 @@ public class GTScannerBenchmark2 {
gen.addMeasure(8);
gen.addMeasure(8, new Randomizer() {
HyperLogLogPlusCounter hllc = new HyperLogLogPlusCounter(12);
-
+
@Override
public int fillRandom(Random rand, byte[] array, int offset) {
try {
@@ -156,19 +156,19 @@ public class GTScannerBenchmark2 {
//@Test
public void testFilter2() throws IOException {
- testFilter( //
- and( //
+ testFilter(//
+ and(//
gt(col(0), 5), //
eq(col(2), 2, 4)));
}
//@Test
public void testFilter3() throws IOException {
- testFilter( //
- and( //
+ testFilter(//
+ and(//
gt(col(0), 2), //
eq(col(4), 1, 3, 5, 9, 12, 14, 23, 43, 52, 78, 92), //
- or( //
+ or(//
eq(col(1), 2, 4), //
eq(col(2), 2, 4, 5, 9))));
}
@@ -183,7 +183,7 @@ public class GTScannerBenchmark2 {
for (GTRecord rec : scanner) {
count++;
}
-
+
t = System.currentTimeMillis() - t;
System.out.println(N + " records filtered to " + count + ", " + calcSpeed(t) + "K rec/sec");
}
@@ -238,11 +238,11 @@ public class GTScannerBenchmark2 {
public static void main(String[] args) throws IOException {
GTScannerBenchmark2 benchmark = new GTScannerBenchmark2();
-
+
benchmark.testFilter1();
benchmark.testFilter2();
benchmark.testFilter3();
-
+
benchmark.testAggregate2();
benchmark.testAggregate2_();
benchmark.testAggregate4();
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/SortedGTRecordGenerator.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/SortedGTRecordGenerator.java b/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/SortedGTRecordGenerator.java
index 882267e..fd87410 100644
--- a/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/SortedGTRecordGenerator.java
+++ b/core-cube/src/main/java/org/apache/kylin/gridtable/benchmark/SortedGTRecordGenerator.java
@@ -62,7 +62,7 @@ public class SortedGTRecordGenerator {
spec.measureRandomizer = randomizer;
colSpecs.add(spec);
}
-
+
public IGTScanner generate(long nRows) {
validate();
return new Generator(nRows);
@@ -85,18 +85,18 @@ public class SortedGTRecordGenerator {
long weightSum;
Randomizer measureRandomizer;
}
-
+
public interface Randomizer {
int fillRandom(Random rand, byte[] array, int offset);
}
-
+
public static class BytesRandomizer implements Randomizer {
- final private byte bytes[];
+ final private byte[] bytes;
public BytesRandomizer(int len) {
this.bytes = new byte[len];
}
-
+
@Override
public int fillRandom(Random rand, byte[] array, int offset) {
rand.nextBytes(bytes);
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java b/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java
index fb2e18b..98cff43 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java
@@ -18,18 +18,23 @@
package org.apache.kylin.cube;
-import com.google.common.collect.Maps;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.kylin.common.util.JsonUtil;
import org.apache.kylin.common.util.LocalFileMetadataTestCase;
import org.apache.kylin.cube.model.CubeDesc;
import org.apache.kylin.cube.model.SelectRule;
import org.apache.kylin.metadata.MetadataManager;
-import org.junit.*;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
import org.junit.rules.ExpectedException;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
+import com.google.common.collect.Maps;
/**
* @author yangli9
@@ -39,7 +44,6 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
@Rule
public ExpectedException thrown = ExpectedException.none();
-
@Before
public void setUp() throws Exception {
this.createTestMetadata();
@@ -109,8 +113,7 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
@Test
public void testBadInit5() throws Exception {
CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
- cubeDesc.getAggregationGroups().get(0).getSelectRule().mandatory_dims = new String[] {
- "seller_id", "META_CATEG_NAME"};
+ cubeDesc.getAggregationGroups().get(0).getSelectRule().mandatory_dims = new String[] { "seller_id", "META_CATEG_NAME" };
cubeDesc.init(getTestConfig(), MetadataManager.getInstance(getTestConfig()).getAllTablesMap());
}
@@ -118,8 +121,7 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
@Test
public void testBadInit6() throws Exception {
CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
- cubeDesc.getAggregationGroups().get(0).getSelectRule().mandatory_dims = new String[] {
- "seller_id", "lstg_format_name"};
+ cubeDesc.getAggregationGroups().get(0).getSelectRule().mandatory_dims = new String[] { "seller_id", "lstg_format_name" };
cubeDesc.init(getTestConfig(), MetadataManager.getInstance(getTestConfig()).getAllTablesMap());
}
@@ -130,8 +132,7 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
thrown.expectMessage("Aggregation group 0 require at least 2 dims in a joint");
CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
- cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] {
- new String[] { "lstg_format_name" } };
+ cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { new String[] { "lstg_format_name" } };
cubeDesc.init(getTestConfig(), MetadataManager.getInstance(getTestConfig()).getAllTablesMap());
}
@@ -142,8 +143,7 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
thrown.expectMessage("Aggregation group 0 hierarchy dims overlap with joint dims");
CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
- cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] {
- new String[] { "META_CATEG_NAME", "CATEG_LVL2_NAME" } };
+ cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { new String[] { "META_CATEG_NAME", "CATEG_LVL2_NAME" } };
cubeDesc.init(getTestConfig(), MetadataManager.getInstance(getTestConfig()).getAllTablesMap());
}
@@ -154,11 +154,8 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
thrown.expectMessage("Aggregation group 0 hierarchy dims overlap with joint dims");
CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
- cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchy_dims = new String[][] {
- new String[] { "META_CATEG_NAME", "CATEG_LVL2_NAME", "CATEG_LVL3_NAME" },
- new String[] { "lstg_format_name", "lstg_site_id" } };
- cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] {
- new String[] { "META_CATEG_NAME", "lstg_format_name" } };
+ cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchy_dims = new String[][] { new String[] { "META_CATEG_NAME", "CATEG_LVL2_NAME", "CATEG_LVL3_NAME" }, new String[] { "lstg_format_name", "lstg_site_id" } };
+ cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { new String[] { "META_CATEG_NAME", "lstg_format_name" } };
cubeDesc.init(getTestConfig(), MetadataManager.getInstance(getTestConfig()).getAllTablesMap());
}
@@ -169,9 +166,7 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
thrown.expectMessage("Aggregation group 0 a dim exist in more than one joint");
CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
- cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] {
- new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd" },
- new String[] { "lstg_format_name", "lstg_site_id", "leaf_categ_id"} };
+ cubeDesc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd" }, new String[] { "lstg_format_name", "lstg_site_id", "leaf_categ_id" } };
cubeDesc.init(getTestConfig(), MetadataManager.getInstance(getTestConfig()).getAllTablesMap());
}
@@ -182,8 +177,7 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
thrown.expectMessage("Aggregation group 0 require at least 2 dims in a hierarchy");
CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
- cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchy_dims = new String[][] {
- new String[] { "META_CATEG_NAME" } };
+ cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchy_dims = new String[][] { new String[] { "META_CATEG_NAME" } };
cubeDesc.init(getTestConfig(), MetadataManager.getInstance(getTestConfig()).getAllTablesMap());
}
@@ -194,9 +188,7 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
thrown.expectMessage("Aggregation group 0 a dim exist in more than one hierarchy");
CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
- cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchy_dims = new String[][] {
- new String[] { "META_CATEG_NAME", "CATEG_LVL2_NAME", "CATEG_LVL3_NAME" },
- new String[] { "META_CATEG_NAME", "CATEG_LVL2_NAME" } };
+ cubeDesc.getAggregationGroups().get(0).getSelectRule().hierarchy_dims = new String[][] { new String[] { "META_CATEG_NAME", "CATEG_LVL2_NAME", "CATEG_LVL3_NAME" }, new String[] { "META_CATEG_NAME", "CATEG_LVL2_NAME" } };
cubeDesc.init(getTestConfig(), MetadataManager.getInstance(getTestConfig()).getAllTablesMap());
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/test/java/org/apache/kylin/cube/CubeManagerTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/CubeManagerTest.java b/core-cube/src/test/java/org/apache/kylin/cube/CubeManagerTest.java
index d2a7357..49bb128 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/CubeManagerTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/CubeManagerTest.java
@@ -18,7 +18,9 @@
package org.apache.kylin.cube;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.NavigableSet;
@@ -53,8 +55,7 @@ public class CubeManagerTest extends LocalFileMetadataTestCase {
@Test
public void testBasics() throws Exception {
-
-
+
CubeInstance cube = CubeManager.getInstance(getTestConfig()).getCube("test_kylin_cube_without_slr_ready");
CubeDesc desc = cube.getDescriptor();
System.out.println(JsonUtil.writeValueAsIndentString(desc));
@@ -95,7 +96,7 @@ public class CubeManagerTest extends LocalFileMetadataTestCase {
CubeManager mgr = CubeManager.getInstance(getTestConfig());
CubeInstance cube = mgr.getCube("test_kylin_cube_with_slr_empty");
- cube.getDescriptor().setAutoMergeTimeRanges(new long[]{2000, 6000});
+ cube.getDescriptor().setAutoMergeTimeRanges(new long[] { 2000, 6000 });
mgr.updateCube(new CubeUpdate(cube));
assertTrue(cube.needAutoMerge());
@@ -127,7 +128,7 @@ public class CubeManagerTest extends LocalFileMetadataTestCase {
final ResourceStore store = ResourceStore.getStore(getTestConfig());
final NavigableSet<String> cubePath = store.listResources(ResourceStore.CUBE_RESOURCE_ROOT);
assertTrue(cubePath.size() > 1);
-
+
final List<CubeInstance> cubes = store.getAllResources(ResourceStore.CUBE_RESOURCE_ROOT, CubeInstance.class, CubeManager.CUBE_SERIALIZER);
assertEquals(cubePath.size(), cubes.size());
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/test/java/org/apache/kylin/cube/CubeSegmentsTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/CubeSegmentsTest.java b/core-cube/src/test/java/org/apache/kylin/cube/CubeSegmentsTest.java
index 64105f1..f70aef9 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/CubeSegmentsTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/CubeSegmentsTest.java
@@ -18,7 +18,8 @@
package org.apache.kylin.cube;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import java.io.IOException;
@@ -144,7 +145,7 @@ public class CubeSegmentsTest extends LocalFileMetadataTestCase {
} catch (IllegalArgumentException ex) {
// good
}
-
+
CubeSegment merge2 = mgr.mergeSegments(cube, 0, 2500, 0, 0, true);
assertEquals(3, cube.getSegments().size());
assertEquals(0, merge2.getDateRangeStart());
@@ -179,7 +180,7 @@ public class CubeSegmentsTest extends LocalFileMetadataTestCase {
} catch (IllegalStateException ex) {
// good
}
-
+
// append the second
CubeSegment seg2 = mgr.appendSegment(cube, 1000, 2000, 0, 0);
seg2.setStatus(SegmentStatusEnum.READY);
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/test/java/org/apache/kylin/cube/CubeSpecificConfigTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/CubeSpecificConfigTest.java b/core-cube/src/test/java/org/apache/kylin/cube/CubeSpecificConfigTest.java
index 51d4e54..4ac8706 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/CubeSpecificConfigTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/CubeSpecificConfigTest.java
@@ -18,7 +18,7 @@
package org.apache.kylin.cube;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import org.apache.kylin.common.KylinConfig;
import org.apache.kylin.common.util.LocalFileMetadataTestCase;
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidSchedulerTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidSchedulerTest.java b/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidSchedulerTest.java
index 02c01b8..ecb1200 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidSchedulerTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidSchedulerTest.java
@@ -88,7 +88,7 @@ public class CuboidSchedulerTest extends LocalFileMetadataTestCase {
private CubeDesc getStreamingCubeDesc() {
return getCubeDescManager().getCubeDesc("test_streaming_table_cube_desc");
}
-
+
private CubeDesc getSSBCubeDesc() {
return getCubeDescManager().getCubeDesc("ssb");
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidTest.java b/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidTest.java
index 1d06d3e..2e64791 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/cuboid/CuboidTest.java
@@ -53,7 +53,7 @@ public class CuboidTest extends LocalFileMetadataTestCase {
return getCubeDescManager().getCubeDesc("test_kylin_cube_without_slr_left_join_desc");
}
-
+
private CubeDesc getSSBCubeDesc() {
return getCubeDescManager().getCubeDesc("ssb");
}
@@ -150,12 +150,12 @@ public class CuboidTest extends LocalFileMetadataTestCase {
CubeDesc cube = getSSBCubeDesc();
assertEquals(false, Cuboid.isValid(cube, toLong("10000000000")));
-
+
// the 4th is mandatory and isMandatoryOnlyValid is true
assertEquals(true, Cuboid.isValid(cube, toLong("10000001000")));
assertEquals(true, Cuboid.isValid(cube, toLong("00000001000")));
}
-
+
@Test
public void testFindCuboidByIdWithSingleAggrGroup2() {
CubeDesc cube = getTestKylinCubeWithSeller();
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/test/java/org/apache/kylin/cube/inmemcubing/MemDiskStoreTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/inmemcubing/MemDiskStoreTest.java b/core-cube/src/test/java/org/apache/kylin/cube/inmemcubing/MemDiskStoreTest.java
index 9d01888..807a6e3 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/inmemcubing/MemDiskStoreTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/inmemcubing/MemDiskStoreTest.java
@@ -100,7 +100,7 @@ public class MemDiskStoreTest extends LocalFileMetadataTestCase {
}
builder.close();
- IGTScanner scanner = table.scan(new GTScanRequest(info,null,null,null));
+ IGTScanner scanner = table.scan(new GTScanRequest(info, null, null, null));
int i = 0;
for (GTRecord r : scanner) {
assertEquals(data.get(i++), r);
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/test/java/org/apache/kylin/cube/model/validation/rule/DictionaryRuleTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/model/validation/rule/DictionaryRuleTest.java b/core-cube/src/test/java/org/apache/kylin/cube/model/validation/rule/DictionaryRuleTest.java
index 99ca7cf..e5afe48 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/model/validation/rule/DictionaryRuleTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/model/validation/rule/DictionaryRuleTest.java
@@ -18,6 +18,13 @@
package org.apache.kylin.cube.model.validation.rule;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
import org.apache.kylin.common.KylinConfig;
import org.apache.kylin.common.util.JsonUtil;
import org.apache.kylin.common.util.LocalFileMetadataTestCase;
@@ -30,12 +37,6 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import static org.junit.Assert.*;
-
/**
* Created by sunyerui on 16/6/1.
*/
@@ -71,22 +72,17 @@ public class DictionaryRuleTest extends LocalFileMetadataTestCase {
@Test
public void testBadDesc() throws IOException {
- testBadDictionaryDesc("Column EDW.TEST_SITES.SITE_NAME has inconsistent builders " +
- "FakeBuilderClass and org.apache.kylin.dict.GlobalDictionaryBuilder",
- DictionaryDesc.create("SITE_NAME", null, "FakeBuilderClass"));
+ testBadDictionaryDesc("Column EDW.TEST_SITES.SITE_NAME has inconsistent builders " + "FakeBuilderClass and org.apache.kylin.dict.GlobalDictionaryBuilder", DictionaryDesc.create("SITE_NAME", null, "FakeBuilderClass"));
}
@Test
public void testBadDesc2() throws IOException {
- testBadDictionaryDesc("Column EDW.TEST_SITES.SITE_NAME has inconsistent builders " +
- "FakeBuilderClass and org.apache.kylin.dict.GlobalDictionaryBuilder",
- DictionaryDesc.create("lstg_site_id", "SITE_NAME", "FakeBuilderClass"));
+ testBadDictionaryDesc("Column EDW.TEST_SITES.SITE_NAME has inconsistent builders " + "FakeBuilderClass and org.apache.kylin.dict.GlobalDictionaryBuilder", DictionaryDesc.create("lstg_site_id", "SITE_NAME", "FakeBuilderClass"));
}
@Test
public void testBadDesc3() throws IOException {
- testBadDictionaryDesc("Column DEFAULT.TEST_KYLIN_FACT.LSTG_SITE_ID used as dimension and conflict with GlobalDictBuilder",
- DictionaryDesc.create("lstg_site_id", null, GlobalDictionaryBuilder.class.getName()));
+ testBadDictionaryDesc("Column DEFAULT.TEST_KYLIN_FACT.LSTG_SITE_ID used as dimension and conflict with GlobalDictBuilder", DictionaryDesc.create("lstg_site_id", null, GlobalDictionaryBuilder.class.getName()));
}
private void testBadDictionaryDesc(String expectMessage, DictionaryDesc... descs) throws IOException {
@@ -94,7 +90,7 @@ public class DictionaryRuleTest extends LocalFileMetadataTestCase {
File f = new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/test_kylin_cube_without_slr_left_join_desc.json");
CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
- for (DictionaryDesc dictDesc: descs) {
+ for (DictionaryDesc dictDesc : descs) {
desc.getDictionaries().add(dictDesc);
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheMemSizeTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheMemSizeTest.java b/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheMemSizeTest.java
index 5b65827..fcd434e 100644
--- a/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheMemSizeTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheMemSizeTest.java
@@ -23,13 +23,13 @@ import java.util.Random;
import java.util.SortedMap;
import java.util.TreeMap;
-import org.apache.kylin.measure.hllc.HyperLogLogPlusCounter;
import org.apache.kylin.common.util.Bytes;
import org.apache.kylin.measure.MeasureAggregator;
import org.apache.kylin.measure.basic.BigDecimalSumAggregator;
import org.apache.kylin.measure.basic.DoubleSumAggregator;
import org.apache.kylin.measure.basic.LongSumAggregator;
import org.apache.kylin.measure.hllc.HLLCAggregator;
+import org.apache.kylin.measure.hllc.HyperLogLogPlusCounter;
import org.apache.kylin.metadata.datatype.DoubleMutable;
import org.apache.kylin.metadata.datatype.LongMutable;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java b/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java
index fd891f5..c92e1aa 100644
--- a/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java
@@ -18,7 +18,8 @@
package org.apache.kylin.gridtable;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.math.BigDecimal;
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/test/java/org/apache/kylin/gridtable/SimpleGridTableTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/gridtable/SimpleGridTableTest.java b/core-cube/src/test/java/org/apache/kylin/gridtable/SimpleGridTableTest.java
index d300787..2abe928 100644
--- a/core-cube/src/test/java/org/apache/kylin/gridtable/SimpleGridTableTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/gridtable/SimpleGridTableTest.java
@@ -17,7 +17,9 @@
package org.apache.kylin.gridtable;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.math.BigDecimal;
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/test/java/org/apache/kylin/gridtable/SimpleInvertedIndexTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/gridtable/SimpleInvertedIndexTest.java b/core-cube/src/test/java/org/apache/kylin/gridtable/SimpleInvertedIndexTest.java
index a9eb269..1026414 100644
--- a/core-cube/src/test/java/org/apache/kylin/gridtable/SimpleInvertedIndexTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/gridtable/SimpleInvertedIndexTest.java
@@ -17,8 +17,7 @@
package org.apache.kylin.gridtable;
-import static org.junit.Assert.*;
-import it.uniroma3.mat.extendedset.intset.ConciseSet;
+import static org.junit.Assert.assertEquals;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
@@ -42,6 +41,8 @@ import org.junit.Test;
import com.google.common.collect.Lists;
+import it.uniroma3.mat.extendedset.intset.ConciseSet;
+
public class SimpleInvertedIndexTest extends LocalFileMetadataTestCase {
GTInfo info;
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java b/core-cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java
index 429157c..1a7e4b3 100644
--- a/core-cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java
@@ -18,7 +18,7 @@
package org.apache.kylin.metadata.measure;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
@@ -27,8 +27,6 @@ import org.apache.kylin.common.util.LocalFileMetadataTestCase;
import org.apache.kylin.measure.BufferedMeasureEncoder;
import org.apache.kylin.measure.bitmap.BitmapCounter;
import org.apache.kylin.measure.hllc.HyperLogLogPlusCounter;
-import org.apache.kylin.measure.topn.TopNCounterSerializer;
-import org.apache.kylin.metadata.datatype.DataType;
import org.apache.kylin.metadata.datatype.DoubleMutable;
import org.apache.kylin.metadata.datatype.LongMutable;
import org.apache.kylin.metadata.model.FunctionDesc;
@@ -53,8 +51,7 @@ public class MeasureCodecTest extends LocalFileMetadataTestCase {
@Test
public void basicTest() {
- MeasureDesc descs[] = new MeasureDesc[] { measure("double"), measure("long"), measure
- ("decimal"), measure("HLLC16"), measure("bitmap") };
+ MeasureDesc descs[] = new MeasureDesc[] { measure("double"), measure("long"), measure("decimal"), measure("HLLC16"), measure("bitmap") };
BufferedMeasureEncoder codec = new BufferedMeasureEncoder(descs);
DoubleMutable d = new DoubleMutable(1.0);
@@ -66,7 +63,7 @@ public class MeasureCodecTest extends LocalFileMetadataTestCase {
BitmapCounter bitmap = new BitmapCounter();
bitmap.add(123);
bitmap.add(45678);
- bitmap.add(Integer.MAX_VALUE-10);
+ bitmap.add(Integer.MAX_VALUE - 10);
Object values[] = new Object[] { d, l, b, hllc, bitmap };
ByteBuffer buf = codec.encode(values);
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-cube/src/test/java/org/apache/kylin/metadata/measure/TopNMeasureTypeTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/metadata/measure/TopNMeasureTypeTest.java b/core-cube/src/test/java/org/apache/kylin/metadata/measure/TopNMeasureTypeTest.java
index 3d3e7d0..9b3126d 100644
--- a/core-cube/src/test/java/org/apache/kylin/metadata/measure/TopNMeasureTypeTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/metadata/measure/TopNMeasureTypeTest.java
@@ -1,6 +1,8 @@
package org.apache.kylin.metadata.measure;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
import org.apache.kylin.common.util.LocalFileMetadataTestCase;
import org.apache.kylin.cube.CubeDescManager;
@@ -13,14 +15,11 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.util.List;
-
/**
* Created by shishaofeng on 6/6/16.
*/
public class TopNMeasureTypeTest extends LocalFileMetadataTestCase {
-
@Before
public void setup() {
this.createTestMetadata();
@@ -47,7 +46,6 @@ public class TopNMeasureTypeTest extends LocalFileMetadataTestCase {
}
TopNMeasureType measureType = (TopNMeasureType) MeasureTypeFactory.create(topSellerMeasure.getFunction().getExpression(), topSellerMeasure.getFunction().getReturnDataType());
-
topSellerMeasure.getFunction().getConfiguration().clear();
List<TblColRef> colsNeedDict = measureType.getColumnsNeedDictionary(topSellerMeasure.getFunction());
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-dictionary/src/main/java/org/apache/kylin/dict/AppendTrieDictionary.java
----------------------------------------------------------------------
diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/AppendTrieDictionary.java b/core-dictionary/src/main/java/org/apache/kylin/dict/AppendTrieDictionary.java
index f6d97c2..f49258d 100644
--- a/core-dictionary/src/main/java/org/apache/kylin/dict/AppendTrieDictionary.java
+++ b/core-dictionary/src/main/java/org/apache/kylin/dict/AppendTrieDictionary.java
@@ -18,7 +18,15 @@
package org.apache.kylin.dict;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.Arrays;
@@ -29,7 +37,11 @@ import java.util.List;
import java.util.TreeMap;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.*;
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.kylin.common.KylinConfig;
@@ -103,18 +115,16 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
int cacheSize = KylinConfig.getInstanceFromEnv().getAppendDictCacheSize();
if (dictSliceMap == null) {
- dictSliceMap = CachedTreeMap.CachedTreeMapBuilder.newBuilder().maxSize(cacheSize)
- .baseDir(baseDir).persistent(true).immutable(true).keyClazz(DictSliceKey.class).valueClazz(DictSlice.class).build();
+ dictSliceMap = CachedTreeMap.CachedTreeMapBuilder.newBuilder().maxSize(cacheSize).baseDir(baseDir).persistent(true).immutable(true).keyClazz(DictSliceKey.class).valueClazz(DictSlice.class).build();
}
dictSliceMap.clear();
- ((Writable)dictSliceMap).readFields(input);
+ ((Writable) dictSliceMap).readFields(input);
}
-
public byte[] writeDictMap() throws IOException {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(buf);
- ((Writable)dictSliceMap).write(out);
+ ((Writable) dictSliceMap).write(out);
byte[] dictMapBytes = buf.toByteArray();
buf.close();
out.close();
@@ -146,7 +156,7 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
if (!(o instanceof DictSliceKey)) {
return -1;
}
- DictSliceKey other = (DictSliceKey)o;
+ DictSliceKey other = (DictSliceKey) o;
return Bytes.compareTo(key, other.key);
}
@@ -164,7 +174,8 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
}
public static class DictSlice<T> implements Writable {
- public DictSlice() {}
+ public DictSlice() {
+ }
public DictSlice(byte[] trieBytes) {
init(trieBytes);
@@ -288,7 +299,7 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
}
private DictNode rebuildTrieTree() {
- return rebuildTrieTreeR(headSize, null);
+ return rebuildTrieTreeR(headSize, null);
}
private DictNode rebuildTrieTreeR(int n, DictNode parent) {
@@ -332,13 +343,13 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
}
public void readFields(DataInput in) throws IOException {
- byte[] headPartial = new byte[HEAD_MAGIC.length + Short.SIZE/Byte.SIZE + Integer.SIZE/Byte.SIZE];
+ byte[] headPartial = new byte[HEAD_MAGIC.length + Short.SIZE / Byte.SIZE + Integer.SIZE / Byte.SIZE];
in.readFully(headPartial);
if (BytesUtil.compareBytes(HEAD_MAGIC, 0, headPartial, 0, HEAD_MAGIC.length) != 0)
throw new IllegalArgumentException("Wrong file type (magic does not match)");
- DataInputStream headIn = new DataInputStream( //
+ DataInputStream headIn = new DataInputStream(//
new ByteArrayInputStream(headPartial, HEAD_SIZE_I, headPartial.length - HEAD_SIZE_I));
int headSize = headIn.readShort();
int bodyLen = headIn.readInt();
@@ -388,7 +399,8 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
public DictNode parent;
public int childrenCount = 1;
- public DictNode() {}
+ public DictNode() {
+ }
public void clone(DictNode o) {
this.part = o.part;
@@ -488,7 +500,7 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
int index = p.children.indexOf(current);
assert index != -1;
DictNode newParent = p.duplicateNode();
- for (int i = p.children.size()-1; i >= index; i--) {
+ for (int i = p.children.size() - 1; i >= index; i--) {
DictNode child = p.removeChild(i);
newParent.addChild(0, child);
}
@@ -502,12 +514,12 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
DictNode current = root;
DictNode child;
while (!current.children.isEmpty()) {
- child = leftOrRight == 0 ? current.children.get(0) : current.children.get(current.children.size()-1);
+ child = leftOrRight == 0 ? current.children.get(0) : current.children.get(current.children.size() - 1);
if (current.children.size() > 1 || current.isEndOfValue) {
current = child;
continue;
}
- byte[] newValue = new byte[current.part.length+child.part.length];
+ byte[] newValue = new byte[current.part.length + child.part.length];
System.arraycopy(current.part, 0, newValue, 0, current.part.length);
System.arraycopy(child.part, 0, newValue, current.part.length, child.part.length);
current.reset(newValue, child.isEndOfValue, child.children);
@@ -639,7 +651,6 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
visitor.visit(node, level);
}
-
public int nValues; // number of values in total
public int nValueBytesPlain; // number of bytes for all values
// uncompressed
@@ -659,7 +670,7 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
public int mbpn_sizeNoValueBytes; // size of field noValueBytes
public int mbpn_sizeChildOffset; // size of field childOffset, points to
// first child in flattened array
- public int mbpn_sizeId; // size of id value, always be 4
+ public int mbpn_sizeId; // size of id value, always be 4
public int mbpn_footprint; // MBPN footprint in bytes
/**
@@ -792,11 +803,9 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
MAX_ENTRY_IN_SLICE = KylinConfig.getInstanceFromEnv().getAppendDictEntrySize();
int cacheSize = KylinConfig.getInstanceFromEnv().getAppendDictCacheSize();
// create a new cached map with baseDir
- dictSliceMap = CachedTreeMap.CachedTreeMapBuilder.newBuilder().maxSize(cacheSize)
- .baseDir(baseDir).keyClazz(DictSliceKey.class).valueClazz(DictNode.class)
- .persistent(true).immutable(false).build();
+ dictSliceMap = CachedTreeMap.CachedTreeMapBuilder.newBuilder().maxSize(cacheSize).baseDir(baseDir).keyClazz(DictSliceKey.class).valueClazz(DictNode.class).persistent(true).immutable(false).build();
if (dictMapBytes != null) {
- ((Writable)dictSliceMap).readFields(new DataInputStream(new ByteArrayInputStream(dictMapBytes)));
+ ((Writable) dictSliceMap).readFields(new DataInputStream(new ByteArrayInputStream(dictMapBytes)));
}
}
@@ -833,22 +842,22 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
private DictNode splitNodeTree(DictNode root) {
DictNode parent = root;
DictNode splitNode;
- int childCountToSplit = (int)(MAX_ENTRY_IN_SLICE * MAX_ENTRY_OVERHEAD_FACTOR / 2);
+ int childCountToSplit = (int) (MAX_ENTRY_IN_SLICE * MAX_ENTRY_OVERHEAD_FACTOR / 2);
while (true) {
List<DictNode> children = parent.children;
- if (children.size() == 0){
+ if (children.size() == 0) {
splitNode = parent;
break;
} else if (children.size() == 1) {
parent = children.get(0);
continue;
} else {
- for (int i = children.size()-1; i >= 0; i--) {
+ for (int i = children.size() - 1; i >= 0; i--) {
parent = children.get(i);
if (childCountToSplit > children.get(i).childrenCount) {
childCountToSplit -= children.get(i).childrenCount;
} else {
- childCountToSplit --;
+ childCountToSplit--;
break;
}
}
@@ -862,7 +871,7 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
if (maxId < 0) {
throw new IllegalArgumentException("AppendTrieDictionary Id overflow Integer.MAX_VALUE");
}
- nValues ++;
+ nValues++;
return id;
}
@@ -951,7 +960,7 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
public AppendTrieDictionary<T> build(int baseId) throws IOException {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(buf);
- ((Writable)dictSliceMap).write(out);
+ ((Writable) dictSliceMap).write(out);
byte[] dictMapBytes = buf.toByteArray();
buf.close();
out.close();
@@ -966,7 +975,6 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
}
}
-
@Override
protected int getIdFromValueBytesImpl(byte[] value, int offset, int len, int roundingFlag) {
if (dictSliceMap.isEmpty()) {
@@ -1042,15 +1050,15 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
}
public void flushIndex() throws IOException {
- Path filePath = new Path(baseDir+"/.index");
+ Path filePath = new Path(baseDir + "/.index");
Configuration conf = new Configuration();
- try (FSDataOutputStream indexOut = (FileSystem.get(filePath.toUri(), conf)).create(filePath, true, 8*1024*1024, (short)2, 8*1024*1024*8)) {
+ try (FSDataOutputStream indexOut = (FileSystem.get(filePath.toUri(), conf)).create(filePath, true, 8 * 1024 * 1024, (short) 2, 8 * 1024 * 1024 * 8)) {
indexOut.writeInt(baseId);
indexOut.writeInt(maxId);
indexOut.writeInt(maxValueLength);
indexOut.writeInt(nValues);
indexOut.writeUTF(bytesConverter.getClass().getName());
- ((Writable)dictSliceMap).write(indexOut);
+ ((Writable) dictSliceMap).write(indexOut);
}
}
@@ -1058,8 +1066,7 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
public AppendTrieDictionary copyToAnotherMeta(KylinConfig srcConfig, KylinConfig dstConfig) throws IOException {
Configuration conf = new Configuration();
AppendTrieDictionary newDict = new AppendTrieDictionary();
- newDict.update(baseDir.replaceFirst(srcConfig.getHdfsWorkingDirectory(), dstConfig.getHdfsWorkingDirectory()),
- baseId, maxId, maxValueLength, nValues, bytesConverter, writeDictMap());
+ newDict.update(baseDir.replaceFirst(srcConfig.getHdfsWorkingDirectory(), dstConfig.getHdfsWorkingDirectory()), baseId, maxId, maxValueLength, nValues, bytesConverter, writeDictMap());
logger.info("Copy AppendDict from {} to {}", this.baseDir, newDict.baseDir);
Path srcPath = new Path(this.baseDir);
Path dstPath = new Path(newDict.baseDir);
@@ -1082,9 +1089,9 @@ public class AppendTrieDictionary<T> extends Dictionary<T> {
@Override
public void readFields(DataInput in) throws IOException {
String baseDir = in.readUTF();
- Path filePath = new Path(baseDir+"/.index");
+ Path filePath = new Path(baseDir + "/.index");
Configuration conf = new Configuration();
- try (FSDataInputStream input = (FileSystem.get(filePath.toUri(), conf)).open(filePath, 8*1024*1024)) {
+ try (FSDataInputStream input = (FileSystem.get(filePath.toUri(), conf)).open(filePath, 8 * 1024 * 1024)) {
int baseId = input.readInt();
int maxId = input.readInt();
int maxValueLength = input.readInt();
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-dictionary/src/main/java/org/apache/kylin/dict/BuildInFunctionTransformer.java
----------------------------------------------------------------------
diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/BuildInFunctionTransformer.java b/core-dictionary/src/main/java/org/apache/kylin/dict/BuildInFunctionTransformer.java
index 21d76ea..9156b67 100644
--- a/core-dictionary/src/main/java/org/apache/kylin/dict/BuildInFunctionTransformer.java
+++ b/core-dictionary/src/main/java/org/apache/kylin/dict/BuildInFunctionTransformer.java
@@ -109,7 +109,7 @@ public class BuildInFunctionTransformer implements ITupleFilterTransformer {
return null;
BuildInFunctionTupleFilter buildInFunctionTupleFilter = (BuildInFunctionTupleFilter) compTupleFilter.getFunction();
-
+
if (!buildInFunctionTupleFilter.isValid())
return null;
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-dictionary/src/main/java/org/apache/kylin/dict/CachedTreeMap.java
----------------------------------------------------------------------
diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/CachedTreeMap.java b/core-dictionary/src/main/java/org/apache/kylin/dict/CachedTreeMap.java
index 43e0950..9e9e7d6 100644
--- a/core-dictionary/src/main/java/org/apache/kylin/dict/CachedTreeMap.java
+++ b/core-dictionary/src/main/java/org/apache/kylin/dict/CachedTreeMap.java
@@ -77,7 +77,8 @@ public class CachedTreeMap<K extends WritableComparable, V extends Writable> ext
return new CachedTreeMapBuilder();
}
- private CachedTreeMapBuilder() {}
+ private CachedTreeMapBuilder() {
+ }
public CachedTreeMapBuilder keyClazz(Class<K> clazz) {
this.keyClazz = clazz;
@@ -133,19 +134,17 @@ public class CachedTreeMap<K extends WritableComparable, V extends Writable> ext
CacheBuilder builder = CacheBuilder.newBuilder().removalListener(new RemovalListener<K, V>() {
@Override
public void onRemoval(RemovalNotification<K, V> notification) {
- logger.info(String.format("Evict cache key %s(%d) with value %s caused by %s, size %d/%d ",
- notification.getKey(), notification.getKey().hashCode(), notification.getValue(), notification.getCause(),
- size(), valueCache.size()));
+ logger.info(String.format("Evict cache key %s(%d) with value %s caused by %s, size %d/%d ", notification.getKey(), notification.getKey().hashCode(), notification.getValue(), notification.getCause(), size(), valueCache.size()));
switch (notification.getCause()) {
- case SIZE:
- writeValue(notification.getKey(), notification.getValue());
- break;
- case EXPLICIT:
- // skip delete files to recover from error during dict appending
- // deleteValue(notification.getKey());
- break;
- default:
- throw new RuntimeException("unexpected evict reason " + notification.getCause());
+ case SIZE:
+ writeValue(notification.getKey(), notification.getValue());
+ break;
+ case EXPLICIT:
+ // skip delete files to recover from error during dict appending
+ // deleteValue(notification.getKey());
+ break;
+ default:
+ throw new RuntimeException("unexpected evict reason " + notification.getCause());
}
}
}).maximumSize(maxCount);
@@ -175,7 +174,7 @@ public class CachedTreeMap<K extends WritableComparable, V extends Writable> ext
long t0 = System.currentTimeMillis();
String fileName = generateFileName(key);
Path filePath = new Path(fileName);
- try (FSDataOutputStream out = (FileSystem.get(filePath.toUri(), conf)).create(filePath, true, BUFFER_SIZE, (short)2, BUFFER_SIZE*8)) {
+ try (FSDataOutputStream out = (FileSystem.get(filePath.toUri(), conf)).create(filePath, true, BUFFER_SIZE, (short) 2, BUFFER_SIZE * 8)) {
value.write(out);
if (!persistent) {
FileSystem.get(filePath.toUri(), conf).deleteOnExit(filePath);
@@ -234,7 +233,7 @@ public class CachedTreeMap<K extends WritableComparable, V extends Writable> ext
public V get(Object key) {
if (super.containsKey(key)) {
try {
- return valueCache.get((K)key);
+ return valueCache.get((K) key);
} catch (ExecutionException e) {
logger.error(String.format("get value with key %s exception: ", key, e), e);
return null;
@@ -292,7 +291,7 @@ public class CachedTreeMap<K extends WritableComparable, V extends Writable> ext
public V next() {
currentKey = keyIterator.next();
try {
- return (V)valueCache.get(currentKey);
+ return (V) valueCache.get(currentKey);
} catch (ExecutionException e) {
logger.error(String.format("get value with key %s exception: ", currentKey, e), e);
return null;
@@ -335,6 +334,7 @@ public class CachedTreeMap<K extends WritableComparable, V extends Writable> ext
}
// clean up all tmp files
+ @SuppressWarnings("checkstyle:nofinalizer")
@Override
public void finalize() throws Throwable {
if (persistent) {
@@ -347,11 +347,14 @@ public class CachedTreeMap<K extends WritableComparable, V extends Writable> ext
Path filePath = new Path(file);
FileSystem fs = FileSystem.get(filePath.toUri(), conf);
fs.delete(filePath, true);
- } catch (Throwable t) {}
+ } catch (Throwable t) {
+ //do nothing?
+ }
}
} catch (Throwable t) {
+ //do nothing
} finally {
- super.finalize();
+ super.finalize();
}
}
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-dictionary/src/main/java/org/apache/kylin/dict/DateStrDictionary.java
----------------------------------------------------------------------
diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/DateStrDictionary.java b/core-dictionary/src/main/java/org/apache/kylin/dict/DateStrDictionary.java
index 44a1fa4..ee8534f 100644
--- a/core-dictionary/src/main/java/org/apache/kylin/dict/DateStrDictionary.java
+++ b/core-dictionary/src/main/java/org/apache/kylin/dict/DateStrDictionary.java
@@ -119,7 +119,7 @@ public class DateStrDictionary extends Dictionary<String> {
@Override
final protected byte[] getValueBytesFromIdImpl(int id) {
String date = getValueFromId(id);
- byte bytes[];
+ byte[] bytes;
try {
bytes = date.getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
@@ -130,7 +130,7 @@ public class DateStrDictionary extends Dictionary<String> {
@Override
final protected int getValueBytesFromIdImpl(int id, byte[] returnValue, int offset) {
- byte bytes[] = getValueBytesFromIdImpl(id);
+ byte[] bytes = getValueBytesFromIdImpl(id);
System.arraycopy(bytes, 0, returnValue, offset, bytes.length);
return bytes.length;
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryGenerator.java
----------------------------------------------------------------------
diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryGenerator.java b/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryGenerator.java
index 95b6087..5bd3357 100644
--- a/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryGenerator.java
+++ b/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryGenerator.java
@@ -39,7 +39,7 @@ import com.google.common.base.Preconditions;
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public class DictionaryGenerator {
-
+
private static final int DICT_MAX_CARDINALITY = getDictionaryMaxCardinality();
private static final Logger logger = LoggerFactory.getLogger(DictionaryGenerator.class);
@@ -69,10 +69,10 @@ public class DictionaryGenerator {
} else {
builder = new StringDictBuilder();
}
-
+
return buildDictionary(builder, null, valueEnumerator);
}
-
+
public static Dictionary<String> buildDictionary(IDictionaryBuilder builder, DictionaryInfo dictInfo, IDictionaryValueEnumerator valueEnumerator) throws IOException {
int baseId = 0; // always 0 for now
int nSamples = 5;
@@ -140,7 +140,7 @@ public class DictionaryGenerator {
throw new IllegalStateException("Unrecognized datetime value");
}
}
-
+
private static class TimeDictBuilder implements IDictionaryBuilder {
@Override
public Dictionary<String> build(DictionaryInfo dictInfo, IDictionaryValueEnumerator valueEnumerator, int baseId, int nSamples, ArrayList<String> returnSamples) throws IOException {
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryManager.java
----------------------------------------------------------------------
diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryManager.java b/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryManager.java
index 6a1c22c..74120dc 100644
--- a/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryManager.java
+++ b/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryManager.java
@@ -18,8 +18,16 @@
package org.apache.kylin.dict;
-import com.google.common.cache.*;
-import com.google.common.collect.Lists;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.List;
+import java.util.NavigableSet;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+
import org.apache.kylin.common.KylinConfig;
import org.apache.kylin.common.persistence.ResourceStore;
import org.apache.kylin.common.util.ClassUtil;
@@ -36,15 +44,12 @@ import org.apache.kylin.source.SourceFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.List;
-import java.util.NavigableSet;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.cache.RemovalListener;
+import com.google.common.cache.RemovalNotification;
+import com.google.common.collect.Lists;
public class DictionaryManager {
@@ -268,7 +273,7 @@ public class DictionaryManager {
public DictionaryInfo buildDictionary(DataModelDesc model, TblColRef col, DistinctColumnValuesProvider factTableValueProvider) throws IOException {
return buildDictionary(model, col, factTableValueProvider, null);
}
-
+
public DictionaryInfo buildDictionary(DataModelDesc model, TblColRef col, DistinctColumnValuesProvider factTableValueProvider, String builderClass) throws IOException {
logger.info("building dictionary for " + col);
@@ -307,7 +312,7 @@ public class DictionaryManager {
}
logger.info("Building dictionary object " + JsonUtil.writeValueAsString(dictInfo));
-
+
Dictionary<String> dictionary;
IDictionaryValueEnumerator columnValueEnumerator = null;
try {
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-dictionary/src/main/java/org/apache/kylin/dict/GlobalDictionaryBuilder.java
----------------------------------------------------------------------
diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/GlobalDictionaryBuilder.java b/core-dictionary/src/main/java/org/apache/kylin/dict/GlobalDictionaryBuilder.java
index 9405f46..b8371e9 100644
--- a/core-dictionary/src/main/java/org/apache/kylin/dict/GlobalDictionaryBuilder.java
+++ b/core-dictionary/src/main/java/org/apache/kylin/dict/GlobalDictionaryBuilder.java
@@ -18,6 +18,10 @@
package org.apache.kylin.dict;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.NavigableSet;
+
import org.apache.kylin.common.KylinConfig;
import org.apache.kylin.common.util.Bytes;
import org.apache.kylin.common.util.Dictionary;
@@ -25,10 +29,6 @@ import org.apache.kylin.metadata.MetadataManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.NavigableSet;
-
/**
* GlobalDictinary based on whole cube, to ensure one value has same dict id in different segments.
* GlobalDictinary mainly used for count distinct measure to support rollup among segments.
@@ -62,7 +62,7 @@ public class GlobalDictionaryBuilder implements IDictionaryBuilder {
builder = AppendTrieDictionary.Builder.create(dictDir);
} else if (appendDicts.size() == 1) {
logger.info("GlobalDict {} exist, append value", appendDicts.get(0));
- AppendTrieDictionary dict = (AppendTrieDictionary)DictionaryManager.getInstance(KylinConfig.getInstanceFromEnv()).getDictionary(appendDicts.get(0));
+ AppendTrieDictionary dict = (AppendTrieDictionary) DictionaryManager.getInstance(KylinConfig.getInstanceFromEnv()).getDictionary(appendDicts.get(0));
builder = AppendTrieDictionary.Builder.create(dict);
} else {
throw new IllegalStateException(String.format("GlobalDict %s should have 0 or 1 append dict but %d", dictInfo.getResourceDir(), appendDicts.size()));
@@ -82,4 +82,3 @@ public class GlobalDictionaryBuilder implements IDictionaryBuilder {
return builder.build(baseId);
}
}
-
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-dictionary/src/main/java/org/apache/kylin/dict/MultipleDictionaryValueEnumerator.java
----------------------------------------------------------------------
diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/MultipleDictionaryValueEnumerator.java b/core-dictionary/src/main/java/org/apache/kylin/dict/MultipleDictionaryValueEnumerator.java
index df7b1c6..92ff951 100644
--- a/core-dictionary/src/main/java/org/apache/kylin/dict/MultipleDictionaryValueEnumerator.java
+++ b/core-dictionary/src/main/java/org/apache/kylin/dict/MultipleDictionaryValueEnumerator.java
@@ -18,13 +18,13 @@
package org.apache.kylin.dict;
-import com.google.common.collect.Lists;
+import java.io.IOException;
+import java.util.List;
import org.apache.kylin.common.util.Bytes;
import org.apache.kylin.common.util.Dictionary;
-import java.io.IOException;
-import java.util.List;
+import com.google.common.collect.Lists;
/**
* Created by dongli on 10/28/15.
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-dictionary/src/main/java/org/apache/kylin/dict/TableColumnValueEnumerator.java
----------------------------------------------------------------------
diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/TableColumnValueEnumerator.java b/core-dictionary/src/main/java/org/apache/kylin/dict/TableColumnValueEnumerator.java
index 5f9460c..8efc5e5 100644
--- a/core-dictionary/src/main/java/org/apache/kylin/dict/TableColumnValueEnumerator.java
+++ b/core-dictionary/src/main/java/org/apache/kylin/dict/TableColumnValueEnumerator.java
@@ -18,12 +18,12 @@
package org.apache.kylin.dict;
-import org.apache.kylin.common.util.Bytes;
-import org.apache.kylin.source.ReadableTable;
-
import java.io.IOException;
import java.util.Arrays;
+import org.apache.kylin.common.util.Bytes;
+import org.apache.kylin.source.ReadableTable;
+
/**
* Created by dongli on 10/29/15.
*/
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-dictionary/src/main/java/org/apache/kylin/dict/TimeStrDictionary.java
----------------------------------------------------------------------
diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/TimeStrDictionary.java b/core-dictionary/src/main/java/org/apache/kylin/dict/TimeStrDictionary.java
index 3c96d08..fc3db5f 100644
--- a/core-dictionary/src/main/java/org/apache/kylin/dict/TimeStrDictionary.java
+++ b/core-dictionary/src/main/java/org/apache/kylin/dict/TimeStrDictionary.java
@@ -96,7 +96,7 @@ public class TimeStrDictionary extends Dictionary<String> {
@Override
final protected byte[] getValueBytesFromIdImpl(int id) {
String date = getValueFromId(id);
- byte bytes[];
+ byte[] bytes;
try {
bytes = date.getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
@@ -107,7 +107,7 @@ public class TimeStrDictionary extends Dictionary<String> {
@Override
final protected int getValueBytesFromIdImpl(int id, byte[] returnValue, int offset) {
- byte bytes[] = getValueBytesFromIdImpl(id);
+ byte[] bytes = getValueBytesFromIdImpl(id);
System.arraycopy(bytes, 0, returnValue, offset, bytes.length);
return bytes.length;
}
@@ -123,6 +123,11 @@ public class TimeStrDictionary extends Dictionary<String> {
}
@Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
public boolean equals(Object o) {
if (o == null)
return false;
http://git-wip-us.apache.org/repos/asf/kylin/blob/5d4982e2/core-dictionary/src/main/java/org/apache/kylin/dict/TrieDictionary.java
----------------------------------------------------------------------
diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/TrieDictionary.java b/core-dictionary/src/main/java/org/apache/kylin/dict/TrieDictionary.java
index 5cf672f..efff7e2 100644
--- a/core-dictionary/src/main/java/org/apache/kylin/dict/TrieDictionary.java
+++ b/core-dictionary/src/main/java/org/apache/kylin/dict/TrieDictionary.java
@@ -18,7 +18,19 @@
package org.apache.kylin.dict;
-import com.google.common.base.Preconditions;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintStream;
+import java.lang.ref.SoftReference;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.kylin.common.util.Bytes;
import org.apache.kylin.common.util.BytesUtil;
@@ -27,13 +39,7 @@ import org.apache.kylin.common.util.Dictionary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.*;
-import java.lang.ref.SoftReference;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
+import com.google.common.base.Preconditions;
/**
* A dictionary based on Trie data structure that maps enumerations of byte[] to
@@ -96,7 +102,7 @@ public class TrieDictionary<T> extends Dictionary<T> {
throw new IllegalArgumentException("Wrong file type (magic does not match)");
try {
- DataInputStream headIn = new DataInputStream( //
+ DataInputStream headIn = new DataInputStream(//
new ByteArrayInputStream(trieBytes, HEAD_SIZE_I, trieBytes.length - HEAD_SIZE_I));
this.headSize = headIn.readShort();
this.bodyLen = headIn.readInt();
@@ -445,7 +451,7 @@ public class TrieDictionary<T> extends Dictionary<T> {
if (BytesUtil.compareBytes(HEAD_MAGIC, 0, headPartial, 0, HEAD_MAGIC.length) != 0)
throw new IllegalArgumentException("Wrong file type (magic does not match)");
- DataInputStream headIn = new DataInputStream( //
+ DataInputStream headIn = new DataInputStream(//
new ByteArrayInputStream(headPartial, HEAD_SIZE_I, headPartial.length - HEAD_SIZE_I));
int headSize = headIn.readShort();
int bodyLen = headIn.readInt();
@@ -458,14 +464,12 @@ public class TrieDictionary<T> extends Dictionary<T> {
init(all);
}
- private void writeObject(java.io.ObjectOutputStream stream)
- throws IOException {
+ private void writeObject(java.io.ObjectOutputStream stream) throws IOException {
stream.writeInt(trieBytes.length);
stream.write(trieBytes);
}
- private void readObject(java.io.ObjectInputStream stream)
- throws IOException, ClassNotFoundException {
+ private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
int length = stream.readInt();
byte[] trieBytes = new byte[length];
int currentCount;
@@ -536,12 +540,12 @@ public class TrieDictionary<T> extends Dictionary<T> {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ObjectOutputStream(baos).writeObject(dict);
-
+
TrieDictionary<String> dict2 = (TrieDictionary<String>) new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())).readObject();
Preconditions.checkArgument(dict.contains(dict2));
Preconditions.checkArgument(dict2.contains(dict));
Preconditions.checkArgument(dict.equals(dict2));
-
+
dict2.enableIdToValueBytesCache();
for (int i = 0; i <= dict.getMaxId(); i++) {
System.out.println(Bytes.toString(dict.getValueBytesFromId(i)));