[NO ISSUE]Introduce convenience methods for pointables

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Introduce utils to convert pointables into adm nodes.
- Such functions can be useful for tuple translation of
  Metadata entities, reading constant records in with
  clauses in DDLs, and for debugging runtime.

Change-Id: I705e75d573a7f2c888dd7d83b4c24a2c7050eb88
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2733
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
index 6bb6f35..4d71715 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
@@ -459,26 +459,13 @@
     }
 
     protected void handleCreateDataverseStatement(MetadataProvider metadataProvider, Statement stmt) throws Exception {
-
         CreateDataverseStatement stmtCreateDataverse = (CreateDataverseStatement) stmt;
         String dvName = stmtCreateDataverse.getDataverseName().getValue();
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
-
         lockManager.acquireDataverseReadLock(metadataProvider.getLocks(), dvName);
         try {
-            Dataverse dv = MetadataManager.INSTANCE.getDataverse(metadataProvider.getMetadataTxnContext(), dvName);
-            if (dv != null) {
-                if (stmtCreateDataverse.getIfNotExists()) {
-                    MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-                    return;
-                } else {
-                    throw new CompilationException(ErrorCode.DATAVERSE_EXISTS, stmt.getSourceLocation(), dvName);
-                }
-            }
-            MetadataManager.INSTANCE.addDataverse(metadataProvider.getMetadataTxnContext(),
-                    new Dataverse(dvName, stmtCreateDataverse.getFormat(), MetadataUtil.PENDING_NO_OP));
-            MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+            doCreateDataverseStatement(mdTxnCtx, metadataProvider, stmtCreateDataverse);
         } catch (Exception e) {
             abort(e, e, mdTxnCtx);
             throw e;
@@ -487,6 +474,26 @@
         }
     }
 
+    @SuppressWarnings("squid:S00112")
+    protected boolean doCreateDataverseStatement(MetadataTransactionContext mdTxnCtx, MetadataProvider metadataProvider,
+            CreateDataverseStatement stmtCreateDataverse) throws Exception {
+        String dvName = stmtCreateDataverse.getDataverseName().getValue();
+        Dataverse dv = MetadataManager.INSTANCE.getDataverse(metadataProvider.getMetadataTxnContext(), dvName);
+        if (dv != null) {
+            if (stmtCreateDataverse.getIfNotExists()) {
+                MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+                return false;
+            } else {
+                throw new CompilationException(ErrorCode.DATAVERSE_EXISTS, stmtCreateDataverse.getSourceLocation(),
+                        dvName);
+            }
+        }
+        MetadataManager.INSTANCE.addDataverse(metadataProvider.getMetadataTxnContext(),
+                new Dataverse(dvName, stmtCreateDataverse.getFormat(), MetadataUtil.PENDING_NO_OP));
+        MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+        return true;
+    }
+
     protected static void validateCompactionPolicy(String compactionPolicy,
             Map<String, String> compactionPolicyProperties, MetadataTransactionContext mdTxnCtx,
             boolean isExternalDataset, SourceLocation sourceLoc) throws CompilationException, Exception {
@@ -1220,19 +1227,29 @@
             throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
                     MetadataBuiltinEntities.DEFAULT_DATAVERSE_NAME + " dataverse can't be dropped");
         }
+        lockManager.acquireDataverseWriteLock(metadataProvider.getLocks(), dataverseName);
+        try {
+            doDropDataverse(stmtDelete, sourceLoc, metadataProvider, hcc);
+        } finally {
+            metadataProvider.getLocks().unlock();
+            ExternalDatasetsRegistry.INSTANCE.releaseAcquiredLocks(metadataProvider);
+        }
+    }
 
+    protected boolean doDropDataverse(DataverseDropStatement stmtDelete, SourceLocation sourceLoc,
+            MetadataProvider metadataProvider, IHyracksClientConnection hcc) throws Exception {
+        String dataverseName = stmtDelete.getDataverseName().getValue();
         ProgressState progress = ProgressState.NO_PROGRESS;
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         boolean bActiveTxn = true;
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
         List<JobSpecification> jobsToExecute = new ArrayList<>();
-        lockManager.acquireDataverseWriteLock(metadataProvider.getLocks(), dataverseName);
         try {
             Dataverse dv = MetadataManager.INSTANCE.getDataverse(mdTxnCtx, dataverseName);
             if (dv == null) {
                 if (stmtDelete.getIfExists()) {
                     MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-                    return;
+                    return false;
                 } else {
                     throw new CompilationException(ErrorCode.UNKNOWN_DATAVERSE, sourceLoc, dataverseName);
                 }
@@ -1336,6 +1353,7 @@
                 activeDataverse = null;
             }
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+            return true;
         } catch (Exception e) {
             if (bActiveTxn) {
                 abort(e, e, mdTxnCtx);
@@ -1369,11 +1387,7 @@
                             + ") couldn't be removed from the metadata", e);
                 }
             }
-
             throw e;
-        } finally {
-            metadataProvider.getLocks().unlock();
-            ExternalDatasetsRegistry.INSTANCE.releaseAcquiredLocks(metadataProvider);
         }
     }
 
@@ -2871,7 +2885,7 @@
 
     @Override
     public String getActiveDataverseName(String dataverse) {
-        return (dataverse != null) ? dataverse : activeDataverse.getDataverseName();
+        return (dataverse != null && !dataverse.isEmpty()) ? dataverse : activeDataverse.getDataverseName();
     }
 
     @Override
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
index 447f851..d919d0e 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
@@ -168,6 +168,9 @@
     public static final int TYPE_EXISTS = 1085;
     public static final int PARAMETER_NO_VALUE = 1086;
     public static final int COMPILATION_INVALID_NUM_OF_ARGS = 1087;
+    public static final int FIELD_NOT_FOUND = 1088;
+    public static final int FIELD_NOT_OF_TYPE = 1089;
+    public static final int ARRAY_FIELD_ELEMENTS_MUST_BE_OF_TYPE = 1090;
 
     // Feed errors
     public static final int DATAFLOW_ILLEGAL_STATE = 3001;
diff --git a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
index 720ff57..ac51570 100644
--- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
+++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
@@ -155,6 +155,9 @@
 1085 = A datatype with this name %1$s already exists
 1086 = No value for parameter: %1$s
 1087 = Invalid number of arguments: at least %1$d arguments are required for function %2$s
+1088 = Required field %1$s was not found
+1089 = Field %1$s must be of type %2$s but found to be of type %3$s
+1090 = Field %1$s must be of an array of type %2$s but found to contain an item of type %3$s
 
 # Feed Errors
 3001 = Illegal state.
diff --git a/asterixdb/asterix-lang-common/pom.xml b/asterixdb/asterix-lang-common/pom.xml
index b20bd58..96123d0 100644
--- a/asterixdb/asterix-lang-common/pom.xml
+++ b/asterixdb/asterix-lang-common/pom.xml
@@ -103,10 +103,5 @@
       <groupId>org.apache.hyracks</groupId>
       <artifactId>hyracks-api</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.apache.hyracks</groupId>
-      <artifactId>hyracks-data-std</artifactId>
-    </dependency>
   </dependencies>
-
 </project>
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java
index 8367fa0..c358444 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java
@@ -23,66 +23,53 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
-import org.apache.asterix.builders.OrderedListBuilder;
-import org.apache.asterix.builders.RecordBuilder;
 import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.common.exceptions.ErrorCode;
-import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
 import org.apache.asterix.lang.common.base.Expression;
 import org.apache.asterix.lang.common.base.Literal;
 import org.apache.asterix.lang.common.expression.FieldBinding;
 import org.apache.asterix.lang.common.expression.ListConstructor;
 import org.apache.asterix.lang.common.expression.LiteralExpr;
 import org.apache.asterix.lang.common.expression.RecordConstructor;
+import org.apache.asterix.object.base.AdmArrayNode;
+import org.apache.asterix.object.base.AdmBigIntNode;
+import org.apache.asterix.object.base.AdmBooleanNode;
+import org.apache.asterix.object.base.AdmDoubleNode;
+import org.apache.asterix.object.base.AdmNullNode;
+import org.apache.asterix.object.base.AdmObjectNode;
+import org.apache.asterix.object.base.AdmStringNode;
+import org.apache.asterix.object.base.IAdmNode;
 import org.apache.asterix.om.base.ABoolean;
 import org.apache.asterix.om.base.ADouble;
 import org.apache.asterix.om.base.AInt64;
 import org.apache.asterix.om.base.AMutableString;
-import org.apache.asterix.om.base.ANull;
 import org.apache.asterix.om.base.AOrderedList;
 import org.apache.asterix.om.base.ARecord;
 import org.apache.asterix.om.base.AString;
 import org.apache.asterix.om.base.IACursor;
 import org.apache.asterix.om.base.IAObject;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.utils.RecordUtil;
+import org.apache.asterix.om.types.ATypeTag;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.common.utils.Pair;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 
-@SuppressWarnings("unchecked")
 public class LangRecordParseUtil {
     private static final String NOT_ALLOWED_EXPRESSIONS_ERROR_MESSAGE =
             "JSON record can only have expressions [%1$s, %2$s, %3$s]";
-    private static final ISerializerDeserializer<ADouble> doubleSerde =
-            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ADOUBLE);
-    private static final ISerializerDeserializer<AString> stringSerde =
-            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING);
-    private static final ISerializerDeserializer<AInt64> intSerde =
-            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64);
-    private static final ISerializerDeserializer<ABoolean> booleanSerde =
-            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ABOOLEAN);
-    private static final ISerializerDeserializer<ANull> nullSerde =
-            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ANULL);
 
     private LangRecordParseUtil() {
     }
 
-    private static void parseExpression(Expression expr, ArrayBackedValueStorage serialized)
-            throws HyracksDataException, CompilationException {
+    private static IAdmNode parseExpression(Expression expr) throws HyracksDataException, CompilationException {
         switch (expr.getKind()) {
             case LITERAL_EXPRESSION:
-                parseLiteral((LiteralExpr) expr, serialized);
-                break;
+                return parseLiteral((LiteralExpr) expr);
             case RECORD_CONSTRUCTOR_EXPRESSION:
-                parseRecord((RecordConstructor) expr, serialized, true, Collections.emptyList());
-                break;
+                return parseRecord((RecordConstructor) expr, Collections.emptyList());
             case LIST_CONSTRUCTOR_EXPRESSION:
-                parseList((ListConstructor) expr, serialized);
-                break;
+                return parseList((ListConstructor) expr);
             default:
                 throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
                         NOT_ALLOWED_EXPRESSIONS_ERROR_MESSAGE,
@@ -92,41 +79,30 @@
         }
     }
 
-    public static void parseRecord(RecordConstructor recordValue, ArrayBackedValueStorage serialized, boolean tagged,
-            List<Pair<String, String>> defaults) throws HyracksDataException, CompilationException {
+    public static AdmObjectNode parseRecord(RecordConstructor recordValue, List<Pair<String, String>> defaults)
+            throws HyracksDataException, CompilationException {
+        AdmObjectNode record = new AdmObjectNode();
         AMutableString fieldNameString = new AMutableString(null);
-        ArrayBackedValueStorage fieldName = new ArrayBackedValueStorage();
-        ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
-        RecordBuilder recordBuilder = new RecordBuilder();
-        recordBuilder.reset(RecordUtil.FULLY_OPEN_RECORD_TYPE);
-        recordBuilder.init();
         List<FieldBinding> fbList = recordValue.getFbList();
         HashSet<String> fieldNames = new HashSet<>();
         for (FieldBinding fb : fbList) {
-            fieldName.reset();
-            fieldValue.reset();
             // get key
             fieldNameString.setValue(exprToStringLiteral(fb.getLeftExpr()).getStringValue());
             if (!fieldNames.add(fieldNameString.getStringValue())) {
                 throw new HyracksDataException(
                         "Field " + fieldNameString.getStringValue() + " was specified multiple times");
             }
-            stringSerde.serialize(fieldNameString, fieldName.getDataOutput());
             // get value
-            parseExpression(fb.getRightExpr(), fieldValue);
-            recordBuilder.addField(fieldName, fieldValue);
+            IAdmNode value = parseExpression(fb.getRightExpr());
+            record.set(fieldNameString.getStringValue(), value);
         }
         // defaults
         for (Pair<String, String> kv : defaults) {
             if (!fieldNames.contains(kv.first)) {
-                fieldName.reset();
-                fieldValue.reset();
-                stringSerde.serialize(new AString(kv.first), fieldName.getDataOutput());
-                stringSerde.serialize(new AString(kv.second), fieldValue.getDataOutput());
-                recordBuilder.addField(fieldName, fieldValue);
+                record.set(kv.first, new AdmStringNode(kv.second));
             }
         }
-        recordBuilder.write(serialized.getDataOutput(), tagged);
+        return record;
     }
 
     public static Literal exprToStringLiteral(Expression expr) throws CompilationException {
@@ -143,51 +119,37 @@
         return keyLiteral;
     }
 
-    private static void parseList(ListConstructor valueExpr, ArrayBackedValueStorage serialized)
-            throws CompilationException, HyracksDataException {
+    private static AdmArrayNode parseList(ListConstructor valueExpr) throws CompilationException, HyracksDataException {
         if (valueExpr.getType() != ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR) {
             throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR, "JSON List can't be of type %1$s",
                     valueExpr.getType());
         }
-        ArrayBackedValueStorage serializedValue = new ArrayBackedValueStorage();
-        OrderedListBuilder listBuilder = new OrderedListBuilder();
-        listBuilder.reset(null);
-        for (Expression expr : valueExpr.getExprList()) {
-            serializedValue.reset();
-            parseExpression(expr, serializedValue);
-            listBuilder.addItem(serializedValue);
+        List<Expression> exprs = valueExpr.getExprList();
+        AdmArrayNode list = new AdmArrayNode(exprs.size());
+        for (Expression expr : exprs) {
+            list.add(parseExpression(expr));
         }
-        listBuilder.write(serialized.getDataOutput(), true);
+        return list;
     }
 
-    private static void parseLiteral(LiteralExpr objectExpr, ArrayBackedValueStorage serialized)
-            throws HyracksDataException {
+    private static IAdmNode parseLiteral(LiteralExpr objectExpr) throws HyracksDataException {
         Literal value = objectExpr.getValue();
         switch (value.getLiteralType()) {
             case DOUBLE:
-                doubleSerde.serialize(new ADouble((Double) value.getValue()), serialized.getDataOutput());
-                break;
-            case TRUE:
-                booleanSerde.serialize(ABoolean.TRUE, serialized.getDataOutput());
-                break;
-            case FALSE:
-                booleanSerde.serialize(ABoolean.FALSE, serialized.getDataOutput());
-                break;
             case FLOAT:
-                doubleSerde.serialize(new ADouble((Float) value.getValue()), serialized.getDataOutput());
-                break;
+                return new AdmDoubleNode((Double) value.getValue());
+            case TRUE:
+                return AdmBooleanNode.TRUE;
+            case FALSE:
+                return AdmBooleanNode.FALSE;
             case INTEGER:
-                intSerde.serialize(new AInt64(((Integer) value.getValue()).longValue()), serialized.getDataOutput());
-                break;
+                return new AdmBigIntNode((Integer) value.getValue());
             case LONG:
-                intSerde.serialize(new AInt64((Long) value.getValue()), serialized.getDataOutput());
-                break;
+                return new AdmBigIntNode((Long) value.getValue());
             case NULL:
-                nullSerde.serialize(ANull.NULL, serialized.getDataOutput());
-                break;
+                return AdmNullNode.INSTANCE;
             case STRING:
-                stringSerde.serialize(new AString((String) value.getValue()), serialized.getDataOutput());
-                break;
+                return new AdmStringNode((String) value.getValue());
             default:
                 throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR, "Unknown Literal Type %1$s",
                         value.getLiteralType());
@@ -203,6 +165,21 @@
         }
     }
 
+    public static void recordToMap(Map<String, String> map, AdmObjectNode record) throws AlgebricksException {
+        for (Entry<String, IAdmNode> field : record.getFields()) {
+            String value = aObjToString(field.getValue());
+            map.put(field.getKey(), value);
+        }
+    }
+
+    private static String aObjToString(IAdmNode aObj) {
+        if (aObj.getType() == ATypeTag.STRING) {
+            return ((AdmStringNode) aObj).get();
+        } else {
+            return aObj.toString();
+        }
+    }
+
     public static String aObjToString(IAObject aObj) throws AlgebricksException {
         switch (aObj.getType().getTypeTag()) {
             case DOUBLE:
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataManager.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataManager.java
index 4474684..e5ee163 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataManager.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataManager.java
@@ -25,8 +25,6 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import org.apache.asterix.common.config.MetadataProperties;
 import org.apache.asterix.common.dataflow.ICcApplicationContext;
@@ -60,6 +58,9 @@
 import org.apache.asterix.transaction.management.opcallbacks.AbstractIndexModificationOperationCallback.Operation;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.util.ExitUtil;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 /**
  * Provides access to Asterix metadata via remote methods to the metadata node.
@@ -94,6 +95,7 @@
  * with transaction ids of regular jobs or other metadata transactions.
  */
 public abstract class MetadataManager implements IMetadataManager {
+    private static final Logger LOGGER = LogManager.getLogger();
     private final MetadataCache cache = new MetadataCache();
     protected final Collection<IAsterixStateProxy> proxies;
     protected IMetadataNode metadataNode;
@@ -132,15 +134,29 @@
         return new MetadataTransactionContext(txnId);
     }
 
+    @SuppressWarnings("squid:S1181")
     @Override
-    public void commitTransaction(MetadataTransactionContext ctx) throws RemoteException, ACIDException {
-        metadataNode.commitTransaction(ctx.getTxnId());
-        cache.commit(ctx);
+    public void commitTransaction(MetadataTransactionContext ctx) {
+        try {
+            metadataNode.commitTransaction(ctx.getTxnId());
+            cache.commit(ctx);
+        } catch (Throwable th) {
+            // Metadata node should abort all transactions on re-joining the new CC
+            LOGGER.fatal("Failure committing a metadata transaction", th);
+            ExitUtil.halt(ExitUtil.EC_FAILED_TO_COMMIT_METADATA_TXN);
+        }
     }
 
+    @SuppressWarnings("squid:S1181")
     @Override
-    public void abortTransaction(MetadataTransactionContext ctx) throws RemoteException, ACIDException {
-        metadataNode.abortTransaction(ctx.getTxnId());
+    public void abortTransaction(MetadataTransactionContext ctx) {
+        try {
+            metadataNode.abortTransaction(ctx.getTxnId());
+        } catch (Throwable th) {
+            // Metadata node should abort all transactions on re-joining the new CC
+            LOGGER.fatal("Failure aborting a metadata transaction", th);
+            ExitUtil.halt(ExitUtil.EC_FAILED_TO_ABORT_METADATA_TXN);
+        }
     }
 
     @Override
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataNode.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataNode.java
index 543b794..164c867 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataNode.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataNode.java
@@ -30,18 +30,15 @@
 import org.apache.asterix.common.api.INcApplicationContext;
 import org.apache.asterix.common.config.DatasetConfig.DatasetType;
 import org.apache.asterix.common.config.DatasetConfig.IndexType;
-import org.apache.asterix.common.context.PrimaryIndexOperationTracker;
 import org.apache.asterix.common.dataflow.LSMIndexUtil;
 import org.apache.asterix.common.exceptions.ACIDException;
 import org.apache.asterix.common.functions.FunctionSignature;
 import org.apache.asterix.common.metadata.MetadataIndexImmutableProperties;
-import org.apache.asterix.common.transactions.DatasetId;
 import org.apache.asterix.common.transactions.IRecoveryManager.ResourceType;
 import org.apache.asterix.common.transactions.ITransactionContext;
 import org.apache.asterix.common.transactions.ITransactionManager.AtomicityLevel;
 import org.apache.asterix.common.transactions.ITransactionSubsystem;
 import org.apache.asterix.common.transactions.ITxnIdFactory;
-import org.apache.asterix.common.transactions.ImmutableDatasetId;
 import org.apache.asterix.common.transactions.TransactionOptions;
 import org.apache.asterix.common.transactions.TxnId;
 import org.apache.asterix.common.utils.StoragePathUtil;
@@ -124,10 +121,13 @@
 import org.apache.hyracks.storage.common.IIndexCursor;
 import org.apache.hyracks.storage.common.IModificationOperationCallback;
 import org.apache.hyracks.storage.common.MultiComparator;
+import org.apache.hyracks.util.ExitUtil;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 public class MetadataNode implements IMetadataNode {
     private static final long serialVersionUID = 1L;
-
+    private static final Logger LOGGER = LogManager.getLogger();
     // shared between core and extension
     private IDatasetLifecycleManager datasetLifecycleManager;
     private ITransactionSubsystem transactionSubsystem;
@@ -172,14 +172,28 @@
         transactionSubsystem.getTransactionManager().beginTransaction(transactionId, options);
     }
 
+    @SuppressWarnings("squid:S1181")
     @Override
     public void commitTransaction(TxnId txnId) throws RemoteException, ACIDException {
-        transactionSubsystem.getTransactionManager().commitTransaction(txnId);
+        try {
+            transactionSubsystem.getTransactionManager().commitTransaction(txnId);
+        } catch (Throwable th) {
+            // Metadata node should abort all Metadata transactions on re-start
+            LOGGER.fatal("Failure committing a metadata transaction", th);
+            ExitUtil.halt(ExitUtil.EC_FAILED_TO_COMMIT_METADATA_TXN);
+        }
     }
 
+    @SuppressWarnings("squid:S1181")
     @Override
     public void abortTransaction(TxnId txnId) throws RemoteException, ACIDException {
-        transactionSubsystem.getTransactionManager().abortTransaction(txnId);
+        try {
+            transactionSubsystem.getTransactionManager().abortTransaction(txnId);
+        } catch (Throwable th) {
+            // Metadata node should abort all uncommitted transactions on re-start
+            LOGGER.fatal("Failure committing a metadata transaction", th);
+            ExitUtil.halt(ExitUtil.EC_FAILED_TO_ABORT_METADATA_TXN);
+        }
     }
 
     // TODO(amoudi): make all metadata operations go through the generic methods
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataset.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataset.java
index bcd05ee..d0a22b7 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataset.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataset.java
@@ -127,9 +127,6 @@
      */
     private static final long serialVersionUID = 1L;
     private static final Logger LOGGER = LogManager.getLogger();
-    //TODO: Remove Singletons
-    private static final BTreeResourceFactoryProvider bTreeResourceFactoryProvider =
-            BTreeResourceFactoryProvider.INSTANCE;
     private static final RTreeResourceFactoryProvider rTreeResourceFactoryProvider =
             RTreeResourceFactoryProvider.INSTANCE;
     private static final InvertedIndexResourceFactoryProvider invertedIndexResourceFactoryProvider =
@@ -153,10 +150,6 @@
     private final long rebalanceCount;
     private int pendingOp;
 
-    /*
-     * Transient (For caching)
-     */
-
     public Dataset(String dataverseName, String datasetName, String recordTypeDataverseName, String recordTypeName,
             String nodeGroupName, String compactionPolicy, Map<String, String> compactionPolicyProperties,
             IDatasetDetails datasetDetails, Map<String, String> hints, DatasetType datasetType, int datasetId,
@@ -473,8 +466,9 @@
         IResourceFactory resourceFactory;
         switch (index.getIndexType()) {
             case BTREE:
-                resourceFactory = bTreeResourceFactoryProvider.getResourceFactory(mdProvider, this, index, recordType,
-                        metaType, mergePolicyFactory, mergePolicyProperties, filterTypeTraits, filterCmpFactories);
+                resourceFactory = BTreeResourceFactoryProvider.INSTANCE.getResourceFactory(mdProvider, this, index,
+                        recordType, metaType, mergePolicyFactory, mergePolicyProperties, filterTypeTraits,
+                        filterCmpFactories);
                 break;
             case RTREE:
                 resourceFactory = rTreeResourceFactoryProvider.getResourceFactory(mdProvider, this, index, recordType,
@@ -853,4 +847,8 @@
         }
         return partitions;
     }
+
+    public String getFullyQualifiedName() {
+        return dataverseName + '.' + datasetName;
+    }
 }
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataverse.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataverse.java
index 1b40484..35d21a0 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataverse.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataverse.java
@@ -65,4 +65,19 @@
     public String toString() {
         return getClass().getSimpleName() + ":" + dataverseName;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (!(o instanceof Dataverse)) {
+            return false;
+        }
+        Dataverse other = (Dataverse) o;
+        return dataverseName.equals(other.getDataverseName());
+    }
+
+    @Override
+    public int hashCode() {
+        return dataverseName.hashCode();
+    }
+
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/SerializerDeserializerProvider.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/SerializerDeserializerProvider.java
index d66673d..0cba8b6 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/SerializerDeserializerProvider.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/SerializerDeserializerProvider.java
@@ -81,8 +81,7 @@
     // Can't be shared among threads <Stateful>
     @SuppressWarnings("rawtypes")
     public ISerializerDeserializer getAStringSerializerDeserializer() {
-        return addTag(new AStringSerializerDeserializer(new UTF8StringWriter(), new UTF8StringReader()),
-                ATypeTag.STRING);
+        return addTag(new AStringSerializerDeserializer(new UTF8StringWriter(), new UTF8StringReader()));
     }
 
     @SuppressWarnings("rawtypes")
@@ -98,7 +97,7 @@
                 // we could do smth better for nullable fields
                 return AObjectSerializerDeserializer.INSTANCE;
             default:
-                return addTag(getNonTaggedSerializerDeserializer(aqlType), aqlType.getTypeTag());
+                return addTag(getNonTaggedSerializerDeserializer(aqlType));
         }
     }
 
@@ -172,7 +171,7 @@
     }
 
     @SuppressWarnings("rawtypes")
-    private ISerializerDeserializer addTag(final ISerializerDeserializer nonTaggedSerde, final ATypeTag typeTag) {
+    private ISerializerDeserializer addTag(final ISerializerDeserializer nonTaggedSerde) {
         return new ISerializerDeserializer<IAObject>() {
 
             private static final long serialVersionUID = 1L;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/TypeTraitProvider.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/TypeTraitProvider.java
index 9ec5a08..1836cfa 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/TypeTraitProvider.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/TypeTraitProvider.java
@@ -36,7 +36,7 @@
     private static final ITypeTraits THIRTYTWOBYTETYPETRAIT = new TypeTrait(32 + 1);
     private static final ITypeTraits TWENTYFOURBYTETYPETRAIT = new TypeTrait(24 + 1);
 
-    private static final ITypeTraits VARLENTYPETRAIT = new TypeTrait(false, -1);
+    public static final ITypeTraits VARLENTYPETRAIT = new TypeTrait(false, -1);
 
     public static final TypeTraitProvider INSTANCE = new TypeTraitProvider();
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmArrayNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmArrayNode.java
index e489cd5..60ef41a4 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmArrayNode.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmArrayNode.java
@@ -18,12 +18,19 @@
  */
 package org.apache.asterix.object.base;
 
+import java.io.DataOutput;
+import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
+import org.apache.asterix.builders.OrderedListBuilder;
+import org.apache.asterix.om.types.AOrderedListType;
 import org.apache.asterix.om.types.ATypeTag;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 
-public class AdmArrayNode implements IAdmNode {
+public class AdmArrayNode implements IAdmNode, Iterable<IAdmNode> {
+    private static final long serialVersionUID = 1L;
     private final List<IAdmNode> children;
 
     public AdmArrayNode() {
@@ -42,6 +49,10 @@
         add(AdmBooleanNode.get(value));
     }
 
+    public int size() {
+        return children.size();
+    }
+
     public void add(IAdmNode value) {
         if (value == null) {
             value = AdmNullNode.INSTANCE; // NOSONAR
@@ -74,4 +85,23 @@
     public String toString() {
         return children.toString();
     }
+
+    @Override
+    public void serializeValue(DataOutput dataOutput) throws IOException {
+        OrderedListBuilder listBuilder = new OrderedListBuilder();
+        listBuilder.reset(AOrderedListType.FULL_OPEN_ORDEREDLIST_TYPE);
+        ArrayBackedValueStorage itemValue = new ArrayBackedValueStorage();
+        for (int i = 0; i < children.size(); i++) {
+            itemValue.reset();
+            IAdmNode next = children.get(i);
+            next.serialize(itemValue.getDataOutput());
+            listBuilder.addItem(itemValue);
+        }
+        listBuilder.write(dataOutput, false);
+    }
+
+    @Override
+    public Iterator<IAdmNode> iterator() {
+        return children.iterator();
+    }
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBigIntNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBigIntNode.java
index 0006668..61afc74 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBigIntNode.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBigIntNode.java
@@ -18,9 +18,14 @@
  */
 package org.apache.asterix.object.base;
 
+import java.io.DataOutput;
+import java.io.IOException;
+
 import org.apache.asterix.om.types.ATypeTag;
 
 public class AdmBigIntNode implements IAdmNode {
+
+    private static final long serialVersionUID = 1L;
     private long value;
 
     public AdmBigIntNode() {
@@ -52,4 +57,9 @@
     public String toString() {
         return Long.toString(value);
     }
+
+    @Override
+    public void serializeValue(DataOutput dataOutput) throws IOException {
+        dataOutput.writeLong(value);
+    }
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBooleanNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBooleanNode.java
index aeebd86..721ce4c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBooleanNode.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBooleanNode.java
@@ -18,10 +18,14 @@
  */
 package org.apache.asterix.object.base;
 
+import java.io.DataOutput;
+import java.io.IOException;
+
 import org.apache.asterix.om.types.ATypeTag;
 
 public class AdmBooleanNode implements IAdmNode {
 
+    private static final long serialVersionUID = 1L;
     public static final AdmBooleanNode TRUE = new AdmBooleanNode(true);
     public static final AdmBooleanNode FALSE = new AdmBooleanNode(false);
     private final boolean value;
@@ -56,4 +60,9 @@
     public String toString() {
         return Boolean.toString(value);
     }
+
+    @Override
+    public void serializeValue(DataOutput dataOutput) throws IOException {
+        dataOutput.writeBoolean(value);
+    }
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmDoubleNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmDoubleNode.java
index 0150b4e..0601e63 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmDoubleNode.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmDoubleNode.java
@@ -18,9 +18,13 @@
  */
 package org.apache.asterix.object.base;
 
+import java.io.DataOutput;
+import java.io.IOException;
+
 import org.apache.asterix.om.types.ATypeTag;
 
 public class AdmDoubleNode implements IAdmNode {
+    private static final long serialVersionUID = 1L;
     private double value;
 
     public AdmDoubleNode() {
@@ -53,4 +57,9 @@
     public String toString() {
         return Double.toString(value);
     }
+
+    @Override
+    public void serializeValue(DataOutput dataOutput) throws IOException {
+        dataOutput.writeDouble(value);
+    }
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmNullNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmNullNode.java
index 2804ca3..6fe8357 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmNullNode.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmNullNode.java
@@ -18,10 +18,14 @@
  */
 package org.apache.asterix.object.base;
 
+import java.io.DataOutput;
+import java.io.IOException;
+
 import org.apache.asterix.om.types.ATypeTag;
 
 public class AdmNullNode implements IAdmNode {
 
+    private static final long serialVersionUID = 1L;
     public static final AdmNullNode INSTANCE = new AdmNullNode();
 
     private AdmNullNode() {
@@ -41,4 +45,9 @@
     public String toString() {
         return "null";
     }
+
+    @Override
+    public void serializeValue(DataOutput dataOutput) throws IOException {
+        // Nothing to write
+    }
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmObjectNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmObjectNode.java
index e35b28f..99b7176 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmObjectNode.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmObjectNode.java
@@ -18,23 +18,43 @@
  */
 package org.apache.asterix.object.base;
 
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
+import org.apache.asterix.builders.RecordBuilder;
+import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
+import org.apache.asterix.om.base.AString;
 import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.utils.RecordUtil;
+import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 
 /**
  * An adm object instance
  */
 public class AdmObjectNode implements IAdmNode {
+
+    private static final long serialVersionUID = 1L;
+    public static final AdmObjectNode EMPTY = new AdmObjectNode(Collections.emptyMap());
     private final Map<String, IAdmNode> children;
 
     public AdmObjectNode() {
         children = new HashMap<>();
     }
 
+    public AdmObjectNode(Map<String, IAdmNode> children) {
+        this.children = children;
+    }
+
     @Override
     public ATypeTag getType() {
         return ATypeTag.OBJECT;
@@ -56,10 +76,13 @@
         return children.entrySet();
     }
 
-    public AdmObjectNode set(String fieldName, IAdmNode value) {
+    public AdmObjectNode set(String fieldName, IAdmNode value) throws CompilationException {
         if (value == null) {
             value = AdmNullNode.INSTANCE; // NOSONAR
         }
+        if (children.containsKey(fieldName)) {
+            throw new CompilationException(ErrorCode.DUPLICATE_FIELD_NAME, fieldName);
+        }
         children.put(fieldName, value);
         return this;
     }
@@ -92,4 +115,51 @@
         sb.append("}");
         return sb.toString();
     }
+
+    public static AdmObjectNode from(Map<String, IAdmNode> fields) {
+        return fields.isEmpty() ? EMPTY : new AdmObjectNode(fields);
+    }
+
+    public boolean isEmpty() {
+        return children.isEmpty();
+    }
+
+    @Override
+    public void serializeValue(DataOutput dataOutput) throws IOException {
+        ISerializerDeserializer<AString> stringSerde =
+                SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING);
+        RecordBuilder confRecordBuilder = new RecordBuilder();
+        confRecordBuilder.reset(RecordUtil.FULLY_OPEN_RECORD_TYPE);
+        confRecordBuilder.init();
+        ArrayBackedValueStorage fieldNameBytes = new ArrayBackedValueStorage();
+        ArrayBackedValueStorage fieldValueBytes = new ArrayBackedValueStorage();
+        for (Entry<String, IAdmNode> field : getFields()) {
+            String fieldName = field.getKey();
+            fieldValueBytes.reset();
+            fieldNameBytes.reset();
+            stringSerde.serialize(new AString(fieldName), fieldNameBytes.getDataOutput());
+            IAdmNode value = field.getValue();
+            value.serialize(fieldValueBytes.getDataOutput());
+            confRecordBuilder.addField(fieldNameBytes, fieldValueBytes);
+        }
+        confRecordBuilder.write(dataOutput, false);
+    }
+
+    public boolean contains(String fieldName) {
+        return children.containsKey(fieldName);
+    }
+
+    public String getString(String field) throws HyracksDataException {
+        return getString(this, field);
+    }
+
+    public static String getString(AdmObjectNode openFields, String field) throws HyracksDataException {
+        IAdmNode node = openFields.get(field);
+        if (node == null) {
+            throw HyracksDataException.create(ErrorCode.FIELD_NOT_FOUND, field);
+        } else if (node.getType() != ATypeTag.STRING) {
+            throw HyracksDataException.create(ErrorCode.FIELD_NOT_OF_TYPE, field, ATypeTag.STRING, node.getType());
+        }
+        return ((AdmStringNode) node).get();
+    }
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmStringNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmStringNode.java
index 4c92f09..3dc70d1 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmStringNode.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmStringNode.java
@@ -18,9 +18,15 @@
  */
 package org.apache.asterix.object.base;
 
+import java.io.DataOutput;
+import java.io.IOException;
+
 import org.apache.asterix.om.types.ATypeTag;
+import org.apache.hyracks.util.string.UTF8StringUtil;
 
 public class AdmStringNode implements IAdmNode {
+
+    private static final long serialVersionUID = 1L;
     private String value;
 
     public AdmStringNode() {
@@ -49,4 +55,9 @@
         return "\"" + value + "\"";
     }
 
+    @Override
+    public void serializeValue(DataOutput dataOutput) throws IOException {
+        UTF8StringUtil.writeUTF8(value, dataOutput, null);
+    }
+
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/IAdmNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/IAdmNode.java
index c382fd2..98d7fe4 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/IAdmNode.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/IAdmNode.java
@@ -18,12 +18,16 @@
  */
 package org.apache.asterix.object.base;
 
+import java.io.DataOutput;
+import java.io.IOException;
+import java.io.Serializable;
+
 import org.apache.asterix.om.types.ATypeTag;
 
 /**
  * An interface representing an adm node
  */
-public interface IAdmNode {
+public interface IAdmNode extends Serializable {
 
     /**
      * @return true if the object is a value, false if the object is a container
@@ -62,4 +66,23 @@
      * reset the node
      */
     void reset();
+
+    /**
+     * Serialize the field with a type tag
+     *
+     * @param dataOutput
+     * @throws IOException
+     */
+    default void serialize(DataOutput dataOutput) throws IOException {
+        dataOutput.writeByte(getType().serialize());
+        serializeValue(dataOutput);
+    }
+
+    /**
+     * Serialize the value without a type tag
+     *
+     * @param dataOutput
+     * @throws IOException
+     */
+    void serializeValue(DataOutput dataOutput) throws IOException;
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/AIntervalPointable.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/AIntervalPointable.java
index ce04f6d..299649b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/AIntervalPointable.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/AIntervalPointable.java
@@ -99,6 +99,7 @@
         start.set(bytes, getStartOffset(), getStartSize());
     }
 
+    @Override
     public int getStartOffset() {
         return getTypeOffset() + getTypeSize();
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/AListPointable.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/AListPointable.java
index 7c74a69..8d525f3 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/AListPointable.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/AListPointable.java
@@ -22,7 +22,6 @@
 import java.io.DataOutput;
 import java.io.IOException;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.types.AOrderedListType;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.AbstractCollectionType;
@@ -40,6 +39,7 @@
  * This class interprets the binary data representation of a list.
  *
  * List {
+ *   byte tag;
  *   byte type;
  *   int length;
  *   int numberOfItems;
@@ -62,11 +62,16 @@
         }
     };
 
-    public static final IPointableFactory FACTORY = new IPointableFactory() {
+    public static final AListPointableFactory FACTORY = new AListPointableFactory();
+
+    public static class AListPointableFactory implements IPointableFactory {
         private static final long serialVersionUID = 1L;
 
+        private AListPointableFactory() {
+        }
+
         @Override
-        public IPointable createPointable() {
+        public AListPointable createPointable() {
             return new AListPointable();
         }
 
@@ -169,7 +174,7 @@
             return getItemCountOffset() + getItemCountSize() + index * getFixedLength(inputType);
         } else {
             int offset = getItemCountOffset() + getItemCountSize() + index * ITEM_OFFSET_SIZE;
-            return IntegerPointable.getInteger(bytes, offset);
+            return start + IntegerPointable.getInteger(bytes, offset);
         }
     }
 
@@ -195,5 +200,4 @@
         }
         dOut.write(bytes, getItemOffset(inputType, index), getItemSize(inputType, index));
     }
-
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/ARecordPointable.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/ARecordPointable.java
index 77491e8..8ae533b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/ARecordPointable.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/ARecordPointable.java
@@ -22,7 +22,6 @@
 import java.io.DataOutput;
 import java.io.IOException;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.AUnionType;
@@ -230,6 +229,21 @@
         }
     }
 
+    /**
+     * This is always untagged
+     *
+     * @param recordType
+     * @param fieldId
+     * @param pointable
+     * @throws IOException
+     */
+    public void getClosedFieldValue(ARecordType recordType, int fieldId, IPointable pointable) throws IOException {
+        if (isClosedFieldNull(recordType, fieldId) || isClosedFieldMissing(recordType, fieldId)) {
+            throw new IllegalStateException("Can't read a null or missing field");
+        }
+        pointable.set(bytes, getClosedFieldOffset(recordType, fieldId), getClosedFieldSize(recordType, fieldId));
+    }
+
     public String getClosedFieldName(ARecordType recordType, int fieldId) {
         return recordType.getFieldNames()[fieldId];
     }
@@ -304,6 +318,14 @@
         dOut.write(bytes, getOpenFieldNameOffset(recordType, fieldId), getOpenFieldNameSize(recordType, fieldId));
     }
 
+    public String getOpenFieldName(ARecordType recordType, int fieldId) throws IOException {
+        StringBuilder str = new StringBuilder();
+        int offset = getOpenFieldNameOffset(recordType, fieldId);
+        UTF8StringUtil.toString(str, bytes, offset);
+        String fieldName = str.toString();
+        return fieldName;
+    }
+
     public int getOpenFieldNameSize(ARecordType recordType, int fieldId) {
         int utfleng = UTF8StringUtil.getUTFLength(bytes, getOpenFieldNameOffset(recordType, fieldId));
         return utfleng + UTF8StringUtil.getNumBytesToStoreLength(utfleng);
@@ -340,5 +362,4 @@
     public int getOpenFieldOffsetSize(ARecordType recordType, int fieldId) {
         return OPEN_FIELD_HASH_SIZE;
     }
-
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/utils/AdmNodeUtils.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/utils/AdmNodeUtils.java
new file mode 100644
index 0000000..6f4ee17
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/utils/AdmNodeUtils.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.om.utils;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.asterix.object.base.AdmArrayNode;
+import org.apache.asterix.object.base.AdmBigIntNode;
+import org.apache.asterix.object.base.AdmBooleanNode;
+import org.apache.asterix.object.base.AdmDoubleNode;
+import org.apache.asterix.object.base.AdmNullNode;
+import org.apache.asterix.object.base.AdmObjectNode;
+import org.apache.asterix.object.base.AdmStringNode;
+import org.apache.asterix.object.base.IAdmNode;
+import org.apache.asterix.om.pointables.nonvisitor.AListPointable;
+import org.apache.asterix.om.pointables.nonvisitor.ARecordPointable;
+import org.apache.asterix.om.types.AOrderedListType;
+import org.apache.asterix.om.types.ARecordType;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.hyracks.data.std.primitive.BooleanPointable;
+import org.apache.hyracks.data.std.primitive.DoublePointable;
+import org.apache.hyracks.data.std.primitive.LongPointable;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
+
+public class AdmNodeUtils {
+
+    private AdmNodeUtils() {
+    }
+
+    public static Map<String, IAdmNode> getOpenFields(ARecordPointable recPointable, ARecordType recordType)
+            throws IOException {
+        int openFieldCount = recPointable.getOpenFieldCount(recordType);
+        Map<String, IAdmNode> map = (openFieldCount == 0) ? Collections.emptyMap() : new HashMap<>();
+        for (int i = 0; i < openFieldCount; i++) {
+            map.put(recPointable.getOpenFieldName(recordType, i), getOpenField(recPointable, recordType, i));
+        }
+        return map;
+    }
+
+    private static IAdmNode getOpenField(ARecordPointable recPointable, ARecordType type, int i) throws IOException {
+        byte tagByte = recPointable.getOpenFieldTag(type, i);
+        ATypeTag tag = ATypeTag.VALUE_TYPE_MAPPING[tagByte];
+        switch (tag) {
+            case ARRAY:
+                return getOpenFieldAsArray(recPointable, type, i);
+            case BIGINT:
+                return new AdmBigIntNode(LongPointable.getLong(recPointable.getByteArray(),
+                        recPointable.getOpenFieldValueOffset(type, i) + 1));
+            case BOOLEAN:
+                return AdmBooleanNode.get(BooleanPointable.getBoolean(recPointable.getByteArray(),
+                        recPointable.getOpenFieldValueOffset(type, i) + 1));
+            case DOUBLE:
+                return new AdmDoubleNode(DoublePointable.getDouble(recPointable.getByteArray(),
+                        recPointable.getOpenFieldValueOffset(type, i) + 1));
+            case NULL:
+                return AdmNullNode.INSTANCE;
+            case OBJECT:
+                return getOpenFieldAsObject(recPointable, type, i);
+            case STRING:
+                UTF8StringPointable str = UTF8StringPointable.FACTORY.createPointable();
+                str.set(recPointable.getByteArray(), recPointable.getOpenFieldValueOffset(type, i) + 1,
+                        recPointable.getOpenFieldValueSize(type, i) - 1);
+                return new AdmStringNode(str.toString());
+            default:
+                throw new UnsupportedOperationException("Unsupported item type: " + tag);
+        }
+    }
+
+    private static AdmObjectNode getOpenFieldAsObject(ARecordPointable recPointable, ARecordType type, int i)
+            throws IOException {
+        ARecordPointable pointable = ARecordPointable.FACTORY.createPointable();
+        int offset = recPointable.getOpenFieldValueOffset(type, i);
+        int len = recPointable.getOpenFieldValueSize(type, i);
+        pointable.set(recPointable.getByteArray(), offset, len);
+        return new AdmObjectNode(getOpenFields(pointable, RecordUtil.FULLY_OPEN_RECORD_TYPE));
+    }
+
+    private static AdmArrayNode getOpenFieldAsArray(ARecordPointable recPointable, ARecordType type, int i)
+            throws IOException {
+        AListPointable pointable = AListPointable.FACTORY.createPointable();
+        int offset = recPointable.getOpenFieldValueOffset(type, i);
+        int len = recPointable.getOpenFieldValueSize(type, i);
+        pointable.set(recPointable.getByteArray(), offset, len);
+        return getAsAdmNode(pointable);
+    }
+
+    public static AdmArrayNode getAsAdmNode(AListPointable listPointable) throws IOException {
+        int count = listPointable.getItemCount();
+        AdmArrayNode node = new AdmArrayNode(count);
+        for (int i = 0; i < count; i++) {
+            byte tagByte = listPointable.getItemTag(AOrderedListType.FULL_OPEN_ORDEREDLIST_TYPE, i);
+            ATypeTag itemTag = ATypeTag.VALUE_TYPE_MAPPING[tagByte];
+            switch (itemTag) {
+                case ARRAY:
+                    node.add(getOpenFieldAsArray(listPointable, i));
+                    break;
+                case BIGINT:
+                    node.add(new AdmBigIntNode(LongPointable.getLong(listPointable.getByteArray(),
+                            listPointable.getItemOffset(AOrderedListType.FULL_OPEN_ORDEREDLIST_TYPE, i) + 1)));
+                    break;
+                case BOOLEAN:
+                    node.add(AdmBooleanNode.get(BooleanPointable.getBoolean(listPointable.getByteArray(),
+                            listPointable.getItemOffset(AOrderedListType.FULL_OPEN_ORDEREDLIST_TYPE, i) + 1)));
+                    break;
+                case DOUBLE:
+                    node.add(new AdmDoubleNode(DoublePointable.getDouble(listPointable.getByteArray(),
+                            listPointable.getItemOffset(AOrderedListType.FULL_OPEN_ORDEREDLIST_TYPE, i) + 1)));
+                    break;
+                case NULL:
+                    node.add(AdmNullNode.INSTANCE);
+                    break;
+                case OBJECT:
+                    node.add(getOpenFieldAsObject(listPointable, i));
+                    break;
+                case STRING:
+                    UTF8StringPointable str = UTF8StringPointable.FACTORY.createPointable();
+                    str.set(listPointable.getByteArray(),
+                            listPointable.getItemOffset(AOrderedListType.FULL_OPEN_ORDEREDLIST_TYPE, i) + 1,
+                            listPointable.getItemSize(AOrderedListType.FULL_OPEN_ORDEREDLIST_TYPE, i));
+                    node.add(new AdmStringNode(str.toString()));
+                    break;
+                default:
+                    throw new UnsupportedOperationException("Unsupported item type: " + itemTag);
+            }
+        }
+        return node;
+    }
+
+    private static IAdmNode getOpenFieldAsObject(AListPointable listPointable, int i) throws IOException {
+        ARecordPointable pointable = ARecordPointable.FACTORY.createPointable();
+        int offset = listPointable.getItemOffset(AOrderedListType.FULL_OPEN_ORDEREDLIST_TYPE, i);
+        int len = listPointable.getItemSize(AOrderedListType.FULL_OPEN_ORDEREDLIST_TYPE, i);
+        pointable.set(listPointable.getByteArray(), offset, len);
+        return new AdmObjectNode(AdmNodeUtils.getOpenFields(pointable, RecordUtil.FULLY_OPEN_RECORD_TYPE));
+    }
+
+    private static AdmArrayNode getOpenFieldAsArray(AListPointable listPointable, int i) throws IOException {
+        AListPointable pointable = AListPointable.FACTORY.createPointable();
+        int offset = listPointable.getItemOffset(AOrderedListType.FULL_OPEN_ORDEREDLIST_TYPE, i);
+        int len = listPointable.getItemSize(AOrderedListType.FULL_OPEN_ORDEREDLIST_TYPE, i);
+        pointable.set(listPointable.getByteArray(), offset, len);
+        return getAsAdmNode(pointable);
+    }
+}
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/api/AbstractPointable.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/api/AbstractPointable.java
index 05417a8..2e21048 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/api/AbstractPointable.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/api/AbstractPointable.java
@@ -19,6 +19,7 @@
 package org.apache.hyracks.data.std.api;
 
 public abstract class AbstractPointable implements IPointable {
+
     protected byte[] bytes;
 
     protected int start;
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/api/IPointableFactory.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/api/IPointableFactory.java
index 5294d17..aee3047 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/api/IPointableFactory.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/api/IPointableFactory.java
@@ -23,7 +23,7 @@
 import org.apache.hyracks.api.dataflow.value.ITypeTraits;
 
 public interface IPointableFactory extends Serializable {
-    public IPointable createPointable();
+    IPointable createPointable();
 
-    public ITypeTraits getTypeTraits();
+    ITypeTraits getTypeTraits();
 }
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/BooleanPointable.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/BooleanPointable.java
index bd18ea0..ea6086d 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/BooleanPointable.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/BooleanPointable.java
@@ -26,7 +26,6 @@
 import org.apache.hyracks.data.std.api.IPointableFactory;
 
 public final class BooleanPointable extends AbstractPointable implements IHashable, IComparable {
-
     public static final BooleanPointableFactory FACTORY = new BooleanPointableFactory();
 
     public static final ITypeTraits TYPE_TRAITS = new ITypeTraits() {
@@ -47,11 +46,11 @@
         private static final long serialVersionUID = 1L;
 
         @Override
-        public IPointable createPointable() {
+        public BooleanPointable createPointable() {
             return new BooleanPointable();
         }
 
-        public IPointable createPointable(boolean value) {
+        public BooleanPointable createPointable(boolean value) {
             BooleanPointable pointable = new BooleanPointable();
             pointable.setBoolean(value);
             return pointable;
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/BytePointable.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/BytePointable.java
index 5b623e7..9e81083 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/BytePointable.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/BytePointable.java
@@ -27,6 +27,7 @@
 import org.apache.hyracks.data.std.api.IPointableFactory;
 
 public final class BytePointable extends AbstractPointable implements IHashable, IComparable, INumeric {
+
     public static final ITypeTraits TYPE_TRAITS = new ITypeTraits() {
         private static final long serialVersionUID = 1L;
 
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/DoublePointable.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/DoublePointable.java
index 3464a9f..16294b3 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/DoublePointable.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/DoublePointable.java
@@ -27,14 +27,15 @@
 import org.apache.hyracks.data.std.api.IPointableFactory;
 
 public final class DoublePointable extends AbstractPointable implements IHashable, IComparable, INumeric {
-    private final static double machineEpsilon;
-    static {
-        float epsilon = 1.0f;
 
+    private static final double MACHINE_EPSILON = getMachineEpsilon();
+
+    private static double getMachineEpsilon() {
+        float epsilon = 1.0f;
         do {
             epsilon /= 2.0f;
         } while ((float) (1.0 + (epsilon / 2.0)) != 1.0);
-        machineEpsilon = epsilon;
+        return epsilon;
     }
 
     public static final ITypeTraits TYPE_TRAITS = new ITypeTraits() {
@@ -150,6 +151,6 @@
     }
 
     public static double getEpsilon() {
-        return machineEpsilon;
+        return MACHINE_EPSILON;
     }
 }
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/FloatPointable.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/FloatPointable.java
index b0f686f..4cb298f 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/FloatPointable.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/FloatPointable.java
@@ -27,6 +27,7 @@
 import org.apache.hyracks.data.std.api.IPointableFactory;
 
 public final class FloatPointable extends AbstractPointable implements IHashable, IComparable, INumeric {
+
     public static final ITypeTraits TYPE_TRAITS = new ITypeTraits() {
         private static final long serialVersionUID = 1L;
 
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/IntegerPointable.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/IntegerPointable.java
index a3b9f44..03aaa97 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/IntegerPointable.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/IntegerPointable.java
@@ -27,6 +27,7 @@
 import org.apache.hyracks.data.std.api.IPointableFactory;
 
 public final class IntegerPointable extends AbstractPointable implements IHashable, IComparable, INumeric {
+
     public static final ITypeTraits TYPE_TRAITS = new ITypeTraits() {
         private static final long serialVersionUID = 1L;
 
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/RawUTF8StringPointable.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/RawUTF8StringPointable.java
index 70bac4d..f75db9d 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/RawUTF8StringPointable.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/RawUTF8StringPointable.java
@@ -32,6 +32,7 @@
  * But it works for single-byte character languages.
  */
 public final class RawUTF8StringPointable extends AbstractPointable implements IHashable, IComparable {
+
     public static final ITypeTraits TYPE_TRAITS = new ITypeTraits() {
         private static final long serialVersionUID = 1L;
 
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/ShortPointable.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/ShortPointable.java
index 70ad44c..55e6201 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/ShortPointable.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/ShortPointable.java
@@ -27,6 +27,7 @@
 import org.apache.hyracks.data.std.api.IPointableFactory;
 
 public final class ShortPointable extends AbstractPointable implements IHashable, IComparable, INumeric {
+
     public static final ITypeTraits TYPE_TRAITS = new ITypeTraits() {
         private static final long serialVersionUID = 1L;
 
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/TaggedValuePointable.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/TaggedValuePointable.java
index 7acd32c..dcb1e75 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/TaggedValuePointable.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/TaggedValuePointable.java
@@ -20,23 +20,9 @@
 import org.apache.hyracks.data.std.api.AbstractPointable;
 import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.api.IPointableFactory;
-import org.apache.hyracks.data.std.primitive.BytePointable;
-import org.apache.hyracks.data.std.primitive.VoidPointable;
 
 public class TaggedValuePointable extends AbstractPointable {
-    public static final IPointableFactory FACTORY = new IPointableFactory() {
-        private static final long serialVersionUID = 1L;
-
-        @Override
-        public ITypeTraits getTypeTraits() {
-            return VoidPointable.TYPE_TRAITS;
-        }
-
-        @Override
-        public IPointable createPointable() {
-            return new TaggedValuePointable();
-        }
-    };
+    public static final TaggedValuePointableFactory FACTORY = new TaggedValuePointableFactory();
 
     public byte getTag() {
         return BytePointable.getByte(bytes, start);
@@ -45,4 +31,22 @@
     public void getValue(IPointable value) {
         value.set(bytes, start + 1, length - 1);
     }
+
+    public static final class TaggedValuePointableFactory implements IPointableFactory {
+        private static final long serialVersionUID = 1L;
+
+        private TaggedValuePointableFactory() {
+        }
+
+        @Override
+        public ITypeTraits getTypeTraits() {
+            return VoidPointable.TYPE_TRAITS;
+        }
+
+        @Override
+        public TaggedValuePointable createPointable() {
+            return new TaggedValuePointable();
+        }
+
+    }
 }
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringLowercasePointable.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringLowercasePointable.java
index 6e4810c..57d704f 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringLowercasePointable.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringLowercasePointable.java
@@ -27,6 +27,7 @@
 import org.apache.hyracks.util.string.UTF8StringUtil;
 
 public final class UTF8StringLowercasePointable extends AbstractPointable implements IHashable, IComparable {
+
     public static final ITypeTraits TYPE_TRAITS = new ITypeTraits() {
         private static final long serialVersionUID = 1L;
 
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringLowercaseTokenPointable.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringLowercaseTokenPointable.java
index 66c1ab9..01af13e 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringLowercaseTokenPointable.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringLowercaseTokenPointable.java
@@ -29,6 +29,7 @@
  * Instead, the length of this string is provided as a parameter.
  */
 public final class UTF8StringLowercaseTokenPointable extends AbstractPointable implements IHashable, IComparable {
+
     public static final ITypeTraits TYPE_TRAITS = new ITypeTraits() {
         private static final long serialVersionUID = 1L;
 
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringPointable.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringPointable.java
index 376307d..518e688 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringPointable.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringPointable.java
@@ -70,11 +70,16 @@
         }
     };
 
-    public static final IPointableFactory FACTORY = new IPointableFactory() {
+    public static final UTF8StringPointableFactory FACTORY = new UTF8StringPointableFactory();
+
+    public static class UTF8StringPointableFactory implements IPointableFactory {
         private static final long serialVersionUID = 1L;
 
+        private UTF8StringPointableFactory() {
+        }
+
         @Override
-        public IPointable createPointable() {
+        public UTF8StringPointable createPointable() {
             return new UTF8StringPointable();
         }
 
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ExitUtil.java b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ExitUtil.java
index 8500842..5492919 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ExitUtil.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ExitUtil.java
@@ -35,6 +35,9 @@
     public static final int EC_FAILED_TO_RECOVER = 3;
     public static final int EC_NC_FAILED_TO_ABORT_ALL_PREVIOUS_TASKS = 4;
     public static final int EC_FAILED_TO_PROCESS_UN_INTERRUPTIBLE_REQUEST = 5;
+    public static final int EC_FAILED_TO_COMMIT_METADATA_TXN = 6;
+    public static final int EC_FAILED_TO_ABORT_METADATA_TXN = 7;
+    public static final int EC_INCONSISTENT_METADATA = 8;
     public static final int EC_UNHANDLED_EXCEPTION = 11;
     public static final int EC_IMMEDIATE_HALT = 33;
     public static final int EC_HALT_ABNORMAL_RESERVED_44 = 44;
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/NetworkUtil.java b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/NetworkUtil.java
index 1863b28..e6e21fa 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/NetworkUtil.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/NetworkUtil.java
@@ -88,7 +88,7 @@
     }
 
     public static InetSocketAddress toInetSocketAddress(String maybeLiteralHost, int port) {
-        return InetSocketAddress.createUnresolved(decodeIPv6LiteralHost(maybeLiteralHost), port);
+        return new InetSocketAddress(decodeIPv6LiteralHost(maybeLiteralHost), port);
     }
 
     public static List<InetSocketAddress> parseInetSocketAddresses(String... hostPortStrings) {
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringUtil.java b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringUtil.java
index cdb82bb..5597058 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringUtil.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringUtil.java
@@ -294,6 +294,11 @@
         return hash(bytes, start, length, true, false, 31, Integer.MAX_VALUE);
     }
 
+    public static String toString(byte[] bytes, int start) {
+        StringBuilder builder = new StringBuilder();
+        return toString(builder, bytes, start).toString();
+    }
+
     public static StringBuilder toString(StringBuilder builder, byte[] bytes, int start) {
         int utfLen = getUTFLength(bytes, start);
         int offset = getNumBytesToStoreLength(utfLen);
@@ -650,10 +655,10 @@
         if (writer == null) {
             tempBytes = new byte[utflen + 5];
         } else {
-            if (writer.tempBytes == null || writer.tempBytes.length < utflen + 5) {
-                writer.tempBytes = new byte[utflen + 5];
+            if (writer.getTempBytes() == null || writer.getTempBytes().length < utflen + 5) {
+                writer.setTempBytes(new byte[utflen + 5]);
             }
-            tempBytes = writer.tempBytes;
+            tempBytes = writer.getTempBytes();
         }
         return tempBytes;
     }
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringWriter.java b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringWriter.java
index 485bd7d..3d9a7c5 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringWriter.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringWriter.java
@@ -20,9 +20,12 @@
 
 import java.io.DataOutput;
 import java.io.IOException;
+import java.io.Serializable;
 
-public class UTF8StringWriter {
-    byte[] tempBytes;
+public class UTF8StringWriter implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+    private byte[] tempBytes;
 
     public final void writeUTF8(CharSequence str, DataOutput out) throws IOException {
         UTF8StringUtil.writeUTF8(str, out, this);
@@ -32,4 +35,12 @@
         UTF8StringUtil.writeUTF8(buffer, start, length, out, this);
     }
 
+    public byte[] getTempBytes() {
+        return tempBytes;
+    }
+
+    public void setTempBytes(byte[] tempBytes) {
+        this.tempBytes = tempBytes;
+    }
+
 }