http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanExpressionUnitTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanExpressionUnitTest.java b/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanExpressionUnitTest.java index 38a7222..5391861 100644 --- a/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanExpressionUnitTest.java +++ b/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanExpressionUnitTest.java @@ -106,6 +106,40 @@ public class GreaterThanExpressionUnitTest { } + @Test public void testEvaluateForGreaterThanExpressionWithShortDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression right = new ColumnExpression("id", DataTypes.SHORT); + right.setColIndex(0); + ColumnExpression left = new ColumnExpression("id", DataTypes.SHORT); + left.setColIndex(1); + greaterThanExpression = new GreaterThanExpression(left, right); + RowImpl value = new RowImpl(); + Short[] row = { 170 }; + Short[] row1 = { 70 }; + Object objectRow[] = { row, row1 }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public Short getShort() { + if (returnMockFlag) { + returnMockFlag = false; + return 70; + + } else { + return 170; + + } + + } + }; + + ExpressionResult result = greaterThanExpression.evaluate(value); + assertFalse(result.getBoolean()); + + } + @Test public void testEvaluateForGreaterThanExpressionWithDoubleDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("right_contact", DataTypes.DOUBLE); @@ -217,6 +251,51 @@ public class GreaterThanExpressionUnitTest { } } + @Test public void testEvaluateForGreaterThanExpressionWithTimestampDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + try { + ColumnExpression left = new ColumnExpression("timestamp", DataTypes.TIMESTAMP); + left.setColIndex(0); + ColumnExpression right = new ColumnExpression("timestamp", DataTypes.TIMESTAMP); + right.setColIndex(1); + + greaterThanExpression = new GreaterThanExpression(left, right); + + RowImpl value = new RowImpl(); + + DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); + + Date date = dateFormat.parse("23/09/2007"); + long time = date.getTime(); + Timestamp[] row = { new Timestamp(time) }; + + Date date1 = dateFormat.parse("24/09/2007"); + long time1 = date1.getTime(); + Timestamp[] row1 = { new Timestamp(time1) }; + + Object objectRow[] = { row1, row }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public Long getTime() { + if (returnMockFlag) { + returnMockFlag = false; + return 1190505600L; + } else { + return 1190592000L; + } + } + }; + + ExpressionResult result = greaterThanExpression.evaluate(value); + assertFalse(result.getBoolean()); + } catch (ParseException e) { + System.out.println("Error while parsing " + e.getMessage()); + } + } + @Test public void testEvaluateForGreaterThanExpressionWithLongDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("contact", DataTypes.LONG); @@ -247,6 +326,36 @@ public class GreaterThanExpressionUnitTest { assertTrue(result.getBoolean()); } + @Test public void testEvaluateForGreaterThanExpressionWithLongDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression right = new ColumnExpression("contact", DataTypes.LONG); + right.setColIndex(0); + ColumnExpression left = new ColumnExpression("contact", DataTypes.LONG); + left.setColIndex(1); + greaterThanExpression = new GreaterThanExpression(left, right); + RowImpl value = new RowImpl(); + Long[] row = { 1234567654321L }; + Long[] row1 = { 123456765432234L }; + Object objectRow[] = { row1, row }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public Long getLong() { + if (returnMockFlag) { + returnMockFlag = false; + return 1234567654321L; + } else { + return 123456765432234L; + } + } + }; + + ExpressionResult result = greaterThanExpression.evaluate(value); + assertFalse(result.getBoolean()); + } + @Test public void testEvaluateForGreaterThanExpressionWithDecimalDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("contact", DataTypes.createDefaultDecimalType()); @@ -277,6 +386,36 @@ public class GreaterThanExpressionUnitTest { assertTrue(result.getBoolean()); } + @Test public void testEvaluateForGreaterThanExpressionWithDecimalDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression right = new ColumnExpression("contact", DataTypes.createDefaultDecimalType()); + right.setColIndex(0); + ColumnExpression left = new ColumnExpression("contact", DataTypes.createDefaultDecimalType()); + left.setColIndex(1); + greaterThanExpression = new GreaterThanExpression(left, right); + RowImpl value = new RowImpl(); + BigDecimal[] row = new BigDecimal[] { new BigDecimal(12345.0) }; + BigDecimal[] row1 = new BigDecimal[] { new BigDecimal(123451245.0) }; + Object objectRow[] = { row1, row }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public BigDecimal getDecimal() { + if (returnMockFlag) { + returnMockFlag = false; + return new BigDecimal(12345.0); + } else { + return new BigDecimal(123451245.0); + } + } + }; + + ExpressionResult result = greaterThanExpression.evaluate(value); + assertFalse(result.getBoolean()); + } + @Test public void testForGreaterThanExpressionWithDefaultCase() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("contact", DataTypes.BOOLEAN); @@ -316,6 +455,38 @@ public class GreaterThanExpressionUnitTest { } + @Test public void testEvaluateForGreaterThanExpressionWithIsNullReturnTrue1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression right = new ColumnExpression("id", DataTypes.SHORT); + right.setColIndex(0); + greaterThanExpression = new GreaterThanExpression(right, right); + RowImpl value = new RowImpl(); + Short[] row = { 15 }; + Object objectRow[] = { row }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + boolean isFirst = true; + @Mock public boolean isNull() { + if (isFirst) { + isFirst = false; + return false; + } + return true; + } + }; + + new MockUp<ExpressionResult>() { + @Mock public Short getShort() { + return 15; + } + }; + + ExpressionResult result = greaterThanExpression.evaluate(value); + assertFalse(result.getBoolean()); + + } + @Test public void testEvaluateForGreaterThanExpressionWithLeftAndRightDifferentDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression left = new ColumnExpression("name", DataTypes.STRING); @@ -348,6 +519,38 @@ public class GreaterThanExpressionUnitTest { assertTrue(result.getBoolean()); } + @Test public void testEvaluateForGreaterThanExpressionWithLeftAndRightDifferentDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression left = new ColumnExpression("name", DataTypes.INT); + left.setColIndex(0); + ColumnExpression right = new ColumnExpression("number", DataTypes.STRING); + right.setColIndex(1); + greaterThanExpression = new GreaterThanExpression(left, right); + RowImpl value = new RowImpl(); + String[] row = { "String1" }; + Integer[] row1 = { 14 }; + Object objectRow[] = { row1, row }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public Integer getInt() { + if (returnMockFlag) { + returnMockFlag = false; + return 15; + } else { + return 14; + + } + + } + }; + + ExpressionResult result = greaterThanExpression.evaluate(value); + assertTrue(result.getBoolean()); + } + @Test public void testForGreaterThanExpressionWithGetString() throws Exception { ColumnExpression right = new ColumnExpression("right_name", DataTypes.STRING); right.setColIndex(0);
http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/LessThanEqualToExpressionUnitTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/LessThanEqualToExpressionUnitTest.java b/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/LessThanEqualToExpressionUnitTest.java index d3c8cf4..14594e7 100644 --- a/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/LessThanEqualToExpressionUnitTest.java +++ b/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/LessThanEqualToExpressionUnitTest.java @@ -109,6 +109,40 @@ public class LessThanEqualToExpressionUnitTest { } + @Test public void testEvaluateForLessThanEqualToExpressionWithShortDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression right = new ColumnExpression("id", DataTypes.SHORT); + right.setColIndex(0); + ColumnExpression left = new ColumnExpression("id", DataTypes.SHORT); + left.setColIndex(1); + lessThanEqualToExpression = new LessThanEqualToExpression(left, right); + RowImpl value = new RowImpl(); + Short[] row = { 1550 }; + Short[] row1 = { 3365 }; + Object objectRow[] = { row, row1 }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public Short getShort() { + if (returnMockFlag) { + returnMockFlag = false; + return 3365; + + } else { + return 1550; + + } + + } + }; + + ExpressionResult result = lessThanEqualToExpression.evaluate(value); + assertFalse(result.getBoolean()); + + } + @Test public void testEvaluateForLessThanEqualToExpressionWithDoubleDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("right_contact", DataTypes.DOUBLE); @@ -220,6 +254,51 @@ public class LessThanEqualToExpressionUnitTest { } } + @Test public void testEvaluateForLessThanEqualToExpressionWithTimestampDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + try { + ColumnExpression left = new ColumnExpression("timestamp", DataTypes.TIMESTAMP); + left.setColIndex(0); + ColumnExpression right = new ColumnExpression("timestamp", DataTypes.TIMESTAMP); + right.setColIndex(1); + + lessThanEqualToExpression = new LessThanEqualToExpression(left, right); + + RowImpl value = new RowImpl(); + + DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); + + Date date = dateFormat.parse("23/09/2007"); + long time = date.getTime(); + Timestamp[] row = { new Timestamp(time) }; + + Date date1 = dateFormat.parse("24/09/2007"); + long time1 = date1.getTime(); + Timestamp[] row1 = { new Timestamp(time1) }; + + Object objectRow[] = { row, row1 }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public Long getTime() { + if (returnMockFlag) { + returnMockFlag = false; + return 1190592000L; + } else { + return 1190505600L; + } + } + }; + + ExpressionResult result = lessThanEqualToExpression.evaluate(value); + assertFalse(result.getBoolean()); + } catch (ParseException e) { + System.out.println("Error while parsing " + e.getMessage()); + } + } + @Test public void testEvaluateForLessThanEqualToExpressionWithLongDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("right_contact", DataTypes.LONG); @@ -280,6 +359,38 @@ public class LessThanEqualToExpressionUnitTest { assertTrue(result.getBoolean()); } + @Test public void testEvaluateForLessThanEqualToExpressionWithDecimalDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression right = + new ColumnExpression("right_contact", DataTypes.createDefaultDecimalType()); + right.setColIndex(0); + ColumnExpression left = + new ColumnExpression("left_contact", DataTypes.createDefaultDecimalType()); + left.setColIndex(1); + lessThanEqualToExpression = new LessThanEqualToExpression(left, right); + RowImpl value = new RowImpl(); + BigDecimal[] row = new BigDecimal[] { new BigDecimal(46851.2) }; + BigDecimal[] row1 = new BigDecimal[] { new BigDecimal(45821.02) }; + Object objectRow[] = { row1, row }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public BigDecimal getDecimal() { + if (returnMockFlag) { + returnMockFlag = false; + return new BigDecimal(46851.2); + } else { + return new BigDecimal(45821.02); + } + } + }; + + ExpressionResult result = lessThanEqualToExpression.evaluate(value); + assertFalse(result.getBoolean()); + } + @Test public void testForLessThanEqualToExpressionWithDefaultCase() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("contact", DataTypes.BOOLEAN); @@ -319,6 +430,38 @@ public class LessThanEqualToExpressionUnitTest { } + @Test public void testEvaluateForLessThanEqualToExpressionWithIsNullReturnTrue1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression right = new ColumnExpression("id", DataTypes.SHORT); + right.setColIndex(0); + lessThanEqualToExpression = new LessThanEqualToExpression(right, right); + RowImpl value = new RowImpl(); + Short[] row = { 15856 }; + Object objectRow[] = { row }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + boolean isFirst = true; + @Mock public boolean isNull() { + if (isFirst) { + isFirst = false; + return false; + } + return true; + } + }; + + new MockUp<ExpressionResult>() { + @Mock public Short getShort() { + return 15856; + } + }; + + ExpressionResult result = lessThanEqualToExpression.evaluate(value); + assertFalse(result.getBoolean()); + + } + @Test public void testEvaluateForLessThanEqualToExpressionWithLeftAndRightDifferentDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression left = new ColumnExpression("name", DataTypes.STRING); @@ -351,6 +494,38 @@ public class LessThanEqualToExpressionUnitTest { assertTrue(result.getBoolean()); } + @Test public void testEvaluateForLessThanEqualToExpressionWithLeftAndRightDifferentDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression left = new ColumnExpression("name", DataTypes.INT); + left.setColIndex(0); + ColumnExpression right = new ColumnExpression("number", DataTypes.STRING); + right.setColIndex(1); + lessThanEqualToExpression = new LessThanEqualToExpression(left, right); + RowImpl value = new RowImpl(); + String[] row = { "S" }; + Integer[] row1 = { 1450 }; + Object objectRow[] = { row1, row }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public Integer getInt() { + if (returnMockFlag) { + returnMockFlag = false; + return 84; + } else { + return 1450; + + } + + } + }; + + ExpressionResult result = lessThanEqualToExpression.evaluate(value); + assertTrue(result.getBoolean()); + } + @Test public void testForLessThanEqualToExpressionWithGetString() throws Exception { ColumnExpression right = new ColumnExpression("right_name", DataTypes.STRING); right.setColIndex(0); http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/LessThanExpressionUnitTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/LessThanExpressionUnitTest.java b/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/LessThanExpressionUnitTest.java index e038a56..395750a 100644 --- a/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/LessThanExpressionUnitTest.java +++ b/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/LessThanExpressionUnitTest.java @@ -72,6 +72,37 @@ public class LessThanExpressionUnitTest { assertTrue(result.getBoolean()); } + @Test public void testEvaluateForLessThanExpressionWithStringDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression left = new ColumnExpression("left_name", DataTypes.STRING); + left.setColIndex(0); + ColumnExpression right = new ColumnExpression("right_name", DataTypes.STRING); + right.setColIndex(1); + lessThanExpression = new LessThanExpression(left, right); + RowImpl value = new RowImpl(); + String[] row = { "First String Value" }; + String[] row1 = { "string1" }; + Object objectRow[] = { row, row1 }; + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public String getString() { + if (returnMockFlag) { + returnMockFlag = false; + return "string1"; + + } else { + return "First String Value"; + + } + + } + }; + value.setValues(objectRow); + ExpressionResult result = lessThanExpression.evaluate(value); + assertFalse(result.getBoolean()); + } + @Test public void testEvaluateForLessThanExpressionWithShortDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("id", DataTypes.SHORT); @@ -106,6 +137,40 @@ public class LessThanExpressionUnitTest { } + @Test public void testEvaluateForLessThanExpressionWithShortDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression right = new ColumnExpression("id", DataTypes.SHORT); + right.setColIndex(0); + ColumnExpression left = new ColumnExpression("id", DataTypes.SHORT); + left.setColIndex(1); + lessThanExpression = new LessThanExpression(left, right); + RowImpl value = new RowImpl(); + Short[] row = { 7052 }; + Short[] row1 = { 7450 }; + Object objectRow[] = { row, row1 }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public Short getShort() { + if (returnMockFlag) { + returnMockFlag = false; + return 7450; + + } else { + return 7052; + + } + + } + }; + + ExpressionResult result = lessThanExpression.evaluate(value); + assertFalse(result.getBoolean()); + + } + @Test public void testEvaluateForLessThanExpressionWithDoubleDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("right_contact", DataTypes.DOUBLE); @@ -217,6 +282,51 @@ public class LessThanExpressionUnitTest { } } + @Test public void testEvaluateForLessThanExpressionWithTimestampDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + try { + ColumnExpression left = new ColumnExpression("timestamp", DataTypes.TIMESTAMP); + left.setColIndex(0); + ColumnExpression right = new ColumnExpression("timestamp", DataTypes.TIMESTAMP); + right.setColIndex(1); + + lessThanExpression = new LessThanExpression(left, right); + + RowImpl value = new RowImpl(); + + DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); + + Date date = dateFormat.parse("23/09/2007"); + long time = date.getTime(); + Timestamp[] row = { new Timestamp(time) }; + + Date date1 = dateFormat.parse("24/09/2007"); + long time1 = date1.getTime(); + Timestamp[] row1 = { new Timestamp(time1) }; + + Object objectRow[] = { row, row1 }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public Long getTime() { + if (returnMockFlag) { + returnMockFlag = false; + return 1190592000L; + } else { + return 1190505600L; + } + } + }; + + ExpressionResult result = lessThanExpression.evaluate(value); + assertFalse(result.getBoolean()); + } catch (ParseException e) { + System.out.println("Error while parsing " + e.getMessage()); + } + } + @Test public void testEvaluateForLessThanExpressionWithLongDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("contact", DataTypes.LONG); @@ -247,6 +357,36 @@ public class LessThanExpressionUnitTest { assertTrue(result.getBoolean()); } + @Test public void testEvaluateForLessThanExpressionWithLongDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression right = new ColumnExpression("contact", DataTypes.LONG); + right.setColIndex(0); + ColumnExpression left = new ColumnExpression("contact", DataTypes.LONG); + left.setColIndex(1); + lessThanExpression = new LessThanExpression(left, right); + RowImpl value = new RowImpl(); + Long[] row = { 14523656L }; + Long[] row1 = { 12456325L }; + Object objectRow[] = { row1, row }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public Long getLong() { + if (returnMockFlag) { + returnMockFlag = false; + return 14523656L; + } else { + return 12456325L; + } + } + }; + + ExpressionResult result = lessThanExpression.evaluate(value); + assertFalse(result.getBoolean()); + } + @Test public void testEvaluateForLessThanExpressionWithDecimalDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("contact", DataTypes.createDefaultDecimalType()); @@ -316,6 +456,38 @@ public class LessThanExpressionUnitTest { } + @Test public void testEvaluateForLessThanExpressionWithIsNullReturnTrue1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression right = new ColumnExpression("id", DataTypes.SHORT); + right.setColIndex(0); + lessThanExpression = new LessThanExpression(right, right); + RowImpl value = new RowImpl(); + Short[] row = { 15 }; + Object objectRow[] = { row }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + boolean isFirst = true; + @Mock public boolean isNull() { + if (isFirst) { + isFirst = false; + return false; + } + return true; + } + }; + + new MockUp<ExpressionResult>() { + @Mock public Short getShort() { + return 15; + } + }; + + ExpressionResult result = lessThanExpression.evaluate(value); + assertFalse(result.getBoolean()); + + } + @Test public void testEvaluateForLessThanExpressionWithLeftAndRightDifferentDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression left = new ColumnExpression("name", DataTypes.STRING); @@ -348,6 +520,38 @@ public class LessThanExpressionUnitTest { assertTrue(result.getBoolean()); } + @Test public void testEvaluateForLessThanExpressionWithLeftAndRightDifferentDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression left = new ColumnExpression("name", DataTypes.INT); + left.setColIndex(0); + ColumnExpression right = new ColumnExpression("number", DataTypes.STRING); + right.setColIndex(1); + lessThanExpression = new LessThanExpression(left, right); + RowImpl value = new RowImpl(); + String[] row = { "S" }; + Integer[] row1 = { 1864 }; + Object objectRow[] = { row1, row }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public Integer getInt() { + if (returnMockFlag) { + returnMockFlag = false; + return 84; + } else { + return 1864; + + } + + } + }; + + ExpressionResult result = lessThanExpression.evaluate(value); + assertTrue(result.getBoolean()); + } + @Test public void testForLessThanExpressionWithGetString() throws Exception { ColumnExpression right = new ColumnExpression("right_name", DataTypes.STRING); right.setColIndex(0); http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/ListExpressionUnitTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/ListExpressionUnitTest.java b/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/ListExpressionUnitTest.java index b885fc8..17e5eb7 100644 --- a/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/ListExpressionUnitTest.java +++ b/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/ListExpressionUnitTest.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; public class ListExpressionUnitTest { @@ -58,4 +59,25 @@ public class ListExpressionUnitTest { ExpressionResult result = listExpression.evaluate(value); assertThat(expected_value, is(equalTo(result.getList().get(0).getString()))); } + + @Test public void testGetString() throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression left = new ColumnExpression("left_name", DataTypes.STRING); + left.setColIndex(0); + ColumnExpression right = new ColumnExpression("right_name", DataTypes.STRING); + right.setColIndex(1); + + List<Expression> children = new ArrayList<>(); + children.add(left); + children.add(right); + + listExpression = new ListExpression(children); + RowImpl value = new RowImpl(); + String row = "Row is for left"; + String row1 = "I am row 1"; + Object objectRow[] = { row, row1 }; + value.setValues(objectRow); + String expected_value = "ListExpression(ColumnExpression(left_name);ColumnExpression(right_name);)"; + String exresult = listExpression.getString(); + assertTrue(exresult.equals(expected_value)); + } } http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/NotEqualsExpressionUnitTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/NotEqualsExpressionUnitTest.java b/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/NotEqualsExpressionUnitTest.java index 34448f4..d0ee21e 100644 --- a/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/NotEqualsExpressionUnitTest.java +++ b/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/NotEqualsExpressionUnitTest.java @@ -108,7 +108,34 @@ public class NotEqualsExpressionUnitTest { } - @Test public void testEvaluateForNotEqualsExpressionWithIntDataType() + @Test public void testEvaluateForNotEqualsExpressionWithShortDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + + ColumnExpression left = new ColumnExpression("left_id", DataTypes.SHORT); + left.setColIndex(0); + ColumnExpression right = new ColumnExpression("right_id", DataTypes.SHORT); + right.setColIndex(1); + notEqualsExpression = new NotEqualsExpression(left, right); + RowImpl value = new RowImpl(); + Short[] row = { 15 }; + Short[] row1 = { 16 }; + Object objectRow[] = { row, row1 }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + + @Mock public Short getShort() { + return 15; + + } + }; + + ExpressionResult result = notEqualsExpression.evaluate(value); + assertFalse(result.getBoolean()); + + } + + @Test public void testEvaluateForNotEqualsExpressionWithIntDataType1() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("right_number", DataTypes.INT); right.setColIndex(1); @@ -139,6 +166,29 @@ public class NotEqualsExpressionUnitTest { assertTrue(result.getBoolean()); } + @Test public void testEvaluateForNotEqualsExpressionWithIntDataType() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression right = new ColumnExpression("right_number", DataTypes.INT); + right.setColIndex(1); + ColumnExpression left = new ColumnExpression("left_number", DataTypes.INT); + left.setColIndex(0); + notEqualsExpression = new NotEqualsExpression(left, right); + RowImpl value = new RowImpl(); + Integer[] row = { 15 }; + Integer[] row1 = { 16 }; + Object objectRow[] = { row, row1 }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + @Mock public Integer getInt() { + return 15; + } + }; + + ExpressionResult result = notEqualsExpression.evaluate(value); + assertFalse(result.getBoolean()); + } + @Test public void testEvaluateForNotEqualsExpressionWithDoubleDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("right_contact", DataTypes.DOUBLE); @@ -200,6 +250,31 @@ public class NotEqualsExpressionUnitTest { assertTrue(result.getBoolean()); } + @Test public void testEvaluateForNotEqualsExpressionWithLongDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression right = new ColumnExpression("right_contact", DataTypes.LONG); + right.setColIndex(1); + ColumnExpression left = new ColumnExpression("left_contact", DataTypes.LONG); + left.setColIndex(0); + notEqualsExpression = new NotEqualsExpression(left, right); + RowImpl value = new RowImpl(); + Long[] row = { 1234567654321L }; + Long[] row1 = { 12345676541L }; + Object objectRow[] = { row, row1 }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public Long getLong() { + return 1234567654321L; + } + }; + + ExpressionResult result = notEqualsExpression.evaluate(value); + assertFalse(result.getBoolean()); + } + @Test public void testEvaluateForNotEqualsExpressionWithTimestampDataType() throws FilterUnsupportedException, FilterIllegalMemberException { try { @@ -245,6 +320,46 @@ public class NotEqualsExpressionUnitTest { } } + @Test public void testEvaluateForNotEqualsExpressionWithTimestampDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + try { + ColumnExpression left = new ColumnExpression("left_timestamp", DataTypes.TIMESTAMP); + left.setColIndex(0); + ColumnExpression right = new ColumnExpression("right_timestamp", DataTypes.TIMESTAMP); + right.setColIndex(1); + + notEqualsExpression = new NotEqualsExpression(left, right); + + RowImpl value = new RowImpl(); + + DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); + + Date date = dateFormat.parse("23/09/2007"); + long time = date.getTime(); + Timestamp[] row = { new Timestamp(time) }; + + Date date1 = dateFormat.parse("24/09/2007"); + long time1 = date1.getTime(); + Timestamp[] row1 = { new Timestamp(time1) }; + + Object objectRow[] = { row1, row }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public Long getTime() { + return 1190592000L; + } + }; + + ExpressionResult result = notEqualsExpression.evaluate(value); + assertFalse(result.getBoolean()); + } catch (ParseException e) { + System.out.println("Error while parsing " + e.getMessage()); + } + } + @Test public void testForNotEqualsExpressionWithDefaultCase() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("contact", DataTypes.BOOLEAN); @@ -287,6 +402,31 @@ public class NotEqualsExpressionUnitTest { assertTrue(result.getBoolean()); } + @Test public void testEvaluateWithForNotEqualsExpressionDecimalDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression right = new ColumnExpression("contact", DataTypes.createDefaultDecimalType()); + right.setColIndex(1); + ColumnExpression left = new ColumnExpression("contact", DataTypes.createDefaultDecimalType()); + left.setColIndex(0); + notEqualsExpression = new NotEqualsExpression(left, right); + RowImpl value = new RowImpl(); + BigDecimal[] row = new BigDecimal[] { new BigDecimal(12345.0) }; + BigDecimal[] row1 = new BigDecimal[] { new BigDecimal(1235445.0) }; + Object objectRow[] = { row, row1 }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public BigDecimal getDecimal() { + return new BigDecimal(12345.0); + } + }; + + ExpressionResult result = notEqualsExpression.evaluate(value); + assertFalse(result.getBoolean()); + } + @Test public void testEvaluateForNotEqualsExpressionWithIsNullReturnTrue() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression right = new ColumnExpression("id", DataTypes.SHORT); @@ -314,6 +454,38 @@ public class NotEqualsExpressionUnitTest { } + @Test public void testEvaluateForNotEqualsExpressionWithIsNullReturnTrue1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression right = new ColumnExpression("id", DataTypes.SHORT); + right.setColIndex(0); + notEqualsExpression = new NotEqualsExpression(right, right); + RowImpl value = new RowImpl(); + Short[] row = { 150 }; + Object objectRow[] = { row }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + boolean isFirst = true; + @Mock public boolean isNull() { + if (isFirst) { + isFirst = false; + return false; + } + return true; + } + }; + + new MockUp<ExpressionResult>() { + @Mock public Short getShort() { + return 150; + } + }; + + ExpressionResult result = notEqualsExpression.evaluate(value); + assertFalse(result.getBoolean()); + + } + @Test public void testEvaluateForNotEqualsExpressionWithLeftAndRightDifferentDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression left = new ColumnExpression("name", DataTypes.STRING); @@ -344,6 +516,36 @@ public class NotEqualsExpressionUnitTest { assertTrue(result.getBoolean()); } + @Test public void testEvaluateForNotEqualsExpressionWithLeftAndRightDifferentDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression left = new ColumnExpression("name", DataTypes.INT); + left.setColIndex(0); + ColumnExpression right = new ColumnExpression("number", DataTypes.STRING); + right.setColIndex(1); + notEqualsExpression = new NotEqualsExpression(left, right); + RowImpl value = new RowImpl(); + String[] row1 = { "S" }; + Integer[] row = { 14 }; + Object objectRow[] = { row1, row }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + Boolean returnMockFlag = true; + + @Mock public Integer getInt() { + if (returnMockFlag) { + returnMockFlag = false; + return 84; + } else { + return 14; + } + } + }; + + ExpressionResult result = notEqualsExpression.evaluate(value); + assertTrue(result.getBoolean()); + } + @Test public void testForNotEqualsExpressionWithGetString() throws Exception { ColumnExpression right = new ColumnExpression("right_name", DataTypes.STRING); ColumnExpression left = new ColumnExpression("left_name", DataTypes.STRING); http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpressionUnitTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpressionUnitTest.java b/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpressionUnitTest.java index d31361b..54791cc 100644 --- a/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpressionUnitTest.java +++ b/core/src/test/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpressionUnitTest.java @@ -36,6 +36,7 @@ import mockit.MockUp; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class NotInExpressionUnitTest { @@ -143,6 +144,35 @@ public class NotInExpressionUnitTest { assertTrue(result.getBoolean()); } + @Test public void testEvaluateForNotInExpressionWithDoubleDataType1() + throws FilterUnsupportedException, FilterIllegalMemberException { + ColumnExpression left = new ColumnExpression("left_contact", DataTypes.DOUBLE); + left.setColIndex(0); + ColumnExpression right = new ColumnExpression("right_contact", DataTypes.DOUBLE); + right.setColIndex(1); + notInExpression = new NotInExpression(left, right); + RowImpl value = new RowImpl(); + Double row = 44521D; + Double row1 = 44521.023D; + Object objectRow[] = { row, row1 }; + value.setValues(objectRow); + + new MockUp<ExpressionResult>() { + @Mock public boolean isNull() { + return true; + } + }; + + new MockUp<ExpressionResult>() { + @Mock public Double getDouble() { + return 44521.023D; + } + }; + + ExpressionResult result = notInExpression.evaluate(value); + assertFalse(result.getBoolean()); + } + @Test public void testEvaluateForNotInExpressionWithLongDataType() throws FilterUnsupportedException, FilterIllegalMemberException { ColumnExpression left = new ColumnExpression("left_contact", DataTypes.LONG); http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/AndExpressionTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/AndExpressionTest.java b/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/AndExpressionTest.java index 6bb6900..5cc6a7b 100644 --- a/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/AndExpressionTest.java +++ b/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/AndExpressionTest.java @@ -71,6 +71,74 @@ public class AndExpressionTest { assertTrue(actualValue instanceof ExpressionResult); } + @Test public void testEvaluate1() throws FilterIllegalMemberException, + FilterUnsupportedException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { false }); + final ExpressionResult expressionResult = new ExpressionResult(DataTypes.BOOLEAN, "true"); + new MockUp<ColumnExpression>() { + @Mock public ExpressionResult evaluate(RowIntf value) { + return expressionResult; + } + }; + + assertTrue(andExpression.evaluate(rowImpl) instanceof ExpressionResult); + } + + @Test public void testEvaluate2() throws FilterIllegalMemberException, + FilterUnsupportedException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { false }); + final ExpressionResult expressionResultRight = new ExpressionResult(DataTypes.BOOLEAN, "false"); + final ExpressionResult expressionResultLeft = new ExpressionResult(DataTypes.BOOLEAN, "true"); + new MockUp<ColumnExpression>() { + boolean isLeft = true; + @Mock public ExpressionResult evaluate(RowIntf value) { + if (isLeft) { + isLeft = false; + return expressionResultLeft; + } + return expressionResultRight; + } + }; + + assertTrue(andExpression.evaluate(rowImpl) instanceof ExpressionResult); + } + + @Test public void testEvaluate3() throws FilterIllegalMemberException, + FilterUnsupportedException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { false }); + final ExpressionResult expressionResultRight = new ExpressionResult(DataTypes.BOOLEAN, "false"); + final ExpressionResult expressionResultLeft = new ExpressionResult(DataTypes.BOOLEAN, "false"); + new MockUp<ColumnExpression>() { + boolean isLeft = true; + @Mock public ExpressionResult evaluate(RowIntf value) { + if (isLeft) { + isLeft = false; + return expressionResultLeft; + } + return expressionResultRight; + } + }; + + assertTrue(andExpression.evaluate(rowImpl) instanceof ExpressionResult); + } + + @Test public void testEvaluate4() + throws FilterIllegalMemberException, FilterUnsupportedException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { false }); + final ExpressionResult expressionResult = new ExpressionResult(DataTypes.BOOLEAN, "false"); + new MockUp<ColumnExpression>() { + @Mock public ExpressionResult evaluate(RowIntf value) { + return expressionResult; + } + }; + + assertTrue(andExpression.evaluate(rowImpl) instanceof ExpressionResult); + } + @Test public void testGetString() { String actualValue = andExpression.getString(); String expectedValue = "And(ColumnExpression(IMEI),ColumnExpression(IMEI))"; http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/FalseExpressionTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/FalseExpressionTest.java b/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/FalseExpressionTest.java index 59bf0b5..85486e2 100644 --- a/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/FalseExpressionTest.java +++ b/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/FalseExpressionTest.java @@ -22,6 +22,7 @@ import org.apache.carbondata.core.scan.expression.ColumnExpression; import org.apache.carbondata.core.scan.expression.ExpressionResult; import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException; import org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException; +import org.apache.carbondata.core.scan.filter.intf.ExpressionType; import org.apache.carbondata.core.scan.filter.intf.RowImpl; import org.junit.Before; @@ -43,4 +44,15 @@ public class FalseExpressionTest { ExpressionResult actualValue = falseExpression.evaluate(rowImpl); assertEquals(new ExpressionResult(DataTypes.BOOLEAN, false), actualValue); } + + @Test public void testGetString() { + String actualValue = falseExpression.getString(); + String expectedValue = "False(ColumnExpression(IMEI)"; + assertEquals(expectedValue, actualValue); + } + + @Test public void testFilterExpressionType() { + ExpressionType actualValue = falseExpression.getFilterExpressionType(); + assertEquals(ExpressionType.FALSE, actualValue); + } } http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/OrExpressionTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/OrExpressionTest.java b/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/OrExpressionTest.java index 6acfaea..83c3269 100644 --- a/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/OrExpressionTest.java +++ b/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/OrExpressionTest.java @@ -61,6 +61,74 @@ public class OrExpressionTest { assertTrue(orExpression.evaluate(rowImpl) instanceof ExpressionResult); } + @Test public void testEvaluate1() throws FilterIllegalMemberException, + FilterUnsupportedException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { false }); + final ExpressionResult expressionResult = new ExpressionResult(DataTypes.BOOLEAN, "true"); + new MockUp<ColumnExpression>() { + @Mock public ExpressionResult evaluate(RowIntf value) { + return expressionResult; + } + }; + + assertTrue(orExpression.evaluate(rowImpl) instanceof ExpressionResult); + } + + @Test public void testEvaluate2() throws FilterIllegalMemberException, + FilterUnsupportedException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { false }); + final ExpressionResult expressionResultRight = new ExpressionResult(DataTypes.BOOLEAN, "false"); + final ExpressionResult expressionResultLeft = new ExpressionResult(DataTypes.BOOLEAN, "true"); + new MockUp<ColumnExpression>() { + boolean isLeft = true; + @Mock public ExpressionResult evaluate(RowIntf value) { + if (isLeft) { + isLeft = false; + return expressionResultLeft; + } + return expressionResultRight; + } + }; + + assertTrue(orExpression.evaluate(rowImpl) instanceof ExpressionResult); + } + + @Test public void testEvaluate3() throws FilterIllegalMemberException, + FilterUnsupportedException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { false }); + final ExpressionResult expressionResultRight = new ExpressionResult(DataTypes.BOOLEAN, "false"); + final ExpressionResult expressionResultLeft = new ExpressionResult(DataTypes.BOOLEAN, "false"); + new MockUp<ColumnExpression>() { + boolean isLeft = true; + @Mock public ExpressionResult evaluate(RowIntf value) { + if (isLeft) { + isLeft = false; + return expressionResultLeft; + } + return expressionResultRight; + } + }; + + assertTrue(orExpression.evaluate(rowImpl) instanceof ExpressionResult); + } + + @Test public void testEvaluate4() + throws FilterIllegalMemberException, FilterUnsupportedException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { false }); + final ExpressionResult expressionResult = new ExpressionResult(DataTypes.BOOLEAN, "false"); + new MockUp<ColumnExpression>() { + @Mock public ExpressionResult evaluate(RowIntf value) { + return expressionResult; + } + }; + + assertTrue(orExpression.evaluate(rowImpl) instanceof ExpressionResult); + } + @Test(expected = Exception.class) public void testEvaluateForDefault() throws FilterUnsupportedException, FilterIllegalMemberException { RowImpl rowImpl = new RowImpl(); http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/RangeExpressionTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/RangeExpressionTest.java b/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/RangeExpressionTest.java new file mode 100644 index 0000000..b76a3db --- /dev/null +++ b/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/RangeExpressionTest.java @@ -0,0 +1,148 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.carbondata.core.scan.expression.logical; + +import mockit.Mock; +import mockit.MockUp; + +import org.apache.carbondata.core.metadata.datatype.DataTypes; +import org.apache.carbondata.core.scan.expression.ColumnExpression; +import org.apache.carbondata.core.scan.expression.ExpressionResult; +import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException; +import org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException; +import org.apache.carbondata.core.scan.filter.intf.RowImpl; +import org.apache.carbondata.core.scan.filter.intf.RowIntf; + +import org.junit.Before; +import org.junit.Test; + +import static junit.framework.TestCase.assertTrue; +import static org.junit.Assert.assertEquals; + +public class RangeExpressionTest { + private RangeExpression rangeExpression; + + @Before public void setUp() { + ColumnExpression leftExpression = new ColumnExpression("IMEI", DataTypes.BOOLEAN); + ColumnExpression rightExpression = new ColumnExpression("IMEI", DataTypes.BOOLEAN); + rangeExpression = new RangeExpression(leftExpression, rightExpression); + } + + @Test public void testGetString() { + String actualValue = rangeExpression.getString(); + String expectedValue = "Range(ColumnExpression(IMEI),ColumnExpression(IMEI))"; + assertEquals(expectedValue, actualValue); + } + + @Test public void testEvaluate() throws FilterIllegalMemberException, FilterUnsupportedException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { false }); + final ExpressionResult expressionResult = new ExpressionResult(DataTypes.BOOLEAN, "test"); + new MockUp<ColumnExpression>() { + @Mock public ExpressionResult evaluate(RowIntf value) { + return expressionResult; + } + }; + + assertTrue(rangeExpression.evaluate(rowImpl) instanceof ExpressionResult); + } + + @Test public void testEvaluate1() + throws FilterIllegalMemberException, FilterUnsupportedException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { false }); + final ExpressionResult expressionResult = new ExpressionResult(DataTypes.BOOLEAN, "true"); + new MockUp<ColumnExpression>() { + @Mock public ExpressionResult evaluate(RowIntf value) { + return expressionResult; + } + }; + + assertTrue(rangeExpression.evaluate(rowImpl) instanceof ExpressionResult); + } + + @Test public void testEvaluate2() + throws FilterIllegalMemberException, FilterUnsupportedException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { false }); + final ExpressionResult expressionResultRight = new ExpressionResult(DataTypes.BOOLEAN, "false"); + final ExpressionResult expressionResultLeft = new ExpressionResult(DataTypes.BOOLEAN, "true"); + new MockUp<ColumnExpression>() { + boolean isLeft = true; + + @Mock public ExpressionResult evaluate(RowIntf value) { + if (isLeft) { + isLeft = false; + return expressionResultLeft; + } + return expressionResultRight; + } + }; + + assertTrue(rangeExpression.evaluate(rowImpl) instanceof ExpressionResult); + } + + @Test public void testEvaluate3() + throws FilterIllegalMemberException, FilterUnsupportedException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { false }); + final ExpressionResult expressionResultRight = new ExpressionResult(DataTypes.BOOLEAN, "false"); + final ExpressionResult expressionResultLeft = new ExpressionResult(DataTypes.BOOLEAN, "false"); + new MockUp<ColumnExpression>() { + boolean isLeft = true; + + @Mock public ExpressionResult evaluate(RowIntf value) { + if (isLeft) { + isLeft = false; + return expressionResultLeft; + } + return expressionResultRight; + } + }; + + assertTrue(rangeExpression.evaluate(rowImpl) instanceof ExpressionResult); + } + + @Test public void testEvaluate4() + throws FilterIllegalMemberException, FilterUnsupportedException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { false }); + final ExpressionResult expressionResult = new ExpressionResult(DataTypes.BOOLEAN, "false"); + new MockUp<ColumnExpression>() { + @Mock public ExpressionResult evaluate(RowIntf value) { + return expressionResult; + } + }; + + assertTrue(rangeExpression.evaluate(rowImpl) instanceof ExpressionResult); + } + + @Test(expected = Exception.class) public void testEvaluateForDefault() + throws FilterUnsupportedException, FilterIllegalMemberException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { true }); + final ExpressionResult expressionResult = new ExpressionResult(DataTypes.STRING, "test"); + new MockUp<ColumnExpression>() { + @Mock public ExpressionResult evaluate(RowIntf value) + throws FilterUnsupportedException, FilterIllegalMemberException { + return expressionResult; + } + }; + rangeExpression.evaluate(rowImpl); + } +} http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/TrueExpressionTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/TrueExpressionTest.java b/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/TrueExpressionTest.java new file mode 100644 index 0000000..77afc85 --- /dev/null +++ b/core/src/test/java/org/apache/carbondata/core/scan/expression/logical/TrueExpressionTest.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.carbondata.core.scan.expression.logical; + +import org.apache.carbondata.core.metadata.datatype.DataTypes; +import org.apache.carbondata.core.scan.expression.ColumnExpression; +import org.apache.carbondata.core.scan.expression.ExpressionResult; +import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException; +import org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException; +import org.apache.carbondata.core.scan.filter.intf.ExpressionType; +import org.apache.carbondata.core.scan.filter.intf.RowImpl; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class TrueExpressionTest { + private TrueExpression trueExpression; + + @Before public void setUp() { + ColumnExpression columnExpression = new ColumnExpression("IMEI", DataTypes.BOOLEAN); + trueExpression = new TrueExpression(columnExpression); + } + + @Test public void testEvaluate() throws FilterUnsupportedException, FilterIllegalMemberException { + RowImpl rowImpl = new RowImpl(); + rowImpl.setValues(new Boolean[] { true }); + ExpressionResult actualValue = trueExpression.evaluate(rowImpl); + assertEquals(new ExpressionResult(DataTypes.BOOLEAN, true), actualValue); + } + + @Test public void testGetString() { + String actualValue = trueExpression.getString(); + String expectedValue = "True(ColumnExpression(IMEI)"; + assertEquals(expectedValue, actualValue); + } + + @Test public void testFilterExpressionType() { + ExpressionType actualValue = trueExpression.getFilterExpressionType(); + assertEquals(ExpressionType.TRUE, actualValue); + } +} http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/filter/FilterExpressionProcessorTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/filter/FilterExpressionProcessorTest.java b/core/src/test/java/org/apache/carbondata/core/scan/filter/FilterExpressionProcessorTest.java index f294454..74f9625 100644 --- a/core/src/test/java/org/apache/carbondata/core/scan/filter/FilterExpressionProcessorTest.java +++ b/core/src/test/java/org/apache/carbondata/core/scan/filter/FilterExpressionProcessorTest.java @@ -36,7 +36,6 @@ public class FilterExpressionProcessorTest extends AbstractDictionaryCacheTest { new CarbonTableIdentifier(databaseName, tableName, UUID.randomUUID().toString()); this.carbonStorePath = props.getProperty("storePath", "carbonStore"); columnSchema = new ColumnSchema(); - columnSchema.setColumnar(true); columnSchema.setColumnName("IMEI"); columnSchema.setColumnUniqueId(UUID.randomUUID().toString()); columnSchema.setDataType(DataTypes.STRING); http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/filter/FilterUtilTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/filter/FilterUtilTest.java b/core/src/test/java/org/apache/carbondata/core/scan/filter/FilterUtilTest.java index 9c7c26c..cbc0203 100644 --- a/core/src/test/java/org/apache/carbondata/core/scan/filter/FilterUtilTest.java +++ b/core/src/test/java/org/apache/carbondata/core/scan/filter/FilterUtilTest.java @@ -66,7 +66,6 @@ public class FilterUtilTest extends AbstractDictionaryCacheTest { new CarbonTableIdentifier(databaseName, tableName, UUID.randomUUID().toString()); this.carbonStorePath = props.getProperty("storePath", "carbonStore"); columnSchema = new ColumnSchema(); - columnSchema.setColumnar(true); columnSchema.setColumnName("IMEI"); columnSchema.setColumnUniqueId(UUID.randomUUID().toString()); columnSchema.setDataType(DataTypes.STRING); @@ -232,17 +231,14 @@ public class FilterUtilTest extends AbstractDictionaryCacheTest { new MultiDimKeyVarLengthGenerator(keys); int ordinal = 1; int keyOrdinal = 1; - int columnGroupOrdinal = 1; int complexTypeOrdinal = 1; ColumnSchema columnSchema = new ColumnSchema(); - columnSchema.setColumnar(true); columnSchema.setColumnName("IMEI"); columnSchema.setColumnUniqueId(UUID.randomUUID().toString()); columnSchema.setDataType(DataTypes.STRING); columnSchema.setDimensionColumn(true); CarbonDimension carbonDimension = - new CarbonDimension(columnSchema, ordinal, keyOrdinal, columnGroupOrdinal, - complexTypeOrdinal); + new CarbonDimension(columnSchema, ordinal, keyOrdinal, complexTypeOrdinal); byte[] expectedResult = new byte[] { 1 }; byte[] actualResult = FilterUtil.getMaskKey(surrogate, carbonDimension, multiDimKeyVarLengthGenerator); @@ -257,7 +253,6 @@ public class FilterUtilTest extends AbstractDictionaryCacheTest { boolean isIncludeFilter = true; int ordinal = 1; ColumnSchema dimColumn = new ColumnSchema(); - dimColumn.setColumnar(true); dimColumn.setColumnName("IMEI"); dimColumn.setColumnUniqueId(UUID.randomUUID().toString()); dimColumn.setDataType(DataTypes.STRING); @@ -288,7 +283,6 @@ public class FilterUtilTest extends AbstractDictionaryCacheTest { boolean isIncludeFilter = true; int ordinal = 1; ColumnSchema dimColumn = new ColumnSchema(); - dimColumn.setColumnar(true); dimColumn.setColumnName("IMEI"); dimColumn.setColumnUniqueId(UUID.randomUUID().toString()); dimColumn.setDataType(DataTypes.STRING); http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/filter/executer/IncludeFilterExecuterImplTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/filter/executer/IncludeFilterExecuterImplTest.java b/core/src/test/java/org/apache/carbondata/core/scan/filter/executer/IncludeFilterExecuterImplTest.java index 92c2e85..b9e90d6 100644 --- a/core/src/test/java/org/apache/carbondata/core/scan/filter/executer/IncludeFilterExecuterImplTest.java +++ b/core/src/test/java/org/apache/carbondata/core/scan/filter/executer/IncludeFilterExecuterImplTest.java @@ -194,7 +194,7 @@ public class IncludeFilterExecuterImplTest extends TestCase { oldTime = oldTime + System.currentTimeMillis() - start; start = System.currentTimeMillis(); - BitSet bitNew = this.setFilterdIndexToBitSetNew((FixedLengthDimensionColumnPage) dimensionColumnDataChunk, dataChunkSize, + BitSet bitNew = this.setFilterdIndexToBitSetNew(dimensionColumnDataChunk, dataChunkSize, filterKeys); newTime = newTime + System.currentTimeMillis() - start; http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/scan/wrappers/ByteArrayWrapperTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/scan/wrappers/ByteArrayWrapperTest.java b/core/src/test/java/org/apache/carbondata/core/scan/wrappers/ByteArrayWrapperTest.java index e5104fa..78dca73 100644 --- a/core/src/test/java/org/apache/carbondata/core/scan/wrappers/ByteArrayWrapperTest.java +++ b/core/src/test/java/org/apache/carbondata/core/scan/wrappers/ByteArrayWrapperTest.java @@ -23,6 +23,7 @@ import org.junit.Test; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.assertNotSame; import static junit.framework.TestCase.assertTrue; public class ByteArrayWrapperTest { @@ -30,6 +31,9 @@ public class ByteArrayWrapperTest { byte[] dictionaryKey = new byte[] { 1 }; byte[][] complexTypesKeys = { { 1 }, { 1 } }; byte[][] noDictionaryKeys = new byte[][] { { 1 }, { 1 } }; + byte[] dictionaryKey1 = new byte[] { 2 }; + byte[][] complexTypesKeys1 = { { 2 }, { 1 } }; + byte[][] noDictionaryKeys1 = new byte[][] { { 2 }, { 1 } }; @BeforeClass @@ -91,6 +95,33 @@ public class ByteArrayWrapperTest { assertTrue(result); } + @Test + + public void testEqualsForFirstElementComplexTypesKeysAndOther1() { + ByteArrayWrapper other = new ByteArrayWrapper(); + other.setComplexTypesKeys(complexTypesKeys); + other.setDictionaryKey(dictionaryKey); + other.setNoDictionaryKeys(noDictionaryKeys); + byteArrayWrapper.setComplexTypesKeys(complexTypesKeys); + byteArrayWrapper.setDictionaryKey(dictionaryKey); + byteArrayWrapper.setNoDictionaryKeys(noDictionaryKeys1); + boolean result = byteArrayWrapper.equals(other); + assertFalse(result); + } + + @Test + public void testEqualsForFirstElementComplexTypesKeysAndOther2() { + ByteArrayWrapper other = new ByteArrayWrapper(); + other.setComplexTypesKeys(complexTypesKeys); + other.setDictionaryKey(dictionaryKey); + other.setNoDictionaryKeys(noDictionaryKeys); + byteArrayWrapper.setComplexTypesKeys(complexTypesKeys1); + byteArrayWrapper.setDictionaryKey(dictionaryKey); + byteArrayWrapper.setNoDictionaryKeys(noDictionaryKeys); + boolean result = byteArrayWrapper.equals(other); + assertFalse(result); + } + @Test public void testCompareTo() { byteArrayWrapper.setDictionaryKey(dictionaryKey); ByteArrayWrapper other = new ByteArrayWrapper(); @@ -103,4 +134,30 @@ public class ByteArrayWrapperTest { int expectedResult = 0; assertEquals(expectedResult, actualResult); } + + @Test public void testCompareTo1() { + byteArrayWrapper.setDictionaryKey(dictionaryKey1); + ByteArrayWrapper other = new ByteArrayWrapper(); + other.setDictionaryKey(dictionaryKey1); + other.setNoDictionaryKeys(noDictionaryKeys); + other.setComplexTypesKeys(complexTypesKeys); + byteArrayWrapper.setNoDictionaryKeys(noDictionaryKeys); + byteArrayWrapper.setComplexTypesKeys(complexTypesKeys1); + int actualResult = byteArrayWrapper.compareTo(other); + int expectedResult = 0; + assertNotSame(expectedResult, actualResult); + } + + @Test public void testCompareTo2() { + byteArrayWrapper.setDictionaryKey(dictionaryKey); + ByteArrayWrapper other = new ByteArrayWrapper(); + other.setDictionaryKey(dictionaryKey); + other.setNoDictionaryKeys(noDictionaryKeys); + other.setComplexTypesKeys(complexTypesKeys); + byteArrayWrapper.setNoDictionaryKeys(noDictionaryKeys1); + byteArrayWrapper.setComplexTypesKeys(complexTypesKeys1); + int actualResult = byteArrayWrapper.compareTo(other); + int expectedResult = 0; + assertNotSame(expectedResult, actualResult); + } } http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/util/CarbonMergerUtilTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/util/CarbonMergerUtilTest.java b/core/src/test/java/org/apache/carbondata/core/util/CarbonMergerUtilTest.java deleted file mode 100644 index 53d425f..0000000 --- a/core/src/test/java/org/apache/carbondata/core/util/CarbonMergerUtilTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.carbondata.core.util; - -import static junit.framework.TestCase.*; - -import mockit.Mock; -import mockit.MockUp; -import org.junit.Test; - -import static org.apache.carbondata.core.util.CarbonMergerUtil.getCardinalityFromLevelMetadata; - -public class CarbonMergerUtilTest { - - @Test public void testGetCardinalityFromLevelMetadata() throws Exception { - final int[] localCardinality = { 1, 2, 3, 4, 5, 6 }; - new MockUp<CarbonUtil>() { - @SuppressWarnings("unused") @Mock - public int[] getCardinalityFromLevelMetadataFile(String levelPath) { - return localCardinality; - } - }; - int[] result = getCardinalityFromLevelMetadata("STORE_PATH", "table1"); - assertEquals(result, localCardinality); - } -} http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/util/CarbonUtilTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/util/CarbonUtilTest.java b/core/src/test/java/org/apache/carbondata/core/util/CarbonUtilTest.java index d75f323..5520bfb 100644 --- a/core/src/test/java/org/apache/carbondata/core/util/CarbonUtilTest.java +++ b/core/src/test/java/org/apache/carbondata/core/util/CarbonUtilTest.java @@ -32,7 +32,6 @@ import java.util.Map; import org.apache.carbondata.core.datamap.Segment; import org.apache.carbondata.core.datastore.block.TableBlockInfo; import org.apache.carbondata.core.datastore.chunk.impl.FixedLengthDimensionColumnPage; -import org.apache.carbondata.core.datastore.columnar.ColumnGroupModel; import org.apache.carbondata.core.datastore.filesystem.LocalCarbonFile; import org.apache.carbondata.core.datastore.impl.FileFactory; import org.apache.carbondata.core.metadata.ColumnarFormatVersion; @@ -104,16 +103,6 @@ public class CarbonUtilTest { } } - @Test public void testToGetColGroupModel() { - int[][] cardinality = { { 10, 20, 30 }, { 20, 30 }, {} }; - ColumnGroupModel actualResult = CarbonUtil.getColGroupModel(cardinality); - assertEquals(actualResult.getNoOfColumnStore(), 3); - int[] expectedResult = { 3, 2, 0 }; - for (int i = 0; i < actualResult.getColumnSplit().length; i++) { - assertEquals(actualResult.getColumnSplit()[i], expectedResult[i]); - } - } - @Test public void testToGetIncrementedCardinalityFullyFilled() { int[] cardinality = { 200, 20, 0, 10 }; int[] actualResult = CarbonUtil.getIncrementedCardinalityFullyFilled(cardinality); @@ -298,17 +287,6 @@ public class CarbonUtilTest { assertEquals(result, 5); } - - @Test public void testToGetCardinalityFromLevelMetadataFileForInvalidPath() - throws IOException, InterruptedException { - try { - int[] cardinality = CarbonUtil.getCardinalityFromLevelMetadataFile(""); - assertTrue(false); - } catch (Exception e) { - assertTrue(true); - } - } - @Test public void testToUnescapeChar() { String[] input = { "\\001", "\\t", "\\r", "\\b", "\\n", "\\f" }; String[] output = { "\001", "\t", "\r", "\b", "\n", "\f" }; @@ -522,14 +500,14 @@ public class CarbonUtilTest { encoding.add(Encoding.DICTIONARY); column1Schema.setEncodingList(encoding); ProjectionDimension - column1 = new ProjectionDimension(new CarbonDimension(column1Schema, 1, 1, 1, 1)); + column1 = new ProjectionDimension(new CarbonDimension(column1Schema, 1, 1, 1)); column2Schema.setColumnName("Column2"); List<Encoding> encoding2 = new ArrayList<>(); encoding2.add(Encoding.DELTA); column2Schema.setEncodingList(encoding2); ProjectionDimension - column2 = new ProjectionDimension(new CarbonDimension(column2Schema, 1, 1, 1, 1)); + column2 = new ProjectionDimension(new CarbonDimension(column2Schema, 1, 1, 1)); ProjectionDimension[] queryDimensions = { column1, column2 }; @@ -548,14 +526,14 @@ public class CarbonUtilTest { encoding.add(Encoding.DIRECT_DICTIONARY); column1Schema.setEncodingList(encoding); ProjectionDimension - column1 = new ProjectionDimension(new CarbonDimension(column1Schema, 1, 1, 1, 1)); + column1 = new ProjectionDimension(new CarbonDimension(column1Schema, 1, 1, 1)); column2Schema.setColumnName("Column2"); List<Encoding> encoding2 = new ArrayList<>(); encoding2.add(Encoding.DELTA); column2Schema.setEncodingList(encoding2); ProjectionDimension - column2 = new ProjectionDimension(new CarbonDimension(column2Schema, 1, 1, 1, 1)); + column2 = new ProjectionDimension(new CarbonDimension(column2Schema, 1, 1, 1)); ProjectionDimension[] queryDimensions = { column1, column2 }; @@ -572,12 +550,12 @@ public class CarbonUtilTest { column1Schema.setColumnName("Column1"); column1Schema.setDataType(DataTypes.DATE); ProjectionDimension - column1 = new ProjectionDimension(new CarbonDimension(column1Schema, 1, 1, 1, 1)); + column1 = new ProjectionDimension(new CarbonDimension(column1Schema, 1, 1, 1)); column2Schema.setColumnName("Column2"); column2Schema.setDataType(DataTypes.createDefaultArrayType()); ProjectionDimension - column2 = new ProjectionDimension(new CarbonDimension(column2Schema, 1, 1, 1, 1)); + column2 = new ProjectionDimension(new CarbonDimension(column2Schema, 1, 1, 1)); ProjectionDimension[] queryDimensions = { column1, column2 }; @@ -617,10 +595,10 @@ public class CarbonUtilTest { column1Schema.setColumnName("Column1"); column2Schema.setColumnName("Column2"); List<CarbonDimension> carbonDimension = new ArrayList<>(); - carbonDimension.add(new CarbonDimension(column1Schema, 1, 1, 1, 1)); - carbonDimension.add(new CarbonDimension(column2Schema, 2, 1, 2, 1)); + carbonDimension.add(new CarbonDimension(column1Schema, 1, 1, 1)); + carbonDimension.add(new CarbonDimension(column2Schema, 2, 1, 1)); assertEquals(CarbonUtil.findDimension(carbonDimension, "Column1"), - new CarbonDimension(column1Schema, 1, 1, 1, 1)); + new CarbonDimension(column1Schema, 1, 1, 1)); } @Test public void testToGetFormattedCardinality() { @@ -649,8 +627,8 @@ public class CarbonUtilTest { column1Schema.setColumnName("Column1"); column2Schema.setColumnName("Column2"); List<CarbonDimension> carbonDimension = new ArrayList<>(); - carbonDimension.add(new CarbonDimension(column1Schema, 1, 1, 1, 1)); - carbonDimension.add(new CarbonDimension(column2Schema, 2, 2, 2, 1)); + carbonDimension.add(new CarbonDimension(column1Schema, 1, 1, 1)); + carbonDimension.add(new CarbonDimension(column2Schema, 2, 2, 1)); List<CarbonMeasure> carbonMeasure = new ArrayList<>(); carbonMeasure.add(new CarbonMeasure(column1Schema, 1)); @@ -776,17 +754,14 @@ public class CarbonUtilTest { ColumnSchema column2Schema = new ColumnSchema(); ColumnSchema column3Schema = new ColumnSchema(); column1Schema.setColumnName("Column1"); - column1Schema.setColumnar(true); column1Schema.setEncodingList(Arrays.asList(Encoding.DELTA, Encoding.DICTIONARY)); column2Schema.setColumnName("Column2"); - column2Schema.setColumnar(false); column2Schema.setEncodingList(Arrays.asList(Encoding.DELTA, Encoding.DICTIONARY)); column3Schema.setColumnName("Column3"); - column3Schema.setColumnar(true); column3Schema.setEncodingList(Arrays.asList(Encoding.DELTA, Encoding.INVERTED_INDEX)); - CarbonDimension carbonDimension = new CarbonDimension(column1Schema, 1, 1, 1, 1); - CarbonDimension carbonDimension2 = new CarbonDimension(column2Schema, 2, 2, 2, 2); - CarbonDimension carbonDimension3 = new CarbonDimension(column3Schema, 3, 3, 3, 3); + CarbonDimension carbonDimension = new CarbonDimension(column1Schema, 1, 1, 1); + CarbonDimension carbonDimension2 = new CarbonDimension(column2Schema, 2, 2, 2); + CarbonDimension carbonDimension3 = new CarbonDimension(column3Schema, 3, 3, 3); List<CarbonDimension> carbonDimensions = Arrays.asList(carbonDimension, carbonDimension2, carbonDimension3); boolean[] result = CarbonUtil.identifyDimensionType(carbonDimensions); http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/util/RangeFilterProcessorTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/util/RangeFilterProcessorTest.java b/core/src/test/java/org/apache/carbondata/core/util/RangeFilterProcessorTest.java index 4fb5dcc..9b8be79 100644 --- a/core/src/test/java/org/apache/carbondata/core/util/RangeFilterProcessorTest.java +++ b/core/src/test/java/org/apache/carbondata/core/util/RangeFilterProcessorTest.java @@ -82,7 +82,7 @@ public class RangeFilterProcessorTest { empColumnSchema.setDimensionColumn(true); empColumnSchema.setEncodingList(Arrays.asList(Encoding.DICTIONARY)); empColumnSchema.setDataType(DataTypes.STRING); - CarbonDimension empDimension = new CarbonDimension(empColumnSchema, 0, 0, 0, 0, 0); + CarbonDimension empDimension = new CarbonDimension(empColumnSchema, 0, 0, 0, 0); cola.setDimension(empDimension); Expression greaterThan = @@ -123,7 +123,7 @@ public class RangeFilterProcessorTest { empColumnSchema.setDimensionColumn(true); empColumnSchema.setEncodingList(Arrays.asList(Encoding.DICTIONARY)); empColumnSchema.setDataType(DataTypes.STRING); - CarbonDimension empDimension = new CarbonDimension(empColumnSchema, 0, 0, 0, 0, 0); + CarbonDimension empDimension = new CarbonDimension(empColumnSchema, 0, 0, 0, 0); cola.setDimension(empDimension); Expression greaterThan = @@ -162,7 +162,7 @@ public class RangeFilterProcessorTest { empColumnSchema.setDimensionColumn(true); empColumnSchema.setEncodingList(Arrays.asList(Encoding.DICTIONARY)); empColumnSchema.setDataType(DataTypes.STRING); - CarbonDimension empDimension = new CarbonDimension(empColumnSchema, 0, 0, 0, 0, 0); + CarbonDimension empDimension = new CarbonDimension(empColumnSchema, 0, 0, 0, 0); ColumnExpression cola1 = new ColumnExpression("a", DataTypes.STRING); cola1.setDimension(true); @@ -237,7 +237,7 @@ public class RangeFilterProcessorTest { empColumnSchema.setDimensionColumn(true); empColumnSchema.setEncodingList(Arrays.asList(Encoding.DICTIONARY)); empColumnSchema.setDataType(DataTypes.STRING); - CarbonDimension empDimension = new CarbonDimension(empColumnSchema, 0, 0, 0, 0, 0); + CarbonDimension empDimension = new CarbonDimension(empColumnSchema, 0, 0, 0, 0); ColumnExpression cola1 = new ColumnExpression("a", DataTypes.STRING); cola1.setDimension(true); http://git-wip-us.apache.org/repos/asf/carbondata/blob/f9114036/core/src/test/java/org/apache/carbondata/core/writer/CarbonDictionaryWriterImplTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/writer/CarbonDictionaryWriterImplTest.java b/core/src/test/java/org/apache/carbondata/core/writer/CarbonDictionaryWriterImplTest.java index d5500e1..9f2dc8e 100644 --- a/core/src/test/java/org/apache/carbondata/core/writer/CarbonDictionaryWriterImplTest.java +++ b/core/src/test/java/org/apache/carbondata/core/writer/CarbonDictionaryWriterImplTest.java @@ -119,9 +119,9 @@ public class CarbonDictionaryWriterImplTest { * prepare the dataset required for running test cases */ private void prepareDataSet() { - dataSet1 = Arrays.asList(new String[] { "a", "b" }); - dataSet2 = Arrays.asList(new String[] { "c", "d" }); - dataSet3 = Arrays.asList(new String[] { "e", "f" }); + dataSet1 = Arrays.asList("a", "b"); + dataSet2 = Arrays.asList("c", "d"); + dataSet3 = Arrays.asList("e", "f"); } /**