drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [8/8] drill git commit: DRILL-2508: Added a wrapper class for OptionValue to include status Option status: BOOT, DEFAULT, CHANGED
Date Thu, 07 May 2015 18:02:40 GMT
DRILL-2508: Added a wrapper class for OptionValue to include status Option status: BOOT, DEFAULT,
CHANGED


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/d12bee05
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/d12bee05
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/d12bee05

Branch: refs/heads/master
Commit: d12bee05a8f6e974c70d5d2a94176b176d7dba5b
Parents: 784be4b
Author: Sudheesh Katkam <skatkam@maprtech.com>
Authored: Mon Apr 13 22:29:01 2015 -0700
Committer: Jason Altekruse <altekrusejason@gmail.com>
Committed: Thu May 7 10:08:36 2015 -0700

----------------------------------------------------------------------
 .../server/options/FallbackOptionManager.java   |  4 ++
 .../exec/server/options/OptionManager.java      |  1 +
 .../server/options/SystemOptionManager.java     | 10 +++
 .../drill/exec/store/sys/SystemTable.java       | 73 ++++++++++++++++++--
 4 files changed, 82 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/d12bee05/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FallbackOptionManager.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FallbackOptionManager.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FallbackOptionManager.java
index 0af816d..142fa0e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FallbackOptionManager.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/FallbackOptionManager.java
@@ -70,6 +70,10 @@ public abstract class FallbackOptionManager extends BaseOptionManager {
     }
   }
 
+  @Override
+  public OptionValue getDefault(final String name) {
+    return fallback.getDefault(name);
+  }
 
   @Override
   public OptionAdmin getAdmin() {

http://git-wip-us.apache.org/repos/asf/drill/blob/d12bee05/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionManager.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionManager.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionManager.java
index 1bdc108..414713a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionManager.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionManager.java
@@ -26,6 +26,7 @@ public interface OptionManager extends Iterable<OptionValue> {
   public OptionAdmin getAdmin();
   public OptionManager getSystemManager();
   public OptionList getOptionList();
+  public OptionValue getDefault(final String name);
 
   public boolean getOption(TypeValidators.BooleanValidator validator);
   public double getOption(TypeValidators.DoubleValidator validator);

http://git-wip-us.apache.org/repos/asf/drill/blob/d12bee05/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SystemOptionManager.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SystemOptionManager.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SystemOptionManager.java
index 07ad328..ea4af43 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SystemOptionManager.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/options/SystemOptionManager.java
@@ -163,6 +163,16 @@ public class SystemOptionManager extends BaseOptionManager {
   }
 
   @Override
+  public OptionValue getDefault(final String name) {
+    final OptionValidator validator = knownOptions.get(name);
+    if(validator == null) {
+      return null;
+    } else {
+      return validator.getDefault();
+    }
+  }
+
+  @Override
   public void setOption(final OptionValue value) {
     assert value.type == OptionType.SYSTEM;
     admin.validate(value);

http://git-wip-us.apache.org/repos/asf/drill/blob/d12bee05/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTable.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTable.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTable.java
index bd23d81..cd8af08 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTable.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTable.java
@@ -22,10 +22,9 @@ import org.apache.drill.exec.ops.FragmentContext;
 import org.apache.drill.exec.server.options.DrillConfigIterator;
 import org.apache.drill.exec.server.options.OptionManager;
 import org.apache.drill.exec.server.options.OptionValue;
-import org.apache.drill.exec.store.RecordDataType;
-import org.apache.drill.exec.store.pojo.PojoDataType;
-import org.apache.calcite.rel.type.RelDataType;
-import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.drill.exec.server.options.OptionValue.Kind;
+import org.apache.drill.exec.server.options.OptionValue.OptionType;
+import org.apache.drill.exec.store.sys.SystemTable.OptionValueWrapper.Status;
 
 import java.util.Iterator;
 
@@ -39,12 +38,43 @@ import java.util.Iterator;
  */
 public enum SystemTable {
 
-  OPTION("options", false, OptionValue.class) {
+  OPTION("options", false, OptionValueWrapper.class) {
     @Override
     public Iterator<Object> getIterator(final FragmentContext context) {
       final DrillConfigIterator configOptions = new DrillConfigIterator(context.getConfig());
       final OptionManager fragmentOptions = context.getOptions();
-      return (Iterator<Object>) (Object) Iterators.concat(configOptions.iterator(),
fragmentOptions.iterator());
+      final Iterator<OptionValue> mergedOptions = Iterators.concat(configOptions.iterator(),
fragmentOptions.iterator());
+      final Iterator<OptionValueWrapper> optionValues = new Iterator<OptionValueWrapper>()
{
+        @Override
+        public boolean hasNext() {
+          return mergedOptions.hasNext();
+        }
+
+        @Override
+        public OptionValueWrapper next() {
+          final OptionValue value = mergedOptions.next();
+          final Status status;
+          if (value.type == OptionType.BOOT) {
+            status = Status.BOOT;
+          } else {
+            final OptionValue def = fragmentOptions.getSystemManager().getDefault(value.name);
+            if (value.equals(def)) {
+              status = Status.DEFAULT;
+            } else {
+              status = Status.CHANGED;
+            }
+          }
+          return new OptionValueWrapper(value.name, value.kind, value.type, value.num_val,
value.string_val,
+            value.bool_val, value.float_val, status);
+        }
+
+        @Override
+        public void remove() {
+        }
+      };
+      @SuppressWarnings("unchecked")
+      final Iterator<Object> iterator = (Iterator<Object>) (Object) optionValues;
+      return iterator;
     }
   },
 
@@ -104,4 +134,35 @@ public enum SystemTable {
     return pojoClass;
   }
 
+  /**
+   * Wrapper class for OptionValue to add Status
+   */
+  public static class OptionValueWrapper {
+
+    public static enum Status {
+      BOOT, DEFAULT, CHANGED
+    }
+
+    public final String name;
+    public final Kind kind;
+    public final OptionType type;
+    public final Status status;
+    public final Long num_val;
+    public final String string_val;
+    public final Boolean bool_val;
+    public final Double float_val;
+
+    public OptionValueWrapper(final String name, final Kind kind, final OptionType type,
final Long num_val,
+                              final String string_val, final Boolean bool_val, final Double
float_val,
+                              final Status status) {
+      this.name = name;
+      this.kind = kind;
+      this.type = type;
+      this.num_val = num_val;
+      this.string_val = string_val;
+      this.bool_val = bool_val;
+      this.float_val = float_val;
+      this.status = status;
+    }
+  }
 }


Mime
View raw message