You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by GitBox <gi...@apache.org> on 2019/03/06 05:39:15 UTC

[GitHub] [carbondata] kunal642 commented on a change in pull request #3138: [CARBONDATA-3305] Added DDL to drop cache for a table

kunal642 commented on a change in pull request #3138: [CARBONDATA-3305] Added DDL to drop cache for a table
URL: https://github.com/apache/carbondata/pull/3138#discussion_r262797734
 
 

 ##########
 File path: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/cache/CarbonDropCacheCommand.scala
 ##########
 @@ -0,0 +1,113 @@
+/*
+ * 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.spark.sql.execution.command.cache
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.ListBuffer
+
+import org.apache.spark.sql.{CarbonEnv, Row, SparkSession}
+import org.apache.spark.sql.catalyst.TableIdentifier
+import org.apache.spark.sql.execution.command.MetadataCommand
+
+import org.apache.carbondata.core.cache.CacheProvider
+import org.apache.carbondata.core.cache.dictionary.AbstractColumnDictionaryInfo
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.indexstore.BlockletDataMapIndexWrapper
+import org.apache.carbondata.core.metadata.schema.table.CarbonTable
+import org.apache.carbondata.datamap.bloom.BloomCacheKeyValue
+
+case class CarbonDropCacheCommand(tableIdentifier: TableIdentifier) extends MetadataCommand {
+
+  def clearCache(sparkSession: SparkSession, carbonTable: CarbonTable): Unit = {
+    val tableName = carbonTable.getTableName
+    val databaseName = carbonTable.getDatabaseName
+    val cache = CacheProvider.getInstance().getCarbonCache
+    if (cache != null) {
+      val dbLocation = CarbonEnv
+        .getDatabaseLocation(tableIdentifier.database
+          .getOrElse(sparkSession.catalog.currentDatabase), sparkSession)
+        .replace(CarbonCommonConstants.WINDOWS_FILE_SEPARATOR,
+          CarbonCommonConstants.FILE_SEPARATOR)
+
+      // If table has children tables as well, add them to tablePathsBuffer
+      val tablePathsBuffer = scala.collection.mutable.ArrayBuffer.empty[String]
+      tablePathsBuffer += dbLocation + CarbonCommonConstants.FILE_SEPARATOR +
+                          tableName + CarbonCommonConstants.FILE_SEPARATOR
+      if (carbonTable.hasDataMapSchema) {
+        val childrenSchemas = carbonTable.getTableInfo.getDataMapSchemaList.asScala
 
 Review comment:
   Please add a event and listener to handle datamap drop. Refer DropTableCommand to see how to do the same.
   
   Same has to be done for show cache command

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services