kasakrisz commented on a change in pull request #2984:
URL: https://github.com/apache/hive/pull/2984#discussion_r795393121
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveMaterializedViewsRegistry.java
##########
@@ -139,109 +200,262 @@ public void init() {
}
}
- public void init(Hive db) {
+ private static void init(Hive db) {
final boolean dummy =
db.getConf().get(HiveConf.ConfVars.HIVE_SERVER2_MATERIALIZED_VIEWS_REGISTRY_IMPL.varname)
.equals("DUMMY");
if (dummy) {
// Dummy registry does not cache information and forwards all requests
to metastore
- initialized.set(true);
+ SINGLETON = new MaterializedViewsRegistry() {};
LOG.info("Using dummy materialized views registry");
} else {
+ SINGLETON = new
InMemoryMaterializedViewsRegistry(HiveMaterializedViewsRegistry::createMaterialization);
// We initialize the cache
long period = HiveConf.getTimeVar(db.getConf(),
ConfVars.HIVE_SERVER2_MATERIALIZED_VIEWS_REGISTRY_REFRESH, TimeUnit.SECONDS);
+ if (period <= 0) {
+ return;
+ }
+
ScheduledExecutorService pool =
Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("HiveMaterializedViewsRegistry-%d")
.build());
- pool.scheduleAtFixedRate(new Loader(db), 0, period, TimeUnit.SECONDS);
+
+ MaterializedViewObjects objects =
db::getAllMaterializedViewObjectsForRewriting;
+ pool.scheduleAtFixedRate(new Loader(db.getConf(), SINGLETON, objects),
0, period, TimeUnit.SECONDS);
}
}
- private class Loader implements Runnable {
- private final Hive db;
+ public interface MaterializedViewObjects {
+ List<Table> getAllMaterializedViewObjectsForRewriting() throws
HiveException;
+ }
- private Loader(Hive db) {
- this.db = db;
+ public static class Loader implements Runnable {
Review comment:
Changed to package private.
--
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]