aboutsummaryrefslogtreecommitdiff
path: root/exec/java-exec/src/main
diff options
context:
space:
mode:
authorJinfeng Ni <jni@maprtech.com>2014-08-28 07:21:06 -0700
committerJacques Nadeau <jacques@apache.org>2014-08-29 00:14:31 -0700
commit2754321c46cc34bbf272f456a60f141b8c42ad45 (patch)
tree9f7f044a0fd7dd67f438bde95fbbe324f3e03341 /exec/java-exec/src/main
parentf148694738a84832d75aca4ef69bff47c68b463f (diff)
DRILL-1355: Ensure Drill optimizer will use storage plugin specific rules, when a new storage plugin is added.
Diffstat (limited to 'exec/java-exec/src/main')
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java17
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistry.java21
2 files changed, 15 insertions, 23 deletions
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
index 321d79d4e..2238155a9 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
@@ -57,7 +57,6 @@ public class DrillSqlWorker {
public final static int PHYSICAL_MEM_RULES = 1;
private final QueryContext context;
- private static volatile RuleSet[] allRules;
public DrillSqlWorker(QueryContext context) throws Exception {
final List<RelTraitDef> traitDefs = new ArrayList<RelTraitDef>();
@@ -83,18 +82,12 @@ public class DrillSqlWorker {
}
- private static RuleSet[] getRules(QueryContext context) {
+ private RuleSet[] getRules(QueryContext context) {
StoragePluginRegistry storagePluginRegistry = context.getStorage();
- if (allRules == null) {
- synchronized (DrillSqlWorker.class) {
- if (allRules == null) {
- RuleSet drillPhysicalMem = DrillRuleSets.mergedRuleSets(
- DrillRuleSets.getPhysicalRules(context),
- storagePluginRegistry.getStoragePluginRuleSet());
- allRules = new RuleSet[] {DrillRuleSets.getDrillBasicRules(context), drillPhysicalMem};
- }
- }
- }
+ RuleSet drillPhysicalMem = DrillRuleSets.mergedRuleSets(
+ DrillRuleSets.getPhysicalRules(context),
+ storagePluginRegistry.getStoragePluginRuleSet());
+ RuleSet[] allRules = new RuleSet[] {DrillRuleSets.getDrillBasicRules(context), drillPhysicalMem};
return allRules;
}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistry.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistry.java
index 0b773ddaf..a876ea51f 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistry.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistry.java
@@ -80,7 +80,6 @@ public class StoragePluginRegistry implements Iterable<Map.Entry<String, Storage
private final PStore<StoragePluginConfig> pluginSystemTable;
private final Object updateLock = new Object();
private volatile long lastUpdate = 0;
- private RuleSet storagePluginsRuleSet;
private static final long UPDATE_FREQUENCY = 2 * 60 * 1000;
public StoragePluginRegistry(DrillbitContext context) {
@@ -130,15 +129,6 @@ public class StoragePluginRegistry implements Iterable<Map.Entry<String, Storage
this.plugins = Maps.newConcurrentMap();
this.plugins.putAll(createPlugins());
- // query registered engines for optimizer rules and build the storage plugin RuleSet
- Builder<RelOptRule> setBuilder = ImmutableSet.builder();
- for (StoragePlugin plugin : this.plugins.values()) {
- Set<StoragePluginOptimizerRule> rules = plugin.getOptimizerRules();
- if (rules != null && rules.size() > 0) {
- setBuilder.addAll(rules);
- }
- }
- this.storagePluginsRuleSet = DrillRuleSets.create(setBuilder.build());
}
private Map<String, StoragePlugin> createPlugins() throws DrillbitStartupException {
@@ -279,7 +269,16 @@ public class StoragePluginRegistry implements Iterable<Map.Entry<String, Storage
}
public RuleSet getStoragePluginRuleSet() {
- return storagePluginsRuleSet;
+ // query registered engines for optimizer rules and build the storage plugin RuleSet
+ Builder<RelOptRule> setBuilder = ImmutableSet.builder();
+ for (StoragePlugin plugin : this.plugins.values()) {
+ Set<StoragePluginOptimizerRule> rules = plugin.getOptimizerRules();
+ if (rules != null && rules.size() > 0) {
+ setBuilder.addAll(rules);
+ }
+ }
+
+ return DrillRuleSets.create(setBuilder.build());
}
public DrillSchemaFactory getSchemaFactory() {