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_r406576162 ########## File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/index/CarbonCreateIndexCommand.scala ########## @@ -67,128 +82,195 @@ case class CarbonCreateIndexCommand( throw new MalformedCarbonCommandException("Unsupported operation on non transactional table") } - if (DataMapStoreManager.getInstance().isDataMapExist(parentTable.getTableId, indexName)) { - if (!ifNotExistsSet) { - throw new MalformedIndexCommandException( - s"Index with name ${ indexName } on table " + - s"${parentTable.getDatabaseName}.${parentTable.getTableName} already exists") - } else { - return Seq.empty - } + if (parentTable.isMVTable || parentTable.isIndexTable) { + throw new MalformedIndexCommandException( + "Cannot create index on child table `" + indexName + "`") } if (CarbonUtil.getFormatVersion(parentTable) != ColumnarFormatVersion.V3) { - throw new MalformedCarbonCommandException(s"Unsupported operation on table with " + - s"V1 or V2 format data") + throw new MalformedCarbonCommandException( + s"Unsupported operation on table with V1 or V2 format data") } - dataMapSchema = new DataMapSchema(indexName, indexProviderName) + // get metadata lock to avoid concurrent create index operations + val metadataLock = CarbonLockFactory.getCarbonLockObj( + parentTable.getAbsoluteTableIdentifier, + LockUsage.METADATA_LOCK) - val property = properties.map(x => (x._1.trim, x._2.trim)).asJava - val javaMap = new java.util.HashMap[String, String](property) - javaMap.put(DataMapProperty.DEFERRED_REBUILD, deferredRebuild.toString) - javaMap.put(CarbonCommonConstants.INDEX_COLUMNS, indexModel.columnNames.mkString(",")) - dataMapSchema.setProperties(javaMap) + try { + if (metadataLock.lockWithRetries()) { + LOGGER.info(s"Acquired the metadata lock for table $dbName.$parentTableName") + // get carbon table again to reflect any changes during lock acquire. + parentTable = + CarbonEnv.getInstance(sparkSession).carbonMetaStore + .lookupRelation(Some(dbName), parentTableName)(sparkSession) + .asInstanceOf[CarbonRelation].carbonTable + if (parentTable == null) { + throw new MalformedIndexCommandException(errMsg) + } + val oldIndexMetaData = parentTable.getIndexMetadata + // check whether the column has index created already + if (null != oldIndexMetaData) { + val indexExistsInCarbon = oldIndexMetaData.getIndexTables.asScala.contains(indexName) + if (indexExistsInCarbon) { + throw new MalformedIndexCommandException( + "Index with name `" + indexName + "` already exists on table `" + parentTableName + + "`") + } + } + // set properties + indexSchema.setProperties(indexProperties) + provider = new IndexProvider(parentTable, indexSchema, sparkSession) - if (dataMapSchema.isIndex && parentTable == null) { - throw new MalformedIndexCommandException( - "To create index, main table is required. Use `CREATE INDEX ... ON TABLE ...` ") - } - provider = new IndexProvider(parentTable, dataMapSchema, sparkSession) - if (deferredRebuild && !provider.supportRebuild()) { - throw new MalformedIndexCommandException( - s"DEFERRED REFRESH is not supported on this index $indexName" + - s" with provider ${dataMapSchema.getProviderName}") - } + if (deferredRebuild && !provider.supportRebuild()) { + throw new MalformedIndexCommandException( + "DEFERRED REFRESH is not supported on this index " + indexModel.indexName + + " with provider " + indexProviderName) + } else if (deferredRebuild && provider.supportRebuild()) { + indexProperties.put(CarbonCommonConstants.INDEX_STATUS, IndexStatus.DISABLED.name()) + } - if (parentTable.isMVTable) { - throw new MalformedIndexCommandException( - "Cannot create index on MV table " + parentTable.getTableUniqueName) - } + val isBloomFilter = CarbonIndexProvider.BLOOMFILTER.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 |
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_r406576178 ########## File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/index/CarbonCreateIndexCommand.scala ########## @@ -67,128 +82,195 @@ case class CarbonCreateIndexCommand( throw new MalformedCarbonCommandException("Unsupported operation on non transactional table") } - if (DataMapStoreManager.getInstance().isDataMapExist(parentTable.getTableId, indexName)) { - if (!ifNotExistsSet) { - throw new MalformedIndexCommandException( - s"Index with name ${ indexName } on table " + - s"${parentTable.getDatabaseName}.${parentTable.getTableName} already exists") - } else { - return Seq.empty - } + if (parentTable.isMVTable || parentTable.isIndexTable) { + throw new MalformedIndexCommandException( + "Cannot create index on child table `" + indexName + "`") } if (CarbonUtil.getFormatVersion(parentTable) != ColumnarFormatVersion.V3) { - throw new MalformedCarbonCommandException(s"Unsupported operation on table with " + - s"V1 or V2 format data") + throw new MalformedCarbonCommandException( + s"Unsupported operation on table with V1 or V2 format data") } - dataMapSchema = new DataMapSchema(indexName, indexProviderName) + // get metadata lock to avoid concurrent create index operations + val metadataLock = CarbonLockFactory.getCarbonLockObj( + parentTable.getAbsoluteTableIdentifier, + LockUsage.METADATA_LOCK) - val property = properties.map(x => (x._1.trim, x._2.trim)).asJava - val javaMap = new java.util.HashMap[String, String](property) - javaMap.put(DataMapProperty.DEFERRED_REBUILD, deferredRebuild.toString) - javaMap.put(CarbonCommonConstants.INDEX_COLUMNS, indexModel.columnNames.mkString(",")) - dataMapSchema.setProperties(javaMap) + try { + if (metadataLock.lockWithRetries()) { + LOGGER.info(s"Acquired the metadata lock for table $dbName.$parentTableName") + // get carbon table again to reflect any changes during lock acquire. + parentTable = + CarbonEnv.getInstance(sparkSession).carbonMetaStore + .lookupRelation(Some(dbName), parentTableName)(sparkSession) + .asInstanceOf[CarbonRelation].carbonTable + if (parentTable == null) { + throw new MalformedIndexCommandException(errMsg) + } + val oldIndexMetaData = parentTable.getIndexMetadata + // check whether the column has index created already + if (null != oldIndexMetaData) { + val indexExistsInCarbon = oldIndexMetaData.getIndexTables.asScala.contains(indexName) + if (indexExistsInCarbon) { + throw new MalformedIndexCommandException( + "Index with name `" + indexName + "` already exists on table `" + parentTableName + + "`") + } + } + // set properties + indexSchema.setProperties(indexProperties) + provider = new IndexProvider(parentTable, indexSchema, sparkSession) - if (dataMapSchema.isIndex && parentTable == null) { - throw new MalformedIndexCommandException( - "To create index, main table is required. Use `CREATE INDEX ... ON TABLE ...` ") - } - provider = new IndexProvider(parentTable, dataMapSchema, sparkSession) - if (deferredRebuild && !provider.supportRebuild()) { - throw new MalformedIndexCommandException( - s"DEFERRED REFRESH is not supported on this index $indexName" + - s" with provider ${dataMapSchema.getProviderName}") - } + if (deferredRebuild && !provider.supportRebuild()) { + throw new MalformedIndexCommandException( + "DEFERRED REFRESH is not supported on this index " + indexModel.indexName + + " with provider " + indexProviderName) + } else if (deferredRebuild && provider.supportRebuild()) { + indexProperties.put(CarbonCommonConstants.INDEX_STATUS, IndexStatus.DISABLED.name()) + } - if (parentTable.isMVTable) { - throw new MalformedIndexCommandException( - "Cannot create index on MV table " + parentTable.getTableUniqueName) - } + val isBloomFilter = CarbonIndexProvider.BLOOMFILTER.getIndexProviderName + .equalsIgnoreCase(indexProviderName) - if (parentTable.isIndexTable) { - throw new MalformedIndexCommandException( - "Cannot create index on Secondary Index table") - } + val existingIndexColumn4ThisProvider = 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 |
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_r406576221 ########## File path: core/src/main/java/org/apache/carbondata/core/metadata/schema/table/CarbonTable.java ########## @@ -1202,21 +1192,64 @@ public boolean isIndexTable() throws IOException { } } + public List<String> getIndexTableNames(String indexProvider) throws IOException { + deserializeIndexMetadata(); + if (null != indexMetadata) { + return indexMetadata.getIndexTables(indexProvider); + } else { + return new ArrayList<>(); + } + } + public String getIndexInfo() throws IOException { + return getIndexInfo(null); + } + + public IndexMetadata getIndexMetadata() throws IOException { + deserializeIndexMetadata(); + return indexMetadata; + } + + public String getIndexInfo(String indexProvider) throws IOException { deserializeIndexMetadata(); if (null != indexMetadata) { - IndexTableInfo[] indexTableInfos = - new IndexTableInfo[indexMetadata.getIndexesMap().entrySet().size()]; - int index = 0; - if (!isIndexTable()) { - for (Map.Entry<String, List<String>> entry : indexMetadata.getIndexesMap().entrySet()) { - indexTableInfos[index] = - new IndexTableInfo(getDatabaseName(), entry.getKey(), entry.getValue()); - index++; + if (null != indexProvider) { + if (null != indexMetadata.getIndexesMap().get(indexProvider)) { + IndexTableInfo[] indexTableInfos = + new IndexTableInfo[indexMetadata.getIndexesMap().get(indexProvider).entrySet() + .size()]; + int index = 0; + if (!isIndexTable()) { 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 |
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_r406576369 ########## File path: core/src/main/java/org/apache/carbondata/core/index/IndexStoreManager.java ########## @@ -820,8 +715,11 @@ public synchronized void clearInvalidIndex(CarbonTable carbonTable, List<String> } private boolean hasCGIndex(CarbonTable carbonTable) throws IOException { - for (TableIndex tableIndex : getAllVisibleIndexes(carbonTable)) { - if (tableIndex.getIndexFactory().getDataMapLevel().equals(IndexLevel.CG)) { + if (null == carbonTable) { Review comment: It will be null in case of file format flow ---------------------------------------------------------------- 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 |
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_r406576435 ########## File path: core/src/main/java/org/apache/carbondata/core/datamap/dev/IndexFactory.java ########## @@ -187,7 +187,8 @@ public void deleteSegmentIndexData(String segmentNo) throws IOException { * 4. INDEX_COLUMNS should be exists in table columns */ public void validate() throws MalformedIndexCommandException { - List<CarbonColumn> indexColumns = carbonTable.getIndexedColumns(dataMapSchema); + List<CarbonColumn> indexColumns = + carbonTable.getIndexedColumns(dataMapSchema.getIndexColumns()); 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 |
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-611880284 Build Failed with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/988/ ---------------------------------------------------------------- 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 |
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-611880823 Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/2701/ ---------------------------------------------------------------- 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 |
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-611937488 Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/2705/ ---------------------------------------------------------------- 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 |
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-611942208 Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/992/ ---------------------------------------------------------------- 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 |
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-611958770 @ajantha-bhat Fixed all comments. Please review ---------------------------------------------------------------- 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 |
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_r406777679 ########## File path: integration/spark/src/main/scala/org/apache/spark/sql/parser/CarbonSpark2SqlParser.scala ########## @@ -505,7 +505,7 @@ class CarbonSpark2SqlParser extends CarbonDDLSqlParser { } /** - * INSERT INTO [dbName.]tableName STAGE [OPTIONS (key1=value1, key2=value2, ...)] + * INSERT INTO [dbName.]indexName STAGE [OPTIONS (key1=value1, key2=value2, ...)] Review comment: this is still a table name. ---------------------------------------------------------------- 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 |
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_r406783323 ########## File path: integration/spark/src/main/scala/org/apache/spark/sql/parser/CarbonSpark2SqlParser.scala ########## @@ -505,7 +505,7 @@ class CarbonSpark2SqlParser extends CarbonDDLSqlParser { } /** - * INSERT INTO [dbName.]tableName STAGE [OPTIONS (key1=value1, key2=value2, ...)] + * INSERT INTO [dbName.]indexName STAGE [OPTIONS (key1=value1, key2=value2, ...)] Review comment: Reverted ---------------------------------------------------------------- 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 |
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-612117361 Build Failed with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/998/ ---------------------------------------------------------------- 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 |
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-612131142 Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/2710/ ---------------------------------------------------------------- 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 |
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-612787201 please rebase. LGTM. I feel two people review is better for this PR as changes are more files and chances of missing some issues are more. @jackylk , @QiangCai . @akashrn5 , @kunal642 : can anyone else review ? ---------------------------------------------------------------- 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 |
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-612794400 Build Failed with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/2719/ ---------------------------------------------------------------- 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 |
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-612795589 Build Failed with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/1007/ ---------------------------------------------------------------- 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 |
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-612820846 Build Failed with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/2723/ ---------------------------------------------------------------- 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 |
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-612822372 Build Failed with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/1011/ ---------------------------------------------------------------- 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 |
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-612891431 Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/1013/ ---------------------------------------------------------------- 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 |
Free forum by Nabble | Edit this page |