kasakrisz commented on a change in pull request #2984:
URL: https://github.com/apache/hive/pull/2984#discussion_r795383856



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveMaterializedViewsRegistry.java
##########
@@ -97,23 +98,83 @@
   private static final Logger LOG = 
LoggerFactory.getLogger(HiveMaterializedViewsRegistry.class);
   private static final String CLASS_NAME = 
HiveMaterializedViewsRegistry.class.getName();
 
-  /* Singleton */
-  private static final HiveMaterializedViewsRegistry SINGLETON = new 
HiveMaterializedViewsRegistry();
+  /**
+   * Registry for materialized views. The goal of this cache is to avoid 
parsing and creating
+   * logical plans for the materialized views at query runtime. When a query 
arrives, we will
+   * just need to consult this cache and extract the logical plans for the 
views (which had
+   * already been parsed) from it. This cache lives in HS2.
+   */
+  public interface MaterializedViewsRegistry {
 
-  private final MaterializedViewsCache materializedViewsCache = new 
MaterializedViewsCache();
+    /**
+     * Adds a newly created materialized view to the cache.

Review comment:
       Changed cache to registry, since this is more like a registry.

##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveMaterializedViewsRegistry.java
##########
@@ -97,23 +98,83 @@
   private static final Logger LOG = 
LoggerFactory.getLogger(HiveMaterializedViewsRegistry.class);
   private static final String CLASS_NAME = 
HiveMaterializedViewsRegistry.class.getName();
 
-  /* Singleton */
-  private static final HiveMaterializedViewsRegistry SINGLETON = new 
HiveMaterializedViewsRegistry();
+  /**
+   * Registry for materialized views. The goal of this cache is to avoid 
parsing and creating
+   * logical plans for the materialized views at query runtime. When a query 
arrives, we will
+   * just need to consult this cache and extract the logical plans for the 
views (which had
+   * already been parsed) from it. This cache lives in HS2.
+   */
+  public interface MaterializedViewsRegistry {
 
-  private final MaterializedViewsCache materializedViewsCache = new 
MaterializedViewsCache();
+    /**
+     * Adds a newly created materialized view to the cache.
+     */
+    default void createMaterializedView(HiveConf conf, Table 
materializedViewTable) { }
 
-  /* Whether the cache has been initialized or not. */
-  private final AtomicBoolean initialized = new AtomicBoolean(false);
+    /**
+     * Update the materialized view in the registry (if existing materialized 
view matches).
+     */
+    default void refreshMaterializedView(HiveConf conf, Table 
materializedViewTable) {
+
+    }
 
-  private HiveMaterializedViewsRegistry() {
+    /**
+     * Update the materialized view in the registry (if existing materialized 
view matches).
+     */
+    default void refreshMaterializedView(HiveConf conf, Table 
oldMaterializedViewTable, Table materializedViewTable) {
+
+    }
+
+    /**
+     * Removes the materialized view from the cache (based on table object 
equality), if exists.
+     */
+    default void dropMaterializedView(Table materializedViewTable) { }
+
+    /**
+     * Removes the materialized view from the cache (based on qualified name), 
if exists.
+     */
+    default void dropMaterializedView(String dbName, String tableName) { }
+
+    /**
+     * Returns all the materialized views enabled for Calcite based rewriting 
in the cache.
+     *
+     * @return the collection of materialized views, or the empty collection 
if none
+     */
+    default List<HiveRelOptMaterialization> getRewritingMaterializedViews() { 
return Collections.emptyList(); }
+
+    /**
+     * Returns the materialized views in the cache for the given database.
+     *
+     * @return the collection of materialized views, or the empty collection 
if none
+     */

Review comment:
       Fixed

##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveMaterializedViewsRegistry.java
##########
@@ -97,23 +98,83 @@
   private static final Logger LOG = 
LoggerFactory.getLogger(HiveMaterializedViewsRegistry.class);
   private static final String CLASS_NAME = 
HiveMaterializedViewsRegistry.class.getName();
 
-  /* Singleton */
-  private static final HiveMaterializedViewsRegistry SINGLETON = new 
HiveMaterializedViewsRegistry();
+  /**
+   * Registry for materialized views. The goal of this cache is to avoid 
parsing and creating
+   * logical plans for the materialized views at query runtime. When a query 
arrives, we will
+   * just need to consult this cache and extract the logical plans for the 
views (which had
+   * already been parsed) from it. This cache lives in HS2.
+   */
+  public interface MaterializedViewsRegistry {
 
-  private final MaterializedViewsCache materializedViewsCache = new 
MaterializedViewsCache();
+    /**
+     * Adds a newly created materialized view to the cache.
+     */
+    default void createMaterializedView(HiveConf conf, Table 
materializedViewTable) { }
 
-  /* Whether the cache has been initialized or not. */
-  private final AtomicBoolean initialized = new AtomicBoolean(false);
+    /**
+     * Update the materialized view in the registry (if existing materialized 
view matches).
+     */
+    default void refreshMaterializedView(HiveConf conf, Table 
materializedViewTable) {
+
+    }
 
-  private HiveMaterializedViewsRegistry() {
+    /**
+     * Update the materialized view in the registry (if existing materialized 
view matches).
+     */
+    default void refreshMaterializedView(HiveConf conf, Table 
oldMaterializedViewTable, Table materializedViewTable) {
+
+    }
+
+    /**
+     * Removes the materialized view from the cache (based on table object 
equality), if exists.
+     */
+    default void dropMaterializedView(Table materializedViewTable) { }
+
+    /**
+     * Removes the materialized view from the cache (based on qualified name), 
if exists.
+     */
+    default void dropMaterializedView(String dbName, String tableName) { }
+
+    /**
+     * Returns all the materialized views enabled for Calcite based rewriting 
in the cache.
+     *
+     * @return the collection of materialized views, or the empty collection 
if none
+     */
+    default List<HiveRelOptMaterialization> getRewritingMaterializedViews() { 
return Collections.emptyList(); }
+
+    /**
+     * Returns the materialized views in the cache for the given database.
+     *
+     * @return the collection of materialized views, or the empty collection 
if none
+     */
+    default HiveRelOptMaterialization getRewritingMaterializedView(
+            String dbName, String viewName, 
EnumSet<HiveRelOptMaterialization.RewriteAlgorithm> scope) {
+      return null;
+    }
+
+    default List<HiveRelOptMaterialization> 
getRewritingMaterializedViews(String querySql) {
+      return Collections.emptyList();
+    }
+
+    default boolean isEmpty() {
+      return true;
+    }

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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to