Changed metadata storage format for nullable field types.
Moved field name generation to the client out of metadata node code.
Changed naming scheme for autogenerated types.
Moved GroupName, CompactionPolicy & CompactionPolicyProperties fields
up from External\InternalDetails to Dataset record type definition

Change-Id: I223aded8aaf80f0688358899c0e8b0d6988fac93
Reviewed-on: https://asterix-gerrit.ics.uci.edu/323
Reviewed-by: Till Westmann <tillw@apache.org>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DatasetDecl.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DatasetDecl.java
index 2674da6..9d52e01 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DatasetDecl.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DatasetDecl.java
@@ -21,21 +21,30 @@
 import edu.uci.ics.asterix.aql.expression.visitor.IAqlVisitorWithVoidReturn;
 import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
+import edu.uci.ics.asterix.metadata.bootstrap.MetadataConstants;
 
 public class DatasetDecl implements Statement {
     protected final Identifier name;
     protected final Identifier dataverse;
     protected final Identifier itemTypeName;
+    protected final Identifier nodegroupName;
+    protected final String compactionPolicy;
+    protected final Map<String, String> compactionPolicyProperties;
     protected final DatasetType datasetType;
     protected final IDatasetDetailsDecl datasetDetailsDecl;
     protected final Map<String, String> hints;
     protected final boolean ifNotExists;
 
-    public DatasetDecl(Identifier dataverse, Identifier name, Identifier itemTypeName, Map<String, String> hints,
+    public DatasetDecl(Identifier dataverse, Identifier name, Identifier itemTypeName, Identifier nodeGroupName,
+            String compactionPolicy, Map<String, String> compactionPolicyProperties, Map<String, String> hints,
             DatasetType datasetType, IDatasetDetailsDecl idd, boolean ifNotExists) {
         this.dataverse = dataverse;
         this.name = name;
         this.itemTypeName = itemTypeName;
+        this.nodegroupName = nodeGroupName == null ? new Identifier(MetadataConstants.METADATA_DEFAULT_NODEGROUP_NAME)
+                : nodeGroupName;
+        this.compactionPolicy = compactionPolicy;
+        this.compactionPolicyProperties = compactionPolicyProperties;
         this.hints = hints;
         this.ifNotExists = ifNotExists;
         this.datasetType = datasetType;
@@ -58,6 +67,18 @@
         return itemTypeName;
     }
 
+    public Identifier getNodegroupName() {
+        return nodegroupName;
+    }
+
+    public String getCompactionPolicy() {
+        return compactionPolicy;
+    }
+
+    public Map<String, String> getCompactionPolicyProperties() {
+        return compactionPolicyProperties;
+    }
+
     public Map<String, String> getHints() {
         return hints;
     }
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/ExternalDetailsDecl.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/ExternalDetailsDecl.java
index ff39fd4e..69d5201 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/ExternalDetailsDecl.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/ExternalDetailsDecl.java
@@ -19,9 +19,6 @@
 public class ExternalDetailsDecl implements IDatasetDetailsDecl {
     private Map<String, String> properties;
     private String adapter;
-    private Identifier nodegroupName;
-    private String compactionPolicy;
-    private Map<String, String> compactionPolicyProperties;
 
     public void setAdapter(String adapter) {
         this.adapter = adapter;
@@ -40,34 +37,8 @@
     }
 
     @Override
-    public Identifier getNodegroupName() {
-        return nodegroupName;
-    }
-
-    public void setNodegroupName(Identifier nodegroupName) {
-        this.nodegroupName = nodegroupName;
-    }
-
-    @Override
-    public String getCompactionPolicy() {
-        return compactionPolicy;
-    }
-
-    public void setCompactionPolicy(String compactionPolicy) {
-        this.compactionPolicy = compactionPolicy;
-    }
-
-    @Override
-    public Map<String, String> getCompactionPolicyProperties() {
-        return compactionPolicyProperties;
-    }
-
-    @Override
     public boolean isTemp() {
         return false;
     }
 
-    public void setCompactionPolicyProperties(Map<String, String> compactionPolicyProperties) {
-        this.compactionPolicyProperties = compactionPolicyProperties;
-    }
 }
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/FeedDetailsDecl.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/FeedDetailsDecl.java
index 68cceba..0c773ba 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/FeedDetailsDecl.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/FeedDetailsDecl.java
@@ -25,9 +25,8 @@
     private final FunctionSignature functionSignature;
 
     public FeedDetailsDecl(String adapterFactoryClassname, Map<String, String> configuration,
-            FunctionSignature signature, Identifier nodeGroupName, List<List<String>> partitioningExpr,
-            String compactionPolicy, Map<String, String> compactionPolicyProperties, List<String> filterField) {
-        super(nodeGroupName, partitioningExpr, false, compactionPolicy, compactionPolicyProperties, filterField, false);
+            FunctionSignature signature, List<List<String>> partitioningExpr, List<String> filterField) {
+        super(partitioningExpr, false, filterField, false);
         this.adapterFactoryClassname = adapterFactoryClassname;
         this.configuration = configuration;
         this.functionSignature = signature;
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/IDatasetDetailsDecl.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/IDatasetDetailsDecl.java
index 4ceb969..b86a5f6 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/IDatasetDetailsDecl.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/IDatasetDetailsDecl.java
@@ -14,16 +14,9 @@
  */
 package edu.uci.ics.asterix.aql.expression;
 
-import java.util.Map;
 
 public interface IDatasetDetailsDecl {
 
-    public Identifier getNodegroupName();
-
-    public String getCompactionPolicy();
-
-    public Map<String, String> getCompactionPolicyProperties();
-
     public boolean isTemp();
 
 }
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/InternalDetailsDecl.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/InternalDetailsDecl.java
index aa1b291..3d87a9a 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/InternalDetailsDecl.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/InternalDetailsDecl.java
@@ -15,28 +15,17 @@
 package edu.uci.ics.asterix.aql.expression;
 
 import java.util.List;
-import java.util.Map;
-
-import edu.uci.ics.asterix.metadata.bootstrap.MetadataConstants;
 
 public class InternalDetailsDecl implements IDatasetDetailsDecl {
-    private final Identifier nodegroupName;
     private final List<List<String>> partitioningExprs;
     private final boolean autogenerated;
-    private final String compactionPolicy;
-    private final Map<String, String> compactionPolicyProperties;
     private final boolean temp;
     private final List<String> filterField;
 
-    public InternalDetailsDecl(Identifier nodeGroupName, List<List<String>> partitioningExpr, boolean autogenerated,
-            String compactionPolicy, Map<String, String> compactionPolicyProperties, List<String> filterField,
+    public InternalDetailsDecl(List<List<String>> partitioningExpr, boolean autogenerated, List<String> filterField,
             boolean temp) {
-        this.nodegroupName = nodeGroupName == null ? new Identifier(MetadataConstants.METADATA_DEFAULT_NODEGROUP_NAME)
-                : nodeGroupName;
         this.partitioningExprs = partitioningExpr;
         this.autogenerated = autogenerated;
-        this.compactionPolicy = compactionPolicy;
-        this.compactionPolicyProperties = compactionPolicyProperties;
         this.filterField = filterField;
         this.temp = temp;
     }
@@ -45,26 +34,11 @@
         return partitioningExprs;
     }
 
-    @Override
-    public Identifier getNodegroupName() {
-        return nodegroupName;
-    }
-
     public boolean isAutogenerated() {
         return autogenerated;
     }
 
     @Override
-    public String getCompactionPolicy() {
-        return compactionPolicy;
-    }
-
-    @Override
-    public Map<String, String> getCompactionPolicyProperties() {
-        return compactionPolicyProperties;
-    }
-
-    @Override
     public boolean isTemp() {
         return temp;
     }
diff --git a/asterix-aql/src/main/javacc/AQL.jj b/asterix-aql/src/main/javacc/AQL.jj
index 7044962..52d2b83 100644
--- a/asterix-aql/src/main/javacc/AQL.jj
+++ b/asterix-aql/src/main/javacc/AQL.jj
@@ -427,12 +427,12 @@
         ExternalDetailsDecl edd = new ExternalDetailsDecl();
         edd.setAdapter(adapterName);
         edd.setProperties(properties);
-        edd.setNodegroupName(nodeGroupName != null? new Identifier(nodeGroupName): null);
-        edd.setCompactionPolicy(compactionPolicy);
-        edd.setCompactionPolicyProperties(compactionPolicyProperties);
         dsetDecl = new DatasetDecl(nameComponents.first,
                                    nameComponents.second,
                                    new Identifier(typeName),
+                                   nodeGroupName != null? new Identifier(nodeGroupName): null,
+                                   compactionPolicy,
+                                   compactionPolicyProperties,
                                    hints,
                                    DatasetType.EXTERNAL,
                                    edd,
@@ -453,18 +453,16 @@
     ( "using" "compaction" "policy" compactionPolicy = CompactionPolicy() (compactionPolicyProperties = Configuration())? )?
     ( "with filter on" filterField = NestedField() )?
       {
-        InternalDetailsDecl idd = new InternalDetailsDecl(nodeGroupName != null
-                                                            ? new Identifier(nodeGroupName)
-                                                            : null,
-                                                          primaryKeyFields,
+        InternalDetailsDecl idd = new InternalDetailsDecl(primaryKeyFields,
                                                           autogenerated,
-                                                          compactionPolicy,
-                                                          compactionPolicyProperties,
                                                           filterField,
                                                           temp);
         dsetDecl = new DatasetDecl(nameComponents.first,
                                    nameComponents.second,
                                    new Identifier(typeName),
+                                   nodeGroupName != null ? new Identifier(nodeGroupName) : null,
+                                   compactionPolicy,
+                                   compactionPolicyProperties,
                                    hints,
                                    DatasetType.INTERNAL,
                                    idd,