carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [47/50] [abbrv] carbondata git commit: [CARBONDATA-2125] like% filter is giving ArrayIndexOutOfBoundException in case of table having more pages
Date Sat, 03 Feb 2018 19:43:54 GMT
[CARBONDATA-2125] like% filter is giving ArrayIndexOutOfBoundException in case of table having
more pages

Problem: like% filter is giving ArrayIndexOutOfBoundException in case of table having more
pages
Solution: In RowlevelFilter the number of rows should be filled based on the rows in a page.

This closes #1909


Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/50e2f2c8
Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/50e2f2c8
Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/50e2f2c8

Branch: refs/heads/branch-1.3
Commit: 50e2f2c8f2cc6ee4b72839b704a038666ae629ba
Parents: 54b7db5
Author: dhatchayani <dhatcha.official@gmail.com>
Authored: Fri Feb 2 10:55:19 2018 +0530
Committer: ravipesala <ravi.pesala@gmail.com>
Committed: Sat Feb 3 22:55:36 2018 +0530

----------------------------------------------------------------------
 .../executer/RowLevelFilterExecuterImpl.java    | 10 ++++++--
 .../filter/executer/TrueFilterExecutor.java     |  2 +-
 .../filterexpr/FilterProcessorTestCase.scala    | 25 ++++++++++++++++++++
 3 files changed, 34 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/50e2f2c8/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelFilterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelFilterExecuterImpl.java
b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelFilterExecuterImpl.java
index 224a69f..89489a2 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelFilterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelFilterExecuterImpl.java
@@ -205,7 +205,10 @@ public class RowLevelFilterExecuterImpl implements FilterExecuter {
       } else {
         // specific for restructure case where default values need to be filled
         pageNumbers = blockChunkHolder.getDataBlock().numberOfPages();
-        numberOfRows = new int[] { blockChunkHolder.getDataBlock().nodeSize() };
+        numberOfRows = new int[pageNumbers];
+        for (int i = 0; i < pageNumbers; i++) {
+          numberOfRows[i] = blockChunkHolder.getDataBlock().getPageRowCount(i);
+        }
       }
     }
     if (msrColEvalutorInfoList.size() > 0) {
@@ -217,7 +220,10 @@ public class RowLevelFilterExecuterImpl implements FilterExecuter {
       } else {
         // specific for restructure case where default values need to be filled
         pageNumbers = blockChunkHolder.getDataBlock().numberOfPages();
-        numberOfRows = new int[] { blockChunkHolder.getDataBlock().nodeSize() };
+        numberOfRows = new int[pageNumbers];
+        for (int i = 0; i < pageNumbers; i++) {
+          numberOfRows[i] = blockChunkHolder.getDataBlock().getPageRowCount(i);
+        }
       }
     }
     BitSetGroup bitSetGroup = new BitSetGroup(pageNumbers);

http://git-wip-us.apache.org/repos/asf/carbondata/blob/50e2f2c8/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/TrueFilterExecutor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/TrueFilterExecutor.java
b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/TrueFilterExecutor.java
index 92396ae..4b3738a 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/TrueFilterExecutor.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/TrueFilterExecutor.java
@@ -39,7 +39,7 @@ public class TrueFilterExecutor implements FilterExecuter {
     BitSetGroup group = new BitSetGroup(numberOfPages);
     for (int i = 0; i < numberOfPages; i++) {
       BitSet set = new BitSet();
-      set.flip(0, blockChunkHolder.getDataBlock().nodeSize());
+      set.flip(0, blockChunkHolder.getDataBlock().getPageRowCount(i));
       group.setBitSet(set, i);
     }
     return group;

http://git-wip-us.apache.org/repos/asf/carbondata/blob/50e2f2c8/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/filterexpr/FilterProcessorTestCase.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/filterexpr/FilterProcessorTestCase.scala
b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/filterexpr/FilterProcessorTestCase.scala
index b92b379..d54906f 100644
--- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/filterexpr/FilterProcessorTestCase.scala
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/filterexpr/FilterProcessorTestCase.scala
@@ -21,22 +21,30 @@ import java.sql.Timestamp
 
 import org.apache.spark.sql.Row
 import org.scalatest.BeforeAndAfterAll
+
 import org.apache.carbondata.core.constants.CarbonCommonConstants
 import org.apache.carbondata.core.util.CarbonProperties
 import org.apache.spark.sql.test.util.QueryTest
 
+import org.apache.carbondata.spark.testsuite.datacompaction.CompactionSupportGlobalSortBigFileTest
+
 /**
   * Test Class for filter expression query on String datatypes
   *
   */
 class FilterProcessorTestCase extends QueryTest with BeforeAndAfterAll {
 
+  val file1 = resourcesPath + "/filter/file1.csv"
+
   override def beforeAll {
     sql("drop table if exists filtertestTables")
     sql("drop table if exists filtertestTablesWithDecimal")
     sql("drop table if exists filtertestTablesWithNull")
     sql("drop table if exists filterTimestampDataType")
     sql("drop table if exists noloadtable")
+    sql("drop table if exists like_filter")
+
+    CompactionSupportGlobalSortBigFileTest.createFile(file1, 500000, 0)
 
     sql("CREATE TABLE filtertestTables (ID int, date Timestamp, country String, " +
       "name String, phonetype String, serialname String, salary int) " +
@@ -279,6 +287,21 @@ class FilterProcessorTestCase extends QueryTest with BeforeAndAfterAll
{
     sql("drop table if exists outofrange")
   }
 
+  test("like% test case with restructure") {
+    sql("drop table if exists like_filter")
+    sql(
+      """
+        | CREATE TABLE like_filter(id INT, name STRING, city STRING, age INT)
+        | STORED BY 'org.apache.carbondata.format'
+        | TBLPROPERTIES('SORT_COLUMNS'='city,name', 'SORT_SCOPE'='GLOBAL_SORT')
+      """.stripMargin)
+    sql(s"LOAD DATA LOCAL INPATH '$file1' INTO TABLE like_filter OPTIONS('header'='false')")
+    sql(
+      "ALTER TABLE like_filter ADD COLUMNS(filter STRING) TBLPROPERTIES ('DEFAULT.VALUE"
+
+      ".FILTER'='altered column')")
+    checkAnswer(sql("select count(*) from like_filter where filter like '%column'"), Row(500000))
+  }
+
 
 
 
@@ -294,6 +317,8 @@ class FilterProcessorTestCase extends QueryTest with BeforeAndAfterAll
{
     sql("DROP TABLE IF EXISTS big_int_basicc_Hive_1")
     sql("DROP TABLE IF EXISTS filtertestTablesWithNull")
     sql("DROP TABLE IF EXISTS filtertestTablesWithNullJoin")
+    sql("drop table if exists like_filter")
+    CompactionSupportGlobalSortBigFileTest.deleteFile(file1)
     CarbonProperties.getInstance()
       .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, "dd-MM-yyyy")
   }


Mime
View raw message