Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/14618#discussion_r74549431
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/MetadataCache.scala ---
@@ -0,0 +1,174 @@
+/*
+ * 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.hive
+
+import com.google.common.cache.{CacheBuilder, CacheLoader, LoadingCache}
+
+import org.apache.spark.internal.Logging
+import org.apache.spark.sql.{AnalysisException, SparkSession}
+import org.apache.spark.sql.catalyst.TableIdentifier
+import org.apache.spark.sql.catalyst.catalog._
+import org.apache.spark.sql.catalyst.plans.logical._
+import org.apache.spark.sql.execution.command.CreateDataSourceTableUtils._
+import org.apache.spark.sql.execution.datasources.{Partition => _, _}
+import org.apache.spark.sql.types._
+
+
+/**
+ * Metadata cache is a key-value cache built on Google Guava Cache to
speed up building logical plan
+ * nodes (LogicalRelation) for data source tables. The cache key is a
unique identifier of a table.
+ * Here, the identifier is the fully qualified table name, including the
database in which it
+ * resides. The value is the corresponding LogicalRelation that represents
a specific data source
+ * table.
+ */
+private[hive] class MetadataCache(spark: SparkSession) extends Logging {
+ /** A fully qualified identifier for a table (i.e., database.tableName)
*/
+ case class QualifiedTableName(database: String, name: String)
+
+ private def getQualifiedTableName(tableIdent: TableIdentifier):
QualifiedTableName = {
+ QualifiedTableName(
+
tableIdent.database.getOrElse(spark.sessionState.catalog.getCurrentDatabase).toLowerCase,
+ tableIdent.table.toLowerCase)
+ }
+
+ /** A cache of Spark SQL data source tables that have been accessed. */
+ private val cachedDataSourceTables: LoadingCache[QualifiedTableName,
LogicalPlan] = {
+ val cacheLoader = new CacheLoader[QualifiedTableName, LogicalPlan]() {
+ override def load(in: QualifiedTableName): LogicalPlan = {
--- End diff --
The load function is being revised by another PR:
https://github.com/apache/spark/pull/14155. Thus, after that PR is merged, this
function will be reduced a lot
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]