diff --git a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/dataset/adapter/HDFSAdapter.java b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/dataset/adapter/HDFSAdapter.java
index f7a79cd..744683c 100644
--- a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/dataset/adapter/HDFSAdapter.java
+++ b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/dataset/adapter/HDFSAdapter.java
@@ -40,7 +40,7 @@
 import org.apache.hadoop.mapred.TextInputFormat;
 
 import edu.uci.ics.asterix.om.types.IAType;
-import edu.uci.ics.asterix.runtime.util.AsterixRuntimeUtil;
+import edu.uci.ics.asterix.om.util.AsterixRuntimeUtil;
 import edu.uci.ics.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint;
 import edu.uci.ics.hyracks.algebricks.common.constraints.AlgebricksCountPartitionConstraint;
 import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CastRecordDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CastRecordDescriptor.java
index 4c0a201..8bb4d49 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CastRecordDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CastRecordDescriptor.java
@@ -5,12 +5,12 @@
 import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+import edu.uci.ics.asterix.om.pointables.PointableAllocator;
+import edu.uci.ics.asterix.om.pointables.base.IVisitablePointable;
+import edu.uci.ics.asterix.om.pointables.cast.ACastVisitor;
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.asterix.om.types.IAType;
 import edu.uci.ics.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import edu.uci.ics.asterix.runtime.pointables.PointableAllocator;
-import edu.uci.ics.asterix.runtime.pointables.base.IVisitablePointable;
-import edu.uci.ics.asterix.runtime.pointables.cast.ACastVisitor;
 import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
 import edu.uci.ics.hyracks.algebricks.common.utils.Triple;
 import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/AFlatValuePointable.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/AFlatValuePointable.java
deleted file mode 100644
index a3547a4..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/AFlatValuePointable.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2009-2010 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.pointables;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-import edu.uci.ics.asterix.om.types.IAType;
-import edu.uci.ics.asterix.runtime.pointables.base.IVisitablePointable;
-import edu.uci.ics.asterix.runtime.pointables.visitor.IVisitablePointableVisitor;
-import edu.uci.ics.asterix.runtime.util.container.IObjectFactory;
-import edu.uci.ics.hyracks.data.std.api.IValueReference;
-
-/**
- * This class represents a flat field, e.g., int field, string field, and
- * so on, based on a binary representation.
- */
-public class AFlatValuePointable extends AbstractVisitablePointable {
-
-    /**
-     * DO NOT allow to create AFlatValuePointable object arbitrarily, force to
-     * use object pool based allocator. The factory is not public so that it
-     * cannot called in other places than PointableAllocator.
-     */
-    static IObjectFactory<IVisitablePointable, IAType> FACTORY = new IObjectFactory<IVisitablePointable, IAType>() {
-        public AFlatValuePointable create(IAType type) {
-            return new AFlatValuePointable();
-        }
-    };
-
-    /**
-     * private constructor, to prevent arbitrary creation
-     */
-    private AFlatValuePointable() {
-
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (!(o instanceof IValueReference))
-            return false;
-
-        // get right raw data
-        IValueReference ivf = (IValueReference) o;
-        byte[] odata = ivf.getByteArray();
-        int ostart = ivf.getStartOffset();
-        int olen = ivf.getLength();
-
-        // get left raw data
-        byte[] data = getByteArray();
-        int start = getStartOffset();
-        int len = getLength();
-
-        // bytes length should be equal
-        if (len != olen)
-            return false;
-
-        // check each byte
-        for (int i = 0; i < len; i++) {
-            if (data[start + i] != odata[ostart + i])
-                return false;
-        }
-        return true;
-    }
-
-    @Override
-    public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws AsterixException {
-        return vistor.visit(this, tag);
-    }
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/AListPointable.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/AListPointable.java
deleted file mode 100644
index 6f85694..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/AListPointable.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright 2009-2010 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.pointables;
-
-import java.io.DataOutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.AbstractCollectionType;
-import edu.uci.ics.asterix.om.types.EnumDeserializer;
-import edu.uci.ics.asterix.om.types.IAType;
-import edu.uci.ics.asterix.om.util.NonTaggedFormatUtil;
-import edu.uci.ics.asterix.runtime.pointables.base.IVisitablePointable;
-import edu.uci.ics.asterix.runtime.pointables.visitor.IVisitablePointableVisitor;
-import edu.uci.ics.asterix.runtime.util.ResettableByteArrayOutputStream;
-import edu.uci.ics.asterix.runtime.util.container.IObjectFactory;
-
-/**
- * This class interprets the binary data representation of a list, one can
- * call getItems and getItemTags to get pointable objects for items and item
- * type tags.
- * 
- */
-public class AListPointable extends AbstractVisitablePointable {
-
-    /**
-     * DO NOT allow to create AListPointable object arbitrarily, force to use
-     * object pool based allocator, in order to have object reuse.
-     */
-    static IObjectFactory<IVisitablePointable, IAType> FACTORY = new IObjectFactory<IVisitablePointable, IAType>() {
-        public IVisitablePointable create(IAType type) {
-            return new AListPointable((AbstractCollectionType) type);
-        }
-    };
-
-    private final List<IVisitablePointable> items = new ArrayList<IVisitablePointable>();
-    private final List<IVisitablePointable> itemTags = new ArrayList<IVisitablePointable>();
-    private final PointableAllocator allocator = new PointableAllocator();
-
-    private final ResettableByteArrayOutputStream dataBos = new ResettableByteArrayOutputStream();
-    private final DataOutputStream dataDos = new DataOutputStream(dataBos);
-
-    private IAType itemType;
-    private ATypeTag itemTag;
-    private boolean typedItemList = false;
-
-    /**
-     * private constructor, to prevent constructing it arbitrarily
-     * 
-     * @param inputType
-     */
-    private AListPointable(AbstractCollectionType inputType) {
-        if (inputType != null && inputType.getItemType() != null) {
-            itemType = inputType.getItemType();
-            if (itemType.getTypeTag() == ATypeTag.ANY) {
-                typedItemList = false;
-            } else {
-                typedItemList = true;
-                itemTag = inputType.getItemType().getTypeTag();
-            }
-        } else {
-            this.typedItemList = false;
-        }
-    }
-
-    private void reset() {
-        allocator.reset();
-        items.clear();
-        itemTags.clear();
-        dataBos.reset();
-    }
-
-    @Override
-    public void set(byte[] b, int s, int len) {
-        reset();
-
-        int numberOfitems = AInt32SerializerDeserializer.getInt(b, s + 6);
-        int itemOffset;
-        if (typedItemList) {
-            switch (itemTag) {
-                case STRING:
-                case RECORD:
-                case ORDEREDLIST:
-                case UNORDEREDLIST:
-                case ANY:
-                    itemOffset = s + 10 + (numberOfitems * 4);
-                    break;
-                default:
-                    itemOffset = s + 10;
-            }
-        } else {
-            itemOffset = s + 10 + (numberOfitems * 4);
-        }
-        int itemLength = 0;
-        try {
-            if (typedItemList) {
-                for (int i = 0; i < numberOfitems; i++) {
-                    itemLength = NonTaggedFormatUtil.getFieldValueLength(b, itemOffset, itemTag, false);
-                    IVisitablePointable tag = allocator.allocateEmpty();
-                    IVisitablePointable item = allocator.allocateFieldValue(itemType);
-
-                    // set item type tag
-                    int start = dataBos.size();
-                    dataDos.writeByte(itemTag.serialize());
-                    int end = dataBos.size();
-                    tag.set(dataBos.getByteArray(), start, end - start);
-                    itemTags.add(tag);
-
-                    // set item value
-                    start = dataBos.size();
-                    dataDos.writeByte(itemTag.serialize());
-                    dataDos.write(b, itemOffset, itemLength);
-                    end = dataBos.size();
-                    item.set(dataBos.getByteArray(), start, end - start);
-                    itemOffset += itemLength;
-                    items.add(item);
-                }
-            } else {
-                for (int i = 0; i < numberOfitems; i++) {
-                    itemTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(b[itemOffset]);
-                    itemLength = NonTaggedFormatUtil.getFieldValueLength(b, itemOffset, itemTag, true) + 1;
-                    IVisitablePointable tag = allocator.allocateEmpty();
-                    IVisitablePointable item = allocator.allocateFieldValue(itemType);
-
-                    // set item type tag
-                    int start = dataBos.size();
-                    dataDos.writeByte(itemTag.serialize());
-                    int end = dataBos.size();
-                    tag.set(dataBos.getByteArray(), start, end - start);
-                    itemTags.add(tag);
-
-                    // open part field already include the type tag
-                    item.set(b, itemOffset, itemLength);
-                    itemOffset += itemLength;
-                    items.add(item);
-                }
-            }
-        } catch (Exception e) {
-            throw new IllegalStateException(e);
-        }
-    }
-
-    @Override
-    public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws AsterixException {
-        return vistor.visit(this, tag);
-    }
-
-    public List<IVisitablePointable> getItems() {
-        return items;
-    }
-
-    public List<IVisitablePointable> getItemTags() {
-        return itemTags;
-    }
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/ARecordPointable.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/ARecordPointable.java
deleted file mode 100644
index 5904170..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/ARecordPointable.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Copyright 2009-2010 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.pointables;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-import edu.uci.ics.asterix.dataflow.data.nontagged.AqlNullWriterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import edu.uci.ics.asterix.om.types.ARecordType;
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.AUnionType;
-import edu.uci.ics.asterix.om.types.EnumDeserializer;
-import edu.uci.ics.asterix.om.types.IAType;
-import edu.uci.ics.asterix.om.util.NonTaggedFormatUtil;
-import edu.uci.ics.asterix.runtime.pointables.base.IVisitablePointable;
-import edu.uci.ics.asterix.runtime.pointables.visitor.IVisitablePointableVisitor;
-import edu.uci.ics.asterix.runtime.util.ResettableByteArrayOutputStream;
-import edu.uci.ics.asterix.runtime.util.container.IObjectFactory;
-import edu.uci.ics.hyracks.api.dataflow.value.INullWriter;
-
-/**
- * This class interprets the binary data representation of a record. One can
- * call getFieldNames, getFieldTypeTags and getFieldValues to get pointable
- * objects for field names, field type tags, and field values.
- * 
- */
-public class ARecordPointable extends AbstractVisitablePointable {
-
-    /**
-     * DO NOT allow to create ARecordPointable object arbitrarily, force to use
-     * object pool based allocator, in order to have object reuse
-     */
-    static IObjectFactory<IVisitablePointable, IAType> FACTORY = new IObjectFactory<IVisitablePointable, IAType>() {
-        public IVisitablePointable create(IAType type) {
-            return new ARecordPointable((ARecordType) type);
-        }
-    };
-
-    // access results: field names, field types, and field values
-    private final List<IVisitablePointable> fieldNames = new ArrayList<IVisitablePointable>();
-    private final List<IVisitablePointable> fieldTypeTags = new ArrayList<IVisitablePointable>();
-    private final List<IVisitablePointable> fieldValues = new ArrayList<IVisitablePointable>();
-
-    // pointable allocator
-    private final PointableAllocator allocator = new PointableAllocator();
-
-    private final ResettableByteArrayOutputStream typeBos = new ResettableByteArrayOutputStream();
-    private final DataOutputStream typeDos = new DataOutputStream(typeBos);
-
-    private final ResettableByteArrayOutputStream dataBos = new ResettableByteArrayOutputStream();
-    private final DataOutputStream dataDos = new DataOutputStream(dataBos);
-
-    private final ARecordType inputRecType;
-
-    private final int numberOfSchemaFields;
-    private final int[] fieldOffsets;
-    private final IVisitablePointable nullReference = AFlatValuePointable.FACTORY.create(null);
-
-    private int closedPartTypeInfoSize = 0;
-    private int offsetArrayOffset;
-    private ATypeTag typeTag;
-
-    /**
-     * private constructor, to prevent constructing it arbitrarily
-     * 
-     * @param inputType
-     */
-    private ARecordPointable(ARecordType inputType) {
-        this.inputRecType = inputType;
-        IAType[] fieldTypes = inputType.getFieldTypes();
-        String[] fieldNameStrs = inputType.getFieldNames();
-        numberOfSchemaFields = fieldTypes.length;
-
-        // initialize the buffer for closed parts(fieldName bytes+ type bytes) +
-        // constant(null bytes)
-        typeBos.reset();
-        try {
-            for (int i = 0; i < numberOfSchemaFields; i++) {
-                ATypeTag ftypeTag = fieldTypes[i].getTypeTag();
-
-                if (fieldTypes[i].getTypeTag() == ATypeTag.UNION
-                        && NonTaggedFormatUtil.isOptionalField((AUnionType) fieldTypes[i]))
-                    // optional field: add the embedded non-null type tag
-                    ftypeTag = ((AUnionType) fieldTypes[i]).getUnionList()
-                            .get(NonTaggedFormatUtil.OPTIONAL_TYPE_INDEX_IN_UNION_LIST).getTypeTag();
-
-                // add type tag Reference
-                int tagStart = typeBos.size();
-                typeDos.writeByte(ftypeTag.serialize());
-                int tagEnd = typeBos.size();
-                IVisitablePointable typeTagReference = AFlatValuePointable.FACTORY.create(null);
-                typeTagReference.set(typeBos.getByteArray(), tagStart, tagEnd - tagStart);
-                fieldTypeTags.add(typeTagReference);
-
-                // add type name Reference (including a astring type tag)
-                int nameStart = typeBos.size();
-                typeDos.writeByte(ATypeTag.STRING.serialize());
-                typeDos.writeUTF(fieldNameStrs[i]);
-                int nameEnd = typeBos.size();
-                IVisitablePointable typeNameReference = AFlatValuePointable.FACTORY.create(null);
-                typeNameReference.set(typeBos.getByteArray(), nameStart, nameEnd - nameStart);
-                fieldNames.add(typeNameReference);
-            }
-
-            // initialize a constant: null value bytes reference
-            int nullFieldStart = typeBos.size();
-            INullWriter nullWriter = AqlNullWriterFactory.INSTANCE.createNullWriter();
-            nullWriter.writeNull(typeDos);
-            int nullFieldEnd = typeBos.size();
-            nullReference.set(typeBos.getByteArray(), nullFieldStart, nullFieldEnd - nullFieldStart);
-        } catch (IOException e) {
-            throw new IllegalStateException(e);
-        }
-        closedPartTypeInfoSize = typeBos.size();
-        fieldOffsets = new int[numberOfSchemaFields];
-    }
-
-    private void reset() {
-        typeBos.reset(closedPartTypeInfoSize);
-        dataBos.reset(0);
-        // reset the allocator
-        allocator.reset();
-
-        // clean up the returned containers
-        for (int i = fieldNames.size() - 1; i >= numberOfSchemaFields; i--)
-            fieldNames.remove(i);
-        for (int i = fieldTypeTags.size() - 1; i >= numberOfSchemaFields; i--)
-            fieldTypeTags.remove(i);
-        fieldValues.clear();
-    }
-
-    @Override
-    public void set(byte[] b, int start, int len) {
-        // clear the previous states
-        reset();
-        super.set(b, start, len);
-
-        boolean isExpanded = false;
-        int openPartOffset = 0;
-        int s = start;
-        int recordOffset = s;
-        if (inputRecType == null) {
-            openPartOffset = s + AInt32SerializerDeserializer.getInt(b, s + 6);
-            s += 8;
-            isExpanded = true;
-        } else {
-            if (inputRecType.isOpen()) {
-                isExpanded = b[s + 5] == 1 ? true : false;
-                if (isExpanded) {
-                    openPartOffset = s + AInt32SerializerDeserializer.getInt(b, s + 6);
-                    s += 10;
-                } else {
-                    s += 6;
-                }
-            } else {
-                s += 5;
-            }
-        }
-        try {
-            if (numberOfSchemaFields > 0) {
-                s += 4;
-                int nullBitMapOffset = 0;
-                boolean hasNullableFields = NonTaggedFormatUtil.hasNullableField(inputRecType);
-                if (hasNullableFields) {
-                    nullBitMapOffset = s;
-                    offsetArrayOffset = s
-                            + (this.numberOfSchemaFields % 8 == 0 ? numberOfSchemaFields / 8
-                                    : numberOfSchemaFields / 8 + 1);
-                } else {
-                    offsetArrayOffset = s;
-                }
-                for (int i = 0; i < numberOfSchemaFields; i++) {
-                    fieldOffsets[i] = AInt32SerializerDeserializer.getInt(b, offsetArrayOffset) + recordOffset;
-                    offsetArrayOffset += 4;
-                }
-                for (int fieldNumber = 0; fieldNumber < numberOfSchemaFields; fieldNumber++) {
-                    if (hasNullableFields) {
-                        byte b1 = b[nullBitMapOffset + fieldNumber / 8];
-                        int p = 1 << (7 - (fieldNumber % 8));
-                        if ((b1 & p) == 0) {
-                            // set null value (including type tag inside)
-                            fieldValues.add(nullReference);
-                            continue;
-                        }
-                    }
-                    IAType[] fieldTypes = inputRecType.getFieldTypes();
-                    int fieldValueLength = 0;
-
-                    IAType fieldType = fieldTypes[fieldNumber];
-                    if (fieldTypes[fieldNumber].getTypeTag() == ATypeTag.UNION) {
-                        if (NonTaggedFormatUtil.isOptionalField((AUnionType) fieldTypes[fieldNumber])) {
-                            fieldType = ((AUnionType) fieldTypes[fieldNumber]).getUnionList().get(
-                                    NonTaggedFormatUtil.OPTIONAL_TYPE_INDEX_IN_UNION_LIST);
-                            typeTag = fieldType.getTypeTag();
-                            fieldValueLength = NonTaggedFormatUtil.getFieldValueLength(b, fieldOffsets[fieldNumber],
-                                    typeTag, false);
-                        }
-                    } else {
-                        typeTag = fieldTypes[fieldNumber].getTypeTag();
-                        fieldValueLength = NonTaggedFormatUtil.getFieldValueLength(b, fieldOffsets[fieldNumber],
-                                typeTag, false);
-                    }
-                    // set field value (including the type tag)
-                    int fstart = dataBos.size();
-                    dataDos.writeByte(typeTag.serialize());
-                    dataDos.write(b, fieldOffsets[fieldNumber], fieldValueLength);
-                    int fend = dataBos.size();
-                    IVisitablePointable fieldValue = allocator.allocateFieldValue(fieldType);
-                    fieldValue.set(dataBos.getByteArray(), fstart, fend - fstart);
-                    fieldValues.add(fieldValue);
-                }
-            }
-            if (isExpanded) {
-                int numberOfOpenFields = AInt32SerializerDeserializer.getInt(b, openPartOffset);
-                int fieldOffset = openPartOffset + 4 + (8 * numberOfOpenFields);
-                for (int i = 0; i < numberOfOpenFields; i++) {
-                    // set the field name (including a type tag, which is
-                    // astring)
-                    int fieldValueLength = NonTaggedFormatUtil.getFieldValueLength(b, fieldOffset, ATypeTag.STRING,
-                            false);
-                    int fnstart = dataBos.size();
-                    dataDos.writeByte(ATypeTag.STRING.serialize());
-                    dataDos.write(b, fieldOffset, fieldValueLength);
-                    int fnend = dataBos.size();
-                    IVisitablePointable fieldName = allocator.allocateEmpty();
-                    fieldName.set(dataBos.getByteArray(), fnstart, fnend - fnstart);
-                    fieldNames.add(fieldName);
-                    fieldOffset += fieldValueLength;
-
-                    // set the field type tag
-                    IVisitablePointable fieldTypeTag = allocator.allocateEmpty();
-                    fieldTypeTag.set(b, fieldOffset, 1);
-                    fieldTypeTags.add(fieldTypeTag);
-                    typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(b[fieldOffset]);
-
-                    // set the field value (already including type tag)
-                    fieldValueLength = NonTaggedFormatUtil.getFieldValueLength(b, fieldOffset, typeTag, true) + 1;
-
-                    // allocate
-                    IVisitablePointable fieldValueAccessor = allocator.allocateFieldValue(typeTag);
-                    fieldValueAccessor.set(b, fieldOffset, fieldValueLength);
-                    fieldValues.add(fieldValueAccessor);
-                    fieldOffset += fieldValueLength;
-                }
-            }
-        } catch (Exception e) {
-            throw new IllegalStateException(e);
-        }
-    }
-
-    public List<IVisitablePointable> getFieldNames() {
-        return fieldNames;
-    }
-
-    public List<IVisitablePointable> getFieldTypeTags() {
-        return fieldTypeTags;
-    }
-
-    public List<IVisitablePointable> getFieldValues() {
-        return fieldValues;
-    }
-
-    @Override
-    public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws AsterixException {
-        return vistor.visit(this, tag);
-    }
-
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/AbstractVisitablePointable.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/AbstractVisitablePointable.java
deleted file mode 100644
index 8cfe661..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/AbstractVisitablePointable.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2009-2010 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.pointables;
-
-import edu.uci.ics.asterix.runtime.pointables.base.IVisitablePointable;
-import edu.uci.ics.hyracks.data.std.api.IValueReference;
-
-/**
- * This class implements several "routine" methods in IVisitablePointable
- * interface, so that subclasses do not need to repeat the same code.
- * 
- */
-public abstract class AbstractVisitablePointable implements IVisitablePointable {
-
-    private byte[] data;
-    private int start;
-    private int len;
-
-    @Override
-    public byte[] getByteArray() {
-        return data;
-    }
-
-    @Override
-    public int getLength() {
-        return len;
-    }
-
-    @Override
-    public int getStartOffset() {
-        return start;
-    }
-
-    @Override
-    public void set(byte[] b, int start, int len) {
-        this.data = b;
-        this.start = start;
-        this.len = len;
-    }
-
-    @Override
-    public void set(IValueReference ivf) {
-        set(ivf.getByteArray(), ivf.getStartOffset(), ivf.getLength());
-    }
-
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/PointableAllocator.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/PointableAllocator.java
deleted file mode 100644
index b6116be..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/PointableAllocator.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2009-2010 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.pointables;
-
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.IAType;
-import edu.uci.ics.asterix.runtime.pointables.base.DefaultOpenFieldType;
-import edu.uci.ics.asterix.runtime.pointables.base.IVisitablePointable;
-import edu.uci.ics.asterix.runtime.util.container.IObjectPool;
-import edu.uci.ics.asterix.runtime.util.container.ListObjectPool;
-
-/**
- * This class is the ONLY place to create IVisitablePointable object instances,
- * to enforce use of an object pool.
- */
-public class PointableAllocator {
-
-    private IObjectPool<IVisitablePointable, IAType> flatValueAllocator = new ListObjectPool<IVisitablePointable, IAType>(
-            AFlatValuePointable.FACTORY);
-    private IObjectPool<IVisitablePointable, IAType> recordValueAllocator = new ListObjectPool<IVisitablePointable, IAType>(
-            ARecordPointable.FACTORY);
-    private IObjectPool<IVisitablePointable, IAType> listValueAllocator = new ListObjectPool<IVisitablePointable, IAType>(
-            AListPointable.FACTORY);
-
-    public IVisitablePointable allocateEmpty() {
-        return flatValueAllocator.allocate(null);
-    }
-
-    /**
-     * allocate closed part value pointable
-     * 
-     * @param type
-     * @return the pointable object
-     */
-    public IVisitablePointable allocateFieldValue(IAType type) {
-        if (type == null)
-            return flatValueAllocator.allocate(null);
-        else if (type.getTypeTag().equals(ATypeTag.RECORD))
-            return recordValueAllocator.allocate(type);
-        else if (type.getTypeTag().equals(ATypeTag.UNORDEREDLIST) || type.getTypeTag().equals(ATypeTag.ORDEREDLIST))
-            return listValueAllocator.allocate(type);
-        else
-            return flatValueAllocator.allocate(null);
-    }
-
-    /**
-     * allocate open part value pointable
-     * 
-     * @param typeTag
-     * @return the pointable object
-     */
-    public IVisitablePointable allocateFieldValue(ATypeTag typeTag) {
-        if (typeTag == null)
-            return flatValueAllocator.allocate(null);
-        else if (typeTag.equals(ATypeTag.RECORD))
-            return recordValueAllocator.allocate(DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE);
-        else if (typeTag.equals(ATypeTag.UNORDEREDLIST))
-            return listValueAllocator.allocate(DefaultOpenFieldType.NESTED_OPEN_AUNORDERED_LIST_TYPE);
-        else if (typeTag.equals(ATypeTag.ORDEREDLIST))
-            return listValueAllocator.allocate(DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE);
-        else
-            return flatValueAllocator.allocate(null);
-    }
-
-    public IVisitablePointable allocateListValue(IAType type) {
-        return listValueAllocator.allocate(type);
-    }
-
-    public IVisitablePointable allocateRecordValue(IAType type) {
-        return recordValueAllocator.allocate(type);
-    }
-
-    public void reset() {
-        flatValueAllocator.reset();
-        recordValueAllocator.reset();
-        listValueAllocator.reset();
-    }
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/base/DefaultOpenFieldType.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/base/DefaultOpenFieldType.java
deleted file mode 100644
index 987ac02..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/base/DefaultOpenFieldType.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2009-2010 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.pointables.base;
-
-import edu.uci.ics.asterix.om.types.AOrderedListType;
-import edu.uci.ics.asterix.om.types.ARecordType;
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.AUnorderedListType;
-import edu.uci.ics.asterix.om.types.BuiltinType;
-import edu.uci.ics.asterix.om.types.IAType;
-
-/**
- * This class serves as the repository for the default record type and list type
- * fields in the open part, e.g., a "record" (nested) field in the open part is
- * always a fully open one, and a "list" field in the open part is always a list
- * of "ANY".
- * 
- */
-public class DefaultOpenFieldType {
-
-    // nested open field rec type
-    public static ARecordType NESTED_OPEN_RECORD_TYPE = new ARecordType("nested-open", new String[] {},
-            new IAType[] {}, true);
-
-    // nested open list type
-    public static AOrderedListType NESTED_OPEN_AORDERED_LIST_TYPE = new AOrderedListType(BuiltinType.ANY,
-            "nested-ordered-list");
-
-    // nested open list type
-    public static AUnorderedListType NESTED_OPEN_AUNORDERED_LIST_TYPE = new AUnorderedListType(BuiltinType.ANY,
-            "nested-unordered-list");
-
-    public static IAType getDefaultOpenFieldType(ATypeTag tag) {
-        if (tag.equals(ATypeTag.RECORD))
-            return NESTED_OPEN_RECORD_TYPE;
-        if (tag.equals(ATypeTag.ORDEREDLIST))
-            return NESTED_OPEN_AORDERED_LIST_TYPE;
-        if (tag.equals(ATypeTag.UNORDEREDLIST))
-            return NESTED_OPEN_AUNORDERED_LIST_TYPE;
-        else
-            return null;
-    }
-
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/base/IVisitablePointable.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/base/IVisitablePointable.java
deleted file mode 100644
index 28c61c2..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/base/IVisitablePointable.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2009-2010 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.pointables.base;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-import edu.uci.ics.asterix.runtime.pointables.visitor.IVisitablePointableVisitor;
-import edu.uci.ics.hyracks.data.std.api.IPointable;
-
-/**
- * This interface extends IPointable with a visitor interface in order to ease
- * programming for recursive record structures.
- */
-public interface IVisitablePointable extends IPointable {
-
-    public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws AsterixException;
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/cast/ACastVisitor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/cast/ACastVisitor.java
deleted file mode 100644
index 822e37c..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/cast/ACastVisitor.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2009-2010 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.pointables.cast;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-import edu.uci.ics.asterix.om.types.ARecordType;
-import edu.uci.ics.asterix.om.types.AbstractCollectionType;
-import edu.uci.ics.asterix.om.types.IAType;
-import edu.uci.ics.asterix.runtime.pointables.AFlatValuePointable;
-import edu.uci.ics.asterix.runtime.pointables.AListPointable;
-import edu.uci.ics.asterix.runtime.pointables.ARecordPointable;
-import edu.uci.ics.asterix.runtime.pointables.base.IVisitablePointable;
-import edu.uci.ics.asterix.runtime.pointables.visitor.IVisitablePointableVisitor;
-import edu.uci.ics.hyracks.algebricks.common.utils.Triple;
-
-/**
- * This class is a IVisitablePointableVisitor implementation which recursively
- * visit a given record, list or flat value of a given type, and cast it to a
- * specified type. For example:
- * 
- * A record { "hobby": {{"music", "coding"}}, "id": "001", "name":
- * "Person Three"} which confirms to closed type ( id: string, name: string,
- * hobby: {{string}}? ) can be casted to a open type (id: string )
- * 
- * Since the open/closed part of a record has a completely different underlying
- * memory/storage layout, the visitor will change the layout as specified at
- * runtime.
- */
-public class ACastVisitor implements IVisitablePointableVisitor<Void, Triple<IVisitablePointable, IAType, Boolean>> {
-
-    private final Map<IVisitablePointable, ARecordCaster> raccessorToCaster = new HashMap<IVisitablePointable, ARecordCaster>();
-    private final Map<IVisitablePointable, AListCaster> laccessorToCaster = new HashMap<IVisitablePointable, AListCaster>();
-
-    @Override
-    public Void visit(AListPointable accessor, Triple<IVisitablePointable, IAType, Boolean> arg)
-            throws AsterixException {
-        AListCaster caster = laccessorToCaster.get(accessor);
-        if (caster == null) {
-            caster = new AListCaster();
-            laccessorToCaster.put(accessor, caster);
-        }
-        try {
-            caster.castList(accessor, arg.first, (AbstractCollectionType) arg.second, this);
-        } catch (Exception e) {
-            throw new AsterixException(e);
-        }
-        return null;
-    }
-
-    @Override
-    public Void visit(ARecordPointable accessor, Triple<IVisitablePointable, IAType, Boolean> arg)
-            throws AsterixException {
-        ARecordCaster caster = raccessorToCaster.get(accessor);
-        if (caster == null) {
-            caster = new ARecordCaster();
-            raccessorToCaster.put(accessor, caster);
-        }
-        try {
-            caster.castRecord(accessor, arg.first, (ARecordType) arg.second, this);
-        } catch (Exception e) {
-            throw new AsterixException(e);
-        }
-        return null;
-    }
-
-    @Override
-    public Void visit(AFlatValuePointable accessor, Triple<IVisitablePointable, IAType, Boolean> arg) {
-        // set the pointer for result
-        arg.first.set(accessor);
-        return null;
-    }
-
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/cast/AListCaster.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/cast/AListCaster.java
deleted file mode 100644
index e10fb72..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/cast/AListCaster.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2009-2010 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.pointables.cast;
-
-import java.io.DataOutput;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.List;
-
-import edu.uci.ics.asterix.builders.OrderedListBuilder;
-import edu.uci.ics.asterix.builders.UnorderedListBuilder;
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-import edu.uci.ics.asterix.om.types.AOrderedListType;
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.AUnorderedListType;
-import edu.uci.ics.asterix.om.types.AbstractCollectionType;
-import edu.uci.ics.asterix.om.types.EnumDeserializer;
-import edu.uci.ics.asterix.om.types.IAType;
-import edu.uci.ics.asterix.runtime.pointables.AListPointable;
-import edu.uci.ics.asterix.runtime.pointables.PointableAllocator;
-import edu.uci.ics.asterix.runtime.pointables.base.DefaultOpenFieldType;
-import edu.uci.ics.asterix.runtime.pointables.base.IVisitablePointable;
-import edu.uci.ics.asterix.runtime.util.ResettableByteArrayOutputStream;
-import edu.uci.ics.hyracks.algebricks.common.utils.Triple;
-
-/**
- * This class is to do the runtime type cast for a list. It is ONLY visible to
- * ACastVisitor.
- */
-class AListCaster {
-    // pointable allocator
-    private final PointableAllocator allocator = new PointableAllocator();
-
-    // for storing the cast result
-    private final IVisitablePointable itemTempReference = allocator.allocateEmpty();
-    private final Triple<IVisitablePointable, IAType, Boolean> itemVisitorArg = new Triple<IVisitablePointable, IAType, Boolean>(
-            itemTempReference, null, null);
-
-    private final UnorderedListBuilder unOrderedListBuilder = new UnorderedListBuilder();
-    private final OrderedListBuilder orderedListBuilder = new OrderedListBuilder();
-
-    private final ResettableByteArrayOutputStream dataBos = new ResettableByteArrayOutputStream();
-    private final DataOutput dataDos = new DataOutputStream(dataBos);
-    private IAType reqItemType;
-
-    public AListCaster() {
-
-    }
-
-    public void castList(AListPointable listAccessor, IVisitablePointable resultAccessor,
-            AbstractCollectionType reqType, ACastVisitor visitor) throws IOException, AsterixException {
-        if (reqType.getTypeTag().equals(ATypeTag.UNORDEREDLIST)) {
-            unOrderedListBuilder.reset((AUnorderedListType) reqType);
-        }
-        if (reqType.getTypeTag().equals(ATypeTag.ORDEREDLIST)) {
-            orderedListBuilder.reset((AOrderedListType) reqType);
-        }
-        dataBos.reset();
-
-        List<IVisitablePointable> itemTags = listAccessor.getItemTags();
-        List<IVisitablePointable> items = listAccessor.getItems();
-
-        int start = dataBos.size();
-        for (int i = 0; i < items.size(); i++) {
-            IVisitablePointable itemTypeTag = itemTags.get(i);
-            IVisitablePointable item = items.get(i);
-            ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(itemTypeTag.getByteArray()[itemTypeTag
-                    .getStartOffset()]);
-            if (reqItemType == null || reqItemType.getTypeTag().equals(ATypeTag.ANY)) {
-                itemVisitorArg.second = DefaultOpenFieldType.getDefaultOpenFieldType(typeTag);
-                item.accept(visitor, itemVisitorArg);
-            } else {
-                if (typeTag != reqItemType.getTypeTag())
-                    throw new AsterixException("mismatched item type");
-                itemVisitorArg.second = reqItemType;
-                item.accept(visitor, itemVisitorArg);
-            }
-            if (reqType.getTypeTag().equals(ATypeTag.ORDEREDLIST)) {
-                orderedListBuilder.addItem(itemVisitorArg.first);
-            }
-            if (reqType.getTypeTag().equals(ATypeTag.UNORDEREDLIST)) {
-                unOrderedListBuilder.addItem(itemVisitorArg.first);
-            }
-        }
-        if (reqType.getTypeTag().equals(ATypeTag.ORDEREDLIST)) {
-            orderedListBuilder.write(dataDos, true);
-        }
-        if (reqType.getTypeTag().equals(ATypeTag.UNORDEREDLIST)) {
-            unOrderedListBuilder.write(dataDos, true);
-        }
-        int end = dataBos.size();
-        resultAccessor.set(dataBos.getByteArray(), start, end - start);
-    }
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/cast/ARecordCaster.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/cast/ARecordCaster.java
deleted file mode 100644
index 8ef2ef0..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/cast/ARecordCaster.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright 2009-2010 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.pointables.cast;
-
-import java.io.DataOutput;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import edu.uci.ics.asterix.builders.RecordBuilder;
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-import edu.uci.ics.asterix.dataflow.data.nontagged.AqlNullWriterFactory;
-import edu.uci.ics.asterix.om.types.ARecordType;
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.AUnionType;
-import edu.uci.ics.asterix.om.types.EnumDeserializer;
-import edu.uci.ics.asterix.om.types.IAType;
-import edu.uci.ics.asterix.om.util.NonTaggedFormatUtil;
-import edu.uci.ics.asterix.runtime.pointables.ARecordPointable;
-import edu.uci.ics.asterix.runtime.pointables.PointableAllocator;
-import edu.uci.ics.asterix.runtime.pointables.base.DefaultOpenFieldType;
-import edu.uci.ics.asterix.runtime.pointables.base.IVisitablePointable;
-import edu.uci.ics.asterix.runtime.util.ResettableByteArrayOutputStream;
-import edu.uci.ics.hyracks.algebricks.common.utils.Triple;
-import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
-import edu.uci.ics.hyracks.api.dataflow.value.INullWriter;
-import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
-import edu.uci.ics.hyracks.data.std.api.IValueReference;
-import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
-import edu.uci.ics.hyracks.data.std.util.ByteArrayAccessibleOutputStream;
-
-/**
- * This class is to do the runtime type cast for a record. It is ONLY visible to
- * ACastVisitor.
- */
-class ARecordCaster {
-
-    // pointable allocator
-    private final PointableAllocator allocator = new PointableAllocator();
-
-    private final List<IVisitablePointable> reqFieldNames = new ArrayList<IVisitablePointable>();
-    private final List<IVisitablePointable> reqFieldTypeTags = new ArrayList<IVisitablePointable>();
-    private ARecordType cachedReqType = null;
-
-    private final ResettableByteArrayOutputStream bos = new ResettableByteArrayOutputStream();
-    private final DataOutputStream dos = new DataOutputStream(bos);
-
-    private final RecordBuilder recBuilder = new RecordBuilder();
-    private final IVisitablePointable nullReference = allocator.allocateEmpty();
-    private final IVisitablePointable nullTypeTag = allocator.allocateEmpty();
-
-    private final IBinaryComparator fieldNameComparator = PointableBinaryComparatorFactory.of(
-            UTF8StringPointable.FACTORY).createBinaryComparator();
-
-    private final ByteArrayAccessibleOutputStream outputBos = new ByteArrayAccessibleOutputStream();
-    private final DataOutputStream outputDos = new DataOutputStream(outputBos);
-
-    private final IVisitablePointable fieldTempReference = allocator.allocateEmpty();
-    private final Triple<IVisitablePointable, IAType, Boolean> nestedVisitorArg = new Triple<IVisitablePointable, IAType, Boolean>(
-            fieldTempReference, null, null);
-
-    private int numInputFields = 0;
-
-    // describe closed fields in the required type
-    private int[] fieldPermutation;
-    private boolean[] optionalFields;
-
-    // describe fields (open or not) in the input records
-    private boolean[] openFields;
-    private int[] fieldNamesSortedIndex;
-    private int[] reqFieldNamesSortedIndex;
-
-    public ARecordCaster() {
-        try {
-            bos.reset();
-            int start = bos.size();
-            INullWriter nullWriter = AqlNullWriterFactory.INSTANCE.createNullWriter();
-            nullWriter.writeNull(dos);
-            int end = bos.size();
-            nullReference.set(bos.getByteArray(), start, end - start);
-            start = bos.size();
-            dos.write(ATypeTag.NULL.serialize());
-            end = bos.size();
-            nullTypeTag.set(bos.getByteArray(), start, end);
-        } catch (IOException e) {
-            throw new IllegalStateException(e);
-        }
-    }
-
-    public void castRecord(ARecordPointable recordAccessor, IVisitablePointable resultAccessor, ARecordType reqType,
-            ACastVisitor visitor) throws IOException, AsterixException {
-        List<IVisitablePointable> fieldNames = recordAccessor.getFieldNames();
-        List<IVisitablePointable> fieldTypeTags = recordAccessor.getFieldTypeTags();
-        List<IVisitablePointable> fieldValues = recordAccessor.getFieldValues();
-        numInputFields = fieldNames.size();
-
-        if (openFields == null || numInputFields > openFields.length) {
-            openFields = new boolean[numInputFields];
-            fieldNamesSortedIndex = new int[numInputFields];
-        }
-        if (cachedReqType == null || !reqType.equals(cachedReqType)) {
-            loadRequiredType(reqType);
-        }
-
-        // clear the previous states
-        reset();
-        matchClosedPart(fieldNames, fieldTypeTags, fieldValues);
-        writeOutput(fieldNames, fieldTypeTags, fieldValues, outputDos, visitor);
-        resultAccessor.set(outputBos.getByteArray(), 0, outputBos.size());
-    }
-
-    private void reset() {
-        for (int i = 0; i < numInputFields; i++)
-            openFields[i] = true;
-        for (int i = 0; i < fieldPermutation.length; i++)
-            fieldPermutation[i] = -1;
-        for (int i = 0; i < numInputFields; i++)
-            fieldNamesSortedIndex[i] = i;
-        outputBos.reset();
-    }
-
-    private void loadRequiredType(ARecordType reqType) throws IOException {
-        reqFieldNames.clear();
-        reqFieldTypeTags.clear();
-
-        cachedReqType = reqType;
-        int numSchemaFields = reqType.getFieldTypes().length;
-        IAType[] fieldTypes = reqType.getFieldTypes();
-        String[] fieldNames = reqType.getFieldNames();
-        fieldPermutation = new int[numSchemaFields];
-        optionalFields = new boolean[numSchemaFields];
-        for (int i = 0; i < optionalFields.length; i++)
-            optionalFields[i] = false;
-
-        bos.reset(nullReference.getStartOffset() + nullReference.getLength());
-        for (int i = 0; i < numSchemaFields; i++) {
-            ATypeTag ftypeTag = fieldTypes[i].getTypeTag();
-            String fname = fieldNames[i];
-
-            // add type tag pointable
-            if (fieldTypes[i].getTypeTag() == ATypeTag.UNION
-                    && NonTaggedFormatUtil.isOptionalField((AUnionType) fieldTypes[i])) {
-                // optional field: add the embedded non-null type tag
-                ftypeTag = ((AUnionType) fieldTypes[i]).getUnionList()
-                        .get(NonTaggedFormatUtil.OPTIONAL_TYPE_INDEX_IN_UNION_LIST).getTypeTag();
-                optionalFields[i] = true;
-            }
-            int tagStart = bos.size();
-            dos.writeByte(ftypeTag.serialize());
-            int tagEnd = bos.size();
-            IVisitablePointable typeTagPointable = allocator.allocateEmpty();
-            typeTagPointable.set(bos.getByteArray(), tagStart, tagEnd - tagStart);
-            reqFieldTypeTags.add(typeTagPointable);
-
-            // add type name pointable (including a string type tag)
-            int nameStart = bos.size();
-            dos.write(ATypeTag.STRING.serialize());
-            dos.writeUTF(fname);
-            int nameEnd = bos.size();
-            IVisitablePointable typeNamePointable = allocator.allocateEmpty();
-            typeNamePointable.set(bos.getByteArray(), nameStart, nameEnd - nameStart);
-            reqFieldNames.add(typeNamePointable);
-        }
-
-        reqFieldNamesSortedIndex = new int[reqFieldNames.size()];
-        for (int i = 0; i < reqFieldNamesSortedIndex.length; i++)
-            reqFieldNamesSortedIndex[i] = i;
-        // sort the field name index
-        quickSort(reqFieldNamesSortedIndex, reqFieldNames, 0, reqFieldNamesSortedIndex.length - 1);
-    }
-
-    private void matchClosedPart(List<IVisitablePointable> fieldNames, List<IVisitablePointable> fieldTypeTags,
-            List<IVisitablePointable> fieldValues) {
-        // sort-merge based match
-        quickSort(fieldNamesSortedIndex, fieldNames, 0, numInputFields - 1);
-        int fnStart = 0;
-        int reqFnStart = 0;
-        while (fnStart < numInputFields && reqFnStart < reqFieldNames.size()) {
-            int fnPos = fieldNamesSortedIndex[fnStart];
-            int reqFnPos = reqFieldNamesSortedIndex[reqFnStart];
-            int c = compare(fieldNames.get(fnPos), reqFieldNames.get(reqFnPos));
-            if (c == 0) {
-                IVisitablePointable fieldTypeTag = fieldTypeTags.get(fnPos);
-                IVisitablePointable reqFieldTypeTag = reqFieldTypeTags.get(reqFnPos);
-                if (fieldTypeTag.equals(reqFieldTypeTag) || (
-                // match the null type of optional field
-                        optionalFields[reqFnPos] && fieldTypeTag.equals(nullTypeTag))) {
-                    fieldPermutation[reqFnPos] = fnPos;
-                    openFields[fnPos] = false;
-                }
-                fnStart++;
-                reqFnStart++;
-            }
-            if (c > 0)
-                reqFnStart++;
-            if (c < 0)
-                fnStart++;
-        }
-
-        // check unmatched fields in the input type
-        for (int i = 0; i < openFields.length; i++) {
-            if (openFields[i] == true && !cachedReqType.isOpen())
-                throw new IllegalStateException("type mismatch: including extra closed fields");
-        }
-
-        // check unmatched fields in the required type
-        for (int i = 0; i < fieldPermutation.length; i++) {
-            if (fieldPermutation[i] < 0) {
-                IAType t = cachedReqType.getFieldTypes()[i];
-                if (!(t.getTypeTag() == ATypeTag.UNION && NonTaggedFormatUtil.isOptionalField((AUnionType) t))) {
-                    // no matched field in the input for a required closed field
-                    throw new IllegalStateException("type mismatch: miss a required closed field");
-                }
-            }
-        }
-    }
-
-    private void writeOutput(List<IVisitablePointable> fieldNames, List<IVisitablePointable> fieldTypeTags,
-            List<IVisitablePointable> fieldValues, DataOutput output, ACastVisitor visitor) throws IOException,
-            AsterixException {
-        // reset the states of the record builder
-        recBuilder.reset(cachedReqType);
-        recBuilder.init();
-
-        // write the closed part
-        for (int i = 0; i < fieldPermutation.length; i++) {
-            int pos = fieldPermutation[i];
-            IVisitablePointable field;
-            if (pos >= 0) {
-                field = fieldValues.get(pos);
-            } else {
-                field = nullReference;
-            }
-            IAType fType = cachedReqType.getFieldTypes()[i];
-            nestedVisitorArg.second = fType;
-
-            // recursively casting, the result of casting can always be thought
-            // as flat
-            if (optionalFields[i]) {
-                nestedVisitorArg.second = ((AUnionType) fType).getUnionList().get(
-                        NonTaggedFormatUtil.OPTIONAL_TYPE_INDEX_IN_UNION_LIST);
-            }
-            field.accept(visitor, nestedVisitorArg);
-            recBuilder.addField(i, nestedVisitorArg.first);
-        }
-
-        // write the open part
-        for (int i = 0; i < numInputFields; i++) {
-            if (openFields[i]) {
-                IVisitablePointable name = fieldNames.get(i);
-                IVisitablePointable field = fieldValues.get(i);
-                IVisitablePointable fieldTypeTag = fieldTypeTags.get(i);
-
-                ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
-                        .deserialize(fieldTypeTag.getByteArray()[fieldTypeTag.getStartOffset()]);
-                nestedVisitorArg.second = DefaultOpenFieldType.getDefaultOpenFieldType(typeTag);
-                field.accept(visitor, nestedVisitorArg);
-                recBuilder.addField(name, nestedVisitorArg.first);
-            }
-        }
-        recBuilder.write(output, true);
-    }
-
-    private void quickSort(int[] index, List<IVisitablePointable> names, int start, int end) {
-        if (end <= start)
-            return;
-        int i = partition(index, names, start, end);
-        quickSort(index, names, start, i - 1);
-        quickSort(index, names, i + 1, end);
-    }
-
-    private int partition(int[] index, List<IVisitablePointable> names, int left, int right) {
-        int i = left - 1;
-        int j = right;
-        while (true) {
-            // grow from the left
-            while (compare(names.get(index[++i]), names.get(index[right])) < 0)
-                ;
-            // lower from the right
-            while (compare(names.get(index[right]), names.get(index[--j])) < 0)
-                if (j == left)
-                    break;
-            if (i >= j)
-                break;
-            // swap i and j
-            swap(index, i, j);
-        }
-        // swap i and right
-        swap(index, i, right); // swap with partition element
-        return i;
-    }
-
-    private void swap(int[] array, int i, int j) {
-        int temp = array[i];
-        array[i] = array[j];
-        array[j] = temp;
-    }
-
-    private int compare(IValueReference a, IValueReference b) {
-        // start+1 and len-1 due to the type tag
-        return fieldNameComparator.compare(a.getByteArray(), a.getStartOffset() + 1, a.getLength() - 1,
-                b.getByteArray(), b.getStartOffset() + 1, b.getLength() - 1);
-    }
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/visitor/IVisitablePointableVisitor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/visitor/IVisitablePointableVisitor.java
deleted file mode 100644
index 669e3fc..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/pointables/visitor/IVisitablePointableVisitor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2009-2010 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.pointables.visitor;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-import edu.uci.ics.asterix.runtime.pointables.AFlatValuePointable;
-import edu.uci.ics.asterix.runtime.pointables.AListPointable;
-import edu.uci.ics.asterix.runtime.pointables.ARecordPointable;
-
-/**
- * This interface is a visitor for all the three different IVisitablePointable
- * (Note that right now we have three pointable implementations for type
- * casting) implementations.
- */
-public interface IVisitablePointableVisitor<R, T> {
-
-    public R visit(AListPointable accessor, T arg) throws AsterixException;
-
-    public R visit(ARecordPointable accessor, T arg) throws AsterixException;
-
-    public R visit(AFlatValuePointable accessor, T arg) throws AsterixException;
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/AsterixRuntimeUtil.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/AsterixRuntimeUtil.java
deleted file mode 100644
index ab57288..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/AsterixRuntimeUtil.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2009-2011 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.util;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import edu.uci.ics.asterix.common.api.AsterixAppContextInfoImpl;
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-
-public class AsterixRuntimeUtil {
-
-    public static Set<String> getNodeControllersOnIP(String ipAddress) throws AsterixException {
-        Map<String, Set<String>> nodeControllerInfo = AsterixAppContextInfoImpl.getNodeControllerMap();
-        Set<String> nodeControllersAtLocation = nodeControllerInfo.get(ipAddress);
-        return nodeControllersAtLocation;
-    }
-
-    public static Set<String> getNodeControllersOnHostName(String hostName) throws UnknownHostException {
-        Map<String, Set<String>> nodeControllerInfo = AsterixAppContextInfoImpl.getNodeControllerMap();
-        String address;
-        address = InetAddress.getByName(hostName).getHostAddress();
-        if (address.equals("127.0.1.1")) {
-            address = "127.0.0.1";
-        }
-        Set<String> nodeControllersAtLocation = nodeControllerInfo.get(address);
-        return nodeControllersAtLocation;
-    }
-
-    public static List<String> getAllNodeControllers() {
-
-        Collection<Set<String>> nodeControllersCollection = AsterixAppContextInfoImpl.getNodeControllerMap().values();
-        List<String> nodeControllers = new ArrayList<String>();
-        for (Set<String> ncCollection : nodeControllersCollection) {
-            nodeControllers.addAll(ncCollection);
-        }
-        return nodeControllers;
-    }
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/ResettableByteArrayOutputStream.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/ResettableByteArrayOutputStream.java
deleted file mode 100644
index 968c3f2..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/ResettableByteArrayOutputStream.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package edu.uci.ics.asterix.runtime.util;
-
-import edu.uci.ics.hyracks.data.std.util.ByteArrayAccessibleOutputStream;
-
-/**
- * This class extends ByteArrayAccessibleOutputStream to allow reset to a given
- * size.
- * 
- */
-public class ResettableByteArrayOutputStream extends ByteArrayAccessibleOutputStream {
-
-    public void reset(int size) {
-        count = size;
-    }
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/container/IObjectFactory.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/container/IObjectFactory.java
deleted file mode 100644
index 85f0fa3..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/container/IObjectFactory.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2009-2010 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.util.container;
-
-/**
- * A factory interface to create objects.
- */
-public interface IObjectFactory<E, T> {
-
-    /**
-     * create an element of type E
-     * 
-     * @param arg
-     * @return an E element
-     */
-    public E create(T arg);
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/container/IObjectPool.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/container/IObjectPool.java
deleted file mode 100644
index dd2c3bf..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/container/IObjectPool.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2009-2010 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.util.container;
-
-/**
- * A reusable object pool interface.
- */
-public interface IObjectPool<E, T> {
-
-    /**
-     * Give client an E instance
-     * 
-     * @param arg
-     *            the argument to create E
-     * @return an E instance
-     */
-    public E allocate(T arg);
-
-    /**
-     * Mark all instances in the pool as unused
-     */
-    public void reset();
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/container/ListObjectPool.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/container/ListObjectPool.java
deleted file mode 100644
index b8f8e3a..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/util/container/ListObjectPool.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2009-2010 by The Regents of the University of California
- * Licensed 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 from
- * 
- *     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 edu.uci.ics.asterix.runtime.util.container;
-
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.List;
-
-/**
- * Object pool backed by a list.
- * 
- * The argument for creating E instances could be different. This class also
- * considers arguments in object reusing, e.g., it reuses an E instances ONLY
- * when the construction argument is "equal".
- */
-public class ListObjectPool<E, T> implements IObjectPool<E, T> {
-
-    private IObjectFactory<E, T> factory;
-
-    /**
-     * cache of objects
-     */
-    private List<E> pool = new ArrayList<E>();
-
-    /**
-     * args that are used to create each element in the pool
-     */
-    private List<T> args = new ArrayList<T>();
-
-    /**
-     * bits indicating which element is in use
-     */
-    private BitSet usedBits = new BitSet();
-
-    public ListObjectPool(IObjectFactory<E, T> factory) {
-        this.factory = factory;
-    }
-
-    @Override
-    public E allocate(T arg) {
-        int freeSlot = -1;
-        while (freeSlot + 1 < pool.size()) {
-            freeSlot = usedBits.nextClearBit(freeSlot + 1);
-            if (freeSlot >= pool.size())
-                break;
-
-            // the two cases where an element in the pool is a match
-            if ((arg == null && args.get(freeSlot) == null)
-                    || (arg != null && args.get(freeSlot) != null && arg.equals(args.get(freeSlot)))) {
-                // the element is not used and the arg is the same as
-                // input arg
-                usedBits.set(freeSlot);
-                return pool.get(freeSlot);
-            }
-        }
-
-        // if we do not find a reusable object, allocate a new one
-        E element = factory.create(arg);
-        pool.add(element);
-        args.add(arg);
-        usedBits.set(pool.size() - 1);
-        return element;
-    }
-
-    @Override
-    public void reset() {
-        usedBits.clear();
-    }
-}
