[GitHub] [carbondata] Indhumathi27 opened a new pull request #3688: [WIP] Refactor Index Metadata

classic Classic list List threaded Threaded
119 messages Options
123456
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
ajantha-bhat commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#discussion_r406055127
 
 

 ##########
 File path: integration/spark/src/main/scala/org/apache/spark/sql/secondaryindex/events/SILoadEventListener.scala
 ##########
 @@ -61,21 +61,18 @@ class SILoadEventListener extends OperationEventListener with Logging {
         val indexMetadata = IndexMetadata
           .deserialize(carbonTable.getTableInfo.getFactTable.getTableProperties
             .get(carbonTable.getCarbonTableIdentifier.getTableId))
-        if (null != indexMetadata && null != indexMetadata.getIndexesMap && null != indexMetadata
-          .getIndexesMap.get(CarbonIndexProvider.SI.getIndexProviderName)) {
+        val provider = CarbonIndexProvider.SI.getIndexProviderName
 
 Review comment:
   ```suggestion
           val secondaryIndexProvider = CarbonIndexProvider.SI.getIndexProviderName
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
ajantha-bhat commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#discussion_r406056076
 
 

 ##########
 File path: integration/spark/src/main/scala/org/apache/spark/sql/index/CarbonIndexUtil.scala
 ##########
 @@ -105,7 +105,8 @@ object CarbonIndexUtil {
     val indexMeta = carbonTable.getTableInfo.getFactTable.getTableProperties
       .get(carbonTable.getCarbonTableIdentifier.getTableId)
     val indexesTables = if (null != indexMeta) {
 
 Review comment:
   ```suggestion
       val SecondaryIndexTables = if (null != indexMeta) {
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
ajantha-bhat commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#discussion_r406066860
 
 

 ##########
 File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/index/ShowIndexesCommand.scala
 ##########
 @@ -54,69 +62,87 @@ case class ShowIndexesCommand(
   override def processData(sparkSession: SparkSession): Seq[Row] = {
     val carbonTable = CarbonEnv.getCarbonTable(dbNameOp, tableName)(sparkSession)
     setAuditTable(carbonTable)
-    getFileIndexInfo(carbonTable) ++ getSIInfo(sparkSession, carbonTable)
-  }
-
-  // get info for 'index datamap'
-  private def getFileIndexInfo(carbonTable: CarbonTable): Seq[Row] = {
-    val indexes = DataMapStoreManager.getInstance().getDataMapSchemasOfTable(carbonTable).asScala
-    if (indexes != null && indexes.nonEmpty) {
-      indexes.map { index =>
-        Row(
-          index.getDataMapName,
-          index.getProviderName,
-          index.getIndexColumns.mkString(","),
-          index.getPropertiesAsString,
-          index.getStatus.name(),
-          index.getSyncStatus
-        )
-      }
-    } else {
-      Seq.empty
-    }
+    getIndexInfo(sparkSession, carbonTable)
   }
 
-  // get info for SI
-  private def getSIInfo(sparkSession: SparkSession, carbonTable: CarbonTable): Seq[Row] = {
+  private def getIndexInfo(sparkSession: SparkSession, carbonTable: CarbonTable): Seq[Row] = {
     CarbonInternalMetastore.refreshIndexInfo(
       carbonTable.getDatabaseName, tableName, carbonTable)(sparkSession)
-    val indexesMap = CarbonInternalScalaUtil.getIndexesMap(carbonTable)
-    if (null == indexesMap) {
-      throw new Exception("Secondary index information is not loaded in main table")
-    }
-    val indexTableMap = indexesMap.asScala
-    if (indexTableMap.nonEmpty) {
-      val indexList = indexTableMap.map { indexInfo =>
-        try {
-          val isSITableEnabled = sparkSession.sessionState.catalog
-            .getTableMetadata(TableIdentifier(indexInfo._1, dbNameOp)).storage.properties
-            .getOrElse("isSITableEnabled", "true").equalsIgnoreCase("true")
-          if (isSITableEnabled) {
-            (indexInfo._1, indexInfo._2.asScala.mkString(","), "enabled")
-          } else {
-            (indexInfo._1, indexInfo._2.asScala.mkString(","), "disabled")
+    val indexesMap = CarbonIndexUtil.getIndexesMap(carbonTable)
+    if (null != indexesMap) {
+      val indexTableMap = indexesMap.asScala
+      if (indexTableMap.nonEmpty) {
+        val secondaryIndex = indexTableMap.get(CarbonIndexProvider.SI.getIndexProviderName)
+        var finalIndexList: Seq[(String, String, String, String, String, String)] = Seq.empty
+
+        if (secondaryIndex.isDefined && null != secondaryIndex.get) {
+          val siIterator = secondaryIndex.get.entrySet().iterator()
+          while (siIterator.hasNext) {
+            val indexInfo = siIterator.next()
+            try {
+              val isSITableEnabled = sparkSession.sessionState.catalog
+                .getTableMetadata(TableIdentifier(indexInfo.getKey, dbNameOp)).storage.properties
+                .getOrElse("isSITableEnabled", "true").equalsIgnoreCase("true")
+              if (isSITableEnabled) {
+                finalIndexList = finalIndexList :+
+                                 (indexInfo.getKey, "carbondata", indexInfo.getValue
+                                   .get(CarbonCommonConstants.INDEX_COLUMNS), "NA", "enabled", "NA")
+              } else {
+                finalIndexList = finalIndexList :+
+                                 (indexInfo.getKey, "carbondata", indexInfo.getValue
+                                   .get(CarbonCommonConstants
+                                     .INDEX_COLUMNS), "NA", "disabled", "NA")
+              }
+            } catch {
+              case ex: Exception =>
+                LOGGER.error(s"Access storage properties from hive failed for index table: ${
+                  indexInfo.getKey
+                }")
+                finalIndexList = finalIndexList :+
+                                 (indexInfo.getKey, "carbondata", indexInfo.getValue
+                                   .get(CarbonCommonConstants.INDEX_COLUMNS), "NA", "UNKNOWN", "NA")
+            }
+          }
+        }
+
+        indexesMap.asScala
+          .filter(map => !map._1.equalsIgnoreCase(CarbonIndexProvider.SI.getIndexProviderName))
 
 Review comment:
   No. Now you have map1(map2(map3)))
   SI map - map2(map3)
   Cgfgmap - map2(map3)
   Instead of 3 level map it is two level map. It saves default map location size of map1.
   
   More over size, no need of lookup and code may be cleaner. You can check.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] ajantha-bhat commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
ajantha-bhat commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#issuecomment-611423944
 
 
   We are making cg, fg index like secondary index. But SI is a table, cg fg is not a table. So need separate handling. Which makes code more complex and hard to maintain. @jackylk @qiangcai @indhumathi27

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] Indhumathi27 commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
Indhumathi27 commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#issuecomment-611425237
 
 
   @ajantha-bhat But we are storing only index meta data to carbon table. So, all indexes info will be same

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#discussion_r406071579
 
 

 ##########
 File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/index/ShowIndexesCommand.scala
 ##########
 @@ -54,69 +62,87 @@ case class ShowIndexesCommand(
   override def processData(sparkSession: SparkSession): Seq[Row] = {
     val carbonTable = CarbonEnv.getCarbonTable(dbNameOp, tableName)(sparkSession)
     setAuditTable(carbonTable)
-    getFileIndexInfo(carbonTable) ++ getSIInfo(sparkSession, carbonTable)
-  }
-
-  // get info for 'index datamap'
-  private def getFileIndexInfo(carbonTable: CarbonTable): Seq[Row] = {
-    val indexes = DataMapStoreManager.getInstance().getDataMapSchemasOfTable(carbonTable).asScala
-    if (indexes != null && indexes.nonEmpty) {
-      indexes.map { index =>
-        Row(
-          index.getDataMapName,
-          index.getProviderName,
-          index.getIndexColumns.mkString(","),
-          index.getPropertiesAsString,
-          index.getStatus.name(),
-          index.getSyncStatus
-        )
-      }
-    } else {
-      Seq.empty
-    }
+    getIndexInfo(sparkSession, carbonTable)
   }
 
-  // get info for SI
-  private def getSIInfo(sparkSession: SparkSession, carbonTable: CarbonTable): Seq[Row] = {
+  private def getIndexInfo(sparkSession: SparkSession, carbonTable: CarbonTable): Seq[Row] = {
     CarbonInternalMetastore.refreshIndexInfo(
       carbonTable.getDatabaseName, tableName, carbonTable)(sparkSession)
-    val indexesMap = CarbonInternalScalaUtil.getIndexesMap(carbonTable)
-    if (null == indexesMap) {
-      throw new Exception("Secondary index information is not loaded in main table")
-    }
-    val indexTableMap = indexesMap.asScala
-    if (indexTableMap.nonEmpty) {
-      val indexList = indexTableMap.map { indexInfo =>
-        try {
-          val isSITableEnabled = sparkSession.sessionState.catalog
-            .getTableMetadata(TableIdentifier(indexInfo._1, dbNameOp)).storage.properties
-            .getOrElse("isSITableEnabled", "true").equalsIgnoreCase("true")
-          if (isSITableEnabled) {
-            (indexInfo._1, indexInfo._2.asScala.mkString(","), "enabled")
-          } else {
-            (indexInfo._1, indexInfo._2.asScala.mkString(","), "disabled")
+    val indexesMap = CarbonIndexUtil.getIndexesMap(carbonTable)
+    if (null != indexesMap) {
+      val indexTableMap = indexesMap.asScala
+      if (indexTableMap.nonEmpty) {
+        val secondaryIndex = indexTableMap.get(CarbonIndexProvider.SI.getIndexProviderName)
+        var finalIndexList: Seq[(String, String, String, String, String, String)] = Seq.empty
+
+        if (secondaryIndex.isDefined && null != secondaryIndex.get) {
+          val siIterator = secondaryIndex.get.entrySet().iterator()
+          while (siIterator.hasNext) {
+            val indexInfo = siIterator.next()
+            try {
+              val isSITableEnabled = sparkSession.sessionState.catalog
+                .getTableMetadata(TableIdentifier(indexInfo.getKey, dbNameOp)).storage.properties
+                .getOrElse("isSITableEnabled", "true").equalsIgnoreCase("true")
+              if (isSITableEnabled) {
+                finalIndexList = finalIndexList :+
+                                 (indexInfo.getKey, "carbondata", indexInfo.getValue
+                                   .get(CarbonCommonConstants.INDEX_COLUMNS), "NA", "enabled", "NA")
+              } else {
+                finalIndexList = finalIndexList :+
+                                 (indexInfo.getKey, "carbondata", indexInfo.getValue
+                                   .get(CarbonCommonConstants
+                                     .INDEX_COLUMNS), "NA", "disabled", "NA")
+              }
+            } catch {
+              case ex: Exception =>
+                LOGGER.error(s"Access storage properties from hive failed for index table: ${
+                  indexInfo.getKey
+                }")
+                finalIndexList = finalIndexList :+
+                                 (indexInfo.getKey, "carbondata", indexInfo.getValue
+                                   .get(CarbonCommonConstants.INDEX_COLUMNS), "NA", "UNKNOWN", "NA")
+            }
+          }
+        }
+
+        indexesMap.asScala
+          .filter(map => !map._1.equalsIgnoreCase(CarbonIndexProvider.SI.getIndexProviderName))
 
 Review comment:
   Yes. But if we keep single map with provider and index info, it will be easier to validate index, add index info to hive and drop index. Else, seperately, we need to do for both

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
CarbonDataQA1 commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#issuecomment-611469098
 
 
   Build Failed  with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/978/
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
CarbonDataQA1 commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#issuecomment-611470184
 
 
   Build Failed  with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/2691/
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
CarbonDataQA1 commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#issuecomment-611495688
 
 
   Build Failed  with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/2692/
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
CarbonDataQA1 commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#issuecomment-611501936
 
 
   Build Failed  with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/979/
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
CarbonDataQA1 commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#issuecomment-611621773
 
 
   Build Failed  with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/983/
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
CarbonDataQA1 commented on issue #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#issuecomment-611637209
 
 
   Build Failed  with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/2696/
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#discussion_r406575861
 
 

 ##########
 File path: integration/spark/src/main/scala/org/apache/spark/sql/index/CarbonIndexUtil.scala
 ##########
 @@ -105,7 +105,8 @@ object CarbonIndexUtil {
     val indexMeta = carbonTable.getTableInfo.getFactTable.getTableProperties
       .get(carbonTable.getCarbonTableIdentifier.getTableId)
     val indexesTables = if (null != indexMeta) {
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#discussion_r406575887
 
 

 ##########
 File path: integration/spark/src/main/scala/org/apache/spark/sql/secondaryindex/events/SILoadEventListener.scala
 ##########
 @@ -61,21 +61,18 @@ class SILoadEventListener extends OperationEventListener with Logging {
         val indexMetadata = IndexMetadata
           .deserialize(carbonTable.getTableInfo.getFactTable.getTableProperties
             .get(carbonTable.getCarbonTableIdentifier.getTableId))
-        if (null != indexMetadata && null != indexMetadata.getIndexesMap && null != indexMetadata
-          .getIndexesMap.get(CarbonIndexProvider.SI.getIndexProviderName)) {
+        val provider = CarbonIndexProvider.SI.getIndexProviderName
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#discussion_r406575910
 
 

 ##########
 File path: integration/spark/src/main/scala/org/apache/spark/sql/secondaryindex/events/SILoadEventListenerForFailedSegments.scala
 ##########
 @@ -67,10 +67,11 @@ class SILoadEventListenerForFailedSegments extends OperationEventListener with L
           .deserialize(carbonTable.getTableInfo.getFactTable.getTableProperties
             .get(carbonTable.getCarbonTableIdentifier.getTableId))
         val mainTableDetails = SegmentStatusManager.readLoadMetadata(carbonTable.getMetadataPath)
+        val providerName = CarbonIndexProvider.SI.getIndexProviderName
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#discussion_r406575949
 
 

 ##########
 File path: integration/spark/src/main/scala/org/apache/spark/sql/secondaryindex/hive/CarbonInternalMetastore.scala
 ##########
 @@ -192,6 +226,42 @@ object CarbonInternalMetastore {
           LOGGER.error(e.getMessage)
       }
     }
+    if (null != indexExists) {
+      if (null != carbonTable && (null == indexExists || indexExists.toBoolean)) {
 
 Review comment:
   Handled

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#discussion_r406575980
 
 

 ##########
 File path: integration/spark/src/main/scala/org/apache/spark/sql/secondaryindex/hive/CarbonInternalMetastore.scala
 ##########
 @@ -136,14 +137,16 @@ object CarbonInternalMetastore {
 
   def refreshIndexInfo(dbName: String, tableName: String,
       carbonTable: CarbonTable, needLock: Boolean = true)(sparkSession: SparkSession): Unit = {
-    val indexTableExists = CarbonInternalScalaUtil.isIndexTableExists(carbonTable)
+    val indexTableExists = CarbonIndexUtil.isIndexTableExists(carbonTable)
 
 Review comment:
   Added

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#discussion_r406576037
 
 

 ##########
 File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/index/CarbonRefreshIndexCommand.scala
 ##########
 @@ -71,30 +80,81 @@ case class CarbonRefreshIndexCommand(
   private def refreshIndex(
       sparkSession: SparkSession,
       parentTable: CarbonTable,
-      indexOp: Optional[DataMapSchema]): Unit = {
-    val schema = indexOp.get
+      indexMetaData: IndexMetadata): Unit = {
+    var indexInfo: util.Map[String, String] = new util.HashMap[String, String]()
+    val allIndexesIterator = indexMetaData.getIndexesMap.entrySet().iterator()
+    breakable {
+      while (allIndexesIterator.hasNext) {
+        val currentIndex = allIndexesIterator.next()
+        if (!currentIndex.getKey.equalsIgnoreCase(CarbonIndexProvider.SI.getIndexProviderName)) {
+          val indexIterator = currentIndex.getValue.entrySet().iterator()
+          while (indexIterator.hasNext) {
+            val indexEntry = indexIterator.next()
+            if (indexEntry.getKey.equalsIgnoreCase(indexName)) {
+              indexInfo = indexEntry.getValue
+              break()
+            }
+          }
+        }
+      }
+    }
+    if (indexInfo.isEmpty) {
+      throw new MalformedIndexCommandException(
+        "Index with name `" + indexName + "` is not present" +
+        "on table `" + parentTable.getTableName + "`")
+    }
+    val indexProviderName = indexInfo.get(CarbonCommonConstants.INDEX_PROVIDER)
+    val schema = new DataMapSchema(indexName, indexProviderName)
+    schema.setProperties(indexInfo)
     if (!schema.isLazy) {
       throw new MalformedIndexCommandException(
         s"Non-lazy index $indexName does not support manual refresh")
     }
 
     val provider = DataMapManager.get().getDataMapProvider(parentTable, schema, sparkSession)
     provider.rebuild()
+    // enable bloom or lucene index
+    // get metadata lock to avoid concurrent create index operations
+    val metadataLock = CarbonLockFactory.getCarbonLockObj(
+      parentTable.getAbsoluteTableIdentifier,
+      LockUsage.METADATA_LOCK)
+    try {
+      if (metadataLock.lockWithRetries()) {
+        LOGGER.info(s"Acquired the metadata lock for table " +
+                    s"${ parentTable.getDatabaseName}.${ parentTable.getTableName }")
+        val oldIndexInfo = parentTable.getIndexInfo
+        val updatedIndexInfo = IndexTableInfo.enableIndex(oldIndexInfo, indexName)
+
+        // set index information in parent table
+        val parentIndexMetadata =
+          IndexMetadata.deserialize(parentTable.getTableInfo.getFactTable.getTableProperties
 
 Review comment:
   Handled

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#discussion_r406576086
 
 

 ##########
 File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/index/CarbonRefreshIndexCommand.scala
 ##########
 @@ -71,30 +80,81 @@ case class CarbonRefreshIndexCommand(
   private def refreshIndex(
       sparkSession: SparkSession,
       parentTable: CarbonTable,
-      indexOp: Optional[DataMapSchema]): Unit = {
-    val schema = indexOp.get
+      indexMetaData: IndexMetadata): Unit = {
+    var indexInfo: util.Map[String, String] = new util.HashMap[String, String]()
+    val allIndexesIterator = indexMetaData.getIndexesMap.entrySet().iterator()
+    breakable {
+      while (allIndexesIterator.hasNext) {
+        val currentIndex = allIndexesIterator.next()
+        if (!currentIndex.getKey.equalsIgnoreCase(CarbonIndexProvider.SI.getIndexProviderName)) {
+          val indexIterator = currentIndex.getValue.entrySet().iterator()
+          while (indexIterator.hasNext) {
+            val indexEntry = indexIterator.next()
+            if (indexEntry.getKey.equalsIgnoreCase(indexName)) {
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes

GitBox
In reply to this post by GitBox
Indhumathi27 commented on a change in pull request #3688: [CARBONDATA-3765] Refactor Index Metadata for CG and FG Indexes
URL: https://github.com/apache/carbondata/pull/3688#discussion_r406576125
 
 

 ##########
 File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/index/CarbonRefreshIndexCommand.scala
 ##########
 @@ -71,30 +80,81 @@ case class CarbonRefreshIndexCommand(
   private def refreshIndex(
       sparkSession: SparkSession,
       parentTable: CarbonTable,
-      indexOp: Optional[DataMapSchema]): Unit = {
-    val schema = indexOp.get
+      indexMetaData: IndexMetadata): Unit = {
+    var indexInfo: util.Map[String, String] = new util.HashMap[String, String]()
+    val allIndexesIterator = indexMetaData.getIndexesMap.entrySet().iterator()
+    breakable {
+      while (allIndexesIterator.hasNext) {
+        val currentIndex = allIndexesIterator.next()
+        if (!currentIndex.getKey.equalsIgnoreCase(CarbonIndexProvider.SI.getIndexProviderName)) {
 
 Review comment:
   handled

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services
123456