asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amo...@apache.org
Subject [1/2] asterixdb git commit: Refactor Metadata Record Types
Date Thu, 28 Jul 2016 02:14:21 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 8a6b9ca51 -> dbfd22ed0


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/dbfd22ed/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataRecordTypes.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataRecordTypes.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataRecordTypes.java
index 4c636d5..14ef049 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataRecordTypes.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataRecordTypes.java
@@ -19,192 +19,136 @@
 
 package org.apache.asterix.metadata.bootstrap;
 
-import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.metadata.MetadataException;
 import org.apache.asterix.om.types.AOrderedListType;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.AUnionType;
 import org.apache.asterix.om.types.AUnorderedListType;
 import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 /**
  * Contains static ARecordType's of all metadata record types.
  */
 public final class MetadataRecordTypes {
-    public static ARecordType DATAVERSE_RECORDTYPE;
-    public static ARecordType DATASET_RECORDTYPE;
-    public static ARecordType INTERNAL_DETAILS_RECORDTYPE;
-    public static ARecordType EXTERNAL_DETAILS_RECORDTYPE;
-    public static ARecordType FEED_DETAILS_RECORDTYPE;
-    public static ARecordType DATASET_HINTS_RECORDTYPE;
-    public static ARecordType COMPACTION_POLICY_PROPERTIES_RECORDTYPE;
-    public static ARecordType DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE;
-    public static ARecordType FIELD_RECORDTYPE;
-    public static ARecordType RECORD_RECORDTYPE;
-    public static ARecordType DERIVEDTYPE_RECORDTYPE;
-    public static ARecordType DATATYPE_RECORDTYPE;
-    public static ARecordType INDEX_RECORDTYPE;
-    public static ARecordType NODE_RECORDTYPE;
-    public static ARecordType NODEGROUP_RECORDTYPE;
-    public static ARecordType FUNCTION_RECORDTYPE;
-    public static ARecordType DATASOURCE_ADAPTER_RECORDTYPE;
-    public static ARecordType FEED_RECORDTYPE;
-    public static ARecordType PRIMARY_FEED_DETAILS_RECORDTYPE;
-    public static ARecordType SECONDARY_FEED_DETAILS_RECORDTYPE;
-    public static ARecordType FEED_ADAPTER_CONFIGURATION_RECORDTYPE;
-    public static ARecordType FEED_POLICY_RECORDTYPE;
-    public static ARecordType POLICY_PARAMS_RECORDTYPE;
-    public static ARecordType LIBRARY_RECORDTYPE;
-    public static ARecordType COMPACTION_POLICY_RECORDTYPE;
-    public static ARecordType EXTERNAL_FILE_RECORDTYPE;
 
-    /**
-     * Create all metadata record types.
-     *
-     * @throws HyracksDataException
-     */
-    public static void init() throws MetadataException, HyracksDataException {
-        // Attention: The order of these calls is important because some types
-        // depend on other types being created first.
-        // These calls are one "dependency chain".
-        try {
-            POLICY_PARAMS_RECORDTYPE = createPropertiesRecordType();
-            DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE = createPropertiesRecordType();
-            COMPACTION_POLICY_PROPERTIES_RECORDTYPE = createPropertiesRecordType();
-            INTERNAL_DETAILS_RECORDTYPE = createInternalDetailsRecordType();
-            EXTERNAL_DETAILS_RECORDTYPE = createExternalDetailsRecordType();
-            FEED_DETAILS_RECORDTYPE = createFeedDetailsRecordType();
-            DATASET_HINTS_RECORDTYPE = createPropertiesRecordType();
-            DATASET_RECORDTYPE = createDatasetRecordType();
-
-            // Starting another dependency chain.
-            FIELD_RECORDTYPE = createFieldRecordType();
-            RECORD_RECORDTYPE = createRecordTypeRecordType();
-            DERIVEDTYPE_RECORDTYPE = createDerivedTypeRecordType();
-            DATATYPE_RECORDTYPE = createDatatypeRecordType();
-
-            // Independent of any other types.
-            DATAVERSE_RECORDTYPE = createDataverseRecordType();
-            INDEX_RECORDTYPE = createIndexRecordType();
-            NODE_RECORDTYPE = createNodeRecordType();
-            NODEGROUP_RECORDTYPE = createNodeGroupRecordType();
-            FUNCTION_RECORDTYPE = createFunctionRecordType();
-            DATASOURCE_ADAPTER_RECORDTYPE = createDatasourceAdapterRecordType();
-
-            FEED_ADAPTER_CONFIGURATION_RECORDTYPE = createPropertiesRecordType();
-            PRIMARY_FEED_DETAILS_RECORDTYPE = createPrimaryFeedDetailsRecordType();
-            SECONDARY_FEED_DETAILS_RECORDTYPE = createSecondaryFeedDetailsRecordType();
-            FEED_RECORDTYPE = createFeedRecordType();
-            FEED_POLICY_RECORDTYPE = createFeedPolicyRecordType();
-            LIBRARY_RECORDTYPE = createLibraryRecordType();
-
-            COMPACTION_POLICY_RECORDTYPE = createCompactionPolicyRecordType();
-
-            EXTERNAL_FILE_RECORDTYPE = createExternalFileRecordType();
-
-            //generate nested type names
-            DATASET_RECORDTYPE.generateNestedDerivedTypeNames();
-            DATATYPE_RECORDTYPE.generateNestedDerivedTypeNames();
-            DATAVERSE_RECORDTYPE.generateNestedDerivedTypeNames();
-            INDEX_RECORDTYPE.generateNestedDerivedTypeNames();
-            NODE_RECORDTYPE.generateNestedDerivedTypeNames();
-            NODEGROUP_RECORDTYPE.generateNestedDerivedTypeNames();
-            FUNCTION_RECORDTYPE.generateNestedDerivedTypeNames();
-            DATASOURCE_ADAPTER_RECORDTYPE.generateNestedDerivedTypeNames();
-            FEED_RECORDTYPE.generateNestedDerivedTypeNames();
-            PRIMARY_FEED_DETAILS_RECORDTYPE.generateNestedDerivedTypeNames();
-            SECONDARY_FEED_DETAILS_RECORDTYPE.generateNestedDerivedTypeNames();
-            FEED_POLICY_RECORDTYPE.generateNestedDerivedTypeNames();
-            LIBRARY_RECORDTYPE.generateNestedDerivedTypeNames();
-            COMPACTION_POLICY_RECORDTYPE.generateNestedDerivedTypeNames();
-            EXTERNAL_FILE_RECORDTYPE.generateNestedDerivedTypeNames();
-        } catch (AsterixException e) {
-            throw new MetadataException(e);
-        }
-    }
-
-    public static final int FEED_POLICY_ARECORD_DATAVERSE_NAME_FIELD_INDEX = 0;
-    public static final int FEED_POLICY_ARECORD_POLICY_NAME_FIELD_INDEX = 1;
-    public static final int FEED_POLICY_ARECORD_DESCRIPTION_FIELD_INDEX = 2;
-    public static final int FEED_POLICY_ARECORD_PROPERTIES_FIELD_INDEX = 3;
-
-    private static ARecordType createFeedPolicyRecordType() throws AsterixException {
-        AUnorderedListType listPropertiesType = new AUnorderedListType(POLICY_PARAMS_RECORDTYPE, null);
-        String[] fieldNames = { "DataverseName", "PolicyName", "Description", "Properties" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING, listPropertiesType };
-        return new ARecordType("FeedPolicyRecordType", fieldNames, fieldTypes, true);
-    }
-
-    // Helper constants for accessing fields in an ARecord of type
-    // DataverseRecordType.
-    public static final int DATAVERSE_ARECORD_NAME_FIELD_INDEX = 0;
-    public static final int DATAVERSE_ARECORD_FORMAT_FIELD_INDEX = 1;
-    public static final int DATAVERSE_ARECORD_TIMESTAMP_FIELD_INDEX = 2;
-    public static final int DATAVERSE_ARECORD_PENDINGOP_FIELD_INDEX = 3;
-
-    private static final ARecordType createDataverseRecordType() throws AsterixException {
-        return new ARecordType("DataverseRecordType",
-                new String[] { "DataverseName", "DataFormat", "Timestamp", "PendingOp" },
-                new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.AINT32 },
-                true);
-    }
-
-    // Helper constants for accessing fields in an ARecord of anonymous type
-    // dataset properties.
-    // Used for dataset hints or dataset adapter properties.
+    //--------------------------------------- Fields Names --------------------------------------//
+    public static final String FIELD_NAME_ADAPTER_CONFIGURATION = "AdapterConfiguration";
+    public static final String FIELD_NAME_ADAPTER_NAME = "AdapterName";
+    public static final String FIELD_NAME_ARITY = "Arity";
+    public static final String FIELD_NAME_AUTOGENERATED = "Autogenerated";
+    public static final String FIELD_NAME_CLASSNAME = "Classname";
+    public static final String FIELD_NAME_COMPACTION_POLICY = "CompactionPolicy";
+    public static final String FIELD_NAME_COMPACTION_POLICY_PROPERTIES = "CompactionPolicyProperties";
+    public static final String FIELD_NAME_DATASET_ID = "DatasetId";
+    public static final String FIELD_NAME_DATASET_NAME = "DatasetName";
+    public static final String FIELD_NAME_DATASET_TYPE = "DatasetType";
+    public static final String FIELD_NAME_DATASOURCE_ADAPTER = "DatasourceAdapter";
+    public static final String FIELD_NAME_DATATYPE_DATAVERSE_NAME = "DatatypeDataverseName";
+    public static final String FIELD_NAME_DATATYPE_NAME = "DatatypeName";
+    public static final String FIELD_NAME_DATAVERSE_NAME = "DataverseName";
+    public static final String FIELD_NAME_DATA_FORMAT = "DataFormat";
+    public static final String FIELD_NAME_DEFINITION = "Definition";
+    public static final String FIELD_NAME_DERIVED = "Derived";
+    public static final String FIELD_NAME_DESCRIPTION = "Description";
+    public static final String FIELD_NAME_EXTERNAL_DETAILS = "ExternalDetails";
+    public static final String FIELD_NAME_FEED_NAME = "FeedName";
+    public static final String FIELD_NAME_FEED_TYPE = "FeedType";
+    public static final String FIELD_NAME_FIELDS = "Fields";
+    public static final String FIELD_NAME_FIELD_NAME = "FieldName";
+    public static final String FIELD_NAME_FIELD_TYPE = "FieldType";
+    public static final String FIELD_NAME_FILE_MOD_TIME = "FileModTime";
+    public static final String FIELD_NAME_FILE_NAME = "FileName";
+    public static final String FIELD_NAME_FILE_NUMBER = "FileNumber";
+    public static final String FIELD_NAME_FILE_SIZE = "FileSize";
+    public static final String FIELD_NAME_FILE_STRUCTURE = "FileStructure";
+    public static final String FIELD_NAME_FUNCTION = "Function";
+    public static final String FIELD_NAME_GROUP_NAME = "GroupName";
+    public static final String FIELD_NAME_HINTS = "Hints";
+    public static final String FIELD_NAME_INDEX_NAME = "IndexName";
+    public static final String FIELD_NAME_INDEX_STRUCTURE = "IndexStructure";
+    public static final String FIELD_NAME_INTERNAL_DETAILS = "InternalDetails";
+    public static final String FIELD_NAME_IS_ANONYMOUS = "IsAnonymous";
+    public static final String FIELD_NAME_IS_NULLABLE = "IsNullable";
+    public static final String FIELD_NAME_IS_OPEN = "IsOpen";
+    public static final String FIELD_NAME_IS_PRIMARY = "IsPrimary";
+    public static final String FIELD_NAME_KIND = "Kind";
+    public static final String FIELD_NAME_LANGUAGE = "Language";
+    public static final String FIELD_NAME_LAST_REFRESH_TIME = "LastRefreshTime";
+    public static final String FIELD_NAME_METADATA_DATAVERSE = "MetatypeDataverseName";
+    public static final String FIELD_NAME_METATYPE_NAME = "MetatypeName";
+    public static final String FIELD_NAME_NAME = "Name";
+    public static final String FIELD_NAME_NODE_NAME = "NodeName";
+    public static final String FIELD_NAME_NODE_NAMES = "NodeNames";
+    public static final String FIELD_NAME_NUMBER_OF_CORES = "NumberOfCores";
+    public static final String FIELD_NAME_ORDERED_LIST = "OrderedList";
+    public static final String FIELD_NAME_PARAMS = "Params";
+    public static final String FIELD_NAME_PARTITIONING_KEY = "PartitioningKey";
+    public static final String FIELD_NAME_PARTITIONING_STRATEGY = "PartitioningStrategy";
+    public static final String FIELD_NAME_PENDING_OP = "PendingOp";
+    public static final String FIELD_NAME_POLICY_NAME = "PolicyName";
+    public static final String FIELD_NAME_PRIMARY_KEY = "PrimaryKey";
+    public static final String FIELD_NAME_PRIMARY_TYPE_DETAILS = "PrimaryTypeDetails";
+    public static final String FIELD_NAME_PROPERTIES = "Properties";
+    public static final String FIELD_NAME_RECORD = "Record";
+    public static final String FIELD_NAME_RETURN_TYPE = "ReturnType";
+    public static final String FIELD_NAME_SEARCH_KEY = "SearchKey";
+    public static final String FIELD_NAME_SECONDARY_TYPE_DETAILS = "SecondaryTypeDetails";
+    public static final String FIELD_NAME_SOURCE_FEED_NAME = "SourceFeedName";
+    public static final String FIELD_NAME_STATUS = "Status";
+    public static final String FIELD_NAME_TAG = "Tag";
+    public static final String FIELD_NAME_TIMESTAMP = "Timestamp";
+    public static final String FIELD_NAME_TRANSACTION_STATE = "TransactionState";
+    public static final String FIELD_NAME_TYPE = "Type";
+    public static final String FIELD_NAME_UNORDERED_LIST = "UnorderedList";
+    public static final String FIELD_NAME_VALUE = "Value";
+    public static final String FIELD_NAME_WORKING_MEMORY_SIZE = "WorkingMemorySize";
+
+    //---------------------------------- Record Types Creation ----------------------------------//
+    //--------------------------------------- Properties ----------------------------------------//
     public static final int PROPERTIES_NAME_FIELD_INDEX = 0;
     public static final int PROPERTIES_VALUE_FIELD_INDEX = 1;
+    public static final ARecordType POLICY_PARAMS_RECORDTYPE = createPropertiesRecordType();
+    public static final ARecordType DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE = createPropertiesRecordType();
+    public static final ARecordType COMPACTION_POLICY_PROPERTIES_RECORDTYPE = createPropertiesRecordType();
+    public static final ARecordType DATASET_HINTS_RECORDTYPE = createPropertiesRecordType();
+    public static final ARecordType FEED_ADAPTER_CONFIGURATION_RECORDTYPE = createPropertiesRecordType();
 
-    private static final ARecordType createPropertiesRecordType() throws AsterixException {
-        String[] fieldNames = { "Name", "Value" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING };
-        return new ARecordType(null, fieldNames, fieldTypes, true);
-    };
-
-    // Helper constants for accessing fields in an ARecord of anonymous type
-    // internal details.
+    //----------------------------- Internal Details Record Type --------------------------------//
     public static final int INTERNAL_DETAILS_ARECORD_FILESTRUCTURE_FIELD_INDEX = 0;
     public static final int INTERNAL_DETAILS_ARECORD_PARTITIONSTRATEGY_FIELD_INDEX = 1;
     public static final int INTERNAL_DETAILS_ARECORD_PARTITIONKEY_FIELD_INDEX = 2;
     public static final int INTERNAL_DETAILS_ARECORD_PRIMARYKEY_FIELD_INDEX = 3;
     public static final int INTERNAL_DETAILS_ARECORD_AUTOGENERATED_FIELD_INDEX = 4;
-
-    private static final ARecordType createInternalDetailsRecordType() throws AsterixException {
-        AOrderedListType olType = new AOrderedListType(BuiltinType.ASTRING, null);
-        AOrderedListType ololType = new AOrderedListType(olType, null);
-        String[] fieldNames = { "FileStructure", "PartitioningStrategy", "PartitioningKey", "PrimaryKey",
-                "Autogenerated" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, ololType, ololType, BuiltinType.ABOOLEAN };
-        return new ARecordType(null, fieldNames, fieldTypes, true);
-    }
-
-    // Helper constants for accessing fields in an ARecord of anonymous type
-    // external details.
+    public static final ARecordType INTERNAL_DETAILS_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            null,
+            // FieldNames
+            new String[] { FIELD_NAME_FILE_STRUCTURE, FIELD_NAME_PARTITIONING_STRATEGY, FIELD_NAME_PARTITIONING_KEY,
+                    FIELD_NAME_PRIMARY_KEY, FIELD_NAME_AUTOGENERATED },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING,
+                    new AOrderedListType(new AOrderedListType(BuiltinType.ASTRING, null), null),
+                    new AOrderedListType(new AOrderedListType(BuiltinType.ASTRING, null), null), BuiltinType.ABOOLEAN },
+            //IsOpen?
+            true);
+
+    //----------------------------- External Details Record Type --------------------------------//
     public static final int EXTERNAL_DETAILS_ARECORD_DATASOURCE_ADAPTER_FIELD_INDEX = 0;
     public static final int EXTERNAL_DETAILS_ARECORD_PROPERTIES_FIELD_INDEX = 1;
     public static final int EXTERNAL_DETAILS_ARECORD_LAST_REFRESH_TIME_FIELD_INDEX = 2;
     public static final int EXTERNAL_DETAILS_ARECORD_TRANSACTION_STATE_FIELD_INDEX = 3;
-
-    private static final ARecordType createExternalDetailsRecordType() throws AsterixException {
-        AOrderedListType orderedPropertyListType = new AOrderedListType(DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE, null);
-        String[] fieldNames = { "DatasourceAdapter", "Properties", "LastRefreshTime", "TransactionState", };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, orderedPropertyListType, BuiltinType.ADATETIME,
-                BuiltinType.AINT32 };
-        return new ARecordType(null, fieldNames, fieldTypes, true);
-    }
-
-    public static final int COMPACTION_POLICY_ARECORD_DATAVERSE_NAME_FIELD_INDEX = 0;
-    public static final int COMPACTION_POLICY_ARECORD_POLICY_NAME_FIELD_INDEX = 1;
-    public static final int COMPACTION_POLICY_ARECORD_CLASSNAME_FIELD_INDEX = 2;
-
-    private static ARecordType createCompactionPolicyRecordType() throws AsterixException {
-        String[] fieldNames = { "DataverseName", "CompactionPolicy", "Classname" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING };
-        return new ARecordType("CompactionPolicyRecordType", fieldNames, fieldTypes, true);
-    }
-
+    public static final ARecordType EXTERNAL_DETAILS_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            null,
+            // FieldNames
+            new String[] { FIELD_NAME_DATASOURCE_ADAPTER, FIELD_NAME_PROPERTIES, FIELD_NAME_LAST_REFRESH_TIME,
+                    FIELD_NAME_TRANSACTION_STATE },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, new AOrderedListType(DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE, null),
+                    BuiltinType.ADATETIME, BuiltinType.AINT32 },
+            //IsOpen?
+            true);
+    //-------------------------------------- Feed Details ---------------------------------------//
     public static final int FEED_DETAILS_ARECORD_FILESTRUCTURE_FIELD_INDEX = 0;
     public static final int FEED_DETAILS_ARECORD_PARTITIONSTRATEGY_FIELD_INDEX = 1;
     public static final int FEED_DETAILS_ARECORD_PARTITIONKEY_FIELD_INDEX = 2;
@@ -216,25 +160,25 @@ public final class MetadataRecordTypes {
     public static final int FEED_DETAILS_ARECORD_STATE_FIELD_INDEX = 8;
     public static final int FEED_DETAILS_ARECORD_COMPACTION_POLICY_FIELD_INDEX = 9;
     public static final int FEED_DETAILS_ARECORD_COMPACTION_POLICY_PROPERTIES_FIELD_INDEX = 10;
-
-    private static final ARecordType createFeedDetailsRecordType() throws AsterixException {
-        AOrderedListType orderedListType = new AOrderedListType(BuiltinType.ASTRING, null);
-        AOrderedListType orderedListOfPropertiesType = new AOrderedListType(DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE,
-                null);
-        AOrderedListType compactionPolicyPropertyListType = new AOrderedListType(
-                COMPACTION_POLICY_PROPERTIES_RECORDTYPE, null);
-        String[] fieldNames = { "FileStructure", "PartitioningStrategy", "PartitioningKey", "PrimaryKey", "GroupName",
-                "DatasourceAdapter", "Properties", "Function", "Status", "CompactionPolicy",
-                "CompactionPolicyProperties" };
-
-        IAType feedFunctionUnion = AUnionType.createUnknownableType(BuiltinType.ASTRING);
-
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, orderedListType, orderedListType,
-                BuiltinType.ASTRING, BuiltinType.ASTRING, orderedListOfPropertiesType, feedFunctionUnion,
-                BuiltinType.ASTRING, BuiltinType.ASTRING, compactionPolicyPropertyListType };
-        return new ARecordType(null, fieldNames, fieldTypes, true);
-    }
-
+    public static final ARecordType FEED_DETAILS_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            null,
+            // FieldNames
+            new String[] { FIELD_NAME_FILE_STRUCTURE, FIELD_NAME_PARTITIONING_STRATEGY, FIELD_NAME_PARTITIONING_KEY,
+                    FIELD_NAME_PRIMARY_KEY, FIELD_NAME_GROUP_NAME, FIELD_NAME_DATASOURCE_ADAPTER, FIELD_NAME_PROPERTIES,
+                    FIELD_NAME_FUNCTION, FIELD_NAME_STATUS, FIELD_NAME_COMPACTION_POLICY,
+                    FIELD_NAME_COMPACTION_POLICY_PROPERTIES },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING, new AOrderedListType(BuiltinType.ASTRING, null),
+                    new AOrderedListType(BuiltinType.ASTRING, null), BuiltinType.ASTRING, BuiltinType.ASTRING,
+                    new AOrderedListType(DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE, null),
+                    AUnionType.createUnknownableType(BuiltinType.ASTRING), BuiltinType.ASTRING, BuiltinType.ASTRING,
+                    new AOrderedListType(COMPACTION_POLICY_PROPERTIES_RECORDTYPE, null) },
+            //IsOpen?
+            true);
+
+    //---------------------------------------- Dataset ------------------------------------------//
+    public static final String RECORD_NAME_DATASET = "DatasetRecordType";
     public static final int DATASET_ARECORD_DATAVERSENAME_FIELD_INDEX = 0;
     public static final int DATASET_ARECORD_DATASETNAME_FIELD_INDEX = 1;
     public static final int DATASET_ARECORD_DATATYPEDATAVERSENAME_FIELD_INDEX = 2;
@@ -249,86 +193,106 @@ public final class MetadataRecordTypes {
     public static final int DATASET_ARECORD_TIMESTAMP_FIELD_INDEX = 11;
     public static final int DATASET_ARECORD_DATASETID_FIELD_INDEX = 12;
     public static final int DATASET_ARECORD_PENDINGOP_FIELD_INDEX = 13;
-    public static final String DATASET_ARECORD_METATYPEDATAVERSENAME_FIELD_NAME = "MetatypeDataverseName";
-    public static final String DATASET_ARECORD_METATYPENAME_FIELD_NAME = "MetatypeName";
-
-    private static final ARecordType createDatasetRecordType() throws AsterixException {
-        String[] fieldNames = { "DataverseName", "DatasetName", "DatatypeDataverseName", "DatatypeName", "DatasetType",
-                "GroupName", "CompactionPolicy", "CompactionPolicyProperties", "InternalDetails", "ExternalDetails",
-                "Hints", "Timestamp", "DatasetId", "PendingOp" };
-
-        IAType internalRecordUnion = AUnionType.createUnknownableType(INTERNAL_DETAILS_RECORDTYPE);
-        IAType externalRecordUnion = AUnionType.createUnknownableType(EXTERNAL_DETAILS_RECORDTYPE);
-        AOrderedListType compactionPolicyPropertyListType = new AOrderedListType(
-                COMPACTION_POLICY_PROPERTIES_RECORDTYPE, null);
-
-        AUnorderedListType unorderedListOfHintsType = new AUnorderedListType(DATASET_HINTS_RECORDTYPE, null);
-
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING,
-                BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING, compactionPolicyPropertyListType,
-                internalRecordUnion, externalRecordUnion, unorderedListOfHintsType, BuiltinType.ASTRING,
-                BuiltinType.AINT32, BuiltinType.AINT32 };
-        return new ARecordType("DatasetRecordType", fieldNames, fieldTypes, true);
-    }
-
-    // Helper constants for accessing fields in an ARecord of anonymous type
-    // field type.
+    public static final ARecordType DATASET_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            RECORD_NAME_DATASET,
+            // FieldNames
+            new String[] { FIELD_NAME_DATAVERSE_NAME, FIELD_NAME_DATASET_NAME, FIELD_NAME_DATATYPE_DATAVERSE_NAME,
+                    FIELD_NAME_DATATYPE_NAME, FIELD_NAME_DATASET_TYPE, FIELD_NAME_GROUP_NAME,
+                    FIELD_NAME_COMPACTION_POLICY, FIELD_NAME_COMPACTION_POLICY_PROPERTIES, FIELD_NAME_INTERNAL_DETAILS,
+                    FIELD_NAME_EXTERNAL_DETAILS, FIELD_NAME_HINTS, FIELD_NAME_TIMESTAMP, FIELD_NAME_DATASET_ID,
+                    FIELD_NAME_PENDING_OP },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING,
+                    BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING,
+                    new AOrderedListType(COMPACTION_POLICY_PROPERTIES_RECORDTYPE, null),
+                    AUnionType.createUnknownableType(INTERNAL_DETAILS_RECORDTYPE),
+                    AUnionType.createUnknownableType(EXTERNAL_DETAILS_RECORDTYPE),
+                    new AUnorderedListType(DATASET_HINTS_RECORDTYPE, null), BuiltinType.ASTRING, BuiltinType.AINT32,
+                    BuiltinType.AINT32 },
+            //IsOpen?
+            true);
+
+    //------------------------------------------ Field ------------------------------------------//
     public static final int FIELD_ARECORD_FIELDNAME_FIELD_INDEX = 0;
     public static final int FIELD_ARECORD_FIELDTYPE_FIELD_INDEX = 1;
     public static final int FIELD_ARECORD_ISNULLABLE_FIELD_INDEX = 2;
-
-    private static final ARecordType createFieldRecordType() throws AsterixException {
-        String[] fieldNames = { "FieldName", "FieldType", "IsNullable" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ABOOLEAN };
-        return new ARecordType(null, fieldNames, fieldTypes, true);
-    };
-
-    // Helper constants for accessing fields in an ARecord of anonymous type
-    // record type.
+    public static final ARecordType FIELD_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            null,
+            // FieldNames
+            new String[] { FIELD_NAME_FIELD_NAME, FIELD_NAME_FIELD_TYPE, FIELD_NAME_IS_NULLABLE },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ABOOLEAN },
+            //IsOpen?
+            true);
+    //---------------------------------------- Record Type --------------------------------------//
     public static final int RECORDTYPE_ARECORD_ISOPEN_FIELD_INDEX = 0;
     public static final int RECORDTYPE_ARECORD_FIELDS_FIELD_INDEX = 1;
-
-    private static final ARecordType createRecordTypeRecordType() throws AsterixException {
-        AOrderedListType olType = new AOrderedListType(FIELD_RECORDTYPE, null);
-        String[] fieldNames = { "IsOpen", "Fields" };
-        IAType[] fieldTypes = { BuiltinType.ABOOLEAN, olType };
-        return new ARecordType(null, fieldNames, fieldTypes, true);
-    };
-
-    // Helper constants for accessing fields in an ARecord of anonymous type
-    // derived type.
+    public static final ARecordType RECORD_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            null,
+            // FieldNames
+            new String[] { FIELD_NAME_IS_OPEN, FIELD_NAME_FIELDS },
+            // FieldTypes
+            new IAType[] { BuiltinType.ABOOLEAN, new AOrderedListType(FIELD_RECORDTYPE, null) },
+            //IsOpen?
+            true);
+
+    //-------------------------------------- Derived Type ---------------------------------------//
     public static final int DERIVEDTYPE_ARECORD_TAG_FIELD_INDEX = 0;
     public static final int DERIVEDTYPE_ARECORD_ISANONYMOUS_FIELD_INDEX = 1;
     public static final int DERIVEDTYPE_ARECORD_RECORD_FIELD_INDEX = 2;
     public static final int DERIVEDTYPE_ARECORD_UNORDEREDLIST_FIELD_INDEX = 3;
     public static final int DERIVEDTYPE_ARECORD_ORDEREDLIST_FIELD_INDEX = 4;
-
-    private static final ARecordType createDerivedTypeRecordType() throws AsterixException {
-        String[] fieldNames = { "Tag", "IsAnonymous", "Record", "UnorderedList", "OrderedList" };
-        IAType recordUnion = AUnionType.createUnknownableType(RECORD_RECORDTYPE);
-        IAType collectionUnion = AUnionType.createUnknownableType(BuiltinType.ASTRING);
-
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ABOOLEAN, recordUnion, collectionUnion,
-                collectionUnion };
-        return new ARecordType(null, fieldNames, fieldTypes, true);
-    };
-
-    // Helper constants for accessing fields in an ARecord of type
-    // DatatypeRecordType.
+    public static final ARecordType DERIVEDTYPE_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            null,
+            // FieldNames
+            new String[] { FIELD_NAME_TAG, FIELD_NAME_IS_ANONYMOUS, FIELD_NAME_RECORD, FIELD_NAME_UNORDERED_LIST,
+                    FIELD_NAME_ORDERED_LIST },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ABOOLEAN,
+                    AUnionType.createUnknownableType(RECORD_RECORDTYPE),
+                    AUnionType.createUnknownableType(BuiltinType.ASTRING),
+                    AUnionType.createUnknownableType(BuiltinType.ASTRING) },
+            //IsOpen?
+            true);
+    //---------------------------------------- Data Type ----------------------------------------//
+    public static final String RECORD_NAME_DATATYPE = "DatatypeRecordType";
     public static final int DATATYPE_ARECORD_DATAVERSENAME_FIELD_INDEX = 0;
     public static final int DATATYPE_ARECORD_DATATYPENAME_FIELD_INDEX = 1;
     public static final int DATATYPE_ARECORD_DERIVED_FIELD_INDEX = 2;
     public static final int DATATYPE_ARECORD_TIMESTAMP_FIELD_INDEX = 3;
-
-    private static final ARecordType createDatatypeRecordType() throws AsterixException {
-        String[] fieldNames = { "DataverseName", "DatatypeName", "Derived", "Timestamp" };
-        IAType recordUnion = AUnionType.createUnknownableType(DERIVEDTYPE_RECORDTYPE);
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, recordUnion, BuiltinType.ASTRING };
-        return new ARecordType("DatatypeRecordType", fieldNames, fieldTypes, true);
-    };
-
-    // Helper constants for accessing fields in an ARecord of type
-    // IndexRecordType.
+    public static final ARecordType DATATYPE_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            RECORD_NAME_DATATYPE,
+            // FieldNames
+            new String[] { FIELD_NAME_DATAVERSE_NAME, FIELD_NAME_DATATYPE_NAME, FIELD_NAME_DERIVED,
+                    FIELD_NAME_TIMESTAMP },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING,
+                    AUnionType.createUnknownableType(DERIVEDTYPE_RECORDTYPE), BuiltinType.ASTRING },
+            //IsOpen?
+            true);
+    //-------------------------------------- Dataverse ------------------------------------------//
+    public static final String RECORD_NAME_DATAVERSE = "DataverseRecordType";
+    public static final int DATAVERSE_ARECORD_NAME_FIELD_INDEX = 0;
+    public static final int DATAVERSE_ARECORD_FORMAT_FIELD_INDEX = 1;
+    public static final int DATAVERSE_ARECORD_TIMESTAMP_FIELD_INDEX = 2;
+    public static final int DATAVERSE_ARECORD_PENDINGOP_FIELD_INDEX = 3;
+    public static final ARecordType DATAVERSE_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            RECORD_NAME_DATAVERSE,
+            // FieldNames
+            new String[] { FIELD_NAME_DATAVERSE_NAME, FIELD_NAME_DATA_FORMAT, FIELD_NAME_TIMESTAMP,
+                    FIELD_NAME_PENDING_OP },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.AINT32 },
+            //IsOpen?
+            true);
+    //-------------------------------------------- Index ----------------------------------------//
+    public static final String RECORD_NAME_INDEX = "IndexRecordType";
     public static final int INDEX_ARECORD_DATAVERSENAME_FIELD_INDEX = 0;
     public static final int INDEX_ARECORD_DATASETNAME_FIELD_INDEX = 1;
     public static final int INDEX_ARECORD_INDEXNAME_FIELD_INDEX = 2;
@@ -337,48 +301,50 @@ public final class MetadataRecordTypes {
     public static final int INDEX_ARECORD_ISPRIMARY_FIELD_INDEX = 5;
     public static final int INDEX_ARECORD_TIMESTAMP_FIELD_INDEX = 6;
     public static final int INDEX_ARECORD_PENDINGOP_FIELD_INDEX = 7;
-
-    private static final ARecordType createIndexRecordType() throws AsterixException {
-        AOrderedListType olType = new AOrderedListType(BuiltinType.ASTRING, null);
-        AOrderedListType ololType = new AOrderedListType(olType, null);
-        String[] fieldNames = { "DataverseName", "DatasetName", "IndexName", "IndexStructure", "SearchKey", "IsPrimary",
-                "Timestamp", "PendingOp" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING,
-                ololType, BuiltinType.ABOOLEAN, BuiltinType.ASTRING, BuiltinType.AINT32 };
-        return new ARecordType("IndexRecordType", fieldNames, fieldTypes, true);
-    };
-
-    // Helper constants for accessing fields in an ARecord of type
-    // NodeRecordType.
+    public static final ARecordType INDEX_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            RECORD_NAME_INDEX,
+            // FieldNames
+            new String[] { FIELD_NAME_DATAVERSE_NAME, FIELD_NAME_DATASET_NAME, FIELD_NAME_INDEX_NAME,
+                    FIELD_NAME_INDEX_STRUCTURE, FIELD_NAME_SEARCH_KEY, FIELD_NAME_IS_PRIMARY, FIELD_NAME_TIMESTAMP,
+                    FIELD_NAME_PENDING_OP },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING,
+                    new AOrderedListType(new AOrderedListType(BuiltinType.ASTRING, null), null), BuiltinType.ABOOLEAN,
+                    BuiltinType.ASTRING, BuiltinType.AINT32 },
+            //IsOpen?
+            true);
+    //----------------------------------------- Node --------------------------------------------//
+    public static final String RECORD_NAME_NODE = "NodeRecordType";
     public static final int NODE_ARECORD_NODENAME_FIELD_INDEX = 0;
     public static final int NODE_ARECORD_NUMBEROFCORES_FIELD_INDEX = 1;
     public static final int NODE_ARECORD_WORKINGMEMORYSIZE_FIELD_INDEX = 2;
-
-    private static final ARecordType createNodeRecordType() throws AsterixException {
-        String[] fieldNames = { "NodeName", "NumberOfCores", "WorkingMemorySize" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.AINT64, BuiltinType.AINT64 };
-        return new ARecordType("NodeRecordType", fieldNames, fieldTypes, true);
-    };
-
-    // Helper constants for accessing fields in an ARecord of type
-    // NodeGroupRecordType.
+    public static final ARecordType NODE_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            RECORD_NAME_NODE,
+            // FieldNames
+            new String[] { FIELD_NAME_NODE_NAME, FIELD_NAME_NUMBER_OF_CORES, FIELD_NAME_WORKING_MEMORY_SIZE },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.AINT64, BuiltinType.AINT64 },
+            //IsOpen?
+            true);
+    //--------------------------------------- Node Group ----------------------------------------//
+    public static final String RECORD_NAME_NODE_GROUP = "NodeGroupRecordType";
     public static final int NODEGROUP_ARECORD_GROUPNAME_FIELD_INDEX = 0;
     public static final int NODEGROUP_ARECORD_NODENAMES_FIELD_INDEX = 1;
     public static final int NODEGROUP_ARECORD_TIMESTAMP_FIELD_INDEX = 2;
-
-    private static final ARecordType createNodeGroupRecordType() throws AsterixException {
-        AUnorderedListType ulType = new AUnorderedListType(BuiltinType.ASTRING, null);
-        String[] fieldNames = { "GroupName", "NodeNames", "Timestamp" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, ulType, BuiltinType.ASTRING };
-        return new ARecordType("NodeGroupRecordType", fieldNames, fieldTypes, true);
-    };
-
-    private static IAType createFunctionParamsRecordType() {
-        AOrderedListType orderedParamListType = new AOrderedListType(BuiltinType.ASTRING, null);
-        return orderedParamListType;
-
-    }
-
+    public static final ARecordType NODEGROUP_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            RECORD_NAME_NODE_GROUP,
+            // FieldNames
+            new String[] { FIELD_NAME_GROUP_NAME, FIELD_NAME_NODE_NAMES, FIELD_NAME_TIMESTAMP },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, new AUnorderedListType(BuiltinType.ASTRING, null),
+                    BuiltinType.ASTRING },
+            //IsOpen?
+            true);
+    //----------------------------------------- Function ----------------------------------------//
+    public static final String RECORD_NAME_FUNCTION = "FunctionRecordType";
     public static final int FUNCTION_ARECORD_DATAVERSENAME_FIELD_INDEX = 0;
     public static final int FUNCTION_ARECORD_FUNCTIONNAME_FIELD_INDEX = 1;
     public static final int FUNCTION_ARECORD_FUNCTION_ARITY_FIELD_INDEX = 2;
@@ -387,31 +353,62 @@ public final class MetadataRecordTypes {
     public static final int FUNCTION_ARECORD_FUNCTION_DEFINITION_FIELD_INDEX = 5;
     public static final int FUNCTION_ARECORD_FUNCTION_LANGUAGE_FIELD_INDEX = 6;
     public static final int FUNCTION_ARECORD_FUNCTION_KIND_FIELD_INDEX = 7;
-
-    private static final ARecordType createFunctionRecordType() throws AsterixException {
-        String[] fieldNames = { "DataverseName", "Name", "Arity", "Params", "ReturnType", "Definition", "Language",
-                "Kind" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING,
-                createFunctionParamsRecordType(), BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING,
-                BuiltinType.ASTRING };
-        return new ARecordType("FunctionRecordType", fieldNames, fieldTypes, true);
-    }
-
+    public static final ARecordType FUNCTION_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            RECORD_NAME_FUNCTION,
+            // FieldNames
+            new String[] { FIELD_NAME_DATAVERSE_NAME, FIELD_NAME_NAME, FIELD_NAME_ARITY, FIELD_NAME_PARAMS,
+                    FIELD_NAME_RETURN_TYPE, FIELD_NAME_DEFINITION, FIELD_NAME_LANGUAGE, FIELD_NAME_KIND },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING,
+                    new AOrderedListType(BuiltinType.ASTRING, null), BuiltinType.ASTRING, BuiltinType.ASTRING,
+                    BuiltinType.ASTRING, BuiltinType.ASTRING },
+            //IsOpen?
+            true);
+    //------------------------------------------ Adapter ----------------------------------------//
+    public static final String RECORD_NAME_DATASOURCE_ADAPTER = "DatasourceAdapterRecordType";
     public static final int DATASOURCE_ADAPTER_ARECORD_DATAVERSENAME_FIELD_INDEX = 0;
     public static final int DATASOURCE_ADAPTER_ARECORD_NAME_FIELD_INDEX = 1;
     public static final int DATASOURCE_ADAPTER_ARECORD_CLASSNAME_FIELD_INDEX = 2;
     public static final int DATASOURCE_ADAPTER_ARECORD_TYPE_FIELD_INDEX = 3;
     public static final int DATASOURCE_ADAPTER_ARECORD_TIMESTAMP_FIELD_INDEX = 4;
-
-    private static ARecordType createDatasourceAdapterRecordType() throws AsterixException {
-        String[] fieldNames = { "DataverseName", "Name", "Classname", "Type", "Timestamp" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING,
-                BuiltinType.ASTRING };
-        return new ARecordType("DatasourceAdapterRecordType", fieldNames, fieldTypes, true);
-    }
-
-    // Helper constants for accessing fields in an ARecord of type
-    // FeedActivityRecordType.
+    public static final ARecordType DATASOURCE_ADAPTER_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            RECORD_NAME_DATASOURCE_ADAPTER,
+            // FieldNames
+            new String[] { FIELD_NAME_DATAVERSE_NAME, FIELD_NAME_NAME, FIELD_NAME_CLASSNAME, FIELD_NAME_TYPE,
+                    FIELD_NAME_TIMESTAMP },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING,
+                    BuiltinType.ASTRING },
+            //IsOpen?
+            true);
+    //---------------------------------- Primary Feed Details -----------------------------------//
+    public static final int FEED_TYPE_PRIMARY_ARECORD_ADAPTER_NAME_FIELD_INDEX = 0;
+    public static final int FEED_TYPE_PRIMARY_ARECORD_ADAPTER_CONFIGURATION_FIELD_INDEX = 1;
+    public static final ARecordType PRIMARY_FEED_DETAILS_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            null,
+            // FieldNames
+            new String[] { FIELD_NAME_ADAPTER_NAME, FIELD_NAME_ADAPTER_CONFIGURATION },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING,
+                    new AUnorderedListType(DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE, null) },
+            //IsOpen?
+            true);
+    //--------------------------------- Secondary Feed Details ----------------------------------//
+    public static final int FEED_TYPE_SECONDARY_ARECORD_SOURCE_FEED_NAME_FIELD_INDEX = 0;
+    public static final ARecordType SECONDARY_FEED_DETAILS_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            null,
+            // FieldNames
+            new String[] { FIELD_NAME_SOURCE_FEED_NAME },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING },
+            //IsOpen?
+            true);
+    //---------------------------------------- Feed Activity ------------------------------------//
+    public static final String RECORD_NAME_FEED = "FeedRecordType";
     public static final int FEED_ACTIVITY_ARECORD_DATAVERSE_NAME_FIELD_INDEX = 0;
     public static final int FEED_ACTIVITY_ARECORD_FEED_NAME_FIELD_INDEX = 1;
     public static final int FEED_ACTIVITY_ARECORD_DATASET_NAME_FIELD_INDEX = 2;
@@ -419,7 +416,6 @@ public final class MetadataRecordTypes {
     public static final int FEED_ACTIVITY_ARECORD_ACTIVITY_TYPE_FIELD_INDEX = 4;
     public static final int FEED_ACTIVITY_ARECORD_DETAILS_FIELD_INDEX = 5;
     public static final int FEED_ACTIVITY_ARECORD_LAST_UPDATE_TIMESTAMP_FIELD_INDEX = 6;
-
     public static final int FEED_ARECORD_DATAVERSE_NAME_FIELD_INDEX = 0;
     public static final int FEED_ARECORD_FEED_NAME_FIELD_INDEX = 1;
     public static final int FEED_ARECORD_FUNCTION_FIELD_INDEX = 2;
@@ -427,58 +423,70 @@ public final class MetadataRecordTypes {
     public static final int FEED_ARECORD_PRIMARY_TYPE_DETAILS_FIELD_INDEX = 4;
     public static final int FEED_ARECORD_SECONDARY_TYPE_DETAILS_FIELD_INDEX = 5;
     public static final int FEED_ARECORD_TIMESTAMP_FIELD_INDEX = 6;
-
     public static final int FEED_ARECORD_PRIMARY_FIELD_DETAILS_ADAPTOR_NAME_FIELD_INDEX = 0;
     public static final int FEED_ARECORD_PRIMARY_FIELD_DETAILS_ADAPTOR_CONFIGURATION_FIELD_INDEX = 1;
-
     public static final int FEED_ARECORD_SECONDARY_FIELD_DETAILS_SOURCE_FEED_NAME_FIELD_INDEX = 0;
-
-    private static ARecordType createFeedRecordType() throws AsterixException, HyracksDataException {
-
-        IAType feedFunctionUnion = AUnionType.createUnknownableType(BuiltinType.ASTRING);
-        IAType primaryRecordUnion = AUnionType.createUnknownableType(PRIMARY_FEED_DETAILS_RECORDTYPE);
-        IAType secondaryRecordUnion = AUnionType.createUnknownableType(SECONDARY_FEED_DETAILS_RECORDTYPE);
-
-        String[] fieldNames = { "DataverseName", "FeedName", "Function", "FeedType", "PrimaryTypeDetails",
-                "SecondaryTypeDetails", "Timestamp" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, feedFunctionUnion, BuiltinType.ASTRING,
-                primaryRecordUnion, secondaryRecordUnion, BuiltinType.ASTRING };
-
-        return new ARecordType("FeedRecordType", fieldNames, fieldTypes, true);
-    }
-
-    public static final int FEED_TYPE_PRIMARY_ARECORD_ADAPTER_NAME_FIELD_INDEX = 0;
-    public static final int FEED_TYPE_PRIMARY_ARECORD_ADAPTER_CONFIGURATION_FIELD_INDEX = 1;
-
-    private static final ARecordType createPrimaryFeedDetailsRecordType()
-            throws AsterixException, HyracksDataException {
-        AUnorderedListType unorderedAdaptorPropertyListType = new AUnorderedListType(
-                DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE, null);
-
-        String[] fieldNames = { "AdapterName", "AdapterConfiguration" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, unorderedAdaptorPropertyListType };
-        return new ARecordType(null, fieldNames, fieldTypes, true);
-    }
-
-    public static final int FEED_TYPE_SECONDARY_ARECORD_SOURCE_FEED_NAME_FIELD_INDEX = 0;
-
-    private static final ARecordType createSecondaryFeedDetailsRecordType()
-            throws AsterixException, HyracksDataException {
-        String[] fieldNames = { "SourceFeedName" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING };
-        return new ARecordType(null, fieldNames, fieldTypes, true);
-    }
-
+    public static final ARecordType FEED_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            RECORD_NAME_FEED,
+            // FieldNames
+            new String[] { FIELD_NAME_DATAVERSE_NAME, FIELD_NAME_FEED_NAME, FIELD_NAME_FUNCTION, FIELD_NAME_FEED_TYPE,
+                    FIELD_NAME_PRIMARY_TYPE_DETAILS, FIELD_NAME_SECONDARY_TYPE_DETAILS, FIELD_NAME_TIMESTAMP },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING,
+                    AUnionType.createUnknownableType(BuiltinType.ASTRING), BuiltinType.ASTRING,
+                    AUnionType.createUnknownableType(PRIMARY_FEED_DETAILS_RECORDTYPE),
+                    AUnionType.createUnknownableType(SECONDARY_FEED_DETAILS_RECORDTYPE), BuiltinType.ASTRING },
+            //IsOpen?
+            true);
+
+    //------------------------------------- Feed Policy ---------------------------------------//
+    public static final String RECORD_NAME_FEED_POLICY = "FeedPolicyRecordType";
+    public static final int FEED_POLICY_ARECORD_DATAVERSE_NAME_FIELD_INDEX = 0;
+    public static final int FEED_POLICY_ARECORD_POLICY_NAME_FIELD_INDEX = 1;
+    public static final int FEED_POLICY_ARECORD_DESCRIPTION_FIELD_INDEX = 2;
+    public static final int FEED_POLICY_ARECORD_PROPERTIES_FIELD_INDEX = 3;
+    public static final ARecordType FEED_POLICY_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            RECORD_NAME_FEED_POLICY,
+            // FieldNames
+            new String[] { FIELD_NAME_DATAVERSE_NAME, FIELD_NAME_POLICY_NAME, FIELD_NAME_DESCRIPTION,
+                    FIELD_NAME_PROPERTIES },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING,
+                    new AUnorderedListType(POLICY_PARAMS_RECORDTYPE, null) },
+            //IsOpen?
+            true);
+    //---------------------------------------- Library ------------------------------------------//
+    public static final String RECORD_NAME_LIBRARY = "LibraryRecordType";
     public static final int LIBRARY_ARECORD_DATAVERSENAME_FIELD_INDEX = 0;
     public static final int LIBRARY_ARECORD_NAME_FIELD_INDEX = 1;
     public static final int LIBRARY_ARECORD_TIMESTAMP_FIELD_INDEX = 2;
-
-    private static ARecordType createLibraryRecordType() throws AsterixException {
-        String[] fieldNames = { "DataverseName", "Name", "Timestamp" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING };
-        return new ARecordType("LibraryRecordType", fieldNames, fieldTypes, true);
-    }
-
+    public static final ARecordType LIBRARY_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            RECORD_NAME_LIBRARY,
+            // FieldNames
+            new String[] { FIELD_NAME_DATAVERSE_NAME, FIELD_NAME_NAME, FIELD_NAME_TIMESTAMP },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING },
+            //IsOpen?
+            true);
+    //------------------------------------- Compaction Policy -----------------------------------//
+    public static final String RECORD_NAME_COMPACTION_POLICY = "CompactionPolicyRecordType";
+    public static final int COMPACTION_POLICY_ARECORD_DATAVERSE_NAME_FIELD_INDEX = 0;
+    public static final int COMPACTION_POLICY_ARECORD_POLICY_NAME_FIELD_INDEX = 1;
+    public static final int COMPACTION_POLICY_ARECORD_CLASSNAME_FIELD_INDEX = 2;
+    public static final ARecordType COMPACTION_POLICY_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            RECORD_NAME_COMPACTION_POLICY,
+            // FieldNames
+            new String[] { FIELD_NAME_DATAVERSE_NAME, FIELD_NAME_COMPACTION_POLICY, FIELD_NAME_CLASSNAME },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING },
+            //IsOpen?
+            true);
+    //-------------------------------------- ExternalFile ---------------------------------------//
+    public static final String RECORD_NAME_EXTERNAL_FILE = "ExternalFileRecordType";
     public static final int EXTERNAL_FILE_ARECORD_DATAVERSENAME_FIELD_INDEX = 0;
     public static final int EXTERNAL_FILE_ARECORD_DATASET_NAME_FIELD_INDEX = 1;
     public static final int EXTERNAL_FILE_ARECORD_FILE_NUMBER_FIELD_INDEX = 2;
@@ -486,12 +494,40 @@ public final class MetadataRecordTypes {
     public static final int EXTERNAL_FILE_ARECORD_FILE_SIZE_FIELD_INDEX = 4;
     public static final int EXTERNAL_FILE_ARECORD_FILE_MOD_DATE_FIELD_INDEX = 5;
     public static final int EXTERNAL_FILE_ARECORD_FILE_PENDING_OP_FIELD_INDEX = 6;
+    public static final ARecordType EXTERNAL_FILE_RECORDTYPE = createRecordType(
+            // RecordTypeName
+            RECORD_NAME_EXTERNAL_FILE,
+            // FieldNames
+            new String[] { FIELD_NAME_DATAVERSE_NAME, FIELD_NAME_DATASET_NAME, FIELD_NAME_FILE_NUMBER,
+                    FIELD_NAME_FILE_NAME, FIELD_NAME_FILE_SIZE, FIELD_NAME_FILE_MOD_TIME, FIELD_NAME_PENDING_OP },
+            // FieldTypes
+            new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.AINT32, BuiltinType.ASTRING,
+                    BuiltinType.AINT64, BuiltinType.ADATETIME, BuiltinType.AINT32 },
+            //IsOpen?
+            true);
+
+    // private members
+    private MetadataRecordTypes() {
+    }
 
-    private static ARecordType createExternalFileRecordType() throws AsterixException {
-        String[] fieldNames = { "DataverseName", "DatasetName", "FileNumber", "FileName", "FileSize", "FileModTime",
-                "PendingOp" };
-        IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.AINT32, BuiltinType.ASTRING,
-                BuiltinType.AINT64, BuiltinType.ADATETIME, BuiltinType.AINT32 };
-        return new ARecordType("ExternalFileRecordType", fieldNames, fieldTypes, true);
+    private static ARecordType createRecordType(String recordTypeName, String[] fieldNames, IAType[] fieldTypes,
+            boolean isOpen) {
+        ARecordType recordType = new ARecordType(recordTypeName, fieldNames, fieldTypes, isOpen);
+        if (recordTypeName != null) {
+            recordType.generateNestedDerivedTypeNames();
+        }
+        return recordType;
+    }
+
+    private static final ARecordType createPropertiesRecordType() {
+        return createRecordType(
+                // RecordTypeName
+                null,
+                // FieldNames
+                new String[] { FIELD_NAME_NAME, FIELD_NAME_VALUE },
+                // FieldTypes
+                new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING },
+                //IsOpen? Seriously?
+                true);
     }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/dbfd22ed/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java
index 0825aa4..01380c0 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java
@@ -245,12 +245,12 @@ public class DatasetTupleTranslator extends AbstractTupleTranslator<Dataset> {
         String metaTypeDataverseName = null;
         String metaTypeName = null;
         int metaTypeDataverseNameIndex = datasetRecord.getType()
-                .getFieldIndex(MetadataRecordTypes.DATASET_ARECORD_METATYPEDATAVERSENAME_FIELD_NAME);
+                .getFieldIndex(MetadataRecordTypes.FIELD_NAME_METADATA_DATAVERSE);
         if (metaTypeDataverseNameIndex >= 0) {
             metaTypeDataverseName = ((AString) datasetRecord.getValueByPos(metaTypeDataverseNameIndex))
                     .getStringValue();
             int metaTypeNameIndex = datasetRecord.getType()
-                    .getFieldIndex(MetadataRecordTypes.DATASET_ARECORD_METATYPENAME_FIELD_NAME);
+                    .getFieldIndex(MetadataRecordTypes.FIELD_NAME_METATYPE_NAME);
             metaTypeName = ((AString) datasetRecord.getValueByPos(metaTypeNameIndex)).getStringValue();
         }
 
@@ -377,7 +377,7 @@ public class DatasetTupleTranslator extends AbstractTupleTranslator<Dataset> {
         if (dataset.hasMetaPart()) {
             // write open field 1, the meta item type Dataverse name.
             fieldName.reset();
-            aString.setValue(MetadataRecordTypes.DATASET_ARECORD_METATYPEDATAVERSENAME_FIELD_NAME);
+            aString.setValue(MetadataRecordTypes.FIELD_NAME_METADATA_DATAVERSE);
             stringSerde.serialize(aString, fieldName.getDataOutput());
             fieldValue.reset();
             aString.setValue(dataset.getMetaItemTypeDataverseName());
@@ -386,7 +386,7 @@ public class DatasetTupleTranslator extends AbstractTupleTranslator<Dataset> {
 
             // write open field 2, the meta item type name.
             fieldName.reset();
-            aString.setValue(MetadataRecordTypes.DATASET_ARECORD_METATYPENAME_FIELD_NAME);
+            aString.setValue(MetadataRecordTypes.FIELD_NAME_METATYPE_NAME);
             stringSerde.serialize(aString, fieldName.getDataOutput());
             fieldValue.reset();
             aString.setValue(dataset.getMetaItemTypeName());

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/dbfd22ed/asterixdb/asterix-metadata/src/test/java/org/apache/asterix/metadata/entitytupletranslators/DatasetTupleTranslatorTest.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/test/java/org/apache/asterix/metadata/entitytupletranslators/DatasetTupleTranslatorTest.java b/asterixdb/asterix-metadata/src/test/java/org/apache/asterix/metadata/entitytupletranslators/DatasetTupleTranslatorTest.java
index 182f296..2671834 100644
--- a/asterixdb/asterix-metadata/src/test/java/org/apache/asterix/metadata/entitytupletranslators/DatasetTupleTranslatorTest.java
+++ b/asterixdb/asterix-metadata/src/test/java/org/apache/asterix/metadata/entitytupletranslators/DatasetTupleTranslatorTest.java
@@ -26,7 +26,6 @@ import java.util.Map;
 import org.apache.asterix.common.config.DatasetConfig.DatasetType;
 import org.apache.asterix.metadata.MetadataException;
 import org.apache.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
-import org.apache.asterix.metadata.bootstrap.MetadataRecordTypes;
 import org.apache.asterix.metadata.entities.Dataset;
 import org.apache.asterix.metadata.entities.InternalDatasetDetails;
 import org.apache.asterix.metadata.entities.InternalDatasetDetails.FileStructure;
@@ -56,7 +55,6 @@ public class DatasetTupleTranslatorTest {
                     "prefix", compactionPolicyProperties, details, Collections.emptyMap(), DatasetType.INTERNAL, 115,
                     0);
 
-            MetadataRecordTypes.init();
             MetadataPrimaryIndexes.init();
             DatasetTupleTranslator dtTranslator = new DatasetTupleTranslator(true);
             ITupleReference tuple = dtTranslator.getTupleFromMetadataEntity(dataset);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/dbfd22ed/asterixdb/asterix-metadata/src/test/java/org/apache/asterix/metadata/entitytupletranslators/IndexTupleTranslatorTest.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/test/java/org/apache/asterix/metadata/entitytupletranslators/IndexTupleTranslatorTest.java b/asterixdb/asterix-metadata/src/test/java/org/apache/asterix/metadata/entitytupletranslators/IndexTupleTranslatorTest.java
index de548e2..02b3e4b 100644
--- a/asterixdb/asterix-metadata/src/test/java/org/apache/asterix/metadata/entitytupletranslators/IndexTupleTranslatorTest.java
+++ b/asterixdb/asterix-metadata/src/test/java/org/apache/asterix/metadata/entitytupletranslators/IndexTupleTranslatorTest.java
@@ -33,7 +33,6 @@ import org.apache.asterix.common.config.DatasetConfig.IndexType;
 import org.apache.asterix.metadata.MetadataException;
 import org.apache.asterix.metadata.MetadataNode;
 import org.apache.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
-import org.apache.asterix.metadata.bootstrap.MetadataRecordTypes;
 import org.apache.asterix.metadata.entities.Dataset;
 import org.apache.asterix.metadata.entities.Datatype;
 import org.apache.asterix.metadata.entities.Index;
@@ -72,7 +71,6 @@ public class IndexTupleTranslatorTest {
                     indicator == null ? null : Collections.singletonList(indicator),
                     Collections.singletonList(BuiltinType.AINT64), -1, false, false, 0);
 
-            MetadataRecordTypes.init();
             MetadataPrimaryIndexes.init();
 
             MetadataNode mockMetadataNode = mock(MetadataNode.class);


Mime
View raw message