diff --git a/build-support/IntelliJ-code-format.xml b/build-support/IntelliJ-code-format.xml
index 04c4e7a681e68b..eea3822f66ef32 100644
--- a/build-support/IntelliJ-code-format.xml
+++ b/build-support/IntelliJ-code-format.xml
@@ -66,6 +66,7 @@ under the License.
+
@@ -92,4 +93,3 @@ under the License.
-
diff --git a/fe/check/checkstyle/checkstyle.xml b/fe/check/checkstyle/checkstyle.xml
index c367452c90b4da..1bd1436b667721 100644
--- a/fe/check/checkstyle/checkstyle.xml
+++ b/fe/check/checkstyle/checkstyle.xml
@@ -36,6 +36,10 @@ under the License.
+
+
+
+
@@ -69,6 +73,10 @@ under the License.
+
+
+
+
@@ -100,6 +108,7 @@ under the License.
+
-
+
+
+
-
+
+
+
-
+
+
+
@@ -249,20 +264,22 @@ under the License.
-
+
+
-
+
+
@@ -273,22 +290,26 @@ under the License.
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
-
+
+
-
+
+
-
+
+
+
@@ -305,7 +326,8 @@ under the License.
value="Package name ''{0}'' must match pattern ''{1}''."/>
-
+
+
diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/io/BitmapValue.java b/fe/fe-common/src/main/java/org/apache/doris/common/io/BitmapValue.java
index fe857bf5b3854c..bef2fba4f466b1 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/io/BitmapValue.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/io/BitmapValue.java
@@ -58,7 +58,7 @@ public void add(int value) {
}
public void add(long value) {
- switch (bitmapType) {
+ switch (bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
singleValue = value;
bitmapType = SINGLE_VALUE;
@@ -95,7 +95,7 @@ public boolean contains(long value) {
}
public long cardinality() {
- switch (bitmapType) {
+ switch (bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
return 0;
case SINGLE_VALUE:
@@ -107,7 +107,7 @@ public long cardinality() {
}
public void serialize(DataOutput output) throws IOException {
- switch (bitmapType) {
+ switch (bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
output.writeByte(EMPTY);
break;
@@ -155,12 +155,12 @@ public void deserialize(DataInput input) throws IOException {
// In-place bitwise AND (intersection) operation. The current bitmap is modified.
public void and(BitmapValue other) {
- switch (other.bitmapType) {
+ switch (other.bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
clear();
break;
case SINGLE_VALUE:
- switch (this.bitmapType) {
+ switch (this.bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
break;
case SINGLE_VALUE:
@@ -180,7 +180,7 @@ public void and(BitmapValue other) {
}
break;
case BITMAP_VALUE:
- switch (this.bitmapType) {
+ switch (this.bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
break;
case SINGLE_VALUE:
@@ -199,14 +199,14 @@ public void and(BitmapValue other) {
// In-place bitwise OR (union) operation. The current bitmap is modified.
public void or(BitmapValue other) {
- switch (other.bitmapType) {
+ switch (other.bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
break;
case SINGLE_VALUE:
add(other.singleValue);
break;
case BITMAP_VALUE:
- switch (this.bitmapType) {
+ switch (this.bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
// deep copy the bitmap in case of multi-rollups update the bitmap repeatedly
this.bitmap = new Roaring64Map();
@@ -228,7 +228,7 @@ public void or(BitmapValue other) {
}
public void remove(long value){
- switch (this.bitmapType){
+ switch (this.bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
break;
case SINGLE_VALUE:
@@ -245,14 +245,14 @@ public void remove(long value){
//In-place bitwise ANDNOT (difference) operation. The current bitmap is modified
public void not(BitmapValue other) {
- switch (other.bitmapType) {
+ switch (other.bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
break;
case SINGLE_VALUE:
remove(other.singleValue);
break;
case BITMAP_VALUE:
- switch (this.bitmapType) {
+ switch (this.bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
break;
case SINGLE_VALUE:
@@ -271,11 +271,11 @@ public void not(BitmapValue other) {
//In-place bitwise XOR (symmetric difference) operation. The current bitmap is modified
public void xor(BitmapValue other) {
- switch (other.bitmapType) {
+ switch (other.bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
break;
case SINGLE_VALUE:
- switch (this.bitmapType){
+ switch (this.bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
add(other.singleValue);
break;
@@ -297,7 +297,7 @@ public void xor(BitmapValue other) {
}
break;
case BITMAP_VALUE:
- switch (this.bitmapType) {
+ switch (this.bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
this.bitmap = other.bitmap;
this.bitmapType = BITMAP_VALUE;
@@ -325,7 +325,7 @@ public boolean equals(BitmapValue other) {
if (this.bitmapType != other.bitmapType) {
return false;
}
- switch (other.bitmapType) {
+ switch (other.bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
ret = true;
break;
@@ -348,7 +348,7 @@ public boolean equals(BitmapValue other) {
// TODO(wb): keep getSizeInBytes consistent with be and refactor roaring
public long getSizeInBytes() {
long size = 0;
- switch (bitmapType) {
+ switch (bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
size = 1;
break;
@@ -368,7 +368,7 @@ public long getSizeInBytes() {
@Override
public String toString() {
String toStringStr = "{}";
- switch (bitmapType) {
+ switch (bitmapType) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case EMPTY:
break;
case SINGLE_VALUE:
diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/io/Codec.java b/fe/fe-common/src/main/java/org/apache/doris/common/io/Codec.java
index 05dada16019ae4..2d783a3f383da1 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/io/Codec.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/io/Codec.java
@@ -26,7 +26,7 @@ public class Codec {
// not support encode negative value now
public static void encodeVarint64(long source, DataOutput out) throws IOException {
assert source >= 0;
- short B = 128;
+ short B = 128; // CHECKSTYLE IGNORE THIS LINE
while (source >= B) {
out.write((int) (source & (B - 1) | B));
@@ -39,7 +39,7 @@ public static void encodeVarint64(long source, DataOutput out) throws IOExceptio
public static long decodeVarint64(DataInput in) throws IOException {
long result = 0;
int shift = 0;
- short B = 128;
+ short B = 128; // CHECKSTYLE IGNORE THIS LINE
while (true) {
int oneByte = in.readUnsignedByte();
diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/io/FastByteArrayInputStream.java b/fe/fe-common/src/main/java/org/apache/doris/common/io/FastByteArrayInputStream.java
index c34ccf02e131b4..0375068f48d8f6 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/io/FastByteArrayInputStream.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/io/FastByteArrayInputStream.java
@@ -53,8 +53,9 @@ public final int read() {
}
public final int read(byte[] b, int off, int len) {
- if (pos >= count)
+ if (pos >= count) {
return -1;
+ }
if ((pos + len) > count) {
len = (count - pos);
diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/io/Hll.java b/fe/fe-common/src/main/java/org/apache/doris/common/io/Hll.java
index 36385072a3475c..ed02b0a4892d20 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/io/Hll.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/io/Hll.java
@@ -116,7 +116,7 @@ public void updateWithHash(Object value) {
}
public void update(long hashValue) {
- switch (this.type) {
+ switch (this.type) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case HLL_DATA_EMPTY:
hashSet.add(hashValue);
type = HLL_DATA_EXPLICIT;
@@ -128,7 +128,7 @@ public void update(long hashValue) {
}
convertExplicitToRegister();
type = HLL_DATA_FULL;
- case HLL_DATA_SPARSE:
+ case HLL_DATA_SPARSE: // CHECKSTYLE IGNORE THIS LINE: fall through
case HLL_DATA_FULL:
updateRegisters(hashValue);
break;
@@ -139,10 +139,10 @@ public void merge(Hll other) {
if (other.type == HLL_DATA_EMPTY) {
return;
}
- switch (this.type) {
+ switch (this.type) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case HLL_DATA_EMPTY:
this.type = other.type;
- switch (other.type) {
+ switch (other.type) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case HLL_DATA_EXPLICIT:
this.hashSet.addAll(other.hashSet);
break;
@@ -154,7 +154,7 @@ public void merge(Hll other) {
}
break;
case HLL_DATA_EXPLICIT:
- switch (other.type) {
+ switch (other.type) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case HLL_DATA_EXPLICIT:
this.hashSet.addAll(other.hashSet);
if (this.hashSet.size() > HLL_EXPLICLIT_INT64_NUM) {
@@ -172,7 +172,7 @@ public void merge(Hll other) {
break;
case HLL_DATA_SPARSE:
case HLL_DATA_FULL:
- switch (other.type) {
+ switch (other.type) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case HLL_DATA_EXPLICIT:
for (long value : other.hashSet) {
update(value);
@@ -188,7 +188,7 @@ public void merge(Hll other) {
}
public void serialize(DataOutput output) throws IOException {
- switch (type) {
+ switch (type) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case HLL_DATA_EMPTY:
output.writeByte(type);
break;
@@ -363,20 +363,20 @@ public static long hash64(final byte[] data, final int length, final int seed) {
}
final int index = (nblocks << 3);
- switch (length - index) {
+ switch (length - index) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case 7:
h ^= ((long) data[index + 6] & 0xff) << 48;
- case 6:
+ case 6: // CHECKSTYLE IGNORE THIS LINE: fall through
h ^= ((long) data[index + 5] & 0xff) << 40;
- case 5:
+ case 5: // CHECKSTYLE IGNORE THIS LINE: fall through
h ^= ((long) data[index + 4] & 0xff) << 32;
- case 4:
+ case 4: // CHECKSTYLE IGNORE THIS LINE: fall through
h ^= ((long) data[index + 3] & 0xff) << 24;
- case 3:
+ case 3: // CHECKSTYLE IGNORE THIS LINE: fall through
h ^= ((long) data[index + 2] & 0xff) << 16;
- case 2:
+ case 2: // CHECKSTYLE IGNORE THIS LINE: fall through
h ^= ((long) data[index + 1] & 0xff) << 8;
- case 1:
+ case 1: // CHECKSTYLE IGNORE THIS LINE: fall through
h ^= ((long) data[index] & 0xff);
h *= M64;
}
diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/io/Text.java b/fe/fe-common/src/main/java/org/apache/doris/common/io/Text.java
index 8309e245ba262e..a8977e5ed7f9d0 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/io/Text.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/io/Text.java
@@ -469,7 +469,7 @@ public static void validateUTF8(byte[] utf8, int start, int len)
while (count < start + len) {
int aByte = ((int) utf8[count] & 0xFF);
- switch (state) {
+ switch (state) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case LEAD_BYTE:
leadByte = aByte;
length = bytesFromUTF8[aByte];
@@ -520,8 +520,9 @@ public static void validateUTF8(byte[] utf8, int start, int len)
}
// falls through to regular trail-byte test!!
case TRAIL_BYTE:
- if (aByte < 0x80 || aByte > 0xBF)
+ if (aByte < 0x80 || aByte > 0xBF) {
throw new MalformedInputException(count);
+ }
if (--length == 0) {
state = LEAD_BYTE;
} else {
@@ -570,28 +571,35 @@ public static int bytesToCodePoint(ByteBuffer bytes) {
byte b = bytes.get();
bytes.reset();
int extraBytesToRead = bytesFromUTF8[(b & 0xFF)];
- if (extraBytesToRead < 0)
+ if (extraBytesToRead < 0) {
return -1; // trailing byte!
+ }
int ch = 0;
- switch (extraBytesToRead) {
+ switch (extraBytesToRead) { // CHECKSTYLE IGNORE THIS LINE: missing switch default
case 5:
ch += (bytes.get() & 0xFF);
ch <<= 6; /* remember, illegal UTF-8 */
+ // CHECKSTYLE IGNORE THIS LINE: fall through
case 4:
ch += (bytes.get() & 0xFF);
ch <<= 6; /* remember, illegal UTF-8 */
+ // CHECKSTYLE IGNORE THIS LINE: fall through
case 3:
ch += (bytes.get() & 0xFF);
ch <<= 6;
+ // CHECKSTYLE IGNORE THIS LINE: fall through
case 2:
ch += (bytes.get() & 0xFF);
ch <<= 6;
+ // CHECKSTYLE IGNORE THIS LINE: fall through
case 1:
ch += (bytes.get() & 0xFF);
ch <<= 6;
+ // CHECKSTYLE IGNORE THIS LINE: fall through
case 0:
ch += (bytes.get() & 0xFF);
+ // CHECKSTYLE IGNORE THIS LINE: fall through, missing switch default
}
ch -= offsetsFromUTF8[extraBytesToRead];
diff --git a/fe/fe-common/src/test/java/org/apache/doris/common/io/BitmapValueTest.java b/fe/fe-common/src/test/java/org/apache/doris/common/io/BitmapValueTest.java
index d30e734c91b11f..8c802da3ee0f99 100644
--- a/fe/fe-common/src/test/java/org/apache/doris/common/io/BitmapValueTest.java
+++ b/fe/fe-common/src/test/java/org/apache/doris/common/io/BitmapValueTest.java
@@ -102,112 +102,112 @@ public void testBitmapValueAdd() {
public void testBitmapValueAnd() {
// empty and empty
BitmapValue bitmapValue1 = new BitmapValue();
- BitmapValue bitmapValue1_1 = new BitmapValue();
- bitmapValue1.and(bitmapValue1_1);
+ BitmapValue bitmapValue1Dot1 = new BitmapValue();
+ bitmapValue1.and(bitmapValue1Dot1);
Assert.assertTrue(bitmapValue1.getBitmapType() == BitmapValue.EMPTY);
Assert.assertTrue(bitmapValue1.cardinality() == 0);
// empty and single value
BitmapValue bitmapValue2 = new BitmapValue();
- BitmapValue bitmapValue2_1 = new BitmapValue();
- bitmapValue2_1.add(1);
- bitmapValue2.and(bitmapValue2_1);
+ BitmapValue bitmapValue2Dot1 = new BitmapValue();
+ bitmapValue2Dot1.add(1);
+ bitmapValue2.and(bitmapValue2Dot1);
Assert.assertTrue(bitmapValue2.getBitmapType() == BitmapValue.EMPTY);
Assert.assertTrue(bitmapValue2.cardinality() == 0);
// empty and bitmap
BitmapValue bitmapValue3 = new BitmapValue();
- BitmapValue bitmapValue3_1 =new BitmapValue();
- bitmapValue3_1.add(1);
- bitmapValue3_1.add(2);
- bitmapValue3.and(bitmapValue3_1);
+ BitmapValue bitmapValue3Dot1 =new BitmapValue();
+ bitmapValue3Dot1.add(1);
+ bitmapValue3Dot1.add(2);
+ bitmapValue3.and(bitmapValue3Dot1);
Assert.assertTrue(bitmapValue2.getBitmapType() == BitmapValue.EMPTY);
Assert.assertTrue(bitmapValue3.cardinality() == 0);
// single value and empty
BitmapValue bitmapValue4 = new BitmapValue();
bitmapValue4.add(1);
- BitmapValue bitmapValue4_1 = new BitmapValue();
- bitmapValue4.and(bitmapValue4_1);
+ BitmapValue bitmapValue4Dot1 = new BitmapValue();
+ bitmapValue4.and(bitmapValue4Dot1);
Assert.assertTrue(bitmapValue4.getBitmapType() == BitmapValue.EMPTY);
Assert.assertTrue(bitmapValue4.cardinality() == 0);
// single value and single value
BitmapValue bitmapValue5 = new BitmapValue();
bitmapValue5.add(1);
- BitmapValue bitmapValue5_1 = new BitmapValue();
- bitmapValue5_1.add(1);
- bitmapValue5.and(bitmapValue5_1);
+ BitmapValue bitmapValue5Dot1 = new BitmapValue();
+ bitmapValue5Dot1.add(1);
+ bitmapValue5.and(bitmapValue5Dot1);
Assert.assertTrue(bitmapValue5.getBitmapType() == BitmapValue.SINGLE_VALUE);
Assert.assertTrue(bitmapValue5.contains(1));
bitmapValue5.clear();
- bitmapValue5_1.clear();
+ bitmapValue5Dot1.clear();
bitmapValue5.add(1);
- bitmapValue5_1.add(2);
- bitmapValue5.and(bitmapValue5_1);
+ bitmapValue5Dot1.add(2);
+ bitmapValue5.and(bitmapValue5Dot1);
Assert.assertTrue(bitmapValue5.getBitmapType() == BitmapValue.EMPTY);
// single value and bitmap
BitmapValue bitmapValue6 = new BitmapValue();
bitmapValue6.add(1);
- BitmapValue bitmapValue6_1 = new BitmapValue();
- bitmapValue6_1.add(1);
- bitmapValue6_1.add(2);
- bitmapValue6.and(bitmapValue6_1);
+ BitmapValue bitmapValue6Dot1 = new BitmapValue();
+ bitmapValue6Dot1.add(1);
+ bitmapValue6Dot1.add(2);
+ bitmapValue6.and(bitmapValue6Dot1);
Assert.assertTrue(bitmapValue6.getBitmapType() == BitmapValue.SINGLE_VALUE);
bitmapValue6.clear();
bitmapValue6.add(3);
- bitmapValue6.and(bitmapValue6_1);
+ bitmapValue6.and(bitmapValue6Dot1);
Assert.assertTrue(bitmapValue6.getBitmapType() == BitmapValue.EMPTY);
// bitmap and empty
BitmapValue bitmapValue7 = new BitmapValue();
bitmapValue7.add(1);
bitmapValue7.add(2);
- BitmapValue bitmapValue7_1 = new BitmapValue();
- bitmapValue7.and(bitmapValue7_1);
+ BitmapValue bitmapValue7Dot1 = new BitmapValue();
+ bitmapValue7.and(bitmapValue7Dot1);
Assert.assertTrue(bitmapValue7.getBitmapType() == BitmapValue.EMPTY);
// bitmap and single value
BitmapValue bitmapValue8 = new BitmapValue();
bitmapValue8.add(1);
bitmapValue8.add(2);
- BitmapValue bitmapValue8_1 = new BitmapValue();
- bitmapValue8_1.add(1);
- bitmapValue8.and(bitmapValue8_1);
+ BitmapValue bitmapValue8Dot1 = new BitmapValue();
+ bitmapValue8Dot1.add(1);
+ bitmapValue8.and(bitmapValue8Dot1);
Assert.assertTrue(bitmapValue8.getBitmapType() == BitmapValue.SINGLE_VALUE);
bitmapValue8.clear();
bitmapValue8.add(2);
bitmapValue8.add(3);
- bitmapValue8.and(bitmapValue8_1);
+ bitmapValue8.and(bitmapValue8Dot1);
Assert.assertTrue(bitmapValue8.getBitmapType() == BitmapValue.EMPTY);
// bitmap and bitmap
BitmapValue bitmapValue9 = new BitmapValue();
bitmapValue9.add(1);
bitmapValue9.add(2);
- BitmapValue bitmapValue9_1 = new BitmapValue();
- bitmapValue9_1.add(2);
- bitmapValue9_1.add(3);
- bitmapValue9.and(bitmapValue9_1);
+ BitmapValue bitmapValue9Dot1 = new BitmapValue();
+ bitmapValue9Dot1.add(2);
+ bitmapValue9Dot1.add(3);
+ bitmapValue9.and(bitmapValue9Dot1);
Assert.assertTrue(bitmapValue9.getBitmapType() == BitmapValue.SINGLE_VALUE);
bitmapValue9.clear();
bitmapValue9.add(4);
bitmapValue9.add(5);
- bitmapValue9.and(bitmapValue9_1);
+ bitmapValue9.and(bitmapValue9Dot1);
Assert.assertTrue(bitmapValue9.getBitmapType() == BitmapValue.EMPTY);
bitmapValue9.clear();
bitmapValue9.add(2);
bitmapValue9.add(3);
bitmapValue9.add(4);
- bitmapValue9.and(bitmapValue9_1);
+ bitmapValue9.and(bitmapValue9Dot1);
Assert.assertTrue(bitmapValue9.getBitmapType() == BitmapValue.BITMAP_VALUE);
- Assert.assertTrue(bitmapValue9.equals(bitmapValue9_1));
+ Assert.assertTrue(bitmapValue9.equals(bitmapValue9Dot1));
}
@@ -215,77 +215,77 @@ public void testBitmapValueAnd() {
public void testBitmapValueOr() {
// empty or empty
BitmapValue bitmapValue1 = new BitmapValue();
- BitmapValue bitmapValue1_1 = new BitmapValue();
- bitmapValue1.or(bitmapValue1_1);
+ BitmapValue bitmapValue1Dot1 = new BitmapValue();
+ bitmapValue1.or(bitmapValue1Dot1);
Assert.assertTrue(bitmapValue1.getBitmapType() == BitmapValue.EMPTY);
// empty or single value
BitmapValue bitmapValue2 = new BitmapValue();
- BitmapValue bitmapValue2_1 = new BitmapValue();
- bitmapValue2_1.add(1);
- bitmapValue2.or(bitmapValue2_1);
+ BitmapValue bitmapValue2Dot1 = new BitmapValue();
+ bitmapValue2Dot1.add(1);
+ bitmapValue2.or(bitmapValue2Dot1);
Assert.assertTrue(bitmapValue2.getBitmapType() == BitmapValue.SINGLE_VALUE);
// empty or bitmap
BitmapValue bitmapValue3 = new BitmapValue();
- BitmapValue bitmapValue3_1 = new BitmapValue();
- bitmapValue3_1.add(1);
- bitmapValue3_1.add(2);
- bitmapValue3.or(bitmapValue3_1);
+ BitmapValue bitmapValue3Dot1 = new BitmapValue();
+ bitmapValue3Dot1.add(1);
+ bitmapValue3Dot1.add(2);
+ bitmapValue3.or(bitmapValue3Dot1);
Assert.assertTrue(bitmapValue3.getBitmapType() == BitmapValue.BITMAP_VALUE);
// single or and empty
BitmapValue bitmapValue4 = new BitmapValue();
- BitmapValue bitmapValue4_1 = new BitmapValue();
+ BitmapValue bitmapValue4Dot1 = new BitmapValue();
bitmapValue4.add(1);
- bitmapValue4.or(bitmapValue4_1);
+ bitmapValue4.or(bitmapValue4Dot1);
Assert.assertTrue(bitmapValue4.getBitmapType() == BitmapValue.SINGLE_VALUE);
// single or and single value
BitmapValue bitmapValue5 = new BitmapValue();
- BitmapValue bitmapValue5_1 = new BitmapValue();
+ BitmapValue bitmapValue5Dot1 = new BitmapValue();
bitmapValue5.add(1);
- bitmapValue5_1.add(1);
- bitmapValue5.or(bitmapValue5_1);
+ bitmapValue5Dot1.add(1);
+ bitmapValue5.or(bitmapValue5Dot1);
Assert.assertTrue(bitmapValue5.getBitmapType() == BitmapValue.SINGLE_VALUE);
bitmapValue5.clear();
bitmapValue5.add(2);
- bitmapValue5.or(bitmapValue5_1);
+ bitmapValue5.or(bitmapValue5Dot1);
Assert.assertTrue(bitmapValue5.getBitmapType() == BitmapValue.BITMAP_VALUE);
// single or and bitmap
BitmapValue bitmapValue6 = new BitmapValue();
- BitmapValue bitmapValue6_1 = new BitmapValue();
+ BitmapValue bitmapValue6Dot1 = new BitmapValue();
bitmapValue6.add(1);
- bitmapValue6_1.add(1);
- bitmapValue6_1.add(2);
- bitmapValue6.or(bitmapValue6_1);
+ bitmapValue6Dot1.add(1);
+ bitmapValue6Dot1.add(2);
+ bitmapValue6.or(bitmapValue6Dot1);
Assert.assertTrue(bitmapValue6.getBitmapType() == BitmapValue.BITMAP_VALUE);
// bitmap or empty
BitmapValue bitmapValue7 = new BitmapValue();
bitmapValue7.add(1);
bitmapValue7.add(2);
- BitmapValue bitmapValue7_1 =new BitmapValue();
- bitmapValue7.or(bitmapValue7_1);
+ BitmapValue bitmapValue7Dot1 =new BitmapValue();
+ bitmapValue7.or(bitmapValue7Dot1);
Assert.assertTrue(bitmapValue7.getBitmapType() == BitmapValue.BITMAP_VALUE);
// bitmap or single value
BitmapValue bitmapValue8 = new BitmapValue();
bitmapValue8.add(1);
bitmapValue8.add(2);
- BitmapValue bitmapValue8_1 =new BitmapValue();
- bitmapValue8_1.add(1);
- bitmapValue8.or(bitmapValue8_1);
+ BitmapValue bitmapValue8Dot1 =new BitmapValue();
+ bitmapValue8Dot1.add(1);
+ bitmapValue8.or(bitmapValue8Dot1);
Assert.assertTrue(bitmapValue8.getBitmapType() == BitmapValue.BITMAP_VALUE);
// bitmap or bitmap
BitmapValue bitmapValue9 = new BitmapValue();
bitmapValue9.add(1);
bitmapValue9.add(2);
- BitmapValue bitmapValue9_1 =new BitmapValue();
- bitmapValue9.or(bitmapValue9_1);
+ BitmapValue bitmapValue9Dot1 =new BitmapValue();
+ bitmapValue9.or(bitmapValue9Dot1);
Assert.assertTrue(bitmapValue9.getBitmapType() == BitmapValue.BITMAP_VALUE);
}
diff --git a/fe/fe-common/src/test/java/org/apache/doris/common/io/HllTest.java b/fe/fe-common/src/test/java/org/apache/doris/common/io/HllTest.java
index eecf3ecb94c227..78ba33b6929f8c 100644
--- a/fe/fe-common/src/test/java/org/apache/doris/common/io/HllTest.java
+++ b/fe/fe-common/src/test/java/org/apache/doris/common/io/HllTest.java
@@ -38,7 +38,7 @@ public void testFindFirstNonZeroBitPosition() {
}
@Test
- public void HllBasicTest() throws IOException {
+ public void hllBasicTest() throws IOException {
// test empty
Hll emptyHll = new Hll();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/AlterHandler.java b/fe/fe-core/src/main/java/org/apache/doris/alter/AlterHandler.java
index 7cdd1d3a5e2fec..23a66a3678e974 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/AlterHandler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/AlterHandler.java
@@ -76,8 +76,8 @@ public AlterHandler(String name) {
this(name, FeConstants.default_scheduler_interval_millisecond);
}
- public AlterHandler(String name, int scheduler_interval_millisecond) {
- super(name, scheduler_interval_millisecond);
+ public AlterHandler(String name, int schedulerIntervalMillisecond) {
+ super(name, schedulerIntervalMillisecond);
}
protected void addAlterJobV2(AlterJobV2 alterJob) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java b/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
index a2d04a12c66c97..4d7eb8f5a5ba6e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
@@ -1050,8 +1050,9 @@ public void cancel(CancelStmt stmt) throws DdlException {
if (cancelAlterTableStmt.getAlterJobIdList() != null) {
for (Long jobId : cancelAlterTableStmt.getAlterJobIdList()) {
AlterJobV2 alterJobV2 = getUnfinishedAlterJobV2ByJobId(jobId);
- if (alterJobV2 == null)
+ if (alterJobV2 == null) {
continue;
+ }
rollupJobV2List.add(getUnfinishedAlterJobV2ByJobId(jobId));
}
} else {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfo.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfo.java
index 6040850916e0b1..988dff558439de 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfo.java
@@ -81,41 +81,41 @@ public enum AggPhase {
};
// created by createMergeAggInfo()
- private AggregateInfo mergeAggInfo_;
+ private AggregateInfo mergeAggInfo;
// created by createDistinctAggInfo()
- private AggregateInfo secondPhaseDistinctAggInfo_;
+ private AggregateInfo secondPhaseDistinctAggInfo;
- private final AggPhase aggPhase_;
+ private final AggPhase aggPhase;
// Map from all grouping and aggregate exprs to a SlotRef referencing the corresp. slot
// in the intermediate tuple. Identical to outputTupleSmap_ if no aggregateExpr has an
// output type that is different from its intermediate type.
- protected ExprSubstitutionMap intermediateTupleSmap_ = new ExprSubstitutionMap();
+ protected ExprSubstitutionMap intermediateTupleSmap = new ExprSubstitutionMap();
// Map from all grouping and aggregate exprs to a SlotRef referencing the corresp. slot
// in the output tuple.
- protected ExprSubstitutionMap outputTupleSmap_ = new ExprSubstitutionMap();
+ protected ExprSubstitutionMap outputTupleSmap = new ExprSubstitutionMap();
// Map from slots of outputTupleSmap_ to the corresponding slot in
// intermediateTupleSmap_.
- protected ExprSubstitutionMap outputToIntermediateTupleSmap_ =
+ protected ExprSubstitutionMap outputToIntermediateTupleSmap =
new ExprSubstitutionMap();
// if set, a subset of groupingExprs_; set and used during planning
- private List partitionExprs_;
+ private List partitionExprs;
// indices into aggregateExprs for those that need to be materialized;
// shared between this, mergeAggInfo and secondPhaseDistinctAggInfo
- private ArrayList materializedAggregateSlots_ = Lists.newArrayList();
+ private ArrayList materializedAggregateSlots = Lists.newArrayList();
// if true, this AggregateInfo is the first phase of a 2-phase DISTINCT computation
private boolean isDistinctAgg = false;
// If true, the sql has MultiDistinct
- private boolean isMultiDistinct_;
+ private boolean isMultiDistinct;
// the multi distinct's begin pos and end pos in groupby exprs
- private ArrayList firstIdx_ = Lists.newArrayList();
- private ArrayList lastIdx_ = Lists.newArrayList();
+ private ArrayList firstIdx = Lists.newArrayList();
+ private ArrayList lastIdx = Lists.newArrayList();
// C'tor creates copies of groupingExprs and aggExprs.
private AggregateInfo(ArrayList groupingExprs,
@@ -126,8 +126,8 @@ private AggregateInfo(ArrayList groupingExprs,
private AggregateInfo(ArrayList groupingExprs,
ArrayList aggExprs, AggPhase aggPhase, boolean isMultiDistinct) {
super(groupingExprs, aggExprs);
- aggPhase_ = aggPhase;
- isMultiDistinct_ = isMultiDistinct;
+ this.aggPhase = aggPhase;
+ this.isMultiDistinct = isMultiDistinct;
}
/**
@@ -135,26 +135,26 @@ private AggregateInfo(ArrayList groupingExprs,
*/
private AggregateInfo(AggregateInfo other) {
super(other);
- if (other.mergeAggInfo_ != null) {
- mergeAggInfo_ = other.mergeAggInfo_.clone();
+ if (other.mergeAggInfo != null) {
+ mergeAggInfo = other.mergeAggInfo.clone();
}
- if (other.secondPhaseDistinctAggInfo_ != null) {
- secondPhaseDistinctAggInfo_ = other.secondPhaseDistinctAggInfo_.clone();
+ if (other.secondPhaseDistinctAggInfo != null) {
+ secondPhaseDistinctAggInfo = other.secondPhaseDistinctAggInfo.clone();
}
- aggPhase_ = other.aggPhase_;
- outputTupleSmap_ = other.outputTupleSmap_.clone();
+ aggPhase = other.aggPhase;
+ outputTupleSmap = other.outputTupleSmap.clone();
if (other.requiresIntermediateTuple()) {
- intermediateTupleSmap_ = other.intermediateTupleSmap_.clone();
+ intermediateTupleSmap = other.intermediateTupleSmap.clone();
} else {
- Preconditions.checkState(other.intermediateTupleDesc_ == other.outputTupleDesc_);
- intermediateTupleSmap_ = outputTupleSmap_;
+ Preconditions.checkState(other.intermediateTupleDesc == other.outputTupleDesc);
+ intermediateTupleSmap = outputTupleSmap;
}
- partitionExprs_ =
- (other.partitionExprs_ != null) ? Expr.cloneList(other.partitionExprs_) : null;
+ partitionExprs =
+ (other.partitionExprs != null) ? Expr.cloneList(other.partitionExprs) : null;
}
- public List getPartitionExprs() { return partitionExprs_; }
- public void setPartitionExprs(List exprs) { partitionExprs_ = exprs; }
+ public List getPartitionExprs() { return partitionExprs; }
+ public void setPartitionExprs(List exprs) { partitionExprs = exprs; }
/**
* Creates complete AggregateInfo for groupingExprs and aggExprs, including
@@ -201,8 +201,8 @@ static public AggregateInfo create(
} else {
// A tupleDesc should only be given for UNION DISTINCT.
Preconditions.checkState(aggExprs == null);
- result.outputTupleDesc_ = tupleDesc;
- result.intermediateTupleDesc_ = tupleDesc;
+ result.outputTupleDesc = tupleDesc;
+ result.intermediateTupleDesc = tupleDesc;
}
result.createMergeAggInfo(analyzer);
} else {
@@ -212,7 +212,9 @@ static public AggregateInfo create(
Preconditions.checkState(tupleDesc == null);
result.createDistinctAggInfo(groupingExprs, distinctAggExprs, analyzer);
}
- if (LOG.isDebugEnabled()) LOG.debug("agg info:\n{}", result.debugString());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("agg info:\n{}", result.debugString());
+ }
return result;
}
@@ -309,16 +311,16 @@ private void createDistinctAggInfo(
}
}
- this.isMultiDistinct_= estimateIfContainsMultiDistinct(distinctAggExprs);
+ this.isMultiDistinct = estimateIfContainsMultiDistinct(distinctAggExprs);
isDistinctAgg = true;
// add DISTINCT parameters to grouping exprs
- if (!isMultiDistinct_) {
- groupingExprs_.addAll(expr0Children);
+ if (!isMultiDistinct) {
+ groupingExprs.addAll(expr0Children);
}
// remove DISTINCT aggregate functions from aggExprs
- aggregateExprs_.removeAll(distinctAggExprs);
+ aggregateExprs.removeAll(distinctAggExprs);
createTupleDescs(analyzer);
createSmaps(analyzer);
@@ -328,47 +330,49 @@ private void createDistinctAggInfo(
public ArrayList getMaterializedAggregateExprs() {
ArrayList result = Lists.newArrayList();
- for (Integer i: materializedSlots_) {
- result.add(aggregateExprs_.get(i));
+ for (Integer i: materializedSlots) {
+ result.add(aggregateExprs.get(i));
}
return result;
}
public AggregateInfo getMergeAggInfo() {
- return mergeAggInfo_;
+ return mergeAggInfo;
}
- public boolean isMerge() { return aggPhase_.isMerge(); }
- public boolean isDistinctAgg() { return secondPhaseDistinctAggInfo_ != null; }
- public ExprSubstitutionMap getIntermediateSmap() { return intermediateTupleSmap_; }
- public ExprSubstitutionMap getOutputSmap() { return outputTupleSmap_; }
+ public boolean isMerge() { return aggPhase.isMerge(); }
+ public boolean isDistinctAgg() { return secondPhaseDistinctAggInfo != null; }
+ public ExprSubstitutionMap getIntermediateSmap() { return intermediateTupleSmap; }
+ public ExprSubstitutionMap getOutputSmap() { return outputTupleSmap; }
public ExprSubstitutionMap getOutputToIntermediateSmap() {
- return outputToIntermediateTupleSmap_;
+ return outputToIntermediateTupleSmap;
}
public boolean hasAggregateExprs() {
- return !aggregateExprs_.isEmpty() ||
- (secondPhaseDistinctAggInfo_ != null &&
- !secondPhaseDistinctAggInfo_.getAggregateExprs().isEmpty());
+ return !aggregateExprs.isEmpty() ||
+ (secondPhaseDistinctAggInfo != null &&
+ !secondPhaseDistinctAggInfo.getAggregateExprs().isEmpty());
}
public void setIsMultiDistinct(boolean value) {
- this.isMultiDistinct_ = value;
+ this.isMultiDistinct = value;
}
public boolean isMultiDistinct() {
- return isMultiDistinct_;
+ return isMultiDistinct;
}
public AggregateInfo getSecondPhaseDistinctAggInfo() {
- return secondPhaseDistinctAggInfo_;
+ return secondPhaseDistinctAggInfo;
}
/**
* Return the tuple id produced in the final aggregation step.
*/
public TupleId getResultTupleId() {
- if (isDistinctAgg()) return secondPhaseDistinctAggInfo_.getOutputTupleId();
+ if (isDistinctAgg()) {
+ return secondPhaseDistinctAggInfo.getOutputTupleId();
+ }
return getOutputTupleId();
}
@@ -377,14 +381,14 @@ public TupleId getResultTupleId() {
* of performing the aggregate computation described by this AggregateInfo.
*/
public void getRefdSlots(List ids) {
- Preconditions.checkState(outputTupleDesc_ != null);
- if (groupingExprs_ != null) {
- Expr.getIds(groupingExprs_, null, ids);
+ Preconditions.checkState(outputTupleDesc != null);
+ if (groupingExprs != null) {
+ Expr.getIds(groupingExprs, null, ids);
}
- Expr.getIds(aggregateExprs_, null, ids);
+ Expr.getIds(aggregateExprs, null, ids);
// The backend assumes that the entire aggTupleDesc is materialized
- for (int i = 0; i < outputTupleDesc_.getSlots().size(); ++i) {
- ids.add(outputTupleDesc_.getSlots().get(i).getId());
+ for (int i = 0; i < outputTupleDesc.getSlots().size(); ++i) {
+ ids.add(outputTupleDesc.getSlots().get(i).getId());
}
}
@@ -408,24 +412,24 @@ public void getRefdSlots(List ids) {
* aggTupleDesc
*/
public void substitute(ExprSubstitutionMap smap, Analyzer analyzer) {
- groupingExprs_ = Expr.substituteList(groupingExprs_, smap, analyzer, true);
+ groupingExprs = Expr.substituteList(groupingExprs, smap, analyzer, true);
if (LOG.isTraceEnabled()) {
- LOG.trace("AggInfo: grouping_exprs=" + Expr.debugString(groupingExprs_));
+ LOG.trace("AggInfo: grouping_exprs=" + Expr.debugString(groupingExprs));
}
// The smap in this case should not substitute the aggs themselves, only
// their subexpressions.
List substitutedAggs =
- Expr.substituteList(aggregateExprs_, smap, analyzer, false);
- aggregateExprs_.clear();
+ Expr.substituteList(aggregateExprs, smap, analyzer, false);
+ aggregateExprs.clear();
for (Expr substitutedAgg: substitutedAggs) {
- aggregateExprs_.add((FunctionCallExpr) substitutedAgg);
+ aggregateExprs.add((FunctionCallExpr) substitutedAgg);
}
- outputTupleSmap_.substituteLhs(smap, analyzer);
- intermediateTupleSmap_.substituteLhs(smap, analyzer);
- if (secondPhaseDistinctAggInfo_ != null) {
- secondPhaseDistinctAggInfo_.substitute(smap, analyzer);
+ outputTupleSmap.substituteLhs(smap, analyzer);
+ intermediateTupleSmap.substituteLhs(smap, analyzer);
+ if (secondPhaseDistinctAggInfo != null) {
+ secondPhaseDistinctAggInfo.substitute(smap, analyzer);
}
}
@@ -441,8 +445,8 @@ public void substitute(ExprSubstitutionMap smap, Analyzer analyzer) {
* createAggTupleDesc() must not be called on it.
*/
private void createMergeAggInfo(Analyzer analyzer) {
- Preconditions.checkState(mergeAggInfo_ == null);
- TupleDescriptor inputDesc = intermediateTupleDesc_;
+ Preconditions.checkState(mergeAggInfo == null);
+ TupleDescriptor inputDesc = intermediateTupleDesc;
// construct grouping exprs
ArrayList groupingExprs = Lists.newArrayList();
for (int i = 0; i < getGroupingExprs().size(); ++i) {
@@ -470,13 +474,13 @@ private void createMergeAggInfo(Analyzer analyzer) {
}
AggPhase aggPhase =
- (aggPhase_ == AggPhase.FIRST) ? AggPhase.FIRST_MERGE : AggPhase.SECOND_MERGE;
- mergeAggInfo_ = new AggregateInfo(groupingExprs, aggExprs, aggPhase, isMultiDistinct_);
- mergeAggInfo_.intermediateTupleDesc_ = intermediateTupleDesc_;
- mergeAggInfo_.outputTupleDesc_ = outputTupleDesc_;
- mergeAggInfo_.intermediateTupleSmap_ = intermediateTupleSmap_;
- mergeAggInfo_.outputTupleSmap_ = outputTupleSmap_;
- mergeAggInfo_.materializedSlots_ = materializedSlots_;
+ (this.aggPhase == AggPhase.FIRST) ? AggPhase.FIRST_MERGE : AggPhase.SECOND_MERGE;
+ mergeAggInfo = new AggregateInfo(groupingExprs, aggExprs, aggPhase, isMultiDistinct);
+ mergeAggInfo.intermediateTupleDesc = intermediateTupleDesc;
+ mergeAggInfo.outputTupleDesc = outputTupleDesc;
+ mergeAggInfo.intermediateTupleSmap = intermediateTupleSmap;
+ mergeAggInfo.outputTupleSmap = outputTupleSmap;
+ mergeAggInfo.materializedSlots = materializedSlots;
}
/**
@@ -528,11 +532,11 @@ private Expr createCountDistinctAggExprParam(int firstIdx, int lastIdx,
private void createSecondPhaseAggInfo(
ArrayList origGroupingExprs,
ArrayList distinctAggExprs, Analyzer analyzer) throws AnalysisException {
- Preconditions.checkState(secondPhaseDistinctAggInfo_ == null);
+ Preconditions.checkState(secondPhaseDistinctAggInfo == null);
Preconditions.checkState(!distinctAggExprs.isEmpty());
// The output of the 1st phase agg is the 1st phase intermediate.
- TupleDescriptor inputDesc = intermediateTupleDesc_;
+ TupleDescriptor inputDesc = intermediateTupleDesc;
// construct agg exprs for original DISTINCT aggregate functions
// (these aren't part of this.aggExprs)
@@ -541,7 +545,7 @@ private void createSecondPhaseAggInfo(
for (FunctionCallExpr inputExpr : distinctAggExprs) {
Preconditions.checkState(inputExpr.isAggregateFunction());
FunctionCallExpr aggExpr = null;
- if (!isMultiDistinct_) {
+ if (!isMultiDistinct) {
if (inputExpr.getFnName().getFunction().equalsIgnoreCase(FunctionSet.COUNT)) {
// COUNT(DISTINCT ...) ->
// COUNT(IF(IsNull(), NULL, IF(IsNull(), NULL, ...)))
@@ -561,7 +565,9 @@ private void createSecondPhaseAggInfo(
// tuple reference is correct.
exprList.add(new SlotRef(inputDesc.getSlots().get(origGroupingExprs.size())));
// Check if user provided a custom separator
- if (inputExpr.getChildren().size() == 2) exprList.add(inputExpr.getChild(1));
+ if (inputExpr.getChildren().size() == 2) {
+ exprList.add(inputExpr.getChild(1));
+ }
aggExpr = new FunctionCallExpr(inputExpr.getFnName(), exprList);
} else {
// SUM(DISTINCT ) -> SUM();
@@ -578,8 +584,8 @@ private void createSecondPhaseAggInfo(
}
// map all the remaining agg fns
- for (int i = 0; i < aggregateExprs_.size(); ++i) {
- FunctionCallExpr inputExpr = aggregateExprs_.get(i);
+ for (int i = 0; i < aggregateExprs.size(); ++i) {
+ FunctionCallExpr inputExpr = aggregateExprs.get(i);
Preconditions.checkState(inputExpr.isAggregateFunction());
// we're aggregating an output slot of the 1st agg phase
Expr aggExprParam =
@@ -589,7 +595,7 @@ private void createSecondPhaseAggInfo(
secondPhaseAggExprs.add(aggExpr);
}
Preconditions.checkState(
- secondPhaseAggExprs.size() == aggregateExprs_.size() + distinctAggExprs.size());
+ secondPhaseAggExprs.size() == aggregateExprs.size() + distinctAggExprs.size());
for (FunctionCallExpr aggExpr : secondPhaseAggExprs) {
aggExpr.analyzeNoThrow(analyzer);
@@ -597,12 +603,12 @@ private void createSecondPhaseAggInfo(
}
ArrayList substGroupingExprs =
- Expr.substituteList(origGroupingExprs, intermediateTupleSmap_, analyzer, false);
- secondPhaseDistinctAggInfo_ =
- new AggregateInfo(substGroupingExprs, secondPhaseAggExprs, AggPhase.SECOND, isMultiDistinct_);
- secondPhaseDistinctAggInfo_.createTupleDescs(analyzer);
- secondPhaseDistinctAggInfo_.createSecondPhaseAggSMap(this, distinctAggExprs);
- secondPhaseDistinctAggInfo_.createMergeAggInfo(analyzer);
+ Expr.substituteList(origGroupingExprs, intermediateTupleSmap, analyzer, false);
+ secondPhaseDistinctAggInfo =
+ new AggregateInfo(substGroupingExprs, secondPhaseAggExprs, AggPhase.SECOND, isMultiDistinct);
+ secondPhaseDistinctAggInfo.createTupleDescs(analyzer);
+ secondPhaseDistinctAggInfo.createSecondPhaseAggSMap(this, distinctAggExprs);
+ secondPhaseDistinctAggInfo.createMergeAggInfo(analyzer);
}
/**
@@ -611,12 +617,12 @@ private void createSecondPhaseAggInfo(
*/
private void createSecondPhaseAggSMap(
AggregateInfo inputAggInfo, ArrayList distinctAggExprs) {
- outputTupleSmap_.clear();
+ outputTupleSmap.clear();
int slotIdx = 0;
- ArrayList slotDescs = outputTupleDesc_.getSlots();
+ ArrayList slotDescs = outputTupleDesc.getSlots();
int numDistinctParams = 0;
- if (!isMultiDistinct_) {
+ if (!isMultiDistinct) {
numDistinctParams = distinctAggExprs.get(0).getChildren().size();
// If we are counting distinct params of group_concat, we cannot include the custom
// separator since it is not a distinct param.
@@ -638,20 +644,20 @@ private void createSecondPhaseAggSMap(
// original grouping exprs -> first m slots
for (int i = 0; i < numOrigGroupingExprs; ++i, ++slotIdx) {
Expr groupingExpr = inputAggInfo.getGroupingExprs().get(i);
- outputTupleSmap_.put(
+ outputTupleSmap.put(
groupingExpr.clone(), new SlotRef(slotDescs.get(slotIdx)));
}
// distinct agg exprs -> next n slots
for (int i = 0; i < distinctAggExprs.size(); ++i, ++slotIdx) {
Expr aggExpr = distinctAggExprs.get(i);
- outputTupleSmap_.put(aggExpr.clone(), (new SlotRef(slotDescs.get(slotIdx))));
+ outputTupleSmap.put(aggExpr.clone(), (new SlotRef(slotDescs.get(slotIdx))));
}
// remaining agg exprs -> remaining slots
for (int i = 0; i < inputAggInfo.getAggregateExprs().size(); ++i, ++slotIdx) {
Expr aggExpr = inputAggInfo.getAggregateExprs().get(i);
- outputTupleSmap_.put(aggExpr.clone(), new SlotRef(slotDescs.get(slotIdx)));
+ outputTupleSmap.put(aggExpr.clone(), new SlotRef(slotDescs.get(slotIdx)));
}
}
@@ -662,40 +668,44 @@ private void createSecondPhaseAggSMap(
* predicates between the grouping slots of the two tuples.
*/
public void createSmaps(Analyzer analyzer) {
- Preconditions.checkNotNull(outputTupleDesc_);
- Preconditions.checkNotNull(intermediateTupleDesc_);
+ Preconditions.checkNotNull(outputTupleDesc);
+ Preconditions.checkNotNull(intermediateTupleDesc);
List exprs = Lists.newArrayListWithCapacity(
- groupingExprs_.size() + aggregateExprs_.size());
- exprs.addAll(groupingExprs_);
- exprs.addAll(aggregateExprs_);
+ groupingExprs.size() + aggregateExprs.size());
+ exprs.addAll(groupingExprs);
+ exprs.addAll(aggregateExprs);
for (int i = 0; i < exprs.size(); ++i) {
Expr expr = exprs.get(i);
if (expr.isImplicitCast()) {
- outputTupleSmap_.put(expr.getChild(0).clone(),
- new SlotRef(outputTupleDesc_.getSlots().get(i)));
+ outputTupleSmap.put(expr.getChild(0).clone(),
+ new SlotRef(outputTupleDesc.getSlots().get(i)));
} else {
- outputTupleSmap_.put(expr.clone(),
- new SlotRef(outputTupleDesc_.getSlots().get(i)));
+ outputTupleSmap.put(expr.clone(),
+ new SlotRef(outputTupleDesc.getSlots().get(i)));
+ }
+ if (!requiresIntermediateTuple()) {
+ continue;
}
- if (!requiresIntermediateTuple()) continue;
-
- intermediateTupleSmap_.put(expr.clone(),
- new SlotRef(intermediateTupleDesc_.getSlots().get(i)));
- outputToIntermediateTupleSmap_.put(
- new SlotRef(outputTupleDesc_.getSlots().get(i)),
- new SlotRef(intermediateTupleDesc_.getSlots().get(i)));
- if (i < groupingExprs_.size()) {
+
+ intermediateTupleSmap.put(expr.clone(),
+ new SlotRef(intermediateTupleDesc.getSlots().get(i)));
+ outputToIntermediateTupleSmap.put(
+ new SlotRef(outputTupleDesc.getSlots().get(i)),
+ new SlotRef(intermediateTupleDesc.getSlots().get(i)));
+ if (i < groupingExprs.size()) {
analyzer.createAuxEquivPredicate(
- new SlotRef(outputTupleDesc_.getSlots().get(i)),
- new SlotRef(intermediateTupleDesc_.getSlots().get(i)));
+ new SlotRef(outputTupleDesc.getSlots().get(i)),
+ new SlotRef(intermediateTupleDesc.getSlots().get(i)));
}
}
- if (!requiresIntermediateTuple()) intermediateTupleSmap_ = outputTupleSmap_;
+ if (!requiresIntermediateTuple()) {
+ intermediateTupleSmap = outputTupleSmap;
+ }
if (LOG.isTraceEnabled()) {
- LOG.trace("output smap=" + outputTupleSmap_.debugString());
- LOG.trace("intermediate smap=" + intermediateTupleSmap_.debugString());
+ LOG.trace("output smap=" + outputTupleSmap.debugString());
+ LOG.trace("intermediate smap=" + intermediateTupleSmap.debugString());
}
}
@@ -712,7 +722,7 @@ public void createSmaps(Analyzer analyzer) {
* - Currently only the sum function will involve this problem.
*/
public void updateTypeOfAggregateExprs() {
- for (FunctionCallExpr functionCallExpr : aggregateExprs_) {
+ for (FunctionCallExpr functionCallExpr : aggregateExprs) {
if (!functionCallExpr.getFnName().getFunction().equalsIgnoreCase("sum")) {
continue;
}
@@ -744,43 +754,45 @@ public void updateTypeOfAggregateExprs() {
*/
@Override
public void materializeRequiredSlots(Analyzer analyzer, ExprSubstitutionMap smap) {
- for (int i = 0; i < groupingExprs_.size(); ++i) {
- outputTupleDesc_.getSlots().get(i).setIsMaterialized(true);
- intermediateTupleDesc_.getSlots().get(i).setIsMaterialized(true);
+ for (int i = 0; i < groupingExprs.size(); ++i) {
+ outputTupleDesc.getSlots().get(i).setIsMaterialized(true);
+ intermediateTupleDesc.getSlots().get(i).setIsMaterialized(true);
}
// collect input exprs: grouping exprs plus aggregate exprs that need to be
// materialized
- materializedSlots_.clear();
+ materializedSlots.clear();
List exprs = Lists.newArrayList();
- exprs.addAll(groupingExprs_);
+ exprs.addAll(groupingExprs);
- int aggregateExprsSize = aggregateExprs_.size();
- int groupExprsSize = groupingExprs_.size();
+ int aggregateExprsSize = aggregateExprs.size();
+ int groupExprsSize = groupingExprs.size();
boolean isDistinctAgg = isDistinctAgg();
for (int i = 0; i < aggregateExprsSize; ++i) {
- FunctionCallExpr functionCallExpr = aggregateExprs_.get(i);
+ FunctionCallExpr functionCallExpr = aggregateExprs.get(i);
SlotDescriptor slotDesc =
- outputTupleDesc_.getSlots().get(groupExprsSize + i);
+ outputTupleDesc.getSlots().get(groupExprsSize + i);
SlotDescriptor intermediateSlotDesc =
- intermediateTupleDesc_.getSlots().get(groupExprsSize + i);
- if (isDistinctAgg || isMultiDistinct_) {
+ intermediateTupleDesc.getSlots().get(groupExprsSize + i);
+ if (isDistinctAgg || isMultiDistinct) {
slotDesc.setIsMaterialized(true);
intermediateSlotDesc.setIsMaterialized(true);
}
- if (!slotDesc.isMaterialized()) continue;
+ if (!slotDesc.isMaterialized()) {
+ continue;
+ }
intermediateSlotDesc.setIsMaterialized(true);
exprs.add(functionCallExpr);
- materializedSlots_.add(i);
+ materializedSlots.add(i);
}
List resolvedExprs = Expr.substituteList(exprs, smap, analyzer, false);
analyzer.materializeSlots(resolvedExprs);
if (isDistinctAgg()) {
- secondPhaseDistinctAggInfo_.materializeRequiredSlots(analyzer, null);
+ secondPhaseDistinctAggInfo.materializeRequiredSlots(analyzer, null);
}
}
@@ -791,26 +803,26 @@ public void materializeRequiredSlots(Analyzer analyzer, ExprSubstitutionMap smap
* because we could derive both hash and order-based partitions
*/
public DataPartition getPartition() {
- if (groupingExprs_.isEmpty()) {
+ if (groupingExprs.isEmpty()) {
return DataPartition.UNPARTITIONED;
} else {
- return new DataPartition(TPartitionType.HASH_PARTITIONED, groupingExprs_);
+ return new DataPartition(TPartitionType.HASH_PARTITIONED, groupingExprs);
}
}
public String debugString() {
StringBuilder out = new StringBuilder(super.debugString());
out.append(MoreObjects.toStringHelper(this)
- .add("phase", aggPhase_)
- .add("intermediate_smap", intermediateTupleSmap_.debugString())
- .add("output_smap", outputTupleSmap_.debugString())
+ .add("phase", aggPhase)
+ .add("intermediate_smap", intermediateTupleSmap.debugString())
+ .add("output_smap", outputTupleSmap.debugString())
.toString());
- if (mergeAggInfo_ != this && mergeAggInfo_ != null) {
- out.append("\nmergeAggInfo:\n" + mergeAggInfo_.debugString());
+ if (mergeAggInfo != this && mergeAggInfo != null) {
+ out.append("\nmergeAggInfo:\n" + mergeAggInfo.debugString());
}
- if (secondPhaseDistinctAggInfo_ != null) {
+ if (secondPhaseDistinctAggInfo != null) {
out.append("\nsecondPhaseDistinctAggInfo:\n"
- + secondPhaseDistinctAggInfo_.debugString());
+ + secondPhaseDistinctAggInfo.debugString());
}
return out.toString();
}
@@ -826,6 +838,6 @@ public AggregateInfo clone() {
}
public List getInputPartitionExprs() {
- return partitionExprs_ != null ? partitionExprs_ : groupingExprs_;
+ return partitionExprs != null ? partitionExprs : groupingExprs;
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfoBase.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfoBase.java
index 9961931b299def..7fa14b758d0e6b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfoBase.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfoBase.java
@@ -43,12 +43,12 @@ public abstract class AggregateInfoBase {
// For aggregations: All unique grouping expressions from a select block.
// For analytics: Empty.
- protected ArrayList groupingExprs_;
+ protected ArrayList groupingExprs;
// For aggregations: All unique aggregate expressions from a select block.
// For analytics: The results of AnalyticExpr.getFnCall() for the unique
// AnalyticExprs of a select block.
- protected ArrayList aggregateExprs_;
+ protected ArrayList aggregateExprs;
// The tuple into which the intermediate output of an aggregation is materialized.
// Contains groupingExprs.size() + aggregateExprs.size() slots, the first of which
@@ -57,28 +57,28 @@ public abstract class AggregateInfoBase {
// of the aggregate functions' intermediate types.
// Identical to outputTupleDesc_ if no aggregateExpr has an output type that is
// different from its intermediate type.
- protected TupleDescriptor intermediateTupleDesc_;
+ protected TupleDescriptor intermediateTupleDesc;
// The tuple into which the final output of the aggregation is materialized.
// Contains groupingExprs.size() + aggregateExprs.size() slots, the first of which
// contain the values of the grouping exprs, followed by slots into which the
// aggregateExprs' finalize() symbol write its result, i.e., slots of the aggregate
// functions' output types.
- protected TupleDescriptor outputTupleDesc_;
+ protected TupleDescriptor outputTupleDesc;
// For aggregation: indices into aggregate exprs for that need to be materialized
// For analytics: indices into the analytic exprs and their corresponding aggregate
// exprs that need to be materialized.
// Populated in materializeRequiredSlots() which must be implemented by subclasses.
- protected ArrayList materializedSlots_ = Lists.newArrayList();
+ protected ArrayList materializedSlots = Lists.newArrayList();
protected AggregateInfoBase(ArrayList groupingExprs,
ArrayList aggExprs) {
Preconditions.checkState(groupingExprs != null || aggExprs != null);
- groupingExprs_ =
+ this.groupingExprs =
groupingExprs != null ? Expr.cloneList(groupingExprs) : new ArrayList();
Preconditions.checkState(aggExprs != null || !(this instanceof AnalyticInfo));
- aggregateExprs_ =
+ aggregateExprs =
aggExprs != null ? Expr.cloneList(aggExprs) : new ArrayList();
}
@@ -86,13 +86,13 @@ protected AggregateInfoBase(ArrayList groupingExprs,
* C'tor for cloning.
*/
protected AggregateInfoBase(AggregateInfoBase other) {
- groupingExprs_ =
- (other.groupingExprs_ != null) ? Expr.cloneList(other.groupingExprs_) : null;
- aggregateExprs_ =
- (other.aggregateExprs_ != null) ? Expr.cloneList(other.aggregateExprs_) : null;
- intermediateTupleDesc_ = other.intermediateTupleDesc_;
- outputTupleDesc_ = other.outputTupleDesc_;
- materializedSlots_ = Lists.newArrayList(other.materializedSlots_);
+ groupingExprs =
+ (other.groupingExprs != null) ? Expr.cloneList(other.groupingExprs) : null;
+ aggregateExprs =
+ (other.aggregateExprs != null) ? Expr.cloneList(other.aggregateExprs) : null;
+ intermediateTupleDesc = other.intermediateTupleDesc;
+ outputTupleDesc = other.outputTupleDesc;
+ materializedSlots = Lists.newArrayList(other.materializedSlots);
}
/**
@@ -103,11 +103,11 @@ protected AggregateInfoBase(AggregateInfoBase other) {
protected void createTupleDescs(Analyzer analyzer) {
// Create the intermediate tuple desc first, so that the tuple ids are increasing
// from bottom to top in the plan tree.
- intermediateTupleDesc_ = createTupleDesc(analyzer, false);
- if (requiresIntermediateTuple(aggregateExprs_, groupingExprs_.size() == 0)) {
- outputTupleDesc_ = createTupleDesc(analyzer, true);
+ intermediateTupleDesc = createTupleDesc(analyzer, false);
+ if (requiresIntermediateTuple(aggregateExprs, groupingExprs.size() == 0)) {
+ outputTupleDesc = createTupleDesc(analyzer, true);
} else {
- outputTupleDesc_ = intermediateTupleDesc_;
+ outputTupleDesc = intermediateTupleDesc;
}
}
@@ -122,15 +122,15 @@ private TupleDescriptor createTupleDesc(Analyzer analyzer, boolean isOutputTuple
analyzer.getDescTbl().createTupleDescriptor(
tupleDebugName() + (isOutputTuple ? "-out" : "-intermed"));
List exprs = Lists.newArrayListWithCapacity(
- groupingExprs_.size() + aggregateExprs_.size());
- exprs.addAll(groupingExprs_);
- exprs.addAll(aggregateExprs_);
+ groupingExprs.size() + aggregateExprs.size());
+ exprs.addAll(groupingExprs);
+ exprs.addAll(aggregateExprs);
- int aggregateExprStartIndex = groupingExprs_.size();
+ int aggregateExprStartIndex = groupingExprs.size();
// if agg is grouping set, so we should set all groupingExpr unless last groupingExpr
// must set be be nullable
- boolean isGroupingSet = !groupingExprs_.isEmpty() &&
- groupingExprs_.get(groupingExprs_.size() - 1) instanceof VirtualSlotRef;
+ boolean isGroupingSet = !groupingExprs.isEmpty() &&
+ groupingExprs.get(groupingExprs.size() - 1) instanceof VirtualSlotRef;
for (int i = 0; i < exprs.size(); ++i) {
Expr expr = exprs.get(i);
@@ -160,7 +160,7 @@ private TupleDescriptor createTupleDesc(Analyzer analyzer, boolean isOutputTuple
}
if (isOutputTuple && aggExpr.getFn().getNullableMode().equals(Function.NullableMode.DEPEND_ON_ARGUMENT) &&
- groupingExprs_.size() == 0) {
+ groupingExprs.size() == 0) {
slotDesc.setIsNullable(true);
}
@@ -193,16 +193,16 @@ private TupleDescriptor createTupleDesc(Analyzer analyzer, boolean isOutputTuple
public abstract void materializeRequiredSlots(Analyzer analyzer,
ExprSubstitutionMap smap);
- public ArrayList getGroupingExprs() { return groupingExprs_; }
- public ArrayList getAggregateExprs() { return aggregateExprs_; }
- public TupleDescriptor getOutputTupleDesc() { return outputTupleDesc_; }
- public TupleDescriptor getIntermediateTupleDesc() { return intermediateTupleDesc_; }
- public TupleId getIntermediateTupleId() { return intermediateTupleDesc_.getId(); }
- public TupleId getOutputTupleId() { return outputTupleDesc_.getId(); }
+ public ArrayList getGroupingExprs() { return groupingExprs; }
+ public ArrayList getAggregateExprs() { return aggregateExprs; }
+ public TupleDescriptor getOutputTupleDesc() { return outputTupleDesc; }
+ public TupleDescriptor getIntermediateTupleDesc() { return intermediateTupleDesc; }
+ public TupleId getIntermediateTupleId() { return intermediateTupleDesc.getId(); }
+ public TupleId getOutputTupleId() { return outputTupleDesc.getId(); }
public boolean requiresIntermediateTuple() {
- Preconditions.checkNotNull(intermediateTupleDesc_);
- Preconditions.checkNotNull(outputTupleDesc_);
- return intermediateTupleDesc_ != outputTupleDesc_;
+ Preconditions.checkNotNull(intermediateTupleDesc);
+ Preconditions.checkNotNull(outputTupleDesc);
+ return intermediateTupleDesc != outputTupleDesc;
}
/**
@@ -213,7 +213,9 @@ public boolean requiresIntermediateTuple() {
public static boolean requiresIntermediateTuple(List aggExprs) {
for (Expr aggExpr: aggExprs) {
Type intermediateType = ((AggregateFunction) aggExpr.fn).getIntermediateType();
- if (intermediateType != null) return true;
+ if (intermediateType != null) {
+ return true;
+ }
}
return false;
}
@@ -225,7 +227,9 @@ public static boolean requiresIntermediateTuple(List aggExpr
public static boolean requiresIntermediateTuple(List aggExprs, boolean noGrouping) {
for (Expr aggExpr: aggExprs) {
Type intermediateType = ((AggregateFunction) aggExpr.fn).getIntermediateType();
- if (intermediateType != null) return true;
+ if (intermediateType != null) {
+ return true;
+ }
if (noGrouping && ((AggregateFunction) aggExpr.fn).getNullableMode().equals(Function.NullableMode.DEPEND_ON_ARGUMENT)) {
return true;
}
@@ -236,12 +240,12 @@ public static boolean requiresIntermediateTuple(List aggExpr
public String debugString() {
StringBuilder out = new StringBuilder();
out.append(MoreObjects.toStringHelper(this)
- .add("grouping_exprs", Expr.debugString(groupingExprs_))
- .add("aggregate_exprs", Expr.debugString(aggregateExprs_))
- .add("intermediate_tuple", (intermediateTupleDesc_ == null)
- ? "null" : intermediateTupleDesc_.debugString())
- .add("output_tuple", (outputTupleDesc_ == null)
- ? "null" : outputTupleDesc_.debugString())
+ .add("grouping_exprs", Expr.debugString(groupingExprs))
+ .add("aggregate_exprs", Expr.debugString(aggregateExprs))
+ .add("intermediate_tuple", (intermediateTupleDesc == null)
+ ? "null" : intermediateTupleDesc.debugString())
+ .add("output_tuple", (outputTupleDesc == null)
+ ? "null" : outputTupleDesc.debugString())
.toString());
return out.toString();
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
index 5279ba2b1f37fc..bb3cf7730fc3a5 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
@@ -41,6 +41,7 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
/**
* Representation of an analytic function call with OVER clause.
@@ -142,6 +143,11 @@ public AnalyticWindow getWindow() {
return window;
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), fnCall, orderByElements, window);
+ }
+
@Override
public boolean equals(Object obj) {
if (!super.equals(obj)) {
@@ -868,8 +874,9 @@ public String toDigestImpl() {
}
private String exprListToSql(List extends Expr> exprs) {
- if (exprs == null || exprs.isEmpty())
+ if (exprs == null || exprs.isEmpty()) {
return "";
+ }
List strings = Lists.newArrayList();
for (Expr expr : exprs) {
strings.add(expr.toSql());
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticInfo.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticInfo.java
index 4e84643917d1a9..0b3cf4f1bc6b7e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticInfo.java
@@ -41,23 +41,23 @@ public final class AnalyticInfo extends AggregateInfoBase {
// All unique analytic exprs of a select block. Used to populate
// super.aggregateExprs_ based on AnalyticExpr.getFnCall() for each analytic expr
// in this list.
- private final ArrayList analyticExprs_;
+ private final ArrayList analyticExprs;
// Intersection of the partition exps of all the analytic functions.
- private final List commonPartitionExprs_;
+ private final List commonPartitionExprs;
// map from analyticExprs_ to their corresponding analytic tuple slotrefs
- private final ExprSubstitutionMap analyticTupleSmap_;
+ private final ExprSubstitutionMap analyticTupleSmap;
private AnalyticInfo(ArrayList analyticExprs) {
super(new ArrayList(), new ArrayList());
- analyticExprs_ = Expr.cloneList(analyticExprs);
+ this.analyticExprs = Expr.cloneList(analyticExprs);
// Extract the analytic function calls for each analytic expr.
for (Expr analyticExpr: analyticExprs) {
- aggregateExprs_.add(((AnalyticExpr) analyticExpr).getFnCall());
+ aggregateExprs.add(((AnalyticExpr) analyticExpr).getFnCall());
}
- analyticTupleSmap_ = new ExprSubstitutionMap();
- commonPartitionExprs_ = computeCommonPartitionExprs();
+ analyticTupleSmap = new ExprSubstitutionMap();
+ commonPartitionExprs = computeCommonPartitionExprs();
}
/**
@@ -65,15 +65,15 @@ private AnalyticInfo(ArrayList analyticExprs) {
*/
private AnalyticInfo(AnalyticInfo other) {
super(other);
- analyticExprs_ =
- (other.analyticExprs_ != null) ? Expr.cloneList(other.analyticExprs_) : null;
- analyticTupleSmap_ = other.analyticTupleSmap_.clone();
- commonPartitionExprs_ = Expr.cloneList(other.commonPartitionExprs_);
+ analyticExprs =
+ (other.analyticExprs != null) ? Expr.cloneList(other.analyticExprs) : null;
+ analyticTupleSmap = other.analyticTupleSmap.clone();
+ commonPartitionExprs = Expr.cloneList(other.commonPartitionExprs);
}
- public ArrayList getAnalyticExprs() { return analyticExprs_; }
- public ExprSubstitutionMap getSmap() { return analyticTupleSmap_; }
- public List getCommonPartitionExprs() { return commonPartitionExprs_; }
+ public ArrayList getAnalyticExprs() { return analyticExprs; }
+ public ExprSubstitutionMap getSmap() { return analyticTupleSmap; }
+ public List getCommonPartitionExprs() { return commonPartitionExprs; }
/**
* Creates complete AnalyticInfo for analyticExprs, including tuple descriptors and
@@ -88,20 +88,20 @@ static public AnalyticInfo create(
// The tuple descriptors are logical. Their slots are remapped to physical tuples
// during plan generation.
- result.outputTupleDesc_.setIsMaterialized(false);
- result.intermediateTupleDesc_.setIsMaterialized(false);
+ result.outputTupleDesc.setIsMaterialized(false);
+ result.intermediateTupleDesc.setIsMaterialized(false);
// Populate analyticTupleSmap_
- Preconditions.checkState(analyticExprs.size() == result.outputTupleDesc_.getSlots().size());
+ Preconditions.checkState(analyticExprs.size() == result.outputTupleDesc.getSlots().size());
for (int i = 0; i < analyticExprs.size(); ++i) {
- result.analyticTupleSmap_.put(result.analyticExprs_.get(i),
- new SlotRef(result.outputTupleDesc_.getSlots().get(i)));
- result.outputTupleDesc_.getSlots().get(i).setSourceExpr(result.analyticExprs_.get(i));
+ result.analyticTupleSmap.put(result.analyticExprs.get(i),
+ new SlotRef(result.outputTupleDesc.getSlots().get(i)));
+ result.outputTupleDesc.getSlots().get(i).setSourceExpr(result.analyticExprs.get(i));
}
if (LOG.isDebugEnabled()) {
- LOG.debug("analytictuple=" + result.outputTupleDesc_.debugString());
- LOG.debug("analytictuplesmap=" + result.analyticTupleSmap_.debugString());
+ LOG.debug("analytictuple=" + result.outputTupleDesc.debugString());
+ LOG.debug("analytictuplesmap=" + result.analyticTupleSmap.debugString());
LOG.debug("analytic info:\n" + result.debugString());
}
return result;
@@ -113,15 +113,19 @@ static public AnalyticInfo create(
*/
private List computeCommonPartitionExprs() {
List result = Lists.newArrayList();
- for (Expr analyticExpr: analyticExprs_) {
+ for (Expr analyticExpr: analyticExprs) {
Preconditions.checkState(analyticExpr.isAnalyzed());
List partitionExprs = ((AnalyticExpr) analyticExpr).getPartitionExprs();
- if (partitionExprs == null) continue;
+ if (partitionExprs == null) {
+ continue;
+ }
if (result.isEmpty()) {
result.addAll(partitionExprs);
} else {
result.retainAll(partitionExprs);
- if (result.isEmpty()) break;
+ if (result.isEmpty()) {
+ break;
+ }
}
}
return result;
@@ -129,14 +133,16 @@ private List computeCommonPartitionExprs() {
@Override
public void materializeRequiredSlots(Analyzer analyzer, ExprSubstitutionMap smap) {
- materializedSlots_.clear();
+ materializedSlots.clear();
List exprs = Lists.newArrayList();
- for (int i = 0; i < analyticExprs_.size(); ++i) {
- SlotDescriptor outputSlotDesc = outputTupleDesc_.getSlots().get(i);
- if (!outputSlotDesc.isMaterialized()) continue;
- intermediateTupleDesc_.getSlots().get(i).setIsMaterialized(true);
- exprs.add(analyticExprs_.get(i));
- materializedSlots_.add(i);
+ for (int i = 0; i < analyticExprs.size(); ++i) {
+ SlotDescriptor outputSlotDesc = outputTupleDesc.getSlots().get(i);
+ if (!outputSlotDesc.isMaterialized()) {
+ continue;
+ }
+ intermediateTupleDesc.getSlots().get(i).setIsMaterialized(true);
+ exprs.add(analyticExprs.get(i));
+ materializedSlots.add(i);
}
List resolvedExprs = Expr.substituteList(exprs, smap, analyzer, false);
analyzer.materializeSlots(resolvedExprs);
@@ -149,20 +155,22 @@ public void materializeRequiredSlots(Analyzer analyzer, ExprSubstitutionMap smap
* analytic tuple.
*/
public void checkConsistency() {
- ArrayList slots = intermediateTupleDesc_.getSlots();
+ ArrayList slots = intermediateTupleDesc.getSlots();
// Check materialized slots.
int numMaterializedSlots = 0;
for (SlotDescriptor slotDesc: slots) {
- if (slotDesc.isMaterialized()) ++numMaterializedSlots;
+ if (slotDesc.isMaterialized()) {
+ ++numMaterializedSlots;
+ }
}
Preconditions.checkState(numMaterializedSlots ==
- materializedSlots_.size());
+ materializedSlots.size());
// Check that analytic expr return types match the slot descriptors.
int slotIdx = 0;
- for (int i = 0; i < analyticExprs_.size(); ++i) {
- Expr analyticExpr = analyticExprs_.get(i);
+ for (int i = 0; i < analyticExprs.size(); ++i) {
+ Expr analyticExpr = analyticExprs.get(i);
Type slotType = slots.get(slotIdx).getType();
Preconditions.checkState(analyticExpr.getType().equals(slotType),
String.format("Analytic expr %s returns type %s but its analytic tuple " +
@@ -176,8 +184,8 @@ public void checkConsistency() {
public String debugString() {
StringBuilder out = new StringBuilder(super.debugString());
out.append(MoreObjects.toStringHelper(this)
- .add("analytic_exprs", Expr.debugString(analyticExprs_))
- .add("smap", analyticTupleSmap_.debugString())
+ .add("analytic_exprs", Expr.debugString(analyticExprs))
+ .add("smap", analyticTupleSmap.debugString())
.toString());
return out.toString();
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticWindow.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticWindow.java
index b148a45960aa9c..53265089b4be6c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticWindow.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticWindow.java
@@ -29,6 +29,7 @@
import com.google.common.base.Preconditions;
import java.math.BigDecimal;
+import java.util.Objects;
/**
* Windowing clause of an analytic expr
@@ -44,15 +45,15 @@ enum Type {
ROWS("ROWS"),
RANGE("RANGE");
- private final String description_;
+ private final String description;
private Type(String d) {
- description_ = d;
+ description = d;
}
@Override
public String toString() {
- return description_;
+ return description;
}
public TAnalyticWindowType toThrift() {
return this == ROWS ? TAnalyticWindowType.ROWS : TAnalyticWindowType.RANGE;
@@ -190,6 +191,11 @@ public TAnalyticWindowBoundary toThrift(Type windowType) {
return result;
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(type, expr);
+ }
+
@Override
public boolean equals(Object obj) {
if (obj == null) {
@@ -229,80 +235,80 @@ public void analyze(Analyzer analyzer) throws AnalysisException {
}
}
- private final Type type_;
- private final Boundary leftBoundary_;
- private Boundary rightBoundary_; // may be null before analyze()
- private String toSqlString_; // cached after analysis
+ private final Type type;
+ private final Boundary leftBoundary;
+ private Boundary rightBoundary; // may be null before analyze()
+ private String toSqlString; // cached after analysis
public Type getType() {
- return type_;
+ return type;
}
public Boundary getLeftBoundary() {
- return leftBoundary_;
+ return leftBoundary;
}
public Boundary getRightBoundary() {
- return rightBoundary_;
+ return rightBoundary;
}
public Boundary setRightBoundary(Boundary b) {
- return rightBoundary_ = b;
+ return rightBoundary = b;
}
public AnalyticWindow(Type type, Boundary b) {
- type_ = type;
+ this.type = type;
Preconditions.checkNotNull(b);
- leftBoundary_ = b;
- rightBoundary_ = null;
+ leftBoundary = b;
+ rightBoundary = null;
}
public AnalyticWindow(Type type, Boundary l, Boundary r) {
- type_ = type;
+ this.type = type;
Preconditions.checkNotNull(l);
- leftBoundary_ = l;
+ leftBoundary = l;
Preconditions.checkNotNull(r);
- rightBoundary_ = r;
+ rightBoundary = r;
}
/**
* Clone c'tor
*/
private AnalyticWindow(AnalyticWindow other) {
- type_ = other.type_;
- Preconditions.checkNotNull(other.leftBoundary_);
- leftBoundary_ = other.leftBoundary_.clone();
+ type = other.type;
+ Preconditions.checkNotNull(other.leftBoundary);
+ leftBoundary = other.leftBoundary.clone();
- if (other.rightBoundary_ != null) {
- rightBoundary_ = other.rightBoundary_.clone();
+ if (other.rightBoundary != null) {
+ rightBoundary = other.rightBoundary.clone();
}
- toSqlString_ = other.toSqlString_; // safe to share
+ toSqlString = other.toSqlString; // safe to share
}
public AnalyticWindow reverse() {
- Boundary newRightBoundary = leftBoundary_.converse();
+ Boundary newRightBoundary = leftBoundary.converse();
Boundary newLeftBoundary = null;
- if (rightBoundary_ == null) {
- newLeftBoundary = new Boundary(leftBoundary_.getType(), null);
+ if (rightBoundary == null) {
+ newLeftBoundary = new Boundary(leftBoundary.getType(), null);
} else {
- newLeftBoundary = rightBoundary_.converse();
+ newLeftBoundary = rightBoundary.converse();
}
- return new AnalyticWindow(type_, newLeftBoundary, newRightBoundary);
+ return new AnalyticWindow(type, newLeftBoundary, newRightBoundary);
}
public String toSql() {
- if (toSqlString_ != null) {
- return toSqlString_;
+ if (toSqlString != null) {
+ return toSqlString;
}
StringBuilder sb = new StringBuilder();
- sb.append(type_.toString()).append(" ");
+ sb.append(type.toString()).append(" ");
- if (rightBoundary_ == null) {
- sb.append(leftBoundary_.toSql());
+ if (rightBoundary == null) {
+ sb.append(leftBoundary.toSql());
} else {
- sb.append("BETWEEN ").append(leftBoundary_.toSql()).append(" AND ");
- sb.append(rightBoundary_.toSql());
+ sb.append("BETWEEN ").append(leftBoundary.toSql()).append(" AND ");
+ sb.append(rightBoundary.toSql());
}
return sb.toString();
@@ -310,13 +316,13 @@ public String toSql() {
public String toDigest() {
StringBuilder sb = new StringBuilder();
- sb.append(type_.toString()).append(" ");
+ sb.append(type.toString()).append(" ");
- if (rightBoundary_ == null) {
- sb.append(leftBoundary_.toDigest());
+ if (rightBoundary == null) {
+ sb.append(leftBoundary.toDigest());
} else {
- sb.append("BETWEEN ").append(leftBoundary_.toDigest()).append(" AND ");
- sb.append(rightBoundary_.toDigest());
+ sb.append("BETWEEN ").append(leftBoundary.toDigest()).append(" AND ");
+ sb.append(rightBoundary.toDigest());
}
return sb.toString();
@@ -324,21 +330,26 @@ public String toDigest() {
public TAnalyticWindow toThrift() {
- TAnalyticWindow result = new TAnalyticWindow(type_.toThrift());
+ TAnalyticWindow result = new TAnalyticWindow(type.toThrift());
- if (leftBoundary_.getType() != BoundaryType.UNBOUNDED_PRECEDING) {
- result.setWindowStart(leftBoundary_.toThrift(type_));
+ if (leftBoundary.getType() != BoundaryType.UNBOUNDED_PRECEDING) {
+ result.setWindowStart(leftBoundary.toThrift(type));
}
- Preconditions.checkNotNull(rightBoundary_);
+ Preconditions.checkNotNull(rightBoundary);
- if (rightBoundary_.getType() != BoundaryType.UNBOUNDED_FOLLOWING) {
- result.setWindowEnd(rightBoundary_.toThrift(type_));
+ if (rightBoundary.getType() != BoundaryType.UNBOUNDED_FOLLOWING) {
+ result.setWindowEnd(rightBoundary.toThrift(type));
}
return result;
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(type, leftBoundary, rightBoundary);
+ }
+
@Override
public boolean equals(Object obj) {
if (obj == null) {
@@ -351,14 +362,14 @@ public boolean equals(Object obj) {
AnalyticWindow o = (AnalyticWindow)obj;
boolean rightBoundaryEqual =
- (rightBoundary_ == null) == (o.rightBoundary_ == null);
+ (rightBoundary == null) == (o.rightBoundary == null);
- if (rightBoundaryEqual && rightBoundary_ != null) {
- rightBoundaryEqual = rightBoundary_.equals(o.rightBoundary_);
+ if (rightBoundaryEqual && rightBoundary != null) {
+ rightBoundaryEqual = rightBoundary.equals(o.rightBoundary);
}
- return type_ == o.type_
- && leftBoundary_.equals(o.leftBoundary_)
+ return type == o.type
+ && leftBoundary.equals(o.leftBoundary)
&& rightBoundaryEqual;
}
@@ -393,7 +404,7 @@ private void checkOffsetExpr(Analyzer analyzer, Boundary boundary)
}
}
- if (type_ == Type.ROWS) {
+ if (type == Type.ROWS) {
if (!e.isConstant() || !e.getType().isFixedPointType() || !isPos) {
throw new AnalysisException(
"For ROWS window, the value of a PRECEDING/FOLLOWING offset must be a "
@@ -445,84 +456,84 @@ private void checkOffsetBoundaries(Analyzer analyzer, Boundary b1, Boundary b2)
}
public void analyze(Analyzer analyzer) throws AnalysisException {
- leftBoundary_.analyze(analyzer);
+ leftBoundary.analyze(analyzer);
- if (rightBoundary_ != null) {
- rightBoundary_.analyze(analyzer);
+ if (rightBoundary != null) {
+ rightBoundary.analyze(analyzer);
}
- if (leftBoundary_.getType() == BoundaryType.UNBOUNDED_FOLLOWING) {
+ if (leftBoundary.getType() == BoundaryType.UNBOUNDED_FOLLOWING) {
throw new AnalysisException(
- leftBoundary_.getType().toString() + " is only allowed for upper bound of "
+ leftBoundary.getType().toString() + " is only allowed for upper bound of "
+ "BETWEEN");
}
- if (rightBoundary_ != null
- && rightBoundary_.getType() == BoundaryType.UNBOUNDED_PRECEDING) {
+ if (rightBoundary != null
+ && rightBoundary.getType() == BoundaryType.UNBOUNDED_PRECEDING) {
throw new AnalysisException(
- rightBoundary_.getType().toString() + " is only allowed for lower bound of "
+ rightBoundary.getType().toString() + " is only allowed for lower bound of "
+ "BETWEEN");
}
// TODO: Remove when RANGE windows with offset boundaries are supported.
- if (type_ == Type.RANGE) {
- if (leftBoundary_.type.isOffset()
- || (rightBoundary_ != null && rightBoundary_.type.isOffset())
- || (leftBoundary_.type == BoundaryType.CURRENT_ROW
- && (rightBoundary_ == null
- || rightBoundary_.type == BoundaryType.CURRENT_ROW))) {
+ if (type == Type.RANGE) {
+ if (leftBoundary.type.isOffset()
+ || (rightBoundary != null && rightBoundary.type.isOffset())
+ || (leftBoundary.type == BoundaryType.CURRENT_ROW
+ && (rightBoundary == null
+ || rightBoundary.type == BoundaryType.CURRENT_ROW))) {
throw new AnalysisException(
"RANGE is only supported with both the lower and upper bounds UNBOUNDED or"
+ " one UNBOUNDED and the other CURRENT ROW.");
}
}
- if (rightBoundary_ == null && leftBoundary_.getType() == BoundaryType.FOLLOWING) {
+ if (rightBoundary == null && leftBoundary.getType() == BoundaryType.FOLLOWING) {
throw new AnalysisException(
- leftBoundary_.getType().toString() + " requires a BETWEEN clause");
+ leftBoundary.getType().toString() + " requires a BETWEEN clause");
}
- if (leftBoundary_.getType().isOffset()) {
- checkOffsetExpr(analyzer, leftBoundary_);
+ if (leftBoundary.getType().isOffset()) {
+ checkOffsetExpr(analyzer, leftBoundary);
}
- if (rightBoundary_ == null) {
+ if (rightBoundary == null) {
// set right boundary to implied value, but make sure to cache toSql string
// beforehand
- toSqlString_ = toSql();
- rightBoundary_ = new Boundary(BoundaryType.CURRENT_ROW, null);
+ toSqlString = toSql();
+ rightBoundary = new Boundary(BoundaryType.CURRENT_ROW, null);
return;
}
- if (rightBoundary_.getType().isOffset()) {
- checkOffsetExpr(analyzer, rightBoundary_);
+ if (rightBoundary.getType().isOffset()) {
+ checkOffsetExpr(analyzer, rightBoundary);
}
- if (leftBoundary_.getType() == BoundaryType.FOLLOWING) {
- if (rightBoundary_.getType() != BoundaryType.FOLLOWING
- && rightBoundary_.getType() != BoundaryType.UNBOUNDED_FOLLOWING) {
+ if (leftBoundary.getType() == BoundaryType.FOLLOWING) {
+ if (rightBoundary.getType() != BoundaryType.FOLLOWING
+ && rightBoundary.getType() != BoundaryType.UNBOUNDED_FOLLOWING) {
throw new AnalysisException(
"A lower window bound of " + BoundaryType.FOLLOWING.toString()
+ " requires that the upper bound also be "
+ BoundaryType.FOLLOWING.toString());
}
- if (rightBoundary_.getType() != BoundaryType.UNBOUNDED_FOLLOWING) {
- checkOffsetBoundaries(analyzer, leftBoundary_, rightBoundary_);
+ if (rightBoundary.getType() != BoundaryType.UNBOUNDED_FOLLOWING) {
+ checkOffsetBoundaries(analyzer, leftBoundary, rightBoundary);
}
}
- if (rightBoundary_.getType() == BoundaryType.PRECEDING) {
- if (leftBoundary_.getType() != BoundaryType.PRECEDING
- && leftBoundary_.getType() != BoundaryType.UNBOUNDED_PRECEDING) {
+ if (rightBoundary.getType() == BoundaryType.PRECEDING) {
+ if (leftBoundary.getType() != BoundaryType.PRECEDING
+ && leftBoundary.getType() != BoundaryType.UNBOUNDED_PRECEDING) {
throw new AnalysisException(
"An upper window bound of " + BoundaryType.PRECEDING.toString()
+ " requires that the lower bound also be "
+ BoundaryType.PRECEDING.toString());
}
- if (leftBoundary_.getType() != BoundaryType.UNBOUNDED_PRECEDING) {
- checkOffsetBoundaries(analyzer, rightBoundary_, leftBoundary_);
+ if (leftBoundary.getType() != BoundaryType.UNBOUNDED_PRECEDING) {
+ checkOffsetBoundaries(analyzer, rightBoundary, leftBoundary);
}
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java
index a47e8a9b5e9b9d..0232f1178ff660 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java
@@ -102,7 +102,7 @@ public class Analyzer {
// NOTE: Alias of table is case sensitive
// UniqueAlias used to check whether the table ref or the alias is unique
// table/view used db.table, inline use alias
- private final Set uniqueTableAliasSet_ = Sets.newHashSet();
+ private final Set uniqueTableAliasSet = Sets.newHashSet();
private final Multimap tupleByAlias = ArrayListMultimap.create();
// NOTE: Alias of column is case ignorance
@@ -135,7 +135,7 @@ public class Analyzer {
private String schemaTable; // table used in DESCRIBE Table
// True if the corresponding select block has a limit and/or offset clause.
- private boolean hasLimitOffsetClause_ = false;
+ private boolean hasLimitOffsetClause = false;
// Current depth of nested analyze() calls. Used for enforcing a
// maximum expr-tree depth. Needs to be manually maintained by the user
@@ -146,7 +146,7 @@ public class Analyzer {
private boolean isSubquery = false;
// Flag indicating whether this analyzer belongs to a WITH clause view.
- private boolean isWithClause_ = false;
+ private boolean isWithClause = false;
// By default, all registered semi-joined tuples are invisible, i.e., their slots
// cannot be referenced. If set, this semi-joined tuple is made visible. Such a tuple
@@ -154,7 +154,7 @@ public class Analyzer {
// In particular, if there are multiple semi-joins in the same query block, then the
// On-clause of any such semi-join is not allowed to reference other semi-joined tuples
// except its own. Therefore, only a single semi-joined tuple can be visible at a time.
- private TupleId visibleSemiJoinedTupleId_ = null;
+ private TupleId visibleSemiJoinedTupleId = null;
// for some situation that udf is not allowed.
private boolean isUDFAllowed = true;
// timezone specified for some operation, such as broker load
@@ -169,8 +169,8 @@ public void setIsSubquery() {
}
public boolean setHasPlanHints() { return globalState.hasPlanHints = true; }
public boolean hasPlanHints() { return globalState.hasPlanHints; }
- public void setIsWithClause() { isWithClause_ = true; }
- public boolean isWithClause() { return isWithClause_; }
+ public void setIsWithClause() { isWithClause = true; }
+ public boolean isWithClause() { return isWithClause; }
public void setUDFAllowed(boolean val) { this.isUDFAllowed = val; }
public boolean isUDFAllowed() { return this.isUDFAllowed; }
@@ -294,7 +294,7 @@ private static class GlobalState {
public final Map blockBySlot = Maps.newHashMap();
// Expr rewriter for normalizing and rewriting expressions.
- private final ExprRewriter exprRewriter_;
+ private final ExprRewriter exprRewriter;
private final ExprRewriter mvExprRewriter;
@@ -322,7 +322,7 @@ public GlobalState(Catalog catalog, ConnectContext context) {
List onceRules = Lists.newArrayList();
onceRules.add(ExtractCommonFactorsRule.INSTANCE);
onceRules.add(InferFiltersRule.INSTANCE);
- exprRewriter_ = new ExprRewriter(rules, onceRules);
+ exprRewriter = new ExprRewriter(rules, onceRules);
// init mv rewriter
List mvRewriteRules = Lists.newArrayList();
mvRewriteRules.add(ToBitmapToSlotRefRule.INSTANCE);
@@ -362,29 +362,29 @@ public GlobalState(Catalog catalog, ConnectContext context) {
private final ArrayList ancestors;
// map from lowercase table alias to a view definition in this analyzer's scope
- private final Map localViews_ = Maps.newHashMap();
+ private final Map localViews = Maps.newHashMap();
// Map from lowercase table alias to descriptor. Tables without an explicit alias
// are assigned two implicit aliases: the unqualified and fully-qualified table name.
// Such tables have two entries pointing to the same descriptor. If an alias is
// ambiguous, then this map retains the first entry with that alias to simplify error
// checking (duplicate vs. ambiguous alias).
- private final Map aliasMap_ = Maps.newHashMap();
+ private final Map aliasMap = Maps.newHashMap();
// Map from tuple id to its corresponding table ref.
- private final Map tableRefMap_ = Maps.newHashMap();
+ private final Map tableRefMap = Maps.newHashMap();
// Set of lowercase ambiguous implicit table aliases.
- private final Set ambiguousAliases_ = Sets.newHashSet();
+ private final Set ambiguousAliases = Sets.newHashSet();
// Indicates whether this analyzer/block is guaranteed to have an empty result set
// due to a limit 0 or constant conjunct evaluating to false.
- private boolean hasEmptyResultSet_ = false;
+ private boolean hasEmptyResultSet = false;
// Indicates whether the select-project-join (spj) portion of this query block
// is guaranteed to return an empty result set. Set due to a constant non-Having
// conjunct evaluating to false.
- private boolean hasEmptySpjResultSet_ = false;
+ private boolean hasEmptySpjResultSet = false;
public Analyzer(Catalog catalog, ConnectContext context) {
ancestors = Lists.newArrayList();
@@ -454,7 +454,7 @@ public void registerLocalView(View view) throws AnalysisException {
"labels must be smaller or equal to the number of returned columns.");
}
}
- if (localViews_.put(view.getName(), view) != null) {
+ if (localViews.put(view.getName(), view) != null) {
throw new AnalysisException(
String.format("Duplicate table alias: '%s'", view.getName()));
}
@@ -498,10 +498,10 @@ public void substitute(ExprSubstitutionMap sMap) {
*/
public TupleDescriptor registerTableRef(TableRef ref) throws AnalysisException {
String uniqueAlias = ref.getUniqueAlias();
- if (uniqueTableAliasSet_.contains(uniqueAlias)) {
+ if (uniqueTableAliasSet.contains(uniqueAlias)) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_NONUNIQ_TABLE, uniqueAlias);
}
- uniqueTableAliasSet_.add(uniqueAlias);
+ uniqueTableAliasSet.add(uniqueAlias);
// If ref has no explicit alias, then the unqualified and the fully-qualified table
// names are legal implicit aliases. Column references against unqualified implicit
@@ -510,12 +510,12 @@ public TupleDescriptor registerTableRef(TableRef ref) throws AnalysisException {
String[] aliases = ref.getAliases();
if (aliases.length > 1) {
unqualifiedAlias = aliases[1];
- TupleDescriptor tupleDesc = aliasMap_.get(unqualifiedAlias);
+ TupleDescriptor tupleDesc = aliasMap.get(unqualifiedAlias);
if (tupleDesc != null) {
if (tupleDesc.hasExplicitAlias()) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_NONUNIQ_TABLE, uniqueAlias);
} else {
- ambiguousAliases_.add(unqualifiedAlias);
+ ambiguousAliases.add(unqualifiedAlias);
}
}
}
@@ -532,7 +532,7 @@ public TupleDescriptor registerTableRef(TableRef ref) throws AnalysisException {
tupleByAlias.put(alias, result);
}
- tableRefMap_.put(result.getId(), ref);
+ tableRefMap.put(result.getId(), ref);
return result;
}
@@ -553,11 +553,11 @@ public TupleDescriptor registerOlapTable(Table table, TableName tableName, List<
slot.setIsMaterialized(true);
slot.setColumn(col);
slot.setIsNullable(col.isAllowNull());
- String key = tableRef.aliases_[0] + "." + col.getName();
+ String key = tableRef.aliases[0] + "." + col.getName();
slotRefMap.put(key, slot);
}
globalState.descTbl.computeStatAndMemLayout();
- tableRefMap_.put(result.getId(), ref);
+ tableRefMap.put(result.getId(), ref);
for (String alias : tableRef.getAliases()) {
tupleByAlias.put(alias, result);
}
@@ -565,7 +565,7 @@ public TupleDescriptor registerOlapTable(Table table, TableName tableName, List<
}
public List getAllTupleIds() {
- return new ArrayList<>(tableRefMap_.keySet());
+ return new ArrayList<>(tableRefMap.keySet());
}
/**
@@ -581,7 +581,9 @@ public List getAllTupleIds() {
*/
public TableRef resolveTableRef(TableRef tableRef) throws AnalysisException {
// Return the table if it is already resolved.
- if (tableRef.isResolved()) return tableRef;
+ if (tableRef.isResolved()) {
+ return tableRef;
+ }
// Try to find a matching local view.
TableName tableName = tableRef.getName();
if (!tableName.isFullyQualified()) {
@@ -590,8 +592,10 @@ public TableRef resolveTableRef(TableRef tableRef) throws AnalysisException {
String viewAlias = tableName.getTbl();
Analyzer analyzer = this;
do {
- View localView = analyzer.localViews_.get(viewAlias);
- if (localView != null) return new InlineViewRef(localView, tableRef);
+ View localView = analyzer.localViews.get(viewAlias);
+ if (localView != null) {
+ return new InlineViewRef(localView, tableRef);
+ }
analyzer = (analyzer.ancestors.isEmpty() ? null : analyzer.ancestors.get(0));
} while (analyzer != null);
}
@@ -647,7 +651,7 @@ public Table getTableOrAnalysisException(TableName tblName) throws AnalysisExcep
}
public ExprRewriter getExprRewriter() {
- return globalState.exprRewriter_;
+ return globalState.exprRewriter;
}
public ExprRewriter getMVExprRewriter() {
@@ -853,7 +857,9 @@ public void registerFullOuterJoinedConjunct(Expr e) {
List tids = Lists.newArrayList();
e.getIds(tids, null);
for (TupleId tid: tids) {
- if (!globalState.fullOuterJoinedTupleIds.containsKey(tid)) continue;
+ if (!globalState.fullOuterJoinedTupleIds.containsKey(tid)) {
+ continue;
+ }
TableRef currentOuterJoin = globalState.fullOuterJoinedTupleIds.get(tid);
globalState.fullOuterJoinedConjuncts.put(e.getId(), currentOuterJoin);
break;
@@ -1170,7 +1176,9 @@ public void setAssignedConjuncts(Set assigned) {
public List getUnassignedConjuncts(List tupleIds) {
List result = Lists.newArrayList();
for (Expr e : getUnassignedConjuncts(tupleIds, true)) {
- if (canEvalPredicate(tupleIds, e)) result.add(e);
+ if (canEvalPredicate(tupleIds, e)) {
+ result.add(e);
+ }
}
return result;
}
@@ -1280,7 +1288,9 @@ public List getUnassignedOjConjuncts(TableRef ref) {
public boolean evalAfterJoin(Expr e) {
List tids = Lists.newArrayList();
e.getIds(tids, null);
- if (tids.isEmpty()) return false;
+ if (tids.isEmpty()) {
+ return false;
+ }
if (tids.size() > 1 || isOjConjunct(e) || isFullOuterJoined(e)
|| (isOuterJoined(tids.get(0))
&& (!e.isOnClauseConjunct() || isIjConjunct(e)))
@@ -1337,7 +1347,9 @@ public boolean isAntiJoinedConjunct(Expr e) {
public TableRef getAntiJoinRef(Expr e) {
TableRef tblRef = globalState.sjClauseByConjunct.get(e.getId());
- if (tblRef == null) return null;
+ if (tblRef == null) {
+ return null;
+ }
return (tblRef.getJoinOp().isAntiJoin()) ? tblRef : null;
}
@@ -1354,12 +1366,14 @@ public boolean isFullOuterJoined(SlotId sid) {
}
public boolean isVisible(TupleId tid) {
- return tid == visibleSemiJoinedTupleId_ || !isSemiJoined(tid);
+ return tid == visibleSemiJoinedTupleId || !isSemiJoined(tid);
}
public boolean containsOuterJoinedTid(List tids) {
for (TupleId tid: tids) {
- if (isOuterJoined(tid)) return true;
+ if (isOuterJoined(tid)) {
+ return true;
+ }
}
return false;
}
@@ -1373,7 +1387,7 @@ public Catalog getCatalog() {
}
public Set getAliases() {
- return uniqueTableAliasSet_;
+ return uniqueTableAliasSet;
}
public List getAllConjuncts(TupleId id) {
@@ -1455,8 +1469,8 @@ public Set getOnIsNullDeDuplication() {
public void setVisibleSemiJoinedTuple(TupleId tid) {
Preconditions.checkState(tid == null
|| globalState.semiJoinedTupleIds.containsKey(tid));
- Preconditions.checkState(tid == null || visibleSemiJoinedTupleId_ == null);
- visibleSemiJoinedTupleId_ = tid;
+ Preconditions.checkState(tid == null || visibleSemiJoinedTupleId == null);
+ visibleSemiJoinedTupleId = tid;
}
/**
@@ -1475,13 +1489,13 @@ public Analyzer getParentAnalyzer() {
* to return an empty result set, e.g., due to a limit 0 or a constant predicate
* that evaluates to false.
*/
- public boolean hasEmptyResultSet() { return hasEmptyResultSet_; }
- public void setHasEmptyResultSet() { hasEmptyResultSet_ = true; }
+ public boolean hasEmptyResultSet() { return hasEmptyResultSet; }
+ public void setHasEmptyResultSet() { hasEmptyResultSet = true; }
- public boolean hasEmptySpjResultSet() { return hasEmptySpjResultSet_; }
+ public boolean hasEmptySpjResultSet() { return hasEmptySpjResultSet; }
public void setHasLimitOffsetClause(boolean hasLimitOffset) {
- this.hasLimitOffsetClause_ = hasLimitOffset;
+ this.hasLimitOffsetClause = hasLimitOffset;
}
/**
@@ -1530,9 +1544,11 @@ public void registerOnClauseConjuncts(List conjuncts, TableRef rhsRef)
*/
private void markConstantConjunct(Expr conjunct, boolean fromHavingClause)
throws AnalysisException {
- if (!conjunct.isConstant() || isOjConjunct(conjunct)) return;
- if ((!fromHavingClause && !hasEmptySpjResultSet_)
- || (fromHavingClause && !hasEmptyResultSet_)) {
+ if (!conjunct.isConstant() || isOjConjunct(conjunct)) {
+ return;
+ }
+ if ((!fromHavingClause && !hasEmptySpjResultSet)
+ || (fromHavingClause && !hasEmptyResultSet)) {
try {
if (conjunct instanceof BetweenPredicate) {
// Rewrite the BetweenPredicate into a CompoundPredicate so we can evaluate it
@@ -1549,18 +1565,18 @@ private void markConstantConjunct(Expr conjunct, boolean fromHavingClause)
final BoolLiteral value = (BoolLiteral) newConjunct;
if (!value.getValue()) {
if (fromHavingClause) {
- hasEmptyResultSet_ = true;
+ hasEmptyResultSet = true;
} else {
- hasEmptySpjResultSet_ = true;
+ hasEmptySpjResultSet = true;
}
}
markConjunctAssigned(conjunct);
}
if (newConjunct instanceof NullLiteral) {
if (fromHavingClause) {
- hasEmptyResultSet_ = true;
+ hasEmptyResultSet = true;
} else {
- hasEmptySpjResultSet_ = true;
+ hasEmptySpjResultSet = true;
}
markConjunctAssigned(conjunct);
}
@@ -1600,7 +1616,9 @@ public TableRef getOjRef(Expr e) {
*/
public boolean canEvalOuterJoinedConjunct(Expr e, List tids) {
TableRef outerJoin = getOjRef(e);
- if (outerJoin == null) return true;
+ if (outerJoin == null) {
+ return true;
+ }
return tids.containsAll(outerJoin.getAllTableRefIds());
}
@@ -1618,9 +1636,13 @@ public List getEqJoinConjuncts(List lhsTblRefIds,
List conjunctIds = Lists.newArrayList();
for (TupleId rhsId: rhsTblRefIds) {
List cids = globalState.eqJoinConjuncts.get(rhsId);
- if (cids == null) continue;
+ if (cids == null) {
+ continue;
+ }
for (ExprId eid: cids) {
- if (!conjunctIds.contains(eid)) conjunctIds.add(eid);
+ if (!conjunctIds.contains(eid)) {
+ conjunctIds.add(eid);
+ }
}
}
@@ -1645,7 +1667,9 @@ public List getEqJoinConjuncts(List lhsTblRefIds,
continue;
}
- if (ojClauseConjuncts != null && !ojClauseConjuncts.contains(conjunctId)) continue;
+ if (ojClauseConjuncts != null && !ojClauseConjuncts.contains(conjunctId)) {
+ continue;
+ }
result.add(e);
}
return result;
@@ -1799,7 +1823,9 @@ public Type castAllToCompatibleType(List exprs) throws AnalysisException {
*/
public void castToSetOpsCompatibleTypes(List> exprLists)
throws AnalysisException {
- if (exprLists == null || exprLists.size() < 2) return;
+ if (exprLists == null || exprLists.size() < 2) {
+ return;
+ }
// Determine compatible types for exprs, position by position.
List firstList = exprLists.get(0);
@@ -1982,9 +2008,13 @@ public boolean canEvalPredicate(List tupleIds, Expr e) {
if (e.isOnClauseConjunct()) {
- if (isAntiJoinedConjunct(e)) return canEvalAntiJoinedConjunct(e, tupleIds);
+ if (isAntiJoinedConjunct(e)) {
+ return canEvalAntiJoinedConjunct(e, tupleIds);
+ }
if (isIjConjunct(e) || isSjConjunct(e)) {
- if (!containsOuterJoinedTid(tids)) return true;
+ if (!containsOuterJoinedTid(tids)) {
+ return true;
+ }
// If the predicate references an outer-joined tuple, then evaluate it at
// the join that the On-clause belongs to.
TableRef onClauseTableRef = null;
@@ -1997,11 +2027,15 @@ public boolean canEvalPredicate(List tupleIds, Expr e) {
return tupleIds.containsAll(onClauseTableRef.getAllTableRefIds());
}
- if (isFullOuterJoined(e)) return canEvalFullOuterJoinedConjunct(e, tupleIds);
+ if (isFullOuterJoined(e)) {
+ return canEvalFullOuterJoinedConjunct(e, tupleIds);
+ }
if (isOjConjunct(e)) {
// Force this predicate to be evaluated by the corresponding outer join node.
// The join node will pick up the predicate later via getUnassignedOjConjuncts().
- if (tids.size() > 1) return false;
+ if (tids.size() > 1) {
+ return false;
+ }
// Optimization for single-tid predicates: Legal to assign below the outer join
// if the predicate is from the same On-clause that makes tid nullable
// (otherwise e needn't be true when that tuple is set).
@@ -2031,7 +2065,9 @@ public boolean canEvalPredicate(List tupleIds, Expr e) {
*/
public boolean canEvalAntiJoinedConjunct(Expr e, List nodeTupleIds) {
TableRef antiJoinRef = getAntiJoinRef(e);
- if (antiJoinRef == null) return true;
+ if (antiJoinRef == null) {
+ return true;
+ }
List tids = Lists.newArrayList();
e.getIds(tids, null);
if (tids.size() > 1) {
@@ -2049,7 +2085,9 @@ public boolean canEvalAntiJoinedConjunct(Expr e, List nodeTupleIds) {
*/
public boolean canEvalFullOuterJoinedConjunct(Expr e, List tids) {
TableRef fullOuterJoin = getFullOuterJoinRef(e);
- if (fullOuterJoin == null) return true;
+ if (fullOuterJoin == null) {
+ return true;
+ }
return tids.containsAll(fullOuterJoin.getAllTableRefIds());
}
@@ -2100,7 +2138,7 @@ public void materializeSlots(List exprs) {
}
}
- public Map getLocalViews() { return localViews_; }
+ public Map getLocalViews() { return localViews; }
public boolean isOuterJoined(TupleId tid) {
return globalState.outerJoinedTupleIds.containsKey(tid);
@@ -2187,7 +2225,9 @@ public List getValueTransferTargets(SlotId srcSid) {
public boolean hasOuterJoinedValueTransferTarget(List sids) {
for (SlotId srcSid : sids) {
for (SlotId dstSid : getValueTransferTargets(srcSid)) {
- if (isOuterJoined(getTupleId(dstSid))) return true;
+ if (isOuterJoined(getTupleId(dstSid))) {
+ return true;
+ }
}
}
return false;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java
index 361d8c4cf6670b..bd1ac2d0b7e702 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java
@@ -361,6 +361,7 @@ public void analyzeImpl(Analyzer analyzer) throws AnalysisException {
if (isConstant()) {
castUpperInteger(t1, t2);
}
+ break;
case MOD:
if (t1.isDecimalV2() || t2.isDecimalV2()) {
castBinaryOp(findCommonType(t1, t2));
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/BaseTableRef.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/BaseTableRef.java
index 09269f37f82a84..39f722a92a5222 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/BaseTableRef.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/BaseTableRef.java
@@ -37,8 +37,10 @@ public BaseTableRef(TableRef ref, Table table, TableName tableName) {
this.table = table;
this.name = tableName;
// Set implicit aliases if no explicit one was given.
- if (hasExplicitAlias()) return;
- aliases_ = new String[] { name.toString(), tableName.getNoClusterString(), tableName.getTbl() };
+ if (hasExplicitAlias()) {
+ return;
+ }
+ aliases = new String[] { name.toString(), tableName.getNoClusterString(), tableName.getTbl() };
}
protected BaseTableRef(BaseTableRef other) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/BetweenPredicate.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/BetweenPredicate.java
index d3787c26bbc86c..5dc2e4c5a9fb01 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/BetweenPredicate.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/BetweenPredicate.java
@@ -110,6 +110,21 @@ public String toDigestImpl() {
@Override
public Expr clone(ExprSubstitutionMap sMap) { return new BetweenPredicate(this); }
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ if (!super.equals(o)) {
+ return false;
+ }
+ BetweenPredicate that = (BetweenPredicate) o;
+ return isNotBetween == that.isNotBetween;
+ }
+
@Override
public int hashCode() {
return 31 * super.hashCode() + Boolean.hashCode(isNotBetween);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
index cc1c4cc29c9e38..271c8d22603146 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
@@ -52,7 +52,7 @@ public class BinaryPredicate extends Predicate implements Writable {
private final static Logger LOG = LogManager.getLogger(BinaryPredicate.class);
// true if this BinaryPredicate is inferred from slot equivalences, false otherwise.
- private boolean isInferred_ = false;
+ private boolean isInferred = false;
public enum Operator {
EQ("=", "eq", TExprOpcode.EQ),
@@ -104,8 +104,9 @@ public Operator commutative() {
return LE;
case EQ_FOR_NULL:
return this;
+ default:
+ return null;
}
- return null;
}
public Operator converse() {
@@ -163,15 +164,17 @@ protected BinaryPredicate(BinaryPredicate other) {
super(other);
op = other.op;
slotIsleft= other.slotIsleft;
- isInferred_ = other.isInferred_;
+ isInferred = other.isInferred;
}
- public boolean isInferred() { return isInferred_; }
- public void setIsInferred() { isInferred_ = true; }
+ public boolean isInferred() { return isInferred; }
+ public void setIsInferred() { isInferred = true; }
public static void initBuiltins(FunctionSet functionSet) {
for (Type t: Type.getSupportedTypes()) {
- if (t.isNull()) continue; // NULL is handled through type promotion.
+ if (t.isNull()) {
+ continue; // NULL is handled through type promotion.
+ }
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltinOperator(
Operator.EQ.getName(), Lists.newArrayList(t, t), Type.BOOLEAN));
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltinOperator(
@@ -455,7 +458,9 @@ public Expr getSlotBinding(SlotId id) {
* casts, returns those two slots; otherwise returns null.
*/
public static Pair getEqSlots(Expr e) {
- if (!(e instanceof BinaryPredicate)) return null;
+ if (!(e instanceof BinaryPredicate)) {
+ return null;
+ }
return ((BinaryPredicate) e).getEqSlots();
}
@@ -465,11 +470,17 @@ public static Pair getEqSlots(Expr e) {
*/
@Override
public Pair getEqSlots() {
- if (op != Operator.EQ) return null;
+ if (op != Operator.EQ) {
+ return null;
+ }
SlotRef lhs = getChild(0).unwrapSlotRef(true);
- if (lhs == null) return null;
+ if (lhs == null) {
+ return null;
+ }
SlotRef rhs = getChild(1).unwrapSlotRef(true);
- if (rhs == null) return null;
+ if (rhs == null) {
+ return null;
+ }
return new Pair(lhs.getSlotId(), rhs.getSlotId());
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/BoolLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/BoolLiteral.java
index 4a6ef66c0face8..e434668286ae9f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/BoolLiteral.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/BoolLiteral.java
@@ -152,4 +152,19 @@ public static BoolLiteral read(DataInput in) throws IOException {
public int hashCode() {
return 31 * super.hashCode() + Boolean.hashCode(value);
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ if (!super.equals(o)) {
+ return false;
+ }
+ BoolLiteral that = (BoolLiteral) o;
+ return value == that.value;
+ }
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/BuiltinAggregateFunction.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/BuiltinAggregateFunction.java
index bef35e2b066138..ff66fb29e4078f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/BuiltinAggregateFunction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/BuiltinAggregateFunction.java
@@ -34,7 +34,7 @@
* Internal representation of a builtin aggregate function.
*/
public class BuiltinAggregateFunction extends Function {
- private final Operator op_;
+ private final Operator op;
// this is to judge the analytic function
private boolean isAnalyticFn = false;
@@ -42,7 +42,7 @@ public boolean isAnalyticFn() {
return isAnalyticFn;
}
// TODO: this is not used yet until the planner understand this.
- private org.apache.doris.catalog.Type intermediateType_;
+ private org.apache.doris.catalog.Type intermediateType;
private boolean reqIntermediateTuple = false;
public boolean isReqIntermediateTuple() {
@@ -58,8 +58,8 @@ public BuiltinAggregateFunction(Operator op, ArrayList argTypes,
Preconditions.checkState(op != null);
// may be no need to analyze
// intermediateType.analyze();
- op_ = op;
- intermediateType_ = intermediateType;
+ this.op = op;
+ this.intermediateType = intermediateType;
if (isAnalyticFn && !intermediateType.equals(retType)) {
reqIntermediateTuple = true;
}
@@ -71,25 +71,25 @@ public BuiltinAggregateFunction(Operator op, ArrayList argTypes,
public TFunction toThrift() {
TFunction fn = super.toThrift();
// TODO: for now, just put the op_ enum as the id.
- if (op_ == BuiltinAggregateFunction.Operator.FIRST_VALUE_REWRITE) {
+ if (op == BuiltinAggregateFunction.Operator.FIRST_VALUE_REWRITE) {
fn.setId(0);
} else {
- fn.setId(op_.thriftOp.ordinal());
+ fn.setId(op.thriftOp.ordinal());
}
- fn.setAggregateFn(new TAggregateFunction(intermediateType_.toThrift()));
+ fn.setAggregateFn(new TAggregateFunction(intermediateType.toThrift()));
return fn;
}
public Operator op() {
- return op_;
+ return op;
}
public org.apache.doris.catalog.Type getIntermediateType() {
- return intermediateType_;
+ return intermediateType;
}
public void setIntermediateType(org.apache.doris.catalog.Type t) {
- intermediateType_ = t;
+ intermediateType = t;
}
// TODO: this is effectively a catalog of builtin aggregate functions.
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CaseExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CaseExpr.java
index 8a41e91d35f2ca..e74dab7b182949 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CaseExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CaseExpr.java
@@ -32,6 +32,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
/**
* CASE and DECODE are represented using this class. The backend implementation is
@@ -98,6 +99,11 @@ public Expr clone() {
return new CaseExpr(this);
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), hasCaseExpr, hasElseExpr);
+ }
+
@Override
public boolean equals(Object obj) {
if (!super.equals(obj)) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
index cca6217816ff0d..d2e9691bf2a04c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
@@ -313,6 +313,11 @@ public void analyzeImpl(Analyzer analyzer) throws AnalysisException {
analyze();
}
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
@Override
public boolean equals(Object obj) {
if (!super.equals(obj)) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
index 29e3aed56da863..86a818ff8e159f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
@@ -280,6 +280,7 @@ public static void validateDefaultValue(Type type, String defaultValue) throws A
if (floatLiteral.getType().equals(Type.DOUBLE)) {
throw new AnalysisException("Default value will loose precision: " + defaultValue);
}
+ break;
case DOUBLE:
FloatLiteral doubleLiteral = new FloatLiteral(defaultValue);
break;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CompoundPredicate.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CompoundPredicate.java
index 8b454ce533c6e4..87b0dfd8830521 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CompoundPredicate.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CompoundPredicate.java
@@ -145,6 +145,8 @@ public void analyzeImpl(Analyzer analyzer) throws AnalysisException {
case NOT:
selectivity = 1.0 - getChild(0).selectivity;
break;
+ default:
+ throw new AnalysisException("not support operator: " + op);
}
selectivity = Math.max(0.0, Math.min(1.0, selectivity));
if (LOG.isDebugEnabled()) {
@@ -180,7 +182,9 @@ public TExprOpcode toThrift() {
*/
@Override
public Expr negate() {
- if (op == Operator.NOT) return getChild(0);
+ if (op == Operator.NOT) {
+ return getChild(0);
+ }
Expr negatedLeft = getChild(0).negate();
Expr negatedRight = getChild(1).negate();
Operator newOp = (op == Operator.OR) ? Operator.AND : Operator.OR;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java
index 09dd6b1f8dda19..75fcb05f2a117d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java
@@ -428,8 +428,8 @@ public void castToDate() {
private long makePackedDatetime() {
long ymd = ((year * 13 + month) << 5) | day;
long hms = (hour << 12) | (minute << 6) | second;
- long packed_datetime = ((ymd << 17) | hms) << 24 + microsecond;
- return packed_datetime;
+ long packedDatetime = ((ymd << 17) | hms) << 24 + microsecond;
+ return packedDatetime;
}
@Override
@@ -446,9 +446,9 @@ public void write(DataOutput out) throws IOException {
out.writeLong(makePackedDatetime());
}
- private void fromPackedDatetime(long packed_time) {
- microsecond = (packed_time % (1L << 24));
- long ymdhms = (packed_time >> 24);
+ private void fromPackedDatetime(long packedTime) {
+ microsecond = (packedTime % (1L << 24));
+ long ymdhms = (packedTime >> 24);
long ymd = ymdhms >> 17;
long hms = ymdhms % (1 << 17);
@@ -467,11 +467,11 @@ private void fromPackedDatetime(long packed_time) {
public void readFields(DataInput in) throws IOException {
super.readFields(in);
- short date_literal_type = in.readShort();
+ short dateLiteralType = in.readShort();
fromPackedDatetime(in.readLong());
- if (date_literal_type == DateLiteralType.DATETIME.value()) {
+ if (dateLiteralType == DateLiteralType.DATETIME.value()) {
this.type = Type.DATETIME;
- } else if (date_literal_type == DateLiteralType.DATE.value()) {
+ } else if (dateLiteralType == DateLiteralType.DATE.value()) {
this.type = Type.DATE;
} else {
throw new IOException("Error date literal type : " + type);
@@ -815,8 +815,7 @@ public int fromDateFormatStr(String format, String value, boolean hasSubVal) thr
case 'I':
case 'l':
usaTime = true;
- // Fall through
- case 'k':
+ case 'k': // CHECKSTYLE IGNORE THIS LINE: Fall through
case 'H':
tmp = findNumber(value, vp, 2);
intValue = strToLong(value.substring(vp, tmp));
@@ -1024,12 +1023,12 @@ public int fromDateFormatStr(String format, String value, boolean hasSubVal) thr
}
long days = calcDaynr(strictWeekNumber ? strictWeekNumberYear : this.year, 1, 1);
- long weekday_b = calcWeekday(days, sundayFirst);
+ long weekdayB = calcWeekday(days, sundayFirst);
if (sundayFirst) {
- days += ((weekday_b == 0) ? 0 : 7) - weekday_b + (weekNum - 1) * 7 + weekday % 7;
+ days += ((weekdayB == 0) ? 0 : 7) - weekdayB + (weekNum - 1) * 7 + weekday % 7;
} else {
- days += ((weekday_b <= 3) ? 0 : 7) - weekday_b + (weekNum - 1) * 7 + weekday - 1;
+ days += ((weekdayB <= 3) ? 0 : 7) - weekdayB + (weekNum - 1) * 7 + weekday - 1;
}
getDateFromDaynr(days);
}
@@ -1194,12 +1193,12 @@ public void fromDateStr(String dateStr) throws AnalysisException {
int fieldLen = yearLen;
while (pre < dateStr.length() && Character.isDigit(dateStr.charAt(pre)) && fieldIdx < MAX_DATE_PARTS - 1) {
int start = pre;
- int temp_val = 0;
+ int tempVal = 0;
boolean scanToDelim = (!isIntervalFormat) && (fieldIdx != 6);
while (pre < dateStr.length() && Character.isDigit(dateStr.charAt(pre)) && (scanToDelim || fieldLen-- != 0)) {
- temp_val = temp_val * 10 + (dateStr.charAt(pre++) - '0');
+ tempVal = tempVal * 10 + (dateStr.charAt(pre++) - '0');
}
- dateVal[fieldIdx] = temp_val;
+ dateVal[fieldIdx] = tempVal;
dateLen[fieldIdx] = pre - start;
fieldLen = 2;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DescriptorTable.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DescriptorTable.java
index 148c93fb915e03..e2f933291f9a0a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DescriptorTable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DescriptorTable.java
@@ -47,27 +47,27 @@ public class DescriptorTable {
// List of referenced tables with no associated TupleDescriptor to ship to the BE.
// For example, the output table of an insert query.
private final List referencedTables = new ArrayList();
- private final IdGenerator tupleIdGenerator_ = TupleId.createGenerator();
- private final IdGenerator slotIdGenerator_ = SlotId.createGenerator();
+ private final IdGenerator tupleIdGenerator = TupleId.createGenerator();
+ private final IdGenerator slotIdGenerator = SlotId.createGenerator();
private final HashMap slotDescs = Maps.newHashMap();
public DescriptorTable() {
}
public TupleDescriptor createTupleDescriptor() {
- TupleDescriptor d = new TupleDescriptor(tupleIdGenerator_.getNextId());
+ TupleDescriptor d = new TupleDescriptor(tupleIdGenerator.getNextId());
tupleDescs.put(d.getId(), d);
return d;
}
public TupleDescriptor createTupleDescriptor(String debugName) {
- TupleDescriptor d = new TupleDescriptor(tupleIdGenerator_.getNextId(), debugName);
+ TupleDescriptor d = new TupleDescriptor(tupleIdGenerator.getNextId(), debugName);
tupleDescs.put(d.getId(), d);
return d;
}
public SlotDescriptor addSlotDescriptor(TupleDescriptor d) {
- SlotDescriptor result = new SlotDescriptor(slotIdGenerator_.getNextId(), d);
+ SlotDescriptor result = new SlotDescriptor(slotIdGenerator.getNextId(), d);
d.addSlot(result);
slotDescs.put(result.getId(), result);
return result;
@@ -78,7 +78,7 @@ public SlotDescriptor addSlotDescriptor(TupleDescriptor d) {
* computed.
*/
public TupleDescriptor copyTupleDescriptor(TupleId srcId, String debugName) {
- TupleDescriptor d = new TupleDescriptor(tupleIdGenerator_.getNextId(), debugName);
+ TupleDescriptor d = new TupleDescriptor(tupleIdGenerator.getNextId(), debugName);
tupleDescs.put(d.getId(), d);
// create copies of slots
TupleDescriptor src = tupleDescs.get(srcId);
@@ -93,7 +93,7 @@ public TupleDescriptor copyTupleDescriptor(TupleId srcId, String debugName) {
* Append copy of src to dest.
*/
public SlotDescriptor copySlotDescriptor(TupleDescriptor dest, SlotDescriptor src) {
- SlotDescriptor result = new SlotDescriptor(slotIdGenerator_.getNextId(), dest, src);
+ SlotDescriptor result = new SlotDescriptor(slotIdGenerator.getNextId(), dest, src);
dest.addSlot(result);
slotDescs.put(result.getId(), result);
return result;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
index c125e742fccec2..82130639657979 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
@@ -240,7 +240,7 @@ public boolean apply(Expr arg) {
protected Type type; // result of analysis
- protected boolean isOnClauseConjunct_; // set by analyzer
+ protected boolean isOnClauseConjunct; // set by analyzer
protected boolean isAnalyzed = false; // true after analyze() has been called
@@ -267,7 +267,7 @@ public boolean apply(Expr arg) {
protected Function fn;
// Cached value of IsConstant(), set during analyze() and valid if isAnalyzed_ is true.
- private boolean isConstant_;
+ private boolean isConstant;
// Flag to indicate whether to wrap this expr's toSql() in parenthesis. Set by parser.
// Needed for properly capturing expr precedences in the SQL string.
@@ -292,7 +292,7 @@ protected Expr(Expr other) {
numDistinctValues = other.numDistinctValues;
opcode = other.opcode;
outputScale = other.outputScale;
- isConstant_ = other.isConstant_;
+ isConstant = other.isConstant;
fn = other.fn;
printSqlInParens = other.printSqlInParens;
children = Expr.cloneList(other.children);
@@ -357,8 +357,8 @@ public void setIsFilter(boolean v) {
isFilter = v;
}
- public boolean isOnClauseConjunct() { return isOnClauseConjunct_; }
- public void setIsOnClauseConjunct(boolean b) { isOnClauseConjunct_ = b; }
+ public boolean isOnClauseConjunct() { return isOnClauseConjunct; }
+ public void setIsOnClauseConjunct(boolean b) { isOnClauseConjunct = b; }
public boolean isAuxExpr() { return isAuxExpr; }
public void setIsAuxExpr() { isAuxExpr = true; }
public Function getFn() {
@@ -378,7 +378,9 @@ public void setPrintSqlInParens(boolean b) {
* Throws exception if any errors found.
*/
public final void analyze(Analyzer analyzer) throws AnalysisException {
- if (isAnalyzed()) return;
+ if (isAnalyzed()) {
+ return;
+ }
// Check the expr child limit.
if (children.size() > Config.expr_children_limit) {
@@ -401,7 +403,9 @@ public final void analyze(Analyzer analyzer) throws AnalysisException {
for (Expr child: children) {
child.analyze(analyzer);
}
- if (analyzer != null) analyzer.decrementCallDepth();
+ if (analyzer != null) {
+ analyzer.decrementCallDepth();
+ }
computeNumDistinctValues();
// Do all the analysis for the expr subclass before marking the Expr analyzed.
@@ -424,7 +428,7 @@ protected void analysisDone() {
Preconditions.checkState(!isAnalyzed);
// We need to compute the const-ness as the last step, since analysis may change
// the result, e.g. by resolving function.
- isConstant_ = isConstantImpl();
+ isConstant = isConstantImpl();
isAnalyzed = true;
}
@@ -691,10 +695,14 @@ public Expr trySubstitute(ExprSubstitutionMap smap, Analyzer analyzer,
boolean preserveRootType) throws AnalysisException {
Expr result = clone();
// Return clone to avoid removing casts.
- if (smap == null) return result;
+ if (smap == null) {
+ return result;
+ }
result = result.substituteImpl(smap, analyzer);
result.analyze(analyzer);
- if (preserveRootType && !type.equals(result.getType())) result = result.castTo(type);
+ if (preserveRootType && !type.equals(result.getType())) {
+ result = result.castTo(type);
+ }
return result;
}
@@ -751,10 +759,14 @@ public static ArrayList substituteList(
*/
protected Expr substituteImpl(ExprSubstitutionMap smap, Analyzer analyzer)
throws AnalysisException {
- if (isImplicitCast()) return getChild(0).substituteImpl(smap, analyzer);
+ if (isImplicitCast()) {
+ return getChild(0).substituteImpl(smap, analyzer);
+ }
if (smap != null) {
Expr substExpr = smap.get(this);
- if (substExpr != null) return substExpr.clone();
+ if (substExpr != null) {
+ return substExpr.clone();
+ }
}
for (int i = 0; i < children.size(); ++i) {
children.set(i, children.get(i).substituteImpl(smap, analyzer));
@@ -762,7 +774,9 @@ protected Expr substituteImpl(ExprSubstitutionMap smap, Analyzer analyzer)
// SlotRefs must remain analyzed to support substitution across query blocks. All
// other exprs must be analyzed again after the substitution to add implicit casts
// and for resolving their correct function signature.
- if (!(this instanceof SlotRef)) resetAnalysisState();
+ if (!(this instanceof SlotRef)) {
+ resetAnalysisState();
+ }
return this;
}
@@ -824,7 +838,9 @@ public void markAgg() {
* the exprs have an invalid number of distinct values.
*/
public static long getNumDistinctValues(List exprs) {
- if (exprs == null || exprs.isEmpty()) return 0;
+ if (exprs == null || exprs.isEmpty()) {
+ return 0;
+ }
long numDistinctValues = 1;
for (Expr expr: exprs) {
if (expr.getNumDistinctValues() == -1) {
@@ -1012,7 +1028,9 @@ public String debugString() {
* Resets the internal analysis state of this expr tree. Removes implicit casts.
*/
public Expr reset() {
- if (isImplicitCast()) return getChild(0).reset();
+ if (isImplicitCast()) {
+ return getChild(0).reset();
+ }
for (int i = 0; i < children.size(); ++i) {
children.set(i, children.get(i).reset());
}
@@ -1172,7 +1190,9 @@ public boolean isBound(TupleId tid) {
*/
public boolean isBoundByTupleIds(List tids) {
for (Expr child: children) {
- if (!child.isBoundByTupleIds(tids)) return false;
+ if (!child.isBoundByTupleIds(tids)) {
+ return false;
+ }
}
return true;
}
@@ -1241,7 +1261,9 @@ public boolean isLiteral() {
* FunctionCallExpr.isConstant()).
*/
public final boolean isConstant() {
- if (isAnalyzed) return isConstant_;
+ if (isAnalyzed) {
+ return isConstant;
+ }
return isConstantImpl();
}
@@ -1250,7 +1272,9 @@ public final boolean isConstant() {
*/
protected boolean isConstantImpl() {
for (Expr expr : children) {
- if (!expr.isConstant()) return false;
+ if (!expr.isConstant()) {
+ return false;
+ }
}
return true;
}
@@ -1518,7 +1542,9 @@ public SlotRef unwrapSlotRef() {
*/
public SlotRef unwrapSlotRef(boolean implicitOnly) {
Expr unwrappedExpr = unwrapExpr(implicitOnly);
- if (unwrappedExpr instanceof SlotRef) return (SlotRef) unwrappedExpr;
+ if (unwrappedExpr instanceof SlotRef) {
+ return (SlotRef) unwrappedExpr;
+ }
return null;
}
@@ -1870,7 +1896,9 @@ public String getStringValue() {
public static Expr getFirstBoundChild(Expr expr, List tids) {
for (Expr child: expr.getChildren()) {
- if (child.isBoundByTupleIds(tids)) return child;
+ if (child.isBoundByTupleIds(tids)) {
+ return child;
+ }
}
return null;
}
@@ -1879,10 +1907,16 @@ public static Expr getFirstBoundChild(Expr expr, List tids) {
* Returns true if expr contains specify function, otherwise false.
*/
public boolean isContainsFunction(String functionName) {
- if (fn == null) return false;
- if (fn.functionName().equalsIgnoreCase(functionName)) return true;
+ if (fn == null) {
+ return false;
+ }
+ if (fn.functionName().equalsIgnoreCase(functionName)) {
+ return true;
+ }
for (Expr child: children) {
- if (child.isContainsFunction(functionName)) return true;
+ if (child.isContainsFunction(functionName)) {
+ return true;
+ }
}
return false;
}
@@ -1891,16 +1925,22 @@ public boolean isContainsFunction(String functionName) {
* Returns true if expr contains specify className, otherwise false.
*/
public boolean isContainsClass(String className) {
- if (this.getClass().getName().equalsIgnoreCase(className)) return true;
+ if (this.getClass().getName().equalsIgnoreCase(className)) {
+ return true;
+ }
for (Expr child: children) {
- if (child.isContainsClass(className)) return true;
+ if (child.isContainsClass(className)) {
+ return true;
+ }
}
return false;
}
protected boolean hasNullableChild() {
for (Expr expr : children) {
- if (expr.isNullable()) return true;
+ if (expr.isNullable()) {
+ return true;
+ }
}
return false;
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprId.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprId.java
index dc8af2cd53c50c..8507fd26a52b88 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprId.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprId.java
@@ -37,9 +37,9 @@ public ExprId(int id) {
public static IdGenerator createGenerator() {
return new IdGenerator() {
@Override
- public ExprId getNextId() { return new ExprId(nextId_++); }
+ public ExprId getNextId() { return new ExprId(nextId++); }
@Override
- public ExprId getMaxId() { return new ExprId(nextId_ - 1); }
+ public ExprId getMaxId() { return new ExprId(nextId - 1); }
};
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprSubstitutionMap.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprSubstitutionMap.java
index 20eccffb4f0012..b7d44fe501a324 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprSubstitutionMap.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprSubstitutionMap.java
@@ -39,9 +39,9 @@
public final class ExprSubstitutionMap {
private final static Logger LOG = LoggerFactory.getLogger(ExprSubstitutionMap.class);
- private boolean checkAnalyzed_ = true;
- private List lhs_; // left-hand side
- private List rhs_; // right-hand side
+ private boolean checkAnalyzed = true;
+ private List lhs; // left-hand side
+ private List rhs; // right-hand side
public ExprSubstitutionMap() {
this(Lists.newArrayList(), Lists.newArrayList());
@@ -50,12 +50,12 @@ public ExprSubstitutionMap() {
// Only used to convert show statement to select statement
public ExprSubstitutionMap(boolean checkAnalyzed) {
this(Lists.newArrayList(), Lists.newArrayList());
- this.checkAnalyzed_ = checkAnalyzed;
+ this.checkAnalyzed = checkAnalyzed;
}
public ExprSubstitutionMap(List lhs, List rhs) {
- lhs_ = lhs;
- rhs_ = rhs;
+ this.lhs = lhs;
+ this.rhs = rhs;
}
/**
@@ -63,18 +63,20 @@ public ExprSubstitutionMap(List lhs, List rhs) {
* across query blocks. It is not required that the lhsExpr is analyzed.
*/
public void put(Expr lhsExpr, Expr rhsExpr) {
- Preconditions.checkState(!checkAnalyzed_ || rhsExpr.isAnalyzed(),
+ Preconditions.checkState(!checkAnalyzed || rhsExpr.isAnalyzed(),
"Rhs expr must be analyzed.");
- lhs_.add(lhsExpr);
- rhs_.add(rhsExpr);
+ lhs.add(lhsExpr);
+ rhs.add(rhsExpr);
}
/**
* Returns the expr mapped to lhsExpr or null if no mapping to lhsExpr exists.
*/
public Expr get(Expr lhsExpr) {
- for (int i = 0; i < lhs_.size(); ++i) {
- if (lhsExpr.equals(lhs_.get(i))) return rhs_.get(i);
+ for (int i = 0; i < lhs.size(); ++i) {
+ if (lhsExpr.equals(lhs.get(i))) {
+ return rhs.get(i);
+ }
}
return null;
}
@@ -83,7 +85,7 @@ public Expr get(Expr lhsExpr) {
* Returns true if the smap contains a mapping for lhsExpr.
*/
public boolean containsMappingFor(Expr lhsExpr) {
- return lhs_.contains(lhsExpr);
+ return lhs.contains(lhsExpr);
}
/**
@@ -93,17 +95,23 @@ public boolean containsMappingFor(Expr lhsExpr) {
*/
public static ExprSubstitutionMap compose(ExprSubstitutionMap f, ExprSubstitutionMap g,
Analyzer analyzer) {
- if (f == null && g == null) return new ExprSubstitutionMap();
- if (f == null) return g;
- if (g == null) return f;
+ if (f == null && g == null) {
+ return new ExprSubstitutionMap();
+ }
+ if (f == null) {
+ return g;
+ }
+ if (g == null) {
+ return f;
+ }
ExprSubstitutionMap result = new ExprSubstitutionMap();
// f's substitution targets need to be substituted via g
- result.lhs_ = Expr.cloneList(f.lhs_);
- result.rhs_ = Expr.substituteList(f.rhs_, g, analyzer, false);
+ result.lhs = Expr.cloneList(f.lhs);
+ result.rhs = Expr.substituteList(f.rhs, g, analyzer, false);
// substitution maps are cumulative: the combined map contains all
// substitutions from f and g.
- for (int i = 0; i < g.lhs_.size(); i++) {
+ for (int i = 0; i < g.lhs.size(); i++) {
// If f contains expr1->fn(expr2) and g contains expr2->expr3,
// then result must contain expr1->fn(expr3).
// The check before adding to result.lhs is to ensure that cases
@@ -112,9 +120,9 @@ public static ExprSubstitutionMap compose(ExprSubstitutionMap f, ExprSubstitutio
// and g: count(*) -> slotref
// result.lhs must only have: count(*) -> zeroifnull(slotref) from f above,
// and not count(*) -> slotref from g as well.
- if (!result.lhs_.contains(g.lhs_.get(i))) {
- result.lhs_.add(g.lhs_.get(i).clone());
- result.rhs_.add(g.rhs_.get(i).clone());
+ if (!result.lhs.contains(g.lhs.get(i))) {
+ result.lhs.add(g.lhs.get(i).clone());
+ result.rhs.add(g.rhs.get(i).clone());
}
}
@@ -127,33 +135,39 @@ public static ExprSubstitutionMap compose(ExprSubstitutionMap f, ExprSubstitutio
*/
public static ExprSubstitutionMap combine(ExprSubstitutionMap f,
ExprSubstitutionMap g) {
- if (f == null && g == null) return new ExprSubstitutionMap();
- if (f == null) return g;
- if (g == null) return f;
+ if (f == null && g == null) {
+ return new ExprSubstitutionMap();
+ }
+ if (f == null) {
+ return g;
+ }
+ if (g == null) {
+ return f;
+ }
ExprSubstitutionMap result = new ExprSubstitutionMap();
- result.lhs_ = Lists.newArrayList(f.lhs_);
- result.lhs_.addAll(g.lhs_);
- result.rhs_ = Lists.newArrayList(f.rhs_);
- result.rhs_.addAll(g.rhs_);
+ result.lhs = Lists.newArrayList(f.lhs);
+ result.lhs.addAll(g.lhs);
+ result.rhs = Lists.newArrayList(f.rhs);
+ result.rhs.addAll(g.rhs);
result.verify();
return result;
}
public void substituteLhs(ExprSubstitutionMap lhsSmap, Analyzer analyzer) {
- lhs_ = Expr.substituteList(lhs_, lhsSmap, analyzer, false);
+ lhs = Expr.substituteList(lhs, lhsSmap, analyzer, false);
}
- public List getLhs() { return lhs_; }
- public List getRhs() { return rhs_; }
+ public List getLhs() { return lhs; }
+ public List getRhs() { return rhs; }
- public int size() { return lhs_.size(); }
+ public int size() { return lhs.size(); }
public String debugString() {
- Preconditions.checkState(lhs_.size() == rhs_.size());
+ Preconditions.checkState(lhs.size() == rhs.size());
List output = Lists.newArrayList();
- for (int i = 0; i < lhs_.size(); ++i) {
- output.add(lhs_.get(i).toSql() + ":" + rhs_.get(i).toSql());
- output.add("(" + lhs_.get(i).debugString() + ":" + rhs_.get(i).debugString() + ")");
+ for (int i = 0; i < lhs.size(); ++i) {
+ output.add(lhs.get(i).toSql() + ":" + rhs.get(i).toSql());
+ output.add("(" + lhs.get(i).debugString() + ":" + rhs.get(i).debugString() + ")");
}
return "smap(" + Joiner.on(" ").join(output) + ")";
}
@@ -163,9 +177,9 @@ public String debugString() {
* and that all rhs exprs are analyzed.
*/
private void verify() {
- for (int i = 0; i < lhs_.size(); ++i) {
- for (int j = i + 1; j < lhs_.size(); ++j) {
- if (lhs_.get(i).equals(lhs_.get(j))) {
+ for (int i = 0; i < lhs.size(); ++i) {
+ for (int j = i + 1; j < lhs.size(); ++j) {
+ if (lhs.get(i).equals(lhs.get(j))) {
if (LOG.isTraceEnabled()) {
LOG.trace("verify: smap=" + this.debugString());
}
@@ -173,17 +187,17 @@ private void verify() {
// Preconditions.checkState(false);
}
}
- Preconditions.checkState(!checkAnalyzed_ || rhs_.get(i).isAnalyzed());
+ Preconditions.checkState(!checkAnalyzed || rhs.get(i).isAnalyzed());
}
}
public void clear() {
- lhs_.clear();
- rhs_.clear();
+ lhs.clear();
+ rhs.clear();
}
@Override
public ExprSubstitutionMap clone() {
- return new ExprSubstitutionMap(Expr.cloneList(lhs_), Expr.cloneList(rhs_));
+ return new ExprSubstitutionMap(Expr.cloneList(lhs), Expr.cloneList(rhs));
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExpressionFunctions.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExpressionFunctions.java
index 2557ad89a845df..7789202e884ede 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExpressionFunctions.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExpressionFunctions.java
@@ -288,10 +288,12 @@ public String toString() {
@Override
public boolean equals(Object o) {
- if (this == o)
+ if (this == o) {
return true;
- if (o == null || getClass() != o.getClass())
+ }
+ if (o == null || getClass() != o.getClass()) {
return false;
+ }
FEFunctionSignature signature = (FEFunctionSignature) o;
return Objects.equals(name, signature.name) && Arrays.equals(argTypes, signature.argTypes)
&& Objects.equals(returnType, signature.returnType);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FromClause.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FromClause.java
index 8c1ab2c0eec7c4..4906de085a000c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FromClause.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FromClause.java
@@ -46,27 +46,27 @@
*/
public class FromClause implements ParseNode, Iterable {
- private final ArrayList tableRefs_;
+ private final ArrayList tablerefs;
- private boolean analyzed_ = false;
+ private boolean analyzed = false;
private boolean needToSql = false;
public FromClause(List tableRefs) {
- tableRefs_ = Lists.newArrayList(tableRefs);
+ tablerefs = Lists.newArrayList(tableRefs);
// Set left table refs to ensure correct toSql() before analysis.
- for (int i = 1; i < tableRefs_.size(); ++i) {
- tableRefs_.get(i).setLeftTblRef(tableRefs_.get(i - 1));
+ for (int i = 1; i < tablerefs.size(); ++i) {
+ tablerefs.get(i).setLeftTblRef(tablerefs.get(i - 1));
}
}
- public FromClause() { tableRefs_ = Lists.newArrayList(); }
- public List getTableRefs() { return tableRefs_; }
+ public FromClause() { tablerefs = Lists.newArrayList(); }
+ public List getTableRefs() { return tablerefs; }
public void setNeedToSql(boolean needToSql) {
this.needToSql = needToSql;
}
private void checkFromHiveTable(Analyzer analyzer) throws AnalysisException {
- for (TableRef tblRef : tableRefs_) {
+ for (TableRef tblRef : tablerefs) {
if (!(tblRef instanceof BaseTableRef)) {
continue;
}
@@ -99,7 +99,7 @@ private void checkFromHiveTable(Analyzer analyzer) throws AnalysisException {
* because the table t1 in the on clause cannot be recognized.
*/
private void sortTableRefKeepSequenceOfOnClause() {
- Collections.sort(this.tableRefs_, new Comparator() {
+ Collections.sort(this.tablerefs, new Comparator() {
@Override
public int compare(TableRef tableref1, TableRef tableref2) {
int i1 = 0;
@@ -117,10 +117,12 @@ public int compare(TableRef tableref1, TableRef tableref2) {
@Override
public void analyze(Analyzer analyzer) throws AnalysisException, UserException {
- if (analyzed_) return;
+ if (analyzed) {
+ return;
+ }
- if (tableRefs_.isEmpty()) {
- analyzed_ = true;
+ if (tablerefs.isEmpty()) {
+ analyzed = true;
return;
}
@@ -135,11 +137,11 @@ public void analyze(Analyzer analyzer) throws AnalysisException, UserException {
// Start out with table refs to establish aliases.
TableRef leftTblRef = null; // the one to the left of tblRef
- for (int i = 0; i < tableRefs_.size(); ++i) {
+ for (int i = 0; i < tablerefs.size(); ++i) {
// Resolve and replace non-InlineViewRef table refs with a BaseTableRef or ViewRef.
- TableRef tblRef = tableRefs_.get(i);
+ TableRef tblRef = tablerefs.get(i);
tblRef = analyzer.resolveTableRef(tblRef);
- tableRefs_.set(i, Preconditions.checkNotNull(tblRef));
+ tablerefs.set(i, Preconditions.checkNotNull(tblRef));
tblRef.setLeftTblRef(leftTblRef);
if (tblRef instanceof InlineViewRef) {
((InlineViewRef) tblRef).setNeedToSql(needToSql);
@@ -151,12 +153,14 @@ public void analyze(Analyzer analyzer) throws AnalysisException, UserException {
// TODO: remove when query from hive table is supported
checkFromHiveTable(analyzer);
- analyzed_ = true;
+ analyzed = true;
}
public FromClause clone() {
ArrayList clone = Lists.newArrayList();
- for (TableRef tblRef: tableRefs_) clone.add(tblRef.clone());
+ for (TableRef tblRef: tablerefs) {
+ clone.add(tblRef.clone());
+ }
return new FromClause(clone);
}
@@ -178,16 +182,16 @@ public void reset() {
// }
get(i).reset();
}
- this.analyzed_ = false;
+ this.analyzed = false;
}
@Override
public String toSql() {
StringBuilder builder = new StringBuilder();
- if (!tableRefs_.isEmpty()) {
+ if (!tablerefs.isEmpty()) {
builder.append(" FROM");
- for (int i = 0; i < tableRefs_.size(); ++i) {
- builder.append(" " + tableRefs_.get(i).toSql());
+ for (int i = 0; i < tablerefs.size(); ++i) {
+ builder.append(" " + tablerefs.get(i).toSql());
}
}
return builder.toString();
@@ -195,23 +199,23 @@ public String toSql() {
public String toDigest() {
StringBuilder builder = new StringBuilder();
- if (!tableRefs_.isEmpty()) {
+ if (!tablerefs.isEmpty()) {
builder.append(" FROM");
- for (int i = 0; i < tableRefs_.size(); ++i) {
- builder.append(" " + tableRefs_.get(i).toDigest());
+ for (int i = 0; i < tablerefs.size(); ++i) {
+ builder.append(" " + tablerefs.get(i).toDigest());
}
}
return builder.toString();
}
- public boolean isEmpty() { return tableRefs_.isEmpty(); }
+ public boolean isEmpty() { return tablerefs.isEmpty(); }
@Override
- public Iterator iterator() { return tableRefs_.iterator(); }
- public int size() { return tableRefs_.size(); }
- public TableRef get(int i) { return tableRefs_.get(i); }
- public void set(int i, TableRef tableRef) { tableRefs_.set(i, tableRef); }
- public void add(TableRef t) { tableRefs_.add(t); }
- public void addAll(List t) { tableRefs_.addAll(t); }
- public void clear() { tableRefs_.clear(); }
+ public Iterator iterator() { return tablerefs.iterator(); }
+ public int size() { return tablerefs.size(); }
+ public TableRef get(int i) { return tablerefs.get(i); }
+ public void set(int i, TableRef tableRef) { tablerefs.set(i, tableRef); }
+ public void add(TableRef t) { tablerefs.add(t); }
+ public void addAll(List t) { tablerefs.addAll(t); }
+ public void clear() { tablerefs.clear(); }
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
index 7f55d59fe4dbec..e5f45317bd3b03 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
@@ -1158,7 +1158,9 @@ protected boolean isConstantImpl() {
// TODO: we can't correctly determine const-ness before analyzing 'fn_'. We should
// rework logic so that we do not call this function on unanalyzed exprs.
// Aggregate functions are never constant.
- if (fn instanceof AggregateFunction || fn == null) return false;
+ if (fn instanceof AggregateFunction || fn == null) {
+ return false;
+ }
final String fnName = this.fnName.getFunction();
// Non-deterministic functions are never constant.
@@ -1166,7 +1168,9 @@ protected boolean isConstantImpl() {
return false;
}
// Sleep is a special function for testing.
- if (fnName.equalsIgnoreCase("sleep")) return false;
+ if (fnName.equalsIgnoreCase("sleep")) {
+ return false;
+ }
return super.isConstantImpl();
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionName.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionName.java
index b9aadd3265559d..754a9cf924b928 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionName.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionName.java
@@ -44,35 +44,35 @@
public class FunctionName implements Writable {
private static final Logger LOG = LogManager.getLogger(FunctionName.class);
- private String db_;
- private String fn_;
+ private String db;
+ private String fn;
private FunctionName() {
}
public FunctionName(String db, String fn) {
- db_ = db;
- fn_ = fn.toLowerCase();
- if (db_ != null) {
- db_ = db_.toLowerCase();
+ this.db = db;
+ this.fn = fn.toLowerCase();
+ if (this.db != null) {
+ this.db = this.db.toLowerCase();
}
}
public FunctionName(String fn) {
- db_ = null;
- fn_ = fn.toLowerCase();
+ db = null;
+ this.fn = fn.toLowerCase();
}
public FunctionName(TFunctionName thriftName) {
- db_ = thriftName.db_name.toLowerCase();
- fn_ = thriftName.function_name.toLowerCase();
+ db = thriftName.db_name.toLowerCase();
+ fn = thriftName.function_name.toLowerCase();
}
// Same as FunctionName but for builtins and we'll leave the case
// as is since we aren't matching by string.
public static FunctionName createBuiltinName(String fn) {
FunctionName name = new FunctionName(fn);
- name.fn_ = fn;
+ name.fn = fn;
return name;
}
@@ -86,47 +86,47 @@ public boolean equals(Object obj) {
return false;
}
FunctionName o = (FunctionName) obj;
- if ((db_ == null || o.db_ == null) && (db_ != o.db_)) {
- if (db_ == null && o.db_ != null) {
+ if ((db == null || o.db == null) && (db != o.db)) {
+ if (db == null && o.db != null) {
return false;
}
- if (db_ != null && o.db_ == null) {
+ if (db != null && o.db == null) {
return false;
}
- if (!db_.equalsIgnoreCase(o.db_)) {
+ if (!db.equalsIgnoreCase(o.db)) {
return false;
}
}
- return fn_.equalsIgnoreCase(o.fn_);
+ return fn.equalsIgnoreCase(o.fn);
}
public String getDb() {
- return db_;
+ return db;
}
public void setDb(String db) {
- db_ = db;
+ this.db = db;
}
public String getFunction() {
- return fn_;
+ return fn;
}
public boolean isFullyQualified() {
- return db_ != null;
+ return db != null;
}
@Override
public String toString() {
- if (db_ == null) {
- return fn_;
+ if (db == null) {
+ return fn;
}
- return db_ + "." + fn_;
+ return db + "." + fn;
}
// used to analyze db element in function name, add cluster
public String analyzeDb(Analyzer analyzer) throws AnalysisException {
- String db = db_;
+ String db = this.db;
if (db == null) {
db = analyzer.getDefaultDb();
} else {
@@ -139,29 +139,29 @@ public String analyzeDb(Analyzer analyzer) throws AnalysisException {
}
public void analyze(Analyzer analyzer) throws AnalysisException {
- if (fn_.length() == 0) {
+ if (fn.length() == 0) {
throw new AnalysisException("Function name can not be empty.");
}
- for (int i = 0; i < fn_.length(); ++i) {
- if (!isValidCharacter(fn_.charAt(i))) {
+ for (int i = 0; i < fn.length(); ++i) {
+ if (!isValidCharacter(fn.charAt(i))) {
throw new AnalysisException(
"Function names must be all alphanumeric or underscore. " +
- "Invalid name: " + fn_);
+ "Invalid name: " + fn);
}
}
- if (Character.isDigit(fn_.charAt(0))) {
- throw new AnalysisException("Function cannot start with a digit: " + fn_);
+ if (Character.isDigit(fn.charAt(0))) {
+ throw new AnalysisException("Function cannot start with a digit: " + fn);
}
- if (db_ == null) {
- db_ = analyzer.getDefaultDb();
- if (Strings.isNullOrEmpty(db_)) {
+ if (db == null) {
+ db = analyzer.getDefaultDb();
+ if (Strings.isNullOrEmpty(db)) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_NO_DB_ERROR);
}
} else {
if (Strings.isNullOrEmpty(analyzer.getClusterName())) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_CLUSTER_NAME_NULL);
}
- db_ = ClusterNamespace.getFullName(analyzer.getClusterName(), db_);
+ db = ClusterNamespace.getFullName(analyzer.getClusterName(), db);
}
// If the function name is not fully qualified, it must not be the same as a builtin
@@ -177,28 +177,28 @@ private boolean isValidCharacter(char c) {
}
public TFunctionName toThrift() {
- TFunctionName name = new TFunctionName(fn_);
- name.setDbName(db_);
- name.setFunctionName(fn_);
+ TFunctionName name = new TFunctionName(fn);
+ name.setDbName(db);
+ name.setFunctionName(fn);
return name;
}
@Override
public void write(DataOutput out) throws IOException {
- if (db_ != null) {
+ if (db != null) {
out.writeBoolean(true);
- Text.writeString(out, db_);
+ Text.writeString(out, db);
} else {
out.writeBoolean(false);
}
- Text.writeString(out, fn_);
+ Text.writeString(out, fn);
}
public void readFields(DataInput in) throws IOException {
if (in.readBoolean()) {
- db_ = Text.readString(in);
+ db = Text.readString(in);
}
- fn_ = Text.readString(in);
+ fn = Text.readString(in);
}
public static FunctionName read(DataInput in) throws IOException{
@@ -209,6 +209,6 @@ public static FunctionName read(DataInput in) throws IOException{
@Override
public int hashCode() {
- return 31 * Objects.hashCode(db_) + Objects.hashCode(fn_);
+ return 31 * Objects.hashCode(db) + Objects.hashCode(fn);
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/GroupByClause.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/GroupByClause.java
index 302242bd1db44b..d74218c69e2cfc 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/GroupByClause.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/GroupByClause.java
@@ -50,7 +50,7 @@ public class GroupByClause implements ParseNode {
// max num of distinct sets in grouping sets clause
private final static int MAX_GROUPING_SETS_NUM = 64;
// max num of distinct expressions
- private boolean analyzed_ = false;
+ private boolean analyzed = false;
private boolean exprGenerated = false;
private GroupingType groupingType;
private ArrayList groupingExprs;
@@ -96,7 +96,7 @@ public GroupingType getGroupingType() {
public void reset() {
groupingExprs = new ArrayList<>();
- analyzed_ = false;
+ analyzed = false;
exprGenerated = false;
if (oriGroupingExprs != null) {
Expr.resetList(oriGroupingExprs);
@@ -169,7 +169,7 @@ public void genGroupingExprs() throws AnalysisException {
@Override
public void analyze(Analyzer analyzer) throws AnalysisException {
- if (analyzed_) {
+ if (analyzed) {
return;
}
genGroupingExprs();
@@ -206,7 +206,7 @@ public void analyze(Analyzer analyzer) throws AnalysisException {
throw new AnalysisException("Too many sets in GROUP BY clause, the max grouping sets item is "
+ MAX_GROUPING_SETS_NUM);
}
- analyzed_ = true;
+ analyzed = true;
}
// check if group by clause is contain grouping set/rollup/cube
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/InPredicate.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/InPredicate.java
index 575ce07aa1cb31..de9d7ffad7d37a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/InPredicate.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/InPredicate.java
@@ -60,12 +60,16 @@ public class InPredicate extends Predicate {
public static void initBuiltins(FunctionSet functionSet) {
for (Type t: Type.getSupportedTypes()) {
- if (t.isNull()) continue;
+ if (t.isNull()) {
+ continue;
+ }
// TODO we do not support codegen for CHAR and the In predicate must be codegened
// because it has variable number of arguments. This will force CHARs to be
// cast up to strings; meaning that "in" comparisons will not have CHAR comparison
// semantics.
- if (t.getPrimitiveType() == PrimitiveType.CHAR) continue;
+ if (t.getPrimitiveType() == PrimitiveType.CHAR) {
+ continue;
+ }
String typeString = Function.getUdfTypeName(t.getPrimitiveType());
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/InlineViewRef.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/InlineViewRef.java
index f576f02bd8fde9..835fd21f5e4f3f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/InlineViewRef.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/InlineViewRef.java
@@ -99,20 +99,24 @@ public InlineViewRef(String alias, QueryStmt queryStmt, List colLabels)
public InlineViewRef(View view, TableRef origTblRef) {
super(origTblRef.getName(), origTblRef.getExplicitAlias());
queryStmt = view.getQueryStmt().clone();
- if (view.isLocalView()) queryStmt.reset();
+ if (view.isLocalView()) {
+ queryStmt.reset();
+ }
this.view = view;
sMap = new ExprSubstitutionMap();
baseTblSmap = new ExprSubstitutionMap();
setJoinAttrs(origTblRef);
explicitColLabels = view.getColLabels();
// Set implicit aliases if no explicit one was given.
- if (hasExplicitAlias()) return;
+ if (hasExplicitAlias()) {
+ return;
+ }
// TODO(zc)
// view_.getTableName().toString().toLowerCase(), view.getName().toLowerCase()
if (view.isLocalView()) {
- aliases_ = new String[]{view.getName()};
+ aliases = new String[]{view.getName()};
} else {
- aliases_ = new String[]{name.toString(), view.getName()};
+ aliases = new String[]{name.toString(), view.getName()};
}
if (origTblRef.getLateralViewRefs() != null) {
lateralViewRefs = (ArrayList) origTblRef.getLateralViewRefs().clone();
@@ -181,12 +185,12 @@ public void analyze(Analyzer analyzer) throws AnalysisException, UserException {
inlineViewAnalyzer = new Analyzer(analyzer);
queryStmt.analyze(inlineViewAnalyzer);
- correlatedTupleIds_.addAll(queryStmt.getCorrelatedTupleIds(inlineViewAnalyzer));
+ correlatedTupleIds.addAll(queryStmt.getCorrelatedTupleIds(inlineViewAnalyzer));
queryStmt.getMaterializedTupleIds(materializedTupleIds);
if (view != null && !hasExplicitAlias() && !view.isLocalView()) {
name = analyzer.getFqTableName(name);
- aliases_ = new String[] { name.toString(), view.getName() };
+ aliases = new String[] { name.toString(), view.getName() };
}
//TODO(chenhao16): fix TableName in Db.Table style
// name.analyze(analyzer);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/IsNullPredicate.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/IsNullPredicate.java
index f6643720b81f36..619fe484e099cb 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/IsNullPredicate.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/IsNullPredicate.java
@@ -40,7 +40,9 @@ public class IsNullPredicate extends Predicate {
public static void initBuiltins(FunctionSet functionSet) {
for (Type t: Type.getSupportedTypes()) {
- if (t.isNull()) continue;
+ if (t.isNull()) {
+ continue;
+ }
String isNullSymbol;
if (t == Type.BOOLEAN) {
isNullSymbol = "_ZN5doris15IsNullPredicate7is_nullIN9doris_udf10BooleanValE" +
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/LimitElement.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/LimitElement.java
index a7d4a5120fdda0..8ddeb452ec6995 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/LimitElement.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/LimitElement.java
@@ -109,7 +109,9 @@ public String toDigest() {
}
public void analyze(Analyzer analyzer) {
- if (limit == 0) analyzer.setHasEmptyResultSet();
+ if (limit == 0) {
+ analyzer.setHasEmptyResultSet();
+ }
}
public void reset() {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/OutFileClause.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/OutFileClause.java
index 9f3a8973f06481..9aa8253dabb434 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/OutFileClause.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/OutFileClause.java
@@ -17,7 +17,7 @@
package org.apache.doris.analysis;
-import org.apache.doris.backup.HDFSStorage;
+import org.apache.doris.backup.HdfsStorage;
import org.apache.doris.backup.S3Storage;
import org.apache.doris.catalog.PrimitiveType;
import org.apache.doris.catalog.Type;
@@ -319,6 +319,7 @@ private void genParquetSchema(List resultExprs) throws AnalysisException {
if (ConnectContext.get() != null && ConnectContext.get().getSessionVariable().isReturnObjectDataAsBinary()) {
column.add("byte_array");
}
+ break;
default:
throw new AnalysisException("currently parquet do not support column type: " + expr.getType().getPrimitiveType());
}
@@ -438,7 +439,7 @@ private void analyzeBrokerDesc(Set processedPropKeys) throws UserExcepti
if (storageType == StorageBackend.StorageType.S3) {
S3Storage.checkS3(new CaseInsensitiveMap(brokerProps));
} else if (storageType == StorageBackend.StorageType.HDFS) {
- HDFSStorage.checkHDFS(new CaseInsensitiveMap(brokerProps));
+ HdfsStorage.checkHDFS(new CaseInsensitiveMap(brokerProps));
}
brokerDesc = new BrokerDesc(brokerName, storageType, brokerProps);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java
index c6fc843b7c50f4..7e767a994fec72 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java
@@ -56,7 +56,7 @@ public abstract class QueryStmt extends StatementBase {
/////////////////////////////////////////
// BEGIN: Members that need to be reset()
- protected WithClause withClause_;
+ protected WithClause withClause;
protected ArrayList orderByElements;
// Limit element could not be null, the default limit element is NO_LIMIT
@@ -173,10 +173,14 @@ public abstract class QueryStmt extends StatementBase {
@Override
public void analyze(Analyzer analyzer) throws AnalysisException, UserException {
- if (isAnalyzed()) return;
+ if (isAnalyzed()) {
+ return;
+ }
super.analyze(analyzer);
analyzeLimit(analyzer);
- if (hasWithClause()) withClause_.analyze(analyzer);
+ if (hasWithClause()) {
+ withClause.analyze(analyzer);
+ }
}
private void analyzeLimit(Analyzer analyzer) throws AnalysisException {
@@ -218,7 +222,9 @@ public List getCorrelatedTupleIds(Analyzer analyzer) throws AnalysisExc
List tblRefs = Lists.newArrayList();
collectTableRefs(tblRefs);
for (TableRef tblRef : tblRefs) {
- if (absoluteRef == null && !tblRef.isRelative()) absoluteRef = tblRef;
+ if (absoluteRef == null && !tblRef.isRelative()) {
+ absoluteRef = tblRef;
+ }
/*if (tblRef.isCorrelated()) {
*
* // Check if the correlated table ref is rooted at a tuple descriptor from within
@@ -385,7 +391,9 @@ protected void createSortTupleInfo(Analyzer analyzer) throws AnalysisException {
*/
protected Expr getFirstAmbiguousAlias(List exprs) {
for (Expr exp : exprs) {
- if (ambiguousAliasList.contains(exp)) return exp;
+ if (ambiguousAliasList.contains(exp)) {
+ return exp;
+ }
}
return null;
}
@@ -425,9 +433,13 @@ protected void substituteOrdinalsAliases(List exprs, String errorPrefix,
// select list items. Return null if not an ordinal expression.
private Expr trySubstituteOrdinal(Expr expr, String errorPrefix,
Analyzer analyzer) throws AnalysisException {
- if (!(expr instanceof IntLiteral)) return null;
+ if (!(expr instanceof IntLiteral)) {
+ return null;
+ }
expr.analyze(analyzer);
- if (!expr.getType().isIntegerType()) return null;
+ if (!expr.getType().isIntegerType()) {
+ return null;
+ }
long pos = ((IntLiteral) expr).getLongValue();
if (pos < 1) {
throw new AnalysisException(
@@ -444,14 +456,14 @@ private Expr trySubstituteOrdinal(Expr expr, String errorPrefix,
}
public void getWithClauseTables(Analyzer analyzer, Map tableMap, Set parentViewNameSet) throws AnalysisException {
- if (withClause_ != null) {
- withClause_.getTables(analyzer, tableMap, parentViewNameSet);
+ if (withClause != null) {
+ withClause.getTables(analyzer, tableMap, parentViewNameSet);
}
}
public void getWithClauseTableRefs(Analyzer analyzer, List tblRefs, Set parentViewNameSet) {
- if (withClause_ != null) {
- withClause_.getTableRefs(analyzer, tblRefs, parentViewNameSet);
+ if (withClause != null) {
+ withClause.getTableRefs(analyzer, tblRefs, parentViewNameSet);
}
}
@@ -560,15 +572,15 @@ public void removeOrderByElements() {
}
public void setWithClause(WithClause withClause) {
- this.withClause_ = withClause;
+ this.withClause = withClause;
}
public boolean hasWithClause() {
- return withClause_ != null;
+ return withClause != null;
}
public WithClause getWithClause() {
- return withClause_;
+ return withClause;
}
public boolean hasOrderByClause() {
@@ -689,15 +701,19 @@ public RedirectStatus getRedirectStatus() {
}
public ArrayList cloneOrderByElements() {
- if (orderByElements == null) return null;
+ if (orderByElements == null) {
+ return null;
+ }
ArrayList result =
Lists.newArrayListWithCapacity(orderByElements.size());
- for (OrderByElement o : orderByElements) result.add(o.clone());
+ for (OrderByElement o : orderByElements) {
+ result.add(o.clone());
+ }
return result;
}
public WithClause cloneWithClause() {
- return withClause_ != null ? withClause_.clone() : null;
+ return withClause != null ? withClause.clone() : null;
}
public OutFileClause cloneOutfileCluse() {
@@ -713,7 +729,7 @@ public String toDigest() {
*/
protected QueryStmt(QueryStmt other) {
super(other);
- withClause_ = other.cloneWithClause();
+ withClause = other.cloneWithClause();
outFileClause = other.cloneOutfileCluse();
orderByElements = other.cloneOrderByElements();
limitElement = other.limitElement.clone();
@@ -730,8 +746,9 @@ protected QueryStmt(QueryStmt other) {
public void reset() {
super.reset();
if (orderByElements != null) {
- for (OrderByElement o : orderByElements)
+ for (OrderByElement o : orderByElements) {
o.getExpr().reset();
+ }
}
limitElement.reset();
resultExprs.clear();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index c2f3d32c357102..d861d63d2b0e37 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -79,7 +79,7 @@ public class SelectStmt extends QueryStmt {
protected SelectList selectList;
private final ArrayList colLabels; // lower case column labels
- protected final FromClause fromClause_;
+ protected final FromClause fromClause;
protected GroupByClause groupByClause;
private List originalExpr;
//
@@ -111,7 +111,7 @@ public class SelectStmt extends QueryStmt {
// SQL string of this SelectStmt before inline-view expression substitution.
// Set in analyze().
- protected String sqlString_;
+ protected String sqlString;
// Table alias generator used during query rewriting.
private TableAliasGenerator tableAliasGenerator = null;
@@ -123,7 +123,7 @@ public SelectStmt(ValueList valueList, ArrayList orderByElement,
super(orderByElement, limitElement);
this.valueList = valueList;
this.selectList = new SelectList();
- this.fromClause_ = new FromClause();
+ this.fromClause = new FromClause();
this.colLabels = Lists.newArrayList();
}
@@ -139,9 +139,9 @@ public SelectStmt(ValueList valueList, ArrayList orderByElement,
this.selectList = selectList;
this.originSelectList = selectList.clone();
if (fromClause == null) {
- fromClause_ = new FromClause();
+ this.fromClause = new FromClause();
} else {
- fromClause_ = fromClause;
+ this.fromClause = fromClause;
}
this.whereClause = wherePredicate;
this.groupByClause = groupByClause;
@@ -158,7 +158,7 @@ protected SelectStmt(SelectStmt other) {
super(other);
this.id = other.id;
selectList = other.selectList.clone();
- fromClause_ = other.fromClause_.clone();
+ fromClause = other.fromClause.clone();
whereClause = (other.whereClause != null) ? other.whereClause.clone() : null;
groupByClause = (other.groupByClause != null) ? other.groupByClause.clone() : null;
havingClause = (other.havingClause != null) ? other.havingClause.clone() : null;
@@ -166,7 +166,7 @@ protected SelectStmt(SelectStmt other) {
colLabels = Lists.newArrayList(other.colLabels);
aggInfo = (other.aggInfo != null) ? other.aggInfo.clone() : null;
analyticInfo = (other.analyticInfo != null) ? other.analyticInfo.clone() : null;
- sqlString_ = (other.sqlString_ != null) ? other.sqlString_ : null;
+ sqlString = (other.sqlString != null) ? other.sqlString : null;
baseTblSmap = other.baseTblSmap.clone();
groupingInfo = null;
}
@@ -176,7 +176,7 @@ public void reset() {
super.reset();
selectList.reset();
colLabels.clear();
- fromClause_.reset();
+ fromClause.reset();
if (whereClause != null) {
whereClause.reset();
}
@@ -237,7 +237,7 @@ public Expr getHavingClauseAfterAnaylzed() {
}
public List getTableRefs() {
- return fromClause_.getTableRefs();
+ return fromClause.getTableRefs();
}
public Expr getWhereClause() {
@@ -293,7 +293,7 @@ public ExprSubstitutionMap getBaseTblSmap() {
@Override
public void getTables(Analyzer analyzer, Map tableMap, Set parentViewNameSet) throws AnalysisException {
getWithClauseTables(analyzer, tableMap, parentViewNameSet);
- for (TableRef tblRef : fromClause_) {
+ for (TableRef tblRef : fromClause) {
if (tblRef instanceof InlineViewRef) {
// Inline view reference
QueryStmt inlineStmt = ((InlineViewRef) tblRef).getViewStmt();
@@ -335,7 +335,7 @@ public void getTables(Analyzer analyzer, Map tableMap, Set
@Override
public void getTableRefs(Analyzer analyzer, List tblRefs, Set parentViewNameSet) {
getWithClauseTableRefs(analyzer, tblRefs, parentViewNameSet);
- for (TableRef tblRef : fromClause_) {
+ for (TableRef tblRef : fromClause) {
try {
TableRef tmpTblRef = analyzer.resolveTableRef(tblRef);
if (tmpTblRef instanceof InlineViewRef) {
@@ -360,8 +360,8 @@ private boolean isViewTableRef(String tblName, Set parentViewNameSet) {
return true;
}
- if (withClause_ != null) {
- List views = withClause_.getViews();
+ if (withClause != null) {
+ List views = withClause.getViews();
for (View view : views) {
if (view.getName().equals(tblName)) {
return true;
@@ -398,8 +398,8 @@ public void analyze(Analyzer analyzer) throws UserException {
return;
}
super.analyze(analyzer);
- fromClause_.setNeedToSql(needToSql);
- fromClause_.analyze(analyzer);
+ fromClause.setNeedToSql(needToSql);
+ fromClause.analyze(analyzer);
// Generate !empty() predicates to filter out empty collections.
// Skip this step when analyzing a WITH-clause because CollectionTableRefs
@@ -483,7 +483,7 @@ public void analyze(Analyzer analyzer) throws UserException {
// analyze selectListExprs
Expr.analyze(resultExprs, analyzer);
if (TreeNode.contains(resultExprs, AnalyticExpr.class)) {
- if (fromClause_.isEmpty()) {
+ if (fromClause.isEmpty()) {
throw new AnalysisException("Analytic expressions require FROM clause.");
}
@@ -539,7 +539,7 @@ public void analyze(Analyzer analyzer) throws UserException {
}
if (needToSql) {
- sqlString_ = toSql();
+ sqlString = toSql();
}
if (analyzer.enableStarJoinReorder()) {
LOG.debug("use old reorder logical in select stmt");
@@ -565,7 +565,7 @@ public void analyze(Analyzer analyzer) throws UserException {
public List getTableRefIds() {
List result = Lists.newArrayList();
- for (TableRef ref : fromClause_) {
+ for (TableRef ref : fromClause) {
result.add(ref.getId());
}
@@ -575,7 +575,7 @@ public List getTableRefIds() {
public List getTableRefIdsWithoutInlineView() {
List result = Lists.newArrayList();
- for (TableRef ref : fromClause_) {
+ for (TableRef ref : fromClause) {
if (ref instanceof InlineViewRef) {
continue;
}
@@ -586,7 +586,7 @@ public List getTableRefIdsWithoutInlineView() {
}
public boolean hasInlineView() {
- for (TableRef ref : fromClause_) {
+ for (TableRef ref : fromClause) {
if (ref instanceof InlineViewRef) {
return true;
}
@@ -724,7 +724,7 @@ public void materializeRequiredSlots(Analyzer analyzer) throws AnalysisException
}
// materialized all lateral view column and origin column
- for (TableRef tableRef : fromClause_.getTableRefs()) {
+ for (TableRef tableRef : fromClause.getTableRefs()) {
if (tableRef.lateralViewRefs != null) {
for (LateralViewRef lateralViewRef : tableRef.lateralViewRefs) {
lateralViewRef.materializeRequiredSlots(baseTblSmap, analyzer);
@@ -737,7 +737,7 @@ protected void reorderTable(Analyzer analyzer) throws AnalysisException {
List> candidates = Lists.newArrayList();
// New pair of table ref and row count
- for (TableRef tblRef : fromClause_) {
+ for (TableRef tblRef : fromClause) {
if (tblRef.getJoinOp() != JoinOperator.INNER_JOIN || tblRef.hasJoinHints()) {
// Unsupported reorder outer join
return;
@@ -772,9 +772,9 @@ protected void reorderTable(Analyzer analyzer) throws AnalysisException {
}
// can not get AST only with equal join, MayBe cross join can help
- fromClause_.clear();
+ fromClause.clear();
for (Pair candidate : candidates) {
- fromClause_.add(candidate.first);
+ fromClause.add(candidate.first);
}
}
@@ -785,14 +785,14 @@ protected boolean reorderTable(Analyzer analyzer, TableRef firstRef)
Map tableRefMap = Maps.newHashMap();
// set Map and push list
- for (TableRef tblRef : fromClause_) {
+ for (TableRef tblRef : fromClause) {
tableRefMap.put(tblRef.getId(), tblRef);
tmpRefList.add(tblRef);
}
// clear tableRefList
- fromClause_.clear();
+ fromClause.clear();
// mark first table
- fromClause_.add(firstRef);
+ fromClause.add(firstRef);
tableRefMap.remove(firstRef.getId());
// reserve TupleId has been added successfully
@@ -800,13 +800,13 @@ protected boolean reorderTable(Analyzer analyzer, TableRef firstRef)
validTupleId.add(firstRef.getId());
// find table
int i = 0;
- while (i < fromClause_.size()) {
- TableRef tblRef = fromClause_.get(i);
+ while (i < fromClause.size()) {
+ TableRef tblRef = fromClause.get(i);
// get all equal
List eqJoinPredicates = analyzer.getEqJoinConjuncts(tblRef.getId());
- List tuple_list = Lists.newArrayList();
- Expr.getIds(eqJoinPredicates, tuple_list, null);
- for (TupleId tid : tuple_list) {
+ List tupleList = Lists.newArrayList();
+ Expr.getIds(eqJoinPredicates, tupleList, null);
+ for (TupleId tid : tupleList) {
if (validTupleId.contains(tid)) {
// tid has allreday in the list of validTupleId, ignore it
continue;
@@ -829,7 +829,7 @@ protected boolean reorderTable(Analyzer analyzer, TableRef firstRef)
}
if (count == 0) {
- fromClause_.add(candidateTableRef);
+ fromClause.add(candidateTableRef);
validTupleId.add(tid);
tableRefMap.remove(tid);
}
@@ -839,8 +839,8 @@ protected boolean reorderTable(Analyzer analyzer, TableRef firstRef)
}
// find path failed.
if (0 != tableRefMap.size()) {
- fromClause_.clear();
- fromClause_.addAll(tmpRefList);
+ fromClause.clear();
+ fromClause.addAll(tmpRefList);
return false;
}
return true;
@@ -852,7 +852,7 @@ protected boolean reorderTable(Analyzer analyzer, TableRef firstRef)
*/
protected void resolveInlineViewRefs(Analyzer analyzer) throws AnalysisException {
// Gather the inline view substitution maps from the enclosed inline views
- for (TableRef tblRef : fromClause_) {
+ for (TableRef tblRef : fromClause) {
if (tblRef instanceof InlineViewRef) {
InlineViewRef inlineViewRef = (InlineViewRef) tblRef;
baseTblSmap = ExprSubstitutionMap.combine(baseTblSmap, inlineViewRef.getBaseTblSmap());
@@ -871,11 +871,11 @@ protected void resolveInlineViewRefs(Analyzer analyzer) throws AnalysisException
* Expand "*" select list item.
*/
private void expandStar(Analyzer analyzer) throws AnalysisException {
- if (fromClause_.isEmpty()) {
+ if (fromClause.isEmpty()) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_NO_TABLES_USED);
}
// expand in From clause order
- for (TableRef tableRef : fromClause_) {
+ for (TableRef tableRef : fromClause) {
if (analyzer.isSemiJoined(tableRef.getId())) {
continue;
}
@@ -976,7 +976,7 @@ private void analyzeAggregation(Analyzer analyzer) throws AnalysisException {
}
// If we're computing an aggregate, we must have a FROM clause.
- if (fromClause_.size() == 0) {
+ if (fromClause.size() == 0) {
throw new AnalysisException("Aggregation without a FROM clause is not allowed");
}
@@ -1332,7 +1332,7 @@ private void createAnalyticInfo(Analyzer analyzer) throws AnalysisException {
public void rewriteExprs(ExprRewriter rewriter) throws AnalysisException {
Preconditions.checkState(isAnalyzed());
rewriteSelectList(rewriter);
- for (TableRef ref : fromClause_) {
+ for (TableRef ref : fromClause) {
ref.rewriteExprs(rewriter, analyzer);
}
// Also equal exprs in the statements of subqueries.
@@ -1388,7 +1388,7 @@ public void collectExprs(Map exprMap) {
}
// from clause
- for (TableRef ref : fromClause_) {
+ for (TableRef ref : fromClause) {
Preconditions.checkState(ref.isAnalyzed);
if (ref.onClause != null) {
registerExprId(ref.onClause);
@@ -1499,7 +1499,7 @@ public void putBackExprs(Map rewrittenExprMap) {
}
// from clause
- for (TableRef ref : fromClause_) {
+ for (TableRef ref : fromClause) {
if (ref.onClause != null) {
ref.setOnClause(rewrittenExprMap.get(ref.onClause.getId().toString()));
}
@@ -1627,7 +1627,7 @@ private Expr rewriteSubquery(Expr expr, Analyzer analyzer)
} catch (UserException e) {
throw new AnalysisException(e.getMessage());
}
- fromClause_.add(inlineViewRef);
+ fromClause.add(inlineViewRef);
expr = new SlotRef(inlineViewRef.getAliasAsName(), colAlias);
} else if (CollectionUtils.isNotEmpty(expr.getChildren())) {
for (int i = 0; i < expr.getChildren().size(); ++i) {
@@ -1639,12 +1639,12 @@ private Expr rewriteSubquery(Expr expr, Analyzer analyzer)
@Override
public String toSql() {
- if (sqlString_ != null) {
- return sqlString_;
+ if (sqlString != null) {
+ return sqlString;
}
StringBuilder strBuilder = new StringBuilder();
- if (withClause_ != null) {
- strBuilder.append(withClause_.toSql());
+ if (withClause != null) {
+ strBuilder.append(withClause.toSql());
strBuilder.append(" ");
}
@@ -1668,8 +1668,8 @@ public String toSql() {
}
// From clause
- if (!fromClause_.isEmpty()) {
- strBuilder.append(fromClause_.toSql());
+ if (!fromClause.isEmpty()) {
+ strBuilder.append(fromClause.toSql());
}
// Where clause
@@ -1712,8 +1712,8 @@ public String toSql() {
@Override
public String toDigest() {
StringBuilder strBuilder = new StringBuilder();
- if (withClause_ != null) {
- strBuilder.append(withClause_.toDigest());
+ if (withClause != null) {
+ strBuilder.append(withClause.toDigest());
strBuilder.append(" ");
}
@@ -1745,8 +1745,8 @@ public String toDigest() {
}
// From clause
- if (!fromClause_.isEmpty()) {
- strBuilder.append(fromClause_.toDigest());
+ if (!fromClause.isEmpty()) {
+ strBuilder.append(fromClause.toDigest());
}
// Where clause
@@ -1807,7 +1807,7 @@ public void getMaterializedTupleIds(ArrayList tupleIdList) {
tupleIdList.add(aggInfo.getOutputTupleId());
}
} else {
- for (TableRef tblRef : fromClause_) {
+ for (TableRef tblRef : fromClause) {
tupleIdList.addAll(tblRef.getMaterializedTupleIds());
}
}
@@ -1824,16 +1824,16 @@ public void substituteSelectList(Analyzer analyzer, List newColLabels)
throws AnalysisException, UserException {
// analyze with clause
if (hasWithClause()) {
- withClause_.analyze(analyzer);
+ withClause.analyze(analyzer);
}
// start out with table refs to establish aliases
TableRef leftTblRef = null; // the one to the left of tblRef
- for (int i = 0; i < fromClause_.size(); ++i) {
+ for (int i = 0; i < fromClause.size(); ++i) {
// Resolve and replace non-InlineViewRef table refs with a BaseTableRef or ViewRef.
- TableRef tblRef = fromClause_.get(i);
+ TableRef tblRef = fromClause.get(i);
tblRef = analyzer.resolveTableRef(tblRef);
Preconditions.checkNotNull(tblRef);
- fromClause_.set(i, tblRef);
+ fromClause.set(i, tblRef);
tblRef.setLeftTblRef(leftTblRef);
tblRef.analyze(analyzer);
leftTblRef = tblRef;
@@ -1908,7 +1908,7 @@ public boolean returnsSingleRow() {
return true;
}
// No from clause (base tables or inline views)
- if (fromClause_.isEmpty()) {
+ if (fromClause.isEmpty()) {
return true;
}
// Aggregation with no group by and no DISTINCT
@@ -1921,7 +1921,7 @@ public boolean returnsSingleRow() {
@Override
public void collectTableRefs(List tblRefs) {
- for (TableRef tblRef : fromClause_) {
+ for (TableRef tblRef : fromClause) {
if (tblRef instanceof InlineViewRef) {
InlineViewRef inlineViewRef = (InlineViewRef) tblRef;
inlineViewRef.getViewStmt().collectTableRefs(tblRefs);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetOperationStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetOperationStmt.java
index 976e13eb0c1295..5ffac6a0b71e27 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetOperationStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetOperationStmt.java
@@ -71,12 +71,12 @@ public enum Qualifier {
// filled during analyze(); contains all operands that need to go through
// distinct aggregation
- protected final List distinctOperands_ = Lists.newArrayList();
+ protected final List distinctOperands = Lists.newArrayList();
// filled during analyze(); contains all operands that can be aggregated with
// a simple merge without duplicate elimination (also needs to merge the output
// of the DISTINCT operands)
- protected final List allOperands_ = Lists.newArrayList();
+ protected final List allOperands = Lists.newArrayList();
private AggregateInfo distinctAggInfo; // only set if we have DISTINCT ops
@@ -89,11 +89,11 @@ public enum Qualifier {
private String toSqlString;
// true if any of the operands_ references an AnalyticExpr
- private boolean hasAnalyticExprs_ = false;
+ private boolean hasAnalyticExprs = false;
// List of output expressions produced by the set operation without the ORDER BY portion
// (if any). Same as resultExprs_ if there is no ORDER BY.
- private List setOpsResultExprs_ = Lists.newArrayList();
+ private List setOpsResultExprs = Lists.newArrayList();
// END: Members that need to be reset()
/////////////////////////////////////////
@@ -114,21 +114,27 @@ protected SetOperationStmt(SetOperationStmt other) {
(other.limitElement == null) ? null : other.limitElement.clone());
operands = Lists.newArrayList();
if (analyzer != null) {
- for (SetOperand o: other.distinctOperands_) distinctOperands_.add(o.clone());
- for (SetOperand o: other.allOperands_) allOperands_.add(o.clone());
- operands.addAll(distinctOperands_);
- operands.addAll(allOperands_);
+ for (SetOperand o: other.distinctOperands) {
+ distinctOperands.add(o.clone());
+ }
+ for (SetOperand o: other.allOperands) {
+ allOperands.add(o.clone());
+ }
+ operands.addAll(distinctOperands);
+ operands.addAll(allOperands);
} else {
- for (SetOperand operand: other.operands) operands.add(operand.clone());
+ for (SetOperand operand: other.operands) {
+ operands.add(operand.clone());
+ }
}
analyzer = other.analyzer;
distinctAggInfo =
(other.distinctAggInfo != null) ? other.distinctAggInfo.clone() : null;
tupleId = other.tupleId;
toSqlString = (other.toSqlString != null) ? new String(other.toSqlString) : null;
- hasAnalyticExprs_ = other.hasAnalyticExprs_;
- withClause_ = (other.withClause_ != null) ? other.withClause_.clone() : null;
- setOpsResultExprs_ = Expr.cloneList(other.setOpsResultExprs_);
+ hasAnalyticExprs = other.hasAnalyticExprs;
+ withClause = (other.withClause != null) ? other.withClause.clone() : null;
+ setOpsResultExprs = Expr.cloneList(other.setOpsResultExprs);
}
@Override
@@ -144,14 +150,16 @@ protected SetOperationStmt(SetOperationStmt other) {
@Override
public void reset() {
super.reset();
- for (SetOperand op: operands) op.reset();
- distinctOperands_.clear();
- allOperands_.clear();
+ for (SetOperand op: operands) {
+ op.reset();
+ }
+ distinctOperands.clear();
+ allOperands.clear();
distinctAggInfo = null;
tupleId = null;
toSqlString = null;
- hasAnalyticExprs_ = false;
- setOpsResultExprs_.clear();
+ hasAnalyticExprs = false;
+ setOpsResultExprs.clear();
}
@Override
@@ -162,20 +170,20 @@ public void resetSelectList() {
}
public List getOperands() { return operands; }
- public List getDistinctOperands() { return distinctOperands_; }
- public boolean hasDistinctOps() { return !distinctOperands_.isEmpty(); }
- public List getAllOperands() { return allOperands_; }
- public boolean hasAllOps() { return !allOperands_.isEmpty(); }
+ public List getDistinctOperands() { return distinctOperands; }
+ public boolean hasDistinctOps() { return !distinctOperands.isEmpty(); }
+ public List getAllOperands() { return allOperands; }
+ public boolean hasAllOps() { return !allOperands.isEmpty(); }
public AggregateInfo getDistinctAggInfo() { return distinctAggInfo; }
- public boolean hasAnalyticExprs() { return hasAnalyticExprs_; }
+ public boolean hasAnalyticExprs() { return hasAnalyticExprs; }
public TupleId getTupleId() { return tupleId; }
public void removeAllOperands() {
- operands.removeAll(allOperands_);
- allOperands_.clear();
+ operands.removeAll(allOperands);
+ allOperands.clear();
}
- public List getSetOpsResultExprs() { return setOpsResultExprs_; }
+ public List getSetOpsResultExprs() { return setOpsResultExprs; }
@Override
public void getTables(Analyzer analyzer, Map tableMap, Set parentViewNameSet) throws AnalysisException {
@@ -199,7 +207,9 @@ public void getTableRefs(Analyzer analyzer, List tblRefs, Set
*/
@Override
public void analyze(Analyzer analyzer) throws UserException {
- if (isAnalyzed()) return;
+ if (isAnalyzed()) {
+ return;
+ }
super.analyze(analyzer);
Preconditions.checkState(operands.size() > 0);
@@ -225,10 +235,10 @@ public void analyze(Analyzer analyzer) throws UserException {
unnestOperands(analyzer);
// Compute hasAnalyticExprs_
- hasAnalyticExprs_ = false;
+ hasAnalyticExprs = false;
for (SetOperand op: operands) {
if (op.hasAnalyticExprs()) {
- hasAnalyticExprs_ = true;
+ hasAnalyticExprs = true;
break;
}
}
@@ -246,10 +256,12 @@ public void analyze(Analyzer analyzer) throws UserException {
createSortInfo(analyzer);
// Create unnested operands' smaps.
- for (SetOperand operand: operands) setOperandSmap(operand, analyzer);
+ for (SetOperand operand: operands) {
+ setOperandSmap(operand, analyzer);
+ }
// Create distinctAggInfo, if necessary.
- if (!distinctOperands_.isEmpty()) {
+ if (!distinctOperands.isEmpty()) {
// Aggregate produces exactly the same tuple as the original setOp stmt.
ArrayList groupingExprs = Expr.cloneList(resultExprs);
try {
@@ -261,11 +273,15 @@ public void analyze(Analyzer analyzer) throws UserException {
}
}
- setOpsResultExprs_ = Expr.cloneList(resultExprs);
- if (evaluateOrderBy) createSortTupleInfo(analyzer);
+ setOpsResultExprs = Expr.cloneList(resultExprs);
+ if (evaluateOrderBy) {
+ createSortTupleInfo(analyzer);
+ }
baseTblResultExprs = resultExprs;
- if (hasOutFileClause()) outFileClause.analyze(analyzer, resultExprs);
+ if (hasOutFileClause()) {
+ outFileClause.analyze(analyzer, resultExprs);
+ }
}
/**
@@ -296,7 +312,7 @@ private void analyzeOperands(Analyzer analyzer) throws AnalysisException, UserEx
private void unnestOperands(Analyzer analyzer) throws AnalysisException {
if (operands.size() == 1) {
// ValuesStmt for a single row.
- allOperands_.add(operands.get(0));
+ allOperands.add(operands.get(0));
return;
}
// find index of first ALL operand
@@ -313,23 +329,27 @@ private void unnestOperands(Analyzer analyzer) throws AnalysisException {
Preconditions.checkState(firstAllIdx != 1);
// unnest DISTINCT operands
- Preconditions.checkState(distinctOperands_.isEmpty());
+ Preconditions.checkState(distinctOperands.isEmpty());
for (int i = 0; i < firstAllIdx; ++i) {
- unnestOperand(distinctOperands_, Qualifier.DISTINCT, operands.get(i));
+ unnestOperand(distinctOperands, Qualifier.DISTINCT, operands.get(i));
}
// unnest ALL operands
- Preconditions.checkState(allOperands_.isEmpty());
+ Preconditions.checkState(allOperands.isEmpty());
for (int i = firstAllIdx; i < operands.size(); ++i) {
- unnestOperand(allOperands_, Qualifier.ALL, operands.get(i));
+ unnestOperand(allOperands, Qualifier.ALL, operands.get(i));
}
- for (SetOperand op: distinctOperands_) op.setQualifier(Qualifier.DISTINCT);
- for (SetOperand op: allOperands_) op.setQualifier(Qualifier.ALL);
+ for (SetOperand op: distinctOperands) {
+ op.setQualifier(Qualifier.DISTINCT);
+ }
+ for (SetOperand op: allOperands) {
+ op.setQualifier(Qualifier.ALL);
+ }
operands.clear();
- operands.addAll(distinctOperands_);
- operands.addAll(allOperands_);
+ operands.addAll(distinctOperands);
+ operands.addAll(allOperands);
}
/**
@@ -487,10 +507,16 @@ private void createMetadata(Analyzer analyzer) throws AnalysisException {
if (slotRef == null) {
isNullable |= resultExpr.isNullable();
} else if (slotRef.getDesc().getIsNullable()
- || analyzer.isOuterJoined(slotRef.getDesc().getParent().getId())) isNullable = true;
- if (op.hasAnalyticExprs()) continue;
+ || analyzer.isOuterJoined(slotRef.getDesc().getParent().getId())) {
+ isNullable = true;
+ }
+ if (op.hasAnalyticExprs()) {
+ continue;
+ }
slotRef = resultExpr.unwrapSlotRef(true);
- if (slotRef == null) continue;
+ if (slotRef == null) {
+ continue;
+ }
// analyzer.registerValueTransfer(outputSlotRef.getSlotId(), slotRef.getSlotId());
}
// If all the child slots are not nullable, then the SetOps output slot should not
@@ -510,16 +536,22 @@ public void materializeRequiredSlots(Analyzer analyzer) throws AnalysisException
TupleDescriptor tupleDesc = analyzer.getDescTbl().getTupleDesc(tupleId);
// to keep things simple we materialize all grouping exprs = output slots,
// regardless of what's being referenced externally
- if (!distinctOperands_.isEmpty()) tupleDesc.materializeSlots();
+ if (!distinctOperands.isEmpty()) {
+ tupleDesc.materializeSlots();
+ }
- if (evaluateOrderBy) sortInfo.materializeRequiredSlots(analyzer, null);
+ if (evaluateOrderBy) {
+ sortInfo.materializeRequiredSlots(analyzer, null);
+ }
// collect operands' result exprs
List outputSlots = tupleDesc.getSlots();
List exprs = Lists.newArrayList();
for (int i = 0; i < outputSlots.size(); ++i) {
SlotDescriptor slotDesc = outputSlots.get(i);
- if (!slotDesc.isMaterialized()) continue;
+ if (!slotDesc.isMaterialized()) {
+ continue;
+ }
for (SetOperand op: operands) {
exprs.add(op.getQueryStmt().getBaseTblResultExprs().get(i));
}
@@ -574,7 +606,9 @@ public void putBackExprs(Map rewrittenExprMap) {
@Override
public void rewriteExprs(ExprRewriter rewriter) throws AnalysisException {
- for (SetOperand op: operands) op.getQueryStmt().rewriteExprs(rewriter);
+ for (SetOperand op: operands) {
+ op.getQueryStmt().rewriteExprs(rewriter);
+ }
if (orderByElements != null) {
for (OrderByElement orderByElem: orderByElements) {
orderByElem.setExpr(rewriter.rewrite(orderByElem.getExpr(), analyzer));
@@ -594,13 +628,17 @@ public void getMaterializedTupleIds(ArrayList tupleIdList) {
@Override
public void collectTableRefs(List tblRefs) {
- for (SetOperand op: operands) op.getQueryStmt().collectTableRefs(tblRefs);
+ for (SetOperand op: operands) {
+ op.getQueryStmt().collectTableRefs(tblRefs);
+ }
}
@Override
public List