Reverting the merge of asterix_stabilization_result_distribution until the tests in the corresponding hyracks branch pass.

git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization@1282 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
index 762fa8f..fdf9c0b 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
@@ -83,8 +83,8 @@
 import edu.uci.ics.asterix.metadata.declared.AqlDataSource;
 import edu.uci.ics.asterix.metadata.declared.AqlMetadataProvider;
 import edu.uci.ics.asterix.metadata.declared.AqlSourceId;
-import edu.uci.ics.asterix.metadata.declared.ResultSetDataSink;
-import edu.uci.ics.asterix.metadata.declared.ResultSetSinkId;
+import edu.uci.ics.asterix.metadata.declared.FileSplitDataSink;
+import edu.uci.ics.asterix.metadata.declared.FileSplitSinkId;
 import edu.uci.ics.asterix.metadata.entities.Dataset;
 import edu.uci.ics.asterix.metadata.entities.Function;
 import edu.uci.ics.asterix.metadata.utils.DatasetUtils;
@@ -197,12 +197,10 @@
                 outputFileSplit = getDefaultOutputFileLocation();
             }
             metadataProvider.setOutputFile(outputFileSplit);
-            String resultNodeName = outputFileSplit.getNodeName();
-
             List<Mutable<ILogicalExpression>> writeExprList = new ArrayList<Mutable<ILogicalExpression>>(1);
             writeExprList.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(resVar)));
-            ResultSetSinkId rssId = new ResultSetSinkId(metadataProvider.getResultSetId(), resultNodeName);
-            ResultSetDataSink sink = new ResultSetDataSink(rssId, null);
+            FileSplitSinkId fssi = new FileSplitSinkId(outputFileSplit);
+            FileSplitDataSink sink = new FileSplitDataSink(fssi, null);
             topOp = new WriteOperator(writeExprList, sink);
             topOp.getInputs().add(new MutableObject<ILogicalOperator>(project));
         } else {
diff --git a/asterix-app/pom.xml b/asterix-app/pom.xml
index ac63075..9476178 100644
--- a/asterix-app/pom.xml
+++ b/asterix-app/pom.xml
@@ -140,11 +140,6 @@
 			<artifactId>algebricks-compiler</artifactId>
 		</dependency>
 		<dependency>
-            <groupId>edu.uci.ics.hyracks</groupId>
-            <artifactId>hyracks-client</artifactId>
-            <version>0.2.3-SNAPSHOT</version>
-        </dependency>
-		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-aql</artifactId>
 			<version>0.0.4-SNAPSHOT</version>
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
index 4062392..1eb37cd 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
@@ -146,8 +146,7 @@
 
     public enum DisplayFormat {
         TEXT,
-        HTML,
-        JSON
+        HTML
     }
 
     public static Pair<Query, Integer> reWriteQuery(List<FunctionDecl> declaredFunctions,
@@ -321,7 +320,7 @@
         if (!pc.isGenerateJobSpec()) {
             return null;
         }
-
+        
         AlgebricksPartitionConstraint clusterLocs = queryMetadataProvider.getClusterLocations();
         builder.setBinaryBooleanInspectorFactory(format.getBinaryBooleanInspectorFactory());
         builder.setBinaryIntegerInspectorFactory(format.getBinaryIntegerInspectorFactory());
@@ -332,16 +331,7 @@
         builder.setHashFunctionFactoryProvider(format.getBinaryHashFunctionFactoryProvider());
         builder.setHashFunctionFamilyProvider(format.getBinaryHashFunctionFamilyProvider());
         builder.setNullWriterFactory(format.getNullWriterFactory());
-
-        switch (pdf) {
-            case JSON:
-                builder.setPrinterProvider(format.getJSONPrinterFactoryProvider());
-                break;
-            default:
-                builder.setPrinterProvider(format.getPrinterFactoryProvider());
-                break;
-        }
-
+        builder.setPrinterProvider(format.getPrinterFactoryProvider());
         builder.setSerializerDeserializerProvider(format.getSerdeProvider());
         builder.setTypeTraitProvider(format.getTypeTraitProvider());
         builder.setNormalizedKeyComputerFactoryProvider(format.getNormalizedKeyComputerFactoryProvider());
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
index 2122ada..034e1f4 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
@@ -18,6 +18,7 @@
 import edu.uci.ics.asterix.aql.parser.AQLParser;
 import edu.uci.ics.asterix.aql.parser.ParseException;
 import edu.uci.ics.asterix.aql.translator.AqlTranslator;
+import edu.uci.ics.asterix.aql.translator.QueryResult;
 import edu.uci.ics.asterix.metadata.MetadataManager;
 import edu.uci.ics.hyracks.api.client.HyracksConnection;
 import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
@@ -27,292 +28,8 @@
 
     private static final String HYRACKS_CONNECTION_ATTR = "edu.uci.ics.asterix.HYRACKS_CONNECTION";
 
-    private static final String HTML_HEADER_TEMPLATE = "<!DOCTYPE html>"
-            + "<html lang=\"en\">"
-            + "<head>"
-            + "<meta name=\"description\" content=\"ASTERIX WEB PAGE\" />"
-            + "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
-            + "<link href='http://fonts.googleapis.com/css?family=Bitter|PT+Sans+Caption|Open+Sans' rel='stylesheet' type='text/css'>"
-            + "<script src=\"http://code.jquery.com/jquery.min.js\"></script>"
-            + "<script src=\"http://www.jacklmoore.com/autosize/jquery.autosize.js\"></script>"
-            + "  "
-            + "<link href=\"http://twitter.github.com/bootstrap/assets/css/bootstrap.css\" rel=\"stylesheet\" type=\"text/css\" />"
-            + "<link href=\"http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css\" rel=\"stylesheet\">"
-            + ""
-            + "  "
-            + "<script src=\"http://twitter.github.com/bootstrap/assets/js/bootstrap.js\"></script>"
-            + ""
-            + "<script type=\"text/javascript\">"
-            + "$(document).ready(function(){"
-            + "   $('textarea').autosize();"
-            + "});"
-            + "</script>"
-            + ""
-            + "<meta charset=utf-8 />"
-            + "<title>ASTERIX Demo</title>"
-            + "<style id=\"jsbin-css\">"
-            + "body {"
-            + "    background: none repeat scroll 0 0 white;"
-            + "    color: #222222;"
-            + "    font-family: 'Bitter';"
-            + "    font-size: 14px;"
-            + "    line-height: 17px;"
-            + "    width: 100%;"
-            + "}"
-            + ""
-            + ".content {"
-            + "    margin-top: 70px;"
-            + "}"
-            + ""
-            + "label.query, label.result {"
-            + "    font-size: 24px;"
-            + "    padding-bottom: 10px;"
-            + "    font-weight: bold;"
-            + "}"
-            + ""
-            + "div.host {"
-            + "    float: left;"
-            + "    margin: 0 100px 0 10px;"
-            + "}"
-            + ""
-            + "div.port {"
-            + "}"
-            + ""
-            + "div.left {"
-            + "    float: left;"
-            + "    width: 320px;"
-            + "    padding: 0 20px 0 10px;"
-            + "}"
-            + ""
-            + "div.right {"
-            + "}"
-            + ""
-            + "button.btn {"
-            + "    clear: both;"
-            + "    float: left;"
-            + "    margin: 20px 0 0 10px;;"
-            + "}"
-            + ""
-            + "textarea.query {"
-            + "    -webkit-box-sizing: border-box;"
-            + "    -moz-box-sizing: border-box;"
-            + "    -ms-box-sizing: border-box;"
-            + "    box-sizing: border-box;"
-            + "    font-size: 16px;"
-            + "    line-height: 20px;"
-            + "    font-family: bitter, helvetica;"
-            + "    width: 100%;"
-            + "    padding: 10px;"
-            + "    color: #999;"
-            + "    resize: none;"
-            + "    border: 10px solid #eee;"
-            + "}"
-            + ""
-            + "textarea.query:focus {"
-            + "    outline: none;"
-            + "    color: #333;"
-            + "}"
-            + ""
-            + "label {"
-            + "    padding-top: 10px;"
-            + "}"
-            + ""
-            + "input[type=text] {"
-            + "    height: 20px;"
-            + "}"
-            + ""
-            + ""
-            + "div.output label.heading {"
-            + "    font-size: 24px;"
-            + "    margin-top: 2px;"
-            + "    padding-bottom: 10px;"
-            + "    font-weight: bold;"
-            + "}"
-            + ""
-            + "div.output .message {"
-            + "    -webkit-box-sizing: border-box;"
-            + "    -moz-box-sizing: border-box;"
-            + "    -ms-box-sizing: border-box;"
-            + "    box-sizing: border-box;"
-            + "    -webkit-border-radius: 4px 4px 4px 4px;"
-            + "    -moz-border-radius: 4px 4px 4px 4px;"
-            + "    -ms-border-radius: 4px 4px 4px 4px;"
-            + "    border-radius: 4px 4px 4px 4px;"
-            + "    color: #000;"
-            + "    resize: none;"
-            + "    border: 1px solid #eee;"
-            + "}"
-            + ""
-            + "div.error label.heading {"
-            + "    color: #ff2020;"
-            + "    font-size: 24px;"
-            + "    margin-top: 2px;"
-            + "    padding-bottom: 10px;"
-            + "    font-weight: bold;"
-            + "}"
-            + ""
-            + "div.error .message {"
-            + "    -webkit-box-sizing: border-box;"
-            + "    -moz-box-sizing: border-box;"
-            + "    -ms-box-sizing: border-box;"
-            + "    box-sizing: border-box;"
-            + "    border-color: rgba(82, 168, 236, 0.8);"
-            + "    outline: 0;"
-            + "    outline: thin dotted 9;"
-            + ""
-            + "    -webkit-box-shadow: inset 0 1px 1px rgba(250, 0, 0, 0.075), 0 0 8px rgba(255, 0, 0, 0.8);"
-            + "    -moz-box-shadow: inset 0 1px 1px rgba(250, 0, 0, 0.075), 0 0 8px rgba(255, 0, 0, 1.0);"
-            + "    box-shadow: inset 0 1px 1px rgba(250, 0, 0, 0.075), 0 0 8px rgba(255, 0, 0, 1.0);"
-            + "    color: #000;"
-            + "    resize: none;"
-            + "    border: 1px solid #eee;"
-            + "    margin-top: 7px;"
-            + "    padding: 20px 20px 20px 20px;"
-            + "}"
-            + ""
-            + ".footer {"
-            + "   margin-top: 40px;"
-            + "}"
-            + ""
-            + ".footer .line {"
-            + "    border-top: 1px solid #EEEEEE;"
-            + "    bottom: 20px;"
-            + "    height: 10px;"
-            + "    left: 0;"
-            + "    position: fixed;"
-            + "    width: 100%;"
-            + "}"
-            + ""
-            + ".footer .content {"
-            + "    background: none repeat scroll 0 0 #FFFFFF;"
-            + "    bottom: 0;"
-            + "    color: #666666;"
-            + "    font-size: 12px;"
-            + "    height: 25px;"
-            + "    left: 0;"
-            + "    padding-top: 5px;"
-            + "    position: fixed;"
-            + "    width: 100%;"
-            + "}"
-            + ""
-            + ".footer .content .left {"
-            + "    padding-left: 20px;"
-            + "    float: left;"
-            + "}"
-            + ""
-            + ".footer .content .right {"
-            + "    padding-right: 20px;"
-            + "    float: right;"
-            + "}</style></head>"
-            + "<body>"
-            + "  <div class=\"navbar navbar-inverse navbar-fixed-top\">"
-            + "    <div class=\"navbar-inner\">"
-            + "      <div class=\"container\">"
-            + "        <a class=\"btn btn-navbar\" data-toggle=\"collapse\" data-target=\".nav-collapse\">"
-            + "          <span class=\"icon-bar\"></span>"
-            + "          <span class=\"icon-bar\"></span>"
-            + "          <span class=\"icon-bar\"></span>"
-            + "        </a>"
-            + "        <a class=\"brand\" href=\"#\">ASTERIX</a>"
-            + "        <div class=\"nav-collapse collapse\">"
-            + "          <ul class=\"nav\">"
-            + "            <li><a href=\"#\">Open source</a></li>"
-            + "            <li><a href=\"#about\">File issues</a></li>"
-            + "            <li><a href=\"#contact\">Contact</a></li>"
-            + "          </ul>"
-            + "        </div><!--/.nav-collapse -->"
-            + "      </div>"
-            + "    </div>"
-            + "  </div>"
-            + "";
-    private static final String HTML_FORM_CONTENT_TEMPLATE = "  <div class=\"content\">"
-            + "    <div class=\"container\">"
-            + "      <div class=\"row-fluid\">"
-            + "        <div class=\"span6\">"
-            + "          <form class=\"form-horizontal\" method=\"post\">"
-            + "            <div>"
-            + "              <label class=\"query\">Query</label>"
-            + "              <textarea rows=\"20\" name=\"query\" class=\"query\" value=\"%s\" placeholder=\"Type your AQL query ...\"></textarea>"
-            + "            </div>"
-            + "            <div>"
-            + "              <div class=\"host\">"
-            + "                <label>Host</label><input type=\"text\" name=\"hyracks-ip\" placeholder=\"IP Address or hostname\"/>"
-            + "              </div>"
-            + "              <div class=\"port\">"
-            + "                <label>Port</label><input type=\"text\" name=\"hyracks-port\" placeholder=\"Port number\"/>"
-            + "              </div>"
-            + "            </div>"
-            + "            <div>"
-            + "              <div class=\"left\">"
-            + "                <label class=\"checkbox\"><input type=\"checkbox\" name=\"print-expr-tree\" value=\"true\" /> Print parsed expressions</label>"
-            + "              </div>"
-            + "              <div class=\"right\">"
-            + "                <label class=\"checkbox\"><input type=\"checkbox\" name=\"print-rewritten-expr-tree\" value=\"true\" /> Print rewritten expressions</label>"
-            + "              </div>"
-            + "            </div>"
-            + "            <div>"
-            + "              <div class=\"left\">"
-            + "                <label class=\"checkbox\"><input type=\"checkbox\" name=\"print-logical-plan\" value=\"true\" /> Print logical plan</label>"
-            + "              </div>"
-            + "              <div class=\"right\">"
-            + "                <label class=\"checkbox\"><input type=\"checkbox\" name=\"print-optimized-logical-plan\" value=\"true\" /> Print optimized logical plan</label>"
-            + "              </div>"
-            + "            </div>"
-            + "            <div>"
-            + "              <div class=\"left\">"
-            + "                <label class=\"checkbox\"><input type=\"checkbox\" name=\"print-job\" value=\"true\" /> Print hyracks job</label>"
-            + "              </div>"
-            + "              <div class=\"right\">"
-            + "                <label class=\"checkbox\"><input type=\"checkbox\" name=\"display-result\" value=\"true\" /> Display error/results</label>"
-            + "              </div>"
-            + "            </div>"
-            + "            <button type=\"submit\" class=\"btn btn-danger\">Execute</button>"
-            + "          </form>"
-            + "        </div>";
-
-    private static final String HTML_EMPTY_OUTPUT_TEMPLATE = "        <div class=\"span6\">"
-            + "          <div class=\"output\">"
-            + "            <label class=\"heading\">Output</label>"
-            + "            <div class=\"message\">"
-            + "            </div>"
-            + "          </div>"
-            + "        </div>";
-
-    private static final String HTML_OUTPUT_TEMPLATE = "<div class=\"span6\">"
-            + "  <div class=\"output\">"
-            + "    <label class=\"heading\">Output</label>"
-            + "    <table class=\"table table-bordered table-striped\">"
-            + "      %s"
-            + "    </table>"
-            + "  </div>"
-            + "</div>";
-
-    private static final String HTML_FOOTER_TEMPLATE = "      </div>"
-            + "    </div>"
-            + "  </div>"
-            + "  <div class=\"footer\">"
-            + "    <section class=\"line\"><hr></section>"
-            + "    <section class=\"content\">"
-            + "      <section class=\"left\">"
-            + "        Developed by ASTERIX group"
-            + "      </section>"
-            + "      <section class=\"right\">"
-            + "        &copy; Copyright 2012 University of California, Irvine"
-            + "      </section>"
-            + "    </section>"
-            + "  </div>"
-            + "</body>"
-            + "</html>";
-
     @Override
     public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
-        DisplayFormat format = DisplayFormat.HTML;
-        if (request.getContentType().equals("application/json")) {
-            format = DisplayFormat.JSON;
-        } else if (request.getContentType().equals("text/plain")) {
-            format = DisplayFormat.TEXT;
-        }
-
         String query = request.getParameter("query");
         String printExprParam = request.getParameter("print-expr-tree");
         String printRewrittenExprParam = request.getParameter("print-rewritten-expr-tree");
@@ -343,13 +60,34 @@
                     isSet(printRewrittenExprParam), isSet(printLogicalPlanParam),
                     isSet(printOptimizedLogicalPlanParam), false, true, isSet(printJob));
             MetadataManager.INSTANCE.init();
-            AqlTranslator aqlTranslator = new AqlTranslator(aqlStatements, out, sessionConfig, format);
+            AqlTranslator aqlTranslator = new AqlTranslator(aqlStatements, out, sessionConfig, DisplayFormat.HTML);
+            List<QueryResult> executionResults = null;
             double duration = 0;
             long startTime = System.currentTimeMillis();
-            aqlTranslator.compileAndExecute(hcc, false);
+            executionResults = aqlTranslator.compileAndExecute(hcc);
             long endTime = System.currentTimeMillis();
             duration = (endTime - startTime) / 1000.00;
             out.println("<PRE>Duration of all jobs: " + duration + "</PRE>");
+
+            int queryCount = 1;
+            out.println("<H1>Result:</H1>");
+            out.println("<PRE>");
+            for (QueryResult result : executionResults) {
+                out.println("Query:" + queryCount++ + ":" + " " + result.getResultPath());
+            }
+            out.println("Duration: " + duration);
+            out.println("</PRE>");
+
+            queryCount = 1;
+            if (isSet(strDisplayResult)) {
+                out.println("<PRE>");
+                for (QueryResult result : executionResults) {
+                    out.println("Query:" + queryCount++ + ":" + " " + result.getResultPath());
+                    displayFile(new File(result.getResultPath()), out);
+                    out.println();
+                }
+                out.println("</PRE>");
+            }
         } catch (ParseException pe) {
             String message = pe.getMessage();
             message = message.replace("<", "&lt");
@@ -372,8 +110,21 @@
     public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
         PrintWriter out = response.getWriter();
         response.setContentType("text/html");
-        final String form = HTML_HEADER_TEMPLATE + String.format(HTML_FORM_CONTENT_TEMPLATE, "")
-                + HTML_EMPTY_OUTPUT_TEMPLATE + HTML_FOOTER_TEMPLATE;
+        final String form = "<form method=\"post\">"
+                + "<center><textarea cols=\"80\" rows=\"25\" name=\"query\" ></textarea><br/>"
+                + "IP Address: <input type = \"text\" name = \"hyracks-ip\" size=\"15\" maxlength=\"35\" value=\"localhost\" /><br/>"
+                + "Port: <input type = \"text\" name = \"hyracks-port\" size=\"5\" maxlength=\"5\" value=\"1098\" /><br/>"
+                + "<input type = \"checkbox\" name = \"print-expr-tree\" value=\"true\" />print parsed expressions<P>"
+                + "<input type = \"checkbox\" name = \"print-rewritten-expr-tree\" value=\"true\" />print rewritten expressions<P>"
+                + "<input type = \"checkbox\" name = \"print-logical-plan\" value=\"true\" checked/>print logical plan<P>"
+                + "<input type = \"checkbox\" name = \"print-optimized-logical-plan\" value=\"true\" checked/>print optimized logical plan<P>"
+                + "<input type = \"checkbox\" name = \"print-job\" value=\"true\" checked/>print Hyracks job<P>"
+                + "<input type = \"checkbox\" name = \"display-result\" value=\"true\" checked/>display NFS file<P>"
+                // +
+                // "<input type = \"checkbox\" name = \"serialize-as-xml\" value=\"true\">serialize as XML<P>"
+                // +
+                // "<input type = \"checkbox\" name = \"show-tuples\" value=\"true\">show the entire tuples<P>"
+                + "<input type=\"submit\"/>" + "</center>" + "</form>";
         out.println(form);
     }
 
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/DDLAPIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/DDLAPIServlet.java
deleted file mode 100644
index 1ae3054..0000000
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/DDLAPIServlet.java
+++ /dev/null
@@ -1,42 +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.api.http.servlet;
-
-import java.util.Arrays;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-
-import edu.uci.ics.asterix.aql.base.Statement;
-import edu.uci.ics.asterix.aql.base.Statement.Kind;
-
-public class DDLAPIServlet extends RESTAPIServlet {
-    private static final long serialVersionUID = 1L;
-
-    protected String getQueryParameter(HttpServletRequest request) {
-        return request.getParameter("ddl");
-    }
-
-    protected List<Statement.Kind> getAllowedStatements() {
-        Kind[] statementsArray = { Kind.DATAVERSE_DECL, Kind.DATAVERSE_DROP, Kind.FUNCTION_DECL, Kind.NODEGROUP_DECL,
-                Kind.NODEGROUP_DROP, Kind.TYPE_DECL, Kind.TYPE_DROP, Kind.CREATE_INDEX, Kind.INDEX_DECL,
-                Kind.CREATE_DATAVERSE, Kind.INDEX_DROP, Kind.CREATE_FUNCTION, Kind.FUNCTION_DROP };
-        return Arrays.asList(statementsArray);
-    }
-
-    protected String getErrorMessage() {
-        return "Invalid statement: Non-DDL statement %s to the DDL API.";
-    }
-}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/HyracksProperties.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/HyracksProperties.java
deleted file mode 100644
index c5b532a..0000000
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/HyracksProperties.java
+++ /dev/null
@@ -1,52 +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.api.http.servlet;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-public class HyracksProperties {
-    private final InputStream is;
-
-    private final Properties properties;
-
-    private static String HYRACKS_IP = "127.0.0.1";
-
-    private static int HYRACKS_PORT = 1098;
-
-    public HyracksProperties() throws IOException {
-        is = HyracksProperties.class.getClassLoader().getResourceAsStream("hyracks-deployment.properties");
-        properties = new Properties();
-        properties.load(is);
-    }
-
-    public String getHyracksIPAddress() {
-        String strIP = properties.getProperty("cc.ip");
-        if (strIP == null) {
-            strIP = HYRACKS_IP;
-        }
-        return strIP;
-    }
-
-    public int getHyracksPort() {
-        String strPort = properties.getProperty("cc.port");
-        int port = HYRACKS_PORT;
-        if (strPort != null) {
-            port = Integer.parseInt(strPort);
-        }
-        return port;
-    }
-}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/QueryAPIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/QueryAPIServlet.java
deleted file mode 100644
index a893bd6..0000000
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/QueryAPIServlet.java
+++ /dev/null
@@ -1,41 +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.api.http.servlet;
-
-import java.util.Arrays;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-
-import edu.uci.ics.asterix.aql.base.Statement;
-import edu.uci.ics.asterix.aql.base.Statement.Kind;
-
-public class QueryAPIServlet extends RESTAPIServlet {
-    private static final long serialVersionUID = 1L;
-
-    protected String getQueryParameter(HttpServletRequest request) {
-        return request.getParameter("query");
-    }
-
-    protected List<Statement.Kind> getAllowedStatements() {
-        Kind[] statementsArray = { Kind.DATAVERSE_DECL, Kind.QUERY, Kind.SET, Kind.WRITE, Kind.BEGIN_FEED,
-                Kind.CONTROL_FEED };
-        return Arrays.asList(statementsArray);
-    }
-
-    protected String getErrorMessage() {
-        return "Invalid statement: Non-query statement %s to the query API.";
-    }
-}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/QueryResultAPIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/QueryResultAPIServlet.java
deleted file mode 100644
index 2b0aff4..0000000
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/QueryResultAPIServlet.java
+++ /dev/null
@@ -1,84 +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.api.http.servlet;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.nio.ByteBuffer;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-import edu.uci.ics.asterix.result.ResultReader;
-import edu.uci.ics.asterix.result.ResultUtils;
-import edu.uci.ics.hyracks.api.client.HyracksConnection;
-import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
-import edu.uci.ics.hyracks.api.dataset.ResultSetId;
-import edu.uci.ics.hyracks.api.job.JobId;
-
-public class QueryResultAPIServlet extends HttpServlet {
-    private static final long serialVersionUID = 1L;
-
-    private static final String HYRACKS_CONNECTION_ATTR = "edu.uci.ics.asterix.HYRACKS_CONNECTION";
-
-    @Override
-    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
-        String strHandle = request.getParameter("handle");
-        PrintWriter out = response.getWriter();
-        response.setContentType("text/html");
-        ServletContext context = getServletContext();
-        IHyracksClientConnection hcc;
-        try {
-            HyracksProperties hp = new HyracksProperties();
-            String strIP = hp.getHyracksIPAddress();
-            int port = hp.getHyracksPort();
-
-            synchronized (context) {
-                hcc = (IHyracksClientConnection) context.getAttribute(HYRACKS_CONNECTION_ATTR);
-                if (hcc == null) {
-                    hcc = new HyracksConnection(strIP, port);
-                    context.setAttribute(HYRACKS_CONNECTION_ATTR, hcc);
-                }
-            }
-            JSONObject handleObj = new JSONObject(strHandle);
-            JSONArray handle = handleObj.getJSONArray("handle");
-            JobId jobId = new JobId(handle.getLong(0));
-            ResultSetId rsId = new ResultSetId(handle.getLong(1));
-            ByteBuffer buffer = ByteBuffer.allocate(ResultReader.FRAME_SIZE);
-            /* TODO(madhusudancs): We need to find a way to JSON serialize default format obtained from
-             * metadataProvider in the AQLTranslator and store it as part of the result handle.
-             */
-            ResultReader resultReader = new ResultReader(hcc);
-            resultReader.open(jobId, rsId);
-            buffer.clear();
-            JSONObject jsonResponse = new JSONObject();
-            JSONArray results = new JSONArray();
-            while (resultReader.read(buffer) > 0) {
-                results.put(ResultUtils.getJSONFromBuffer(buffer, resultReader.getFrameTupleAccessor()));
-            }
-            jsonResponse.put("results", results);
-            out.write(jsonResponse.toString());
-
-        } catch (Exception e) {
-            out.println(e.getMessage());
-            e.printStackTrace(out);
-        }
-    }
-}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/QueryStatusAPIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/QueryStatusAPIServlet.java
deleted file mode 100644
index f36e4e3..0000000
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/QueryStatusAPIServlet.java
+++ /dev/null
@@ -1,93 +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.api.http.servlet;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-import edu.uci.ics.asterix.result.ResultReader;
-import edu.uci.ics.hyracks.api.client.HyracksConnection;
-import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
-import edu.uci.ics.hyracks.api.dataset.ResultSetId;
-import edu.uci.ics.hyracks.api.job.JobId;
-
-public class QueryStatusAPIServlet extends HttpServlet {
-    private static final long serialVersionUID = 1L;
-
-    private static final String HYRACKS_CONNECTION_ATTR = "edu.uci.ics.asterix.HYRACKS_CONNECTION";
-
-    @Override
-    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
-        String strHandle = request.getParameter("handle");
-        PrintWriter out = response.getWriter();
-        response.setContentType("text/html");
-        ServletContext context = getServletContext();
-        IHyracksClientConnection hcc;
-        try {
-            HyracksProperties hp = new HyracksProperties();
-            String strIP = hp.getHyracksIPAddress();
-            int port = hp.getHyracksPort();
-
-            synchronized (context) {
-                hcc = (IHyracksClientConnection) context.getAttribute(HYRACKS_CONNECTION_ATTR);
-                if (hcc == null) {
-                    hcc = new HyracksConnection(strIP, port);
-                    context.setAttribute(HYRACKS_CONNECTION_ATTR, hcc);
-                }
-            }
-            JSONObject handleObj = new JSONObject(strHandle);
-            JSONArray handle = handleObj.getJSONArray("handle");
-            JobId jobId = new JobId(handle.getLong(0));
-            ResultSetId rsId = new ResultSetId(handle.getLong(1));
-
-            /* TODO(madhusudancs): We need to find a way to JSON serialize default format obtained from
-             * metadataProvider in the AQLTranslator and store it as part of the result handle.
-             */
-            ResultReader resultReader = new ResultReader(hcc);
-            resultReader.open(jobId, rsId);
-
-            JSONObject jsonResponse = new JSONObject();
-            String status;
-            switch (resultReader.getStatus()) {
-                case RUNNING:
-                    status = "RUNNING";
-                    break;
-                case FAILED:
-                    status = "ERROR";
-                    break;
-                case SUCCESS:
-                    status = "SUCCESS";
-                    break;
-                default:
-                    status = "ERROR";
-                    break;
-            }
-            jsonResponse.put("status", status);
-            out.write(jsonResponse.toString());
-
-        } catch (Exception e) {
-            out.println(e.getMessage());
-            e.printStackTrace(out);
-        }
-    }
-}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/RESTAPIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/RESTAPIServlet.java
deleted file mode 100644
index f0aa3c5..0000000
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/RESTAPIServlet.java
+++ /dev/null
@@ -1,141 +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.api.http.servlet;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.util.List;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.json.JSONObject;
-
-import edu.uci.ics.asterix.api.common.APIFramework.DisplayFormat;
-import edu.uci.ics.asterix.api.common.SessionConfig;
-import edu.uci.ics.asterix.aql.base.Statement;
-import edu.uci.ics.asterix.aql.base.Statement.Kind;
-import edu.uci.ics.asterix.aql.parser.AQLParser;
-import edu.uci.ics.asterix.aql.parser.ParseException;
-import edu.uci.ics.asterix.aql.translator.AqlTranslator;
-import edu.uci.ics.asterix.metadata.MetadataManager;
-import edu.uci.ics.asterix.result.ResultUtils;
-import edu.uci.ics.hyracks.api.client.HyracksConnection;
-import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
-
-abstract class RESTAPIServlet extends HttpServlet {
-    private static final long serialVersionUID = 1L;
-
-    private static final String HYRACKS_CONNECTION_ATTR = "edu.uci.ics.asterix.HYRACKS_CONNECTION";
-
-    @Override
-    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
-        PrintWriter out = response.getWriter();
-
-        DisplayFormat format = DisplayFormat.HTML;
-
-        String contentType = request.getContentType();
-
-        if ((contentType == null) || (contentType.equals("text/plain"))) {
-            format = DisplayFormat.TEXT;
-        } else if (contentType.equals("application/json")) {
-            format = DisplayFormat.JSON;
-        }
-
-        String query = getQueryParameter(request);
-        boolean asyncResults = isAsync(request);
-
-        response.setContentType("application/json");
-        ServletContext context = getServletContext();
-        IHyracksClientConnection hcc;
-
-        try {
-            HyracksProperties hp = new HyracksProperties();
-            String strIP = hp.getHyracksIPAddress();
-            int port = hp.getHyracksPort();
-
-            synchronized (context) {
-                hcc = (IHyracksClientConnection) context.getAttribute(HYRACKS_CONNECTION_ATTR);
-                if (hcc == null) {
-                    hcc = new HyracksConnection(strIP, port);
-                    context.setAttribute(HYRACKS_CONNECTION_ATTR, hcc);
-                }
-            }
-
-            AQLParser parser = new AQLParser(query);
-            List<Statement> aqlStatements = parser.Statement();
-            if (checkForbiddenStatements(aqlStatements, out)) {
-                return;
-            }
-            SessionConfig sessionConfig = new SessionConfig(port, true, false, false, false, false, false, true, false);
-
-            MetadataManager.INSTANCE.init();
-
-            AqlTranslator aqlTranslator = new AqlTranslator(aqlStatements, out, sessionConfig, format);
-
-            aqlTranslator.compileAndExecute(hcc, asyncResults);
-
-        } catch (ParseException pe) {
-            StringBuilder errorMessage = new StringBuilder();
-            String message = pe.getMessage();
-            message = message.replace("<", "&lt");
-            message = message.replace(">", "&gt");
-            errorMessage.append("SyntaxError:" + message + "\n");
-            int pos = message.indexOf("line");
-            if (pos > 0) {
-                int columnPos = message.indexOf(",", pos + 1 + "line".length());
-                int lineNo = Integer.parseInt(message.substring(pos + "line".length() + 1, columnPos));
-                String line = query.split("\n")[lineNo - 1];
-                errorMessage.append("==> " + line + "\n");
-            }
-            JSONObject errorResp = ResultUtils.getErrorResponse(2, errorMessage.toString());
-            out.write(errorResp.toString());
-        } catch (Exception e) {
-            StringBuilder errorMessage = new StringBuilder();
-            errorMessage.append(e.getMessage());
-            JSONObject errorResp = ResultUtils.getErrorResponse(99, errorMessage.toString());
-            out.write(errorResp.toString());
-        }
-    }
-
-    private boolean checkForbiddenStatements(List<Statement> aqlStatements, PrintWriter out) {
-        for (Statement st : aqlStatements) {
-            if (!getAllowedStatements().contains(st.getKind())) {
-                JSONObject errorResp = ResultUtils.getErrorResponse(1, String.format(getErrorMessage(), st.getKind()));
-                out.write(errorResp.toString());
-                return true;
-            }
-        }
-        return false;
-    }
-
-    protected boolean isAsync(HttpServletRequest request) {
-        String mode = request.getParameter("mode");
-        boolean asyncResults = false;
-        if (mode != null && mode.equals("asynchronous")) {
-            asyncResults = true;
-        }
-        return asyncResults;
-    }
-
-    protected abstract String getQueryParameter(HttpServletRequest request);
-
-    protected abstract List<Kind> getAllowedStatements();
-
-    protected abstract String getErrorMessage();
-}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/UpdateAPIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/UpdateAPIServlet.java
deleted file mode 100644
index 7336876..0000000
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/UpdateAPIServlet.java
+++ /dev/null
@@ -1,41 +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.api.http.servlet;
-
-import java.util.Arrays;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-
-import edu.uci.ics.asterix.aql.base.Statement;
-import edu.uci.ics.asterix.aql.base.Statement.Kind;
-
-public class UpdateAPIServlet extends RESTAPIServlet {
-    private static final long serialVersionUID = 1L;
-
-    protected String getQueryParameter(HttpServletRequest request) {
-        return request.getParameter("statements");
-    }
-
-    protected List<Statement.Kind> getAllowedStatements() {
-        Kind[] statementsArray = { Kind.DATAVERSE_DECL, Kind.DATASET_DECL, Kind.DATASET_DROP, Kind.DELETE, Kind.INSERT,
-                Kind.UPDATE, Kind.DML_CMD_LIST, Kind.LOAD_FROM_FILE, Kind.WRITE_FROM_QUERY_RESULT };
-        return Arrays.asList(statementsArray);
-    }
-
-    protected String getErrorMessage() {
-        return "Invalid statement: Non-Update statement %s to the Update API.";
-    }
-}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/java/AsterixJavaClient.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/java/AsterixJavaClient.java
index fb09299..7e72d94 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/java/AsterixJavaClient.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/java/AsterixJavaClient.java
@@ -52,7 +52,7 @@
         int ch;
         StringBuilder builder = new StringBuilder();
         while ((ch = queryText.read()) != -1) {
-            builder.append((char) ch);
+            builder.append((char)ch);
         }
         AQLParser parser = new AQLParser(builder.toString());
         List<Statement> aqlStatements;
@@ -68,7 +68,7 @@
                 generateBinaryRuntime, printJob);
 
         AqlTranslator aqlTranslator = new AqlTranslator(aqlStatements, writer, pc, DisplayFormat.TEXT);
-        aqlTranslator.compileAndExecute(hcc, false);
+        aqlTranslator.compileAndExecute(hcc);
         writer.flush();
     }
 
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
index d6d9382..66239e2 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
@@ -16,7 +16,6 @@
 
 import java.io.File;
 import java.io.PrintWriter;
-import java.nio.ByteBuffer;
 import java.rmi.RemoteException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -24,15 +23,12 @@
 import java.util.Map;
 
 import org.json.JSONException;
-import org.json.JSONArray;
-import org.json.JSONObject;
 
 import edu.uci.ics.asterix.api.common.APIFramework;
 import edu.uci.ics.asterix.api.common.APIFramework.DisplayFormat;
 import edu.uci.ics.asterix.api.common.Job;
 import edu.uci.ics.asterix.api.common.SessionConfig;
 import edu.uci.ics.asterix.aql.base.Statement;
-import edu.uci.ics.asterix.aql.base.Statement.Kind;
 import edu.uci.ics.asterix.aql.expression.BeginFeedStatement;
 import edu.uci.ics.asterix.aql.expression.ControlFeedStatement;
 import edu.uci.ics.asterix.aql.expression.CreateDataverseStatement;
@@ -68,7 +64,6 @@
 import edu.uci.ics.asterix.file.FeedOperations;
 import edu.uci.ics.asterix.file.IndexOperations;
 import edu.uci.ics.asterix.formats.base.IDataFormat;
-import edu.uci.ics.asterix.formats.nontagged.AqlResultSerializerFactoryProvider;
 import edu.uci.ics.asterix.metadata.IDatasetDetails;
 import edu.uci.ics.asterix.metadata.MetadataException;
 import edu.uci.ics.asterix.metadata.MetadataManager;
@@ -86,8 +81,6 @@
 import edu.uci.ics.asterix.om.types.ATypeTag;
 import edu.uci.ics.asterix.om.types.IAType;
 import edu.uci.ics.asterix.om.types.TypeSignature;
-import edu.uci.ics.asterix.result.ResultUtils;
-import edu.uci.ics.asterix.result.ResultReader;
 import edu.uci.ics.asterix.transaction.management.exception.ACIDException;
 import edu.uci.ics.asterix.transaction.management.service.transaction.TransactionIDFactory;
 import edu.uci.ics.asterix.translator.AbstractAqlTranslator;
@@ -106,10 +99,8 @@
 import edu.uci.ics.hyracks.algebricks.common.utils.Pair;
 import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression.FunctionKind;
 import edu.uci.ics.hyracks.algebricks.data.IAWriterFactory;
-import edu.uci.ics.hyracks.algebricks.data.IResultSerializerFactoryProvider;
 import edu.uci.ics.hyracks.algebricks.runtime.writers.PrinterBasedWriterFactory;
 import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
-import edu.uci.ics.hyracks.api.dataset.ResultSetId;
 import edu.uci.ics.hyracks.api.io.FileReference;
 import edu.uci.ics.hyracks.api.job.JobId;
 import edu.uci.ics.hyracks.api.job.JobSpecification;
@@ -149,20 +140,18 @@
 
     /**
      * Compiles and submits for execution a list of AQL statements.
-     *
+     * 
      * @param hcc
-     *            A Hyracks client connection that is used to submit a jobspec to Hyracks.
-     * @param asyncResults
-     *            True if the results should be read asynchronously or false if we should wait for results to be read.
-     * @return A List<QueryResult> containing a QueryResult instance corresponding to each submitted query.
+     *            AHyracks client connection that is used to submit a jobspec to
+     *            Hyracks.
+     * @return A List<QueryResult> containing a QueryResult instance
+     *         corresponding to each submitted query.
      * @throws Exception
      */
-    public List<QueryResult> compileAndExecute(IHyracksClientConnection hcc, boolean asyncResults) throws Exception {
-        int resultSetIdCounter = 0;
+    public List<QueryResult> compileAndExecute(IHyracksClientConnection hcc) throws Exception {
         List<QueryResult> executionResult = new ArrayList<QueryResult>();
         FileSplit outputFile = null;
         IAWriterFactory writerFactory = PrinterBasedWriterFactory.INSTANCE;
-        IResultSerializerFactoryProvider resultSerializerFactoryProvider = AqlResultSerializerFactoryProvider.INSTANCE;
         Map<String, String> config = new HashMap<String, String>();
         List<JobSpecification> jobsToExecute = new ArrayList<JobSpecification>();
 
@@ -171,7 +160,6 @@
             MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
             AqlMetadataProvider metadataProvider = new AqlMetadataProvider(mdTxnCtx, activeDefaultDataverse);
             metadataProvider.setWriterFactory(writerFactory);
-            metadataProvider.setResultSerializerFactoryProvider(resultSerializerFactoryProvider);
             metadataProvider.setOutputFile(outputFile);
             metadataProvider.setConfig(config);
             jobsToExecute.clear();
@@ -264,7 +252,6 @@
                     }
 
                     case QUERY: {
-                        metadataProvider.setResultSetId(new ResultSetId(resultSetIdCounter++));
                         executionResult.add(handleQuery(metadataProvider, (Query) stmt, hcc, jobsToExecute));
                         break;
                     }
@@ -288,30 +275,7 @@
             // Following jobs are run under a separate transaction, that is
             // committed/aborted by the JobEventListener
             for (JobSpecification jobspec : jobsToExecute) {
-                JobId jobId = runJob(hcc, jobspec);
-                if (stmt.getKind() == Kind.QUERY) {
-                    JSONObject response = new JSONObject();
-
-                    if (asyncResults) {
-                        JSONArray handle = new JSONArray();
-                        handle.put(jobId.getId());
-                        handle.put(metadataProvider.getResultSetId().getId());
-                        response.put("handle", handle);
-                    } else {
-                        ByteBuffer buffer = ByteBuffer.allocate(ResultReader.FRAME_SIZE);
-                        ResultReader resultReader = new ResultReader(hcc);
-                        resultReader.open(jobId, metadataProvider.getResultSetId());
-                        buffer.clear();
-                        JSONArray results = new JSONArray();
-                        while (resultReader.read(buffer) > 0) {
-                            results.put(ResultUtils.getJSONFromBuffer(buffer, resultReader.getFrameTupleAccessor()));
-                            buffer.clear();
-                        }
-                        response.put("results", results);
-                    }
-                    out.write(response.toString());
-                }
-                hcc.waitForCompletion(jobId);
+                runJob(hcc, jobspec);
             }
         }
         return executionResult;
@@ -429,8 +393,7 @@
         if (dd.getDatasetType() == DatasetType.INTERNAL || dd.getDatasetType() == DatasetType.FEED) {
             Dataverse dataverse = MetadataManager.INSTANCE.getDataverse(metadataProvider.getMetadataTxnContext(),
                     dataverseName);
-            JobId jobId = runJob(hcc, DatasetOperations.createDatasetJobSpec(dataverse, datasetName, metadataProvider));
-            hcc.waitForCompletion(jobId);
+            runJob(hcc, DatasetOperations.createDatasetJobSpec(dataverse, datasetName, metadataProvider));
         }
     }
 
@@ -468,8 +431,7 @@
                     index.getDatasetName(), index.getKeyFieldNames(), index.getGramLength(), index.getIndexType());
             JobSpecification loadIndexJobSpec = IndexOperations
                     .buildSecondaryIndexLoadingJobSpec(cis, metadataProvider);
-            JobId jobId = runJob(hcc, loadIndexJobSpec);
-            hcc.waitForCompletion(jobId);
+            runJob(hcc, loadIndexJobSpec);
         }
     }
 
@@ -702,9 +664,9 @@
         CompiledWriteFromQueryResultStatement clfrqs = new CompiledWriteFromQueryResultStatement(dataverseName, st1
                 .getDatasetName().getValue(), st1.getQuery(), st1.getVarCounter());
 
-        JobSpecification compiled = rewriteCompileQuery(metadataProvider, clfrqs.getQuery(), clfrqs);
-        if (compiled != null) {
-            jobsToExecute.add(compiled);
+        Pair<JobSpecification, FileSplit> compiled = rewriteCompileQuery(metadataProvider, clfrqs.getQuery(), clfrqs);
+        if (compiled.first != null) {
+            jobsToExecute.add(compiled.first);
         }
     }
 
@@ -716,10 +678,9 @@
                 : activeDefaultDataverse.getDataverseName() : stmtInsert.getDataverseName().getValue();
         CompiledInsertStatement clfrqs = new CompiledInsertStatement(dataverseName, stmtInsert.getDatasetName()
                 .getValue(), stmtInsert.getQuery(), stmtInsert.getVarCounter());
-
-        JobSpecification compiled = rewriteCompileQuery(metadataProvider, clfrqs.getQuery(), clfrqs);
-        if (compiled != null) {
-            jobsToExecute.add(compiled);
+        Pair<JobSpecification, FileSplit> compiled = rewriteCompileQuery(metadataProvider, clfrqs.getQuery(), clfrqs);
+        if (compiled.first != null) {
+            jobsToExecute.add(compiled.first);
         }
     }
 
@@ -732,13 +693,13 @@
         CompiledDeleteStatement clfrqs = new CompiledDeleteStatement(stmtDelete.getVariableExpr(), dataverseName,
                 stmtDelete.getDatasetName().getValue(), stmtDelete.getCondition(), stmtDelete.getDieClause(),
                 stmtDelete.getVarCounter(), metadataProvider);
-        JobSpecification compiled = rewriteCompileQuery(metadataProvider, clfrqs.getQuery(), clfrqs);
-        if (compiled != null) {
-            jobsToExecute.add(compiled);
+        Pair<JobSpecification, FileSplit> compiled = rewriteCompileQuery(metadataProvider, clfrqs.getQuery(), clfrqs);
+        if (compiled.first != null) {
+            jobsToExecute.add(compiled.first);
         }
     }
 
-    private JobSpecification rewriteCompileQuery(AqlMetadataProvider metadataProvider, Query query,
+    private Pair<JobSpecification, FileSplit> rewriteCompileQuery(AqlMetadataProvider metadataProvider, Query query,
             ICompiledDmlStatement stmt) throws AsterixException, RemoteException, AlgebricksException, JSONException,
             ACIDException {
 
@@ -754,7 +715,9 @@
         JobSpecification spec = APIFramework.compileQuery(declaredFunctions, metadataProvider, query,
                 reWrittenQuery.second, stmt == null ? null : stmt.getDatasetName(), sessionConfig, out, pdf, stmt);
 
-        return spec;
+        Pair<JobSpecification, FileSplit> compiled = new Pair<JobSpecification, FileSplit>(spec,
+                metadataProvider.getOutputFile());
+        return compiled;
 
     }
 
@@ -778,10 +741,9 @@
         }
         bfs.initialize(metadataProvider.getMetadataTxnContext(), dataset);
         cbfs.setQuery(bfs.getQuery());
-
-        JobSpecification compiled = rewriteCompileQuery(metadataProvider, bfs.getQuery(), cbfs);
-        if (compiled != null) {
-            jobsToExecute.add(compiled);
+        Pair<JobSpecification, FileSplit> compiled = rewriteCompileQuery(metadataProvider, bfs.getQuery(), cbfs);
+        if (compiled.first != null) {
+            jobsToExecute.add(compiled.first);
         }
     }
 
@@ -797,13 +759,12 @@
 
     private QueryResult handleQuery(AqlMetadataProvider metadataProvider, Query query, IHyracksClientConnection hcc,
             List<JobSpecification> jobsToExecute) throws Exception {
-        JobSpecification compiled = rewriteCompileQuery(metadataProvider, query, null);
-        if (compiled != null) {
-            GlobalConfig.ASTERIX_LOGGER.info(compiled.toJSON().toString(1));
-            jobsToExecute.add(compiled);
+        Pair<JobSpecification, FileSplit> compiled = rewriteCompileQuery(metadataProvider, query, null);
+        if (compiled.first != null) {
+            GlobalConfig.ASTERIX_LOGGER.info(compiled.first.toJSON().toString(1));
+            jobsToExecute.add(compiled.first);
         }
-
-        return new QueryResult(query, metadataProvider.getResultSetId());
+        return new QueryResult(query, compiled.second.getLocalFile().getFile().getAbsolutePath());
     }
 
     private void runCreateIndexJob(IHyracksClientConnection hcc, CreateIndexStatement stmtCreateIndex,
@@ -822,8 +783,7 @@
             throw new AsterixException("Failed to create job spec for creating index '"
                     + stmtCreateIndex.getDatasetName() + "." + stmtCreateIndex.getIndexName() + "'");
         }
-        JobId jobId = runJob(hcc, spec);
-        hcc.waitForCompletion(jobId);
+        runJob(hcc, spec);
     }
 
     private void handleCreateNodeGroupStatement(AqlMetadataProvider metadataProvider, Statement stmt,
@@ -846,16 +806,14 @@
         }
     }
 
-    private JobId runJob(IHyracksClientConnection hcc, JobSpecification spec) throws Exception {
-        JobId[] jobIds = executeJobArray(hcc, new Job[] { new Job(spec) }, out, pdf);
-        return jobIds[0];
+    private void runJob(IHyracksClientConnection hcc, JobSpecification spec) throws Exception {
+        executeJobArray(hcc, new Job[] { new Job(spec) }, out, pdf);
     }
 
     private void compileIndexDropStatement(IHyracksClientConnection hcc, String dataverseName, String datasetName,
             String indexName, AqlMetadataProvider metadataProvider) throws Exception {
         CompiledIndexDropStatement cds = new CompiledIndexDropStatement(dataverseName, datasetName, indexName);
-        JobId jobId = runJob(hcc, IndexOperations.buildDropSecondaryIndexJobSpec(cds, metadataProvider));
-        hcc.waitForCompletion(jobId);
+        runJob(hcc, IndexOperations.buildDropSecondaryIndexJobSpec(cds, metadataProvider));
         MetadataManager.INSTANCE.dropIndex(metadataProvider.getMetadataTxnContext(), dataverseName, datasetName,
                 indexName);
     }
@@ -867,24 +825,20 @@
         Dataset ds = MetadataManager.INSTANCE.getDataset(mdTxnCtx, dataverseName, datasetName);
         if (ds.getDatasetType() == DatasetType.INTERNAL || ds.getDatasetType() == DatasetType.FEED) {
             JobSpecification[] jobSpecs = DatasetOperations.createDropDatasetJobSpec(cds, metadataProvider);
-            for (JobSpecification spec : jobSpecs) {
-                JobId jobId = runJob(hcc, spec);
-                hcc.waitForCompletion(jobId);
-            }
+            for (JobSpecification spec : jobSpecs)
+                runJob(hcc, spec);
         }
         MetadataManager.INSTANCE.dropDataset(mdTxnCtx, dataverseName, datasetName);
     }
 
-    public JobId[] executeJobArray(IHyracksClientConnection hcc, Job[] jobs, PrintWriter out, DisplayFormat pdf)
+    public void executeJobArray(IHyracksClientConnection hcc, Job[] jobs, PrintWriter out, DisplayFormat pdf)
             throws Exception {
-        JobId[] startedJobIds = new JobId[jobs.length];
         for (int i = 0; i < jobs.length; i++) {
             JobSpecification spec = jobs[i].getJobSpec();
             spec.setMaxReattempts(0);
             JobId jobId = hcc.startJob(GlobalConfig.HYRACKS_APP_NAME, spec);
-            startedJobIds[i] = jobId;
+            hcc.waitForCompletion(jobId);
         }
-        return startedJobIds;
     }
 
     private static IDataFormat getDataFormat(MetadataTransactionContext mdTxnCtx, String dataverseName)
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/QueryResult.java b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/QueryResult.java
index 8d6b35e..0b4a2cf 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/QueryResult.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/QueryResult.java
@@ -16,35 +16,23 @@
 
 import edu.uci.ics.asterix.aql.base.Statement;
 import edu.uci.ics.asterix.aql.expression.Query;
-import edu.uci.ics.hyracks.api.dataset.ResultSetId;
-import edu.uci.ics.hyracks.api.job.JobId;
 
 public class QueryResult {
 
     private final Query query;
+    private final String resultPath;
 
-    private final ResultSetId resultSetId;
-
-    private JobId jobId;
-
-    public QueryResult(Query statement, ResultSetId resultSetId) {
+    public QueryResult(Query statement, String resultPath) {
         this.query = statement;
-        this.resultSetId = resultSetId;
-    }
-
-    public void setJobId(JobId jobId) {
-        this.jobId = jobId;
-    }
-
-    public JobId getJobId() {
-        return jobId;
+        this.resultPath = resultPath;
     }
 
     public Statement getStatement() {
         return query;
     }
 
-    public ResultSetId getResultSetId() {
-        return resultSetId;
+    public String getResultPath() {
+        return resultPath;
     }
+
 }
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCBootstrapImpl.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCBootstrapImpl.java
index 0c25e34..9b29427 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCBootstrapImpl.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCBootstrapImpl.java
@@ -23,11 +23,6 @@
 
 import edu.uci.ics.asterix.api.http.servlet.APIServlet;
 import edu.uci.ics.asterix.common.api.AsterixAppContextInfoImpl;
-import edu.uci.ics.asterix.api.http.servlet.DDLAPIServlet;
-import edu.uci.ics.asterix.api.http.servlet.QueryAPIServlet;
-import edu.uci.ics.asterix.api.http.servlet.QueryResultAPIServlet;
-import edu.uci.ics.asterix.api.http.servlet.QueryStatusAPIServlet;
-import edu.uci.ics.asterix.api.http.servlet.UpdateAPIServlet;
 import edu.uci.ics.asterix.common.config.GlobalConfig;
 import edu.uci.ics.asterix.metadata.MetadataManager;
 import edu.uci.ics.asterix.metadata.api.IAsterixStateProxy;
@@ -45,10 +40,7 @@
 
     private static final int DEFAULT_WEB_SERVER_PORT = 19001;
 
-    private static final int DEFAULT_JSON_API_SERVER_PORT = 19101;
-
     private Server webServer;
-    private Server jsonAPIServer;
     private static IAsterixStateProxy proxy;
     private ICCApplicationContext appCtx;
 
@@ -67,10 +59,6 @@
         setupWebServer();
         webServer.start();
 
-        // Setup and start the web interface
-        setupJSONAPIServer();
-        jsonAPIServer.start();
-
         AsterixAppContextInfoImpl.initialize(appCtx);
     }
 
@@ -102,22 +90,4 @@
         webServer.setHandler(context);
         context.addServlet(new ServletHolder(new APIServlet()), "/*");
     }
-
-    private void setupJSONAPIServer() throws Exception {
-        String portStr = System.getProperty(GlobalConfig.JSON_API_SERVER_PORT_PROPERTY);
-        int port = DEFAULT_JSON_API_SERVER_PORT;
-        if (portStr != null) {
-            port = Integer.parseInt(portStr);
-        }
-        jsonAPIServer = new Server(port);
-
-        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
-        context.setContextPath("/");
-        jsonAPIServer.setHandler(context);
-        context.addServlet(new ServletHolder(new QueryAPIServlet()), "/query");
-        context.addServlet(new ServletHolder(new QueryStatusAPIServlet()), "/query/status");
-        context.addServlet(new ServletHolder(new QueryResultAPIServlet()), "/query/result");
-        context.addServlet(new ServletHolder(new UpdateAPIServlet()), "/update");
-        context.addServlet(new ServletHolder(new DDLAPIServlet()), "/ddl");
-    }
-}
+}
\ No newline at end of file
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultFrameTupleAccessor.java b/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultFrameTupleAccessor.java
deleted file mode 100644
index 9d4712b0..0000000
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultFrameTupleAccessor.java
+++ /dev/null
@@ -1,97 +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.result;
-
-import java.io.DataInputStream;
-import java.nio.ByteBuffer;
-
-import edu.uci.ics.hyracks.api.comm.FrameHelper;
-import edu.uci.ics.hyracks.api.comm.IFrameTupleAccessor;
-import edu.uci.ics.hyracks.dataflow.common.comm.util.ByteBufferInputStream;
-
-public class ResultFrameTupleAccessor implements IFrameTupleAccessor {
-
-    private final int frameSize;
-    private ByteBuffer buffer;
-
-    public ResultFrameTupleAccessor(int frameSize) {
-        this.frameSize = frameSize;
-    }
-
-    @Override
-    public void reset(ByteBuffer buffer) {
-        this.buffer = buffer;
-    }
-
-    @Override
-    public ByteBuffer getBuffer() {
-        return buffer;
-    }
-
-    @Override
-    public int getTupleCount() {
-        return buffer.getInt(FrameHelper.getTupleCountOffset(frameSize));
-    }
-
-    @Override
-    public int getTupleStartOffset(int tupleIndex) {
-        return tupleIndex == 0 ? 0 : buffer.getInt(FrameHelper.getTupleCountOffset(frameSize) - 4 * tupleIndex);
-    }
-
-    @Override
-    public int getTupleEndOffset(int tupleIndex) {
-        return buffer.getInt(FrameHelper.getTupleCountOffset(frameSize) - 4 * (tupleIndex + 1));
-    }
-
-    @Override
-    public int getFieldStartOffset(int tupleIndex, int fIdx) {
-        return fIdx == 0 ? 0 : buffer.getInt(getTupleStartOffset(tupleIndex) + (fIdx - 1) * 4);
-    }
-
-    @Override
-    public int getFieldEndOffset(int tupleIndex, int fIdx) {
-        return buffer.getInt(getTupleStartOffset(tupleIndex) + fIdx * 4);
-    }
-
-    @Override
-    public int getFieldLength(int tupleIndex, int fIdx) {
-        return getFieldEndOffset(tupleIndex, fIdx) - getFieldStartOffset(tupleIndex, fIdx);
-    }
-
-    @Override
-    public int getFieldSlotsLength() {
-        return getFieldCount() * 4;
-    }
-
-    public void prettyPrint() {
-        ByteBufferInputStream bbis = new ByteBufferInputStream();
-        DataInputStream dis = new DataInputStream(bbis);
-        int tc = getTupleCount();
-        System.err.println("TC: " + tc);
-        for (int i = 0; i < tc; ++i) {
-            System.err.print(i + ":(" + getTupleStartOffset(i) + ", " + getTupleEndOffset(i) + ")[");
-
-            bbis.setByteBuffer(buffer, getTupleStartOffset(i));
-            System.err.print(dis);
-
-            System.err.println("]");
-        }
-    }
-
-    @Override
-    public int getFieldCount() {
-        return 1;
-    }
-}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultReader.java b/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultReader.java
deleted file mode 100644
index a366abd..0000000
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultReader.java
+++ /dev/null
@@ -1,65 +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.result;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
-import edu.uci.ics.hyracks.api.comm.IFrameTupleAccessor;
-import edu.uci.ics.hyracks.api.dataset.DatasetDirectoryRecord.Status;
-import edu.uci.ics.hyracks.api.dataset.IHyracksDataset;
-import edu.uci.ics.hyracks.api.dataset.ResultSetId;
-import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
-import edu.uci.ics.hyracks.api.job.JobId;
-import edu.uci.ics.hyracks.client.dataset.DatasetClientContext;
-import edu.uci.ics.hyracks.client.dataset.HyracksDataset;
-
-public class ResultReader {
-    private final DatasetClientContext datasetClientCtx;
-
-    private final IHyracksDataset hyracksDataset;
-
-    private IFrameTupleAccessor frameTupleAccessor;
-
-    // Number of parallel result reader buffers
-    private static final int NUM_READERS = 1;
-
-    // 32K buffer size;
-    public static final int FRAME_SIZE = 32768;
-
-    public ResultReader(IHyracksClientConnection hcc) throws Exception {
-        datasetClientCtx = new DatasetClientContext(FRAME_SIZE);
-        hyracksDataset = new HyracksDataset(hcc, datasetClientCtx, NUM_READERS);
-    }
-
-    public void open(JobId jobId, ResultSetId resultSetId) throws IOException, ClassNotFoundException {
-        hyracksDataset.open(jobId, resultSetId);
-
-        frameTupleAccessor = new ResultFrameTupleAccessor(datasetClientCtx.getFrameSize());
-    }
-
-    public Status getStatus() {
-        return hyracksDataset.getResultStatus();
-    }
-
-    public int read(ByteBuffer buffer) throws HyracksDataException {
-        return hyracksDataset.read(buffer);
-    }
-
-    public IFrameTupleAccessor getFrameTupleAccessor() {
-        return frameTupleAccessor;
-    }
-}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultUtils.java b/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultUtils.java
deleted file mode 100644
index e923821..0000000
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultUtils.java
+++ /dev/null
@@ -1,65 +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.result;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import edu.uci.ics.hyracks.api.comm.IFrameTupleAccessor;
-import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
-import edu.uci.ics.hyracks.dataflow.common.comm.util.ByteBufferInputStream;
-
-public class ResultUtils {
-    public static JSONArray getJSONFromBuffer(ByteBuffer buffer, IFrameTupleAccessor fta) throws HyracksDataException {
-        JSONArray resultRecords = new JSONArray();
-        ByteBufferInputStream bbis = new ByteBufferInputStream();
-
-        try {
-            fta.reset(buffer);
-            for (int tIndex = 0; tIndex < fta.getTupleCount(); tIndex++) {
-                int start = fta.getTupleStartOffset(tIndex);
-                int length = fta.getTupleEndOffset(tIndex) - start;
-                bbis.setByteBuffer(buffer, start);
-                byte[] recordBytes = new byte[length];
-                bbis.read(recordBytes, 0, length);
-                resultRecords.put(new String(recordBytes, 0, length));
-            }
-        } finally {
-            try {
-                bbis.close();
-            } catch (IOException e) {
-                throw new HyracksDataException(e);
-            }
-        }
-        return resultRecords;
-    }
-
-    public static JSONObject getErrorResponse(int errorCode, String errorMessage) {
-        JSONObject errorResp = new JSONObject();
-        JSONArray errorArray = new JSONArray();
-        errorArray.put(errorCode);
-        errorArray.put(errorMessage);
-        try {
-            errorResp.put("error-code", errorArray);
-        } catch (JSONException e) {
-            // TODO(madhusudancs): Figure out what to do when JSONException occurs while building the results.
-        }
-        return errorResp;
-    }
-}
diff --git a/asterix-app/src/main/resources/hyracks-deployment.properties b/asterix-app/src/main/resources/hyracks-deployment.properties
index a333d38..a8a943e 100644
--- a/asterix-app/src/main/resources/hyracks-deployment.properties
+++ b/asterix-app/src/main/resources/hyracks-deployment.properties
@@ -1,4 +1,2 @@
 cc.bootstrap.class=edu.uci.ics.asterix.hyracks.bootstrap.CCBootstrapImpl
-nc.bootstrap.class=edu.uci.ics.asterix.hyracks.bootstrap.NCBootstrapImpl
-cc.ip=127.0.0.1
-cc.port=1098
+nc.bootstrap.class=edu.uci.ics.asterix.hyracks.bootstrap.NCBootstrapImpl
\ No newline at end of file
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/GlobalConfig.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/GlobalConfig.java
index 91ea627..bb39f90 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/GlobalConfig.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/GlobalConfig.java
@@ -4,9 +4,9 @@
 
 public class GlobalConfig {
     public static final boolean DEBUG = true;
-
+    
     public static final String ASTERIX_LOGGER_NAME = "edu.uci.ics.asterix";
-
+    
     public static final Logger ASTERIX_LOGGER = Logger.getLogger(ASTERIX_LOGGER_NAME);
 
     public static final String ASTERIX_LOGFILE_PATTERN = "%t/asterix.log";
@@ -19,8 +19,6 @@
 
     public static final String WEB_SERVER_PORT_PROPERTY = "AsterixWebServerPort";
 
-    public static final String JSON_API_SERVER_PORT_PROPERTY = "AsterixJSONAPIServerPort";
-
     public static final String BUFFER_CACHE_PAGE_SIZE_PROPERTY = "BufferCachePageSize";
 
     public static final String BUFFER_CACHE_NUM_PAGES_PROPERTY = "BufferCacheNumPages";
@@ -34,6 +32,6 @@
     public static final String FRAME_SIZE_PROPERTY = "FrameSize";
 
     public static final float DEFAULT_BTREE_FILL_FACTOR = 1.00f;
-
+    
     public static int DEFAULT_INPUT_DATA_COLUMN = 0;
 }
diff --git a/asterix-dist/src/main/scripts/startasterix.sh b/asterix-dist/src/main/scripts/startasterix.sh
index f9d6e6c..b84834f 100644
--- a/asterix-dist/src/main/scripts/startasterix.sh
+++ b/asterix-dist/src/main/scripts/startasterix.sh
@@ -67,8 +67,8 @@
 # start the node controllers
 for ((i=1;i<=$numnc;i++)); do
 	echo "node controller (nc$i) starting..."
-	sh $HYRACKS_SERVER_BIN/hyracksnc -cc-host localhost -cluster-net-ip-address 127.0.0.1 -data-ip-address 127.0.0.1 \
-                -result-ip-address 127.0.0.1 -node-id "nc$i" &> $LOG_DIR/nc$i.log &
+	sh $HYRACKS_SERVER_BIN/hyracksnc -cc-host localhost -cluster-net-ip-address 127.0.0.1 -data-ip-address 127.0.0.1 -node-id "nc$i" \
+		&> $LOG_DIR/nc$i.log &
 
     # avoid socket error
 	sleep .5
diff --git a/asterix-hyracks-glue/pom.xml b/asterix-hyracks-glue/pom.xml
index 1a18d1c..e28b2af 100644
--- a/asterix-hyracks-glue/pom.xml
+++ b/asterix-hyracks-glue/pom.xml
@@ -19,6 +19,7 @@
 				<configuration>
 					<source>1.7</source>
 					<target>1.7</target>
+					<fork>true</fork>
 				</configuration>
 			</plugin>
 		</plugins>
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
index 7fa3659..321a73c 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
@@ -83,17 +83,14 @@
 import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenHelper;
 import edu.uci.ics.hyracks.algebricks.data.IAWriterFactory;
 import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-import edu.uci.ics.hyracks.algebricks.data.IResultSerializerFactoryProvider;
 import edu.uci.ics.hyracks.algebricks.runtime.base.IPushRuntimeFactory;
 import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
 import edu.uci.ics.hyracks.algebricks.runtime.operators.std.SinkWriterRuntimeFactory;
 import edu.uci.ics.hyracks.api.dataflow.IOperatorDescriptor;
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import edu.uci.ics.hyracks.api.dataflow.value.IResultSerializerFactory;
 import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
 import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
 import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor;
-import edu.uci.ics.hyracks.api.dataset.ResultSetId;
 import edu.uci.ics.hyracks.api.io.FileReference;
 import edu.uci.ics.hyracks.api.job.JobSpecification;
 import edu.uci.ics.hyracks.dataflow.std.file.ConstantFileSplitProvider;
@@ -101,7 +98,6 @@
 import edu.uci.ics.hyracks.dataflow.std.file.FileSplit;
 import edu.uci.ics.hyracks.dataflow.std.file.IFileSplitProvider;
 import edu.uci.ics.hyracks.dataflow.std.file.ITupleParserFactory;
-import edu.uci.ics.hyracks.dataflow.std.result.ResultWriterOperatorDescriptor;
 import edu.uci.ics.hyracks.storage.am.btree.dataflow.BTreeDataflowHelperFactory;
 import edu.uci.ics.hyracks.storage.am.btree.dataflow.BTreeSearchOperatorDescriptor;
 import edu.uci.ics.hyracks.storage.am.btree.frames.BTreeNSMInteriorFrameFactory;
@@ -124,8 +120,6 @@
     private Map<String, String> config;
     private IAWriterFactory writerFactory;
     private FileSplit outputFile;
-    private ResultSetId resultSetId;
-    private IResultSerializerFactoryProvider resultSerializerFactoryProvider;
     private long jobTxnId;
 
     private final Dataverse defaultDataverse;
@@ -190,22 +184,6 @@
         this.outputFile = outputFile;
     }
 
-    public ResultSetId getResultSetId() {
-        return resultSetId;
-    }
-
-    public void setResultSetId(ResultSetId resultSetId) {
-        this.resultSetId = resultSetId;
-    }
-
-    public void setResultSerializerFactoryProvider(IResultSerializerFactoryProvider rafp) {
-        this.resultSerializerFactoryProvider = rafp;
-    }
-
-    public IResultSerializerFactoryProvider getResultSerializerFactoryProvider() {
-        return resultSerializerFactoryProvider;
-    }
-
     @Override
     public AqlDataSource findDataSource(AqlSourceId id) throws AlgebricksException {
         AqlSourceId aqlId = (AqlSourceId) id;
@@ -564,29 +542,6 @@
     }
 
     @Override
-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getResultHandleRuntime(IDataSink sink,
-            int[] printColumns, IPrinterFactory[] printerFactories, RecordDescriptor inputDesc, boolean ordered,
-            JobSpecification spec) throws AlgebricksException {
-        ResultSetDataSink rsds = (ResultSetDataSink) sink;
-        ResultSetSinkId rssId = (ResultSetSinkId) rsds.getId();
-        ResultSetId rsId = rssId.getResultSetId();
-        String nodeName = rssId.getResultNodeName();
-
-        ResultWriterOperatorDescriptor resultWriter = null;
-        try {
-            IResultSerializerFactory resultSerializedAppenderFactory = resultSerializerFactoryProvider
-                    .getAqlResultSerializerFactoryProvider(printColumns, printerFactories, getWriterFactory(), inputDesc);
-            resultWriter = new ResultWriterOperatorDescriptor(spec, rsId, ordered, inputDesc,
-                    resultSerializedAppenderFactory);
-        } catch (IOException e) {
-            throw new AlgebricksException(e);
-        }
-
-        AlgebricksPartitionConstraint apc = new AlgebricksAbsolutePartitionConstraint(new String[] { nodeName });
-        return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(resultWriter, apc);
-    }
-
-    @Override
     public IDataSourceIndex<String, AqlSourceId> findDataSourceIndex(String indexId, AqlSourceId dataSourceId)
             throws AlgebricksException {
         AqlDataSource ads = findDataSource(dataSourceId);
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/ResultSetDataSink.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/ResultSetDataSink.java
deleted file mode 100644
index 53513d2..0000000
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/ResultSetDataSink.java
+++ /dev/null
@@ -1,46 +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.metadata.declared;
-
-import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IDataSink;
-import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPartitioningProperty;
-
-public class ResultSetDataSink implements IDataSink {
-
-    private ResultSetSinkId id;
-    private Object[] schemaTypes;
-
-    public ResultSetDataSink(ResultSetSinkId id, Object[] schemaTypes) {
-        this.id = id;
-        this.schemaTypes = schemaTypes;
-    }
-
-    @Override
-    public ResultSetSinkId getId() {
-        return id;
-    }
-
-    @Override
-    public Object[] getSchemaTypes() {
-        return schemaTypes;
-    }
-
-    @Override
-    public IPartitioningProperty getPartitioningProperty() {
-        return IPartitioningProperty.UNPARTITIONED;
-    }
-
-}
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/ResultSetSinkId.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/ResultSetSinkId.java
deleted file mode 100644
index fc5152f..0000000
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/ResultSetSinkId.java
+++ /dev/null
@@ -1,42 +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.metadata.declared;
-
-import edu.uci.ics.hyracks.api.dataset.ResultSetId;
-
-public class ResultSetSinkId {
-
-    private final ResultSetId resultSetId;
-
-    private final String resultNodeName;
-
-    public ResultSetSinkId(ResultSetId resultSetId, String resultNodeName) {
-        this.resultSetId = resultSetId;
-        this.resultNodeName = resultNodeName;
-    }
-
-    @Override
-    public String toString() {
-        return "ResultSetId: " + resultSetId + "@" + resultNodeName;
-    }
-
-    public ResultSetId getResultSetId() {
-        return resultSetId;
-    }
-
-    public String getResultNodeName() {
-        return resultNodeName;
-    }
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ABooleanPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ABooleanPrinter.java
deleted file mode 100644
index 0ae242c..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ABooleanPrinter.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class ABooleanPrinter implements IPrinter {
-
-    public static final ABooleanPrinter INSTANCE = new ABooleanPrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        ps.print(ABooleanSerializerDeserializer.getBoolean(b, s + 1));
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ABooleanPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ABooleanPrinterFactory.java
deleted file mode 100644
index e18072a..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ABooleanPrinterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class ABooleanPrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final ABooleanPrinterFactory INSTANCE = new ABooleanPrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return ABooleanPrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ACirclePrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ACirclePrinter.java
deleted file mode 100644
index 7799aaf..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ACirclePrinter.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class ACirclePrinter implements IPrinter {
-
-    public static final ACirclePrinter INSTANCE = new ACirclePrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        ps.print("{ circle: [");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
-        ps.print(", { point: [");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 9));
-        ps.print(",");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 17));
-        ps.print("]}]}");
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ACirclePrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ACirclePrinterFactory.java
deleted file mode 100644
index e406a23..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ACirclePrinterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class ACirclePrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final ACirclePrinterFactory INSTANCE = new ACirclePrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return ACirclePrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADatePrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADatePrinter.java
deleted file mode 100644
index 0486cf1..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADatePrinter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class ADatePrinter implements IPrinter {
-
-    private static long CHRONON_OF_DAY = 24 * 60 * 60 * 1000;
-    public static final ADatePrinter INSTANCE = new ADatePrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        long chrononTime = AInt32SerializerDeserializer.getInt(b, s + 1) * CHRONON_OF_DAY;
-
-        ps.print("{ date: ");
-        ps.print(chrononTime);
-        ps.print("}");
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADatePrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADatePrinterFactory.java
deleted file mode 100644
index f60a25e..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADatePrinterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class ADatePrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final ADatePrinterFactory INSTANCE = new ADatePrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return ADatePrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADateTimePrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADateTimePrinter.java
deleted file mode 100644
index 4fc3589..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADateTimePrinter.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class ADateTimePrinter implements IPrinter {
-
-    public static final ADateTimePrinter INSTANCE = new ADateTimePrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        long chrononTime = AInt64SerializerDeserializer.getLong(b, s + 1);
-
-        ps.print("{ datetime: ");
-        ps.print(chrononTime);
-        ps.print("}");
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADateTimePrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADateTimePrinterFactory.java
deleted file mode 100644
index 851fb8a..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADateTimePrinterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class ADateTimePrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final ADateTimePrinterFactory INSTANCE = new ADateTimePrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return ADateTimePrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADoublePrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADoublePrinter.java
deleted file mode 100644
index 2b977a5..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADoublePrinter.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class ADoublePrinter implements IPrinter {
-
-    public static final ADoublePrinter INSTANCE = new ADoublePrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADoublePrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADoublePrinterFactory.java
deleted file mode 100644
index 1fdb7d7..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADoublePrinterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class ADoublePrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final ADoublePrinterFactory INSTANCE = new ADoublePrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return ADoublePrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADurationPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADurationPrinter.java
deleted file mode 100644
index 877c00e..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADurationPrinter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class ADurationPrinter implements IPrinter {
-
-    public static final ADurationPrinter INSTANCE = new ADurationPrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        int months = AInt32SerializerDeserializer.getInt(b, s + 1);
-        long milliseconds = AInt64SerializerDeserializer.getLong(b, s + 5);
-
-        ps.print("{ duration: {");
-        ps.print("months: ");
-        ps.print(months);
-        ps.print("millis: ");
-        ps.print(milliseconds);
-        ps.print("}}");
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADurationPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADurationPrinterFactory.java
deleted file mode 100644
index c0b68db..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ADurationPrinterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class ADurationPrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final ADurationPrinterFactory INSTANCE = new ADurationPrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return ADurationPrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AFloatPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AFloatPrinter.java
deleted file mode 100644
index a941043..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AFloatPrinter.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class AFloatPrinter implements IPrinter {
-
-    public static final AFloatPrinter INSTANCE = new AFloatPrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        ps.print(AFloatSerializerDeserializer.getFloat(b, s + 1));
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AFloatPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AFloatPrinterFactory.java
deleted file mode 100644
index 5285daa..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AFloatPrinterFactory.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-
-
-public class AFloatPrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final AFloatPrinterFactory INSTANCE = new AFloatPrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return AFloatPrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt16Printer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt16Printer.java
deleted file mode 100644
index 03dfcdc..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt16Printer.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class AInt16Printer implements IPrinter {
-    public static final AInt16Printer INSTANCE = new AInt16Printer();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        short i = AInt16SerializerDeserializer.getShort(b, s + 1);
-
-        ps.println("{ int16: ");
-        ps.println(i);
-        ps.println("}");
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt16PrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt16PrinterFactory.java
deleted file mode 100644
index c890b19..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt16PrinterFactory.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-
-
-public class AInt16PrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final AInt16PrinterFactory INSTANCE = new AInt16PrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return AInt16Printer.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt32Printer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt32Printer.java
deleted file mode 100644
index 9c3cf42..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt32Printer.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class AInt32Printer implements IPrinter {
-
-    public static final AInt32Printer INSTANCE = new AInt32Printer();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        int d = AInt32SerializerDeserializer.getInt(b, s + 1);
-
-        ps.println("{ int32: ");
-        ps.println(d);
-        ps.println("}");
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt32PrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt32PrinterFactory.java
deleted file mode 100644
index 6026424..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt32PrinterFactory.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-
-
-public class AInt32PrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final AInt32PrinterFactory INSTANCE = new AInt32PrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return AInt32Printer.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt64Printer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt64Printer.java
deleted file mode 100644
index afb690e..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt64Printer.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class AInt64Printer implements IPrinter {
-    public static final AInt64Printer INSTANCE = new AInt64Printer();
-
-    @Override
-    public void init() {
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        long d = AInt64SerializerDeserializer.getLong(b, s + 1);
-        ps.println("{ int64: ");
-        ps.println(d);
-        ps.println("}");
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt64PrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt64PrinterFactory.java
deleted file mode 100644
index e7e59a7..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt64PrinterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class AInt64PrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final AInt64PrinterFactory INSTANCE = new AInt64PrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return AInt64Printer.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt8Printer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt8Printer.java
deleted file mode 100644
index 9890b2e..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt8Printer.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class AInt8Printer implements IPrinter {
-
-    public static final AInt8Printer INSTANCE = new AInt8Printer();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        byte o = AInt8SerializerDeserializer.getByte(b, s + 1);
-
-        ps.println("{ int8: ");
-        ps.println(o);
-        ps.println("}");
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt8PrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt8PrinterFactory.java
deleted file mode 100644
index c9b1155..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AInt8PrinterFactory.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-
-
-public class AInt8PrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final AInt8PrinterFactory INSTANCE = new AInt8PrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return AInt8Printer.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ALinePrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ALinePrinter.java
deleted file mode 100644
index c088904..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ALinePrinter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class ALinePrinter implements IPrinter {
-
-    public static final ALinePrinter INSTANCE = new ALinePrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        ps.print("{ line: ");
-        ps.print(" [{ point: [");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
-        ps.print(", ");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 9));
-        ps.print("]}, { point: [");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 17));
-        ps.print(", ");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
-        ps.print("]}]}");
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ALinePrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ALinePrinterFactory.java
deleted file mode 100644
index 072bdd0..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ALinePrinterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class ALinePrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final ALinePrinterFactory INSTANCE = new ALinePrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return ALinePrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ANullPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ANullPrinter.java
deleted file mode 100644
index a80eec6..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ANullPrinter.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class ANullPrinter implements IPrinter {
-
-    public static final ANullPrinter INSTANCE = new ANullPrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        ps.print("null");
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ANullPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ANullPrinterFactory.java
deleted file mode 100644
index 3184260..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ANullPrinterFactory.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-
-
-public class ANullPrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final ANullPrinterFactory INSTANCE = new ANullPrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return ANullPrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ANullableFieldPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ANullableFieldPrinterFactory.java
deleted file mode 100644
index e2631b0..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ANullableFieldPrinterFactory.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.formats.nontagged.AqlJSONPrinterFactoryProvider;
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.AUnionType;
-import edu.uci.ics.asterix.om.types.BuiltinType;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class ANullableFieldPrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-
-    private AUnionType unionType;
-
-    public ANullableFieldPrinterFactory(AUnionType unionType) {
-        this.unionType = unionType;
-    }
-
-    @Override
-    public IPrinter createPrinter() {
-        return new IPrinter() {
-            private IPrinter nullPrinter;
-            private IPrinter fieldPrinter;
-
-            @Override
-            public void init() throws AlgebricksException {
-                nullPrinter = (AqlJSONPrinterFactoryProvider.INSTANCE.getPrinterFactory(BuiltinType.ANULL))
-                        .createPrinter();
-                fieldPrinter = (AqlJSONPrinterFactoryProvider.INSTANCE.getPrinterFactory(unionType.getUnionList()
-                        .get(1))).createPrinter();
-            }
-
-            @Override
-            public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-                fieldPrinter.init();
-                if (b[s] == ATypeTag.NULL.serialize())
-                    nullPrinter.print(b, s, l, ps);
-                else
-                    fieldPrinter.print(b, s, l, ps);
-            }
-
-        };
-    }
-
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AObjectPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AObjectPrinter.java
deleted file mode 100644
index 29c4ee1..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AObjectPrinter.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.EnumDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.NotImplementedException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class AObjectPrinter implements IPrinter {
-
-    public static final AObjectPrinter INSTANCE = new AObjectPrinter();
-
-    private IPrinter recordPrinter = new ARecordPrinterFactory(null).createPrinter();
-    private IPrinter orderedlistPrinter = new AOrderedlistPrinterFactory(null).createPrinter();
-    private IPrinter unorderedListPrinter = new AUnorderedlistPrinterFactory(null).createPrinter();
-
-    @Override
-    public void init() throws AlgebricksException {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(b[s]);
-        switch (typeTag) {
-            case INT8: {
-                AInt8Printer.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case INT16: {
-                AInt16Printer.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case INT32: {
-                AInt32Printer.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case INT64: {
-                AInt64Printer.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case NULL: {
-                ANullPrinter.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case BOOLEAN: {
-                ABooleanPrinter.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case FLOAT: {
-                AFloatPrinter.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case DOUBLE: {
-                ADoublePrinter.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case DATE: {
-                ADatePrinter.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case TIME: {
-                ATimePrinter.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case DATETIME: {
-                ADateTimePrinter.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case DURATION: {
-                ADurationPrinter.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case POINT: {
-                APointPrinter.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case POINT3D: {
-                APoint3DPrinter.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case LINE: {
-                ALinePrinter.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case POLYGON: {
-                APolygonPrinter.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case CIRCLE: {
-                ACirclePrinter.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case STRING: {
-                AStringPrinter.INSTANCE.print(b, s, l, ps);
-                break;
-            }
-            case RECORD: {
-                this.recordPrinter.init();
-                recordPrinter.print(b, s, l, ps);
-                break;
-            }
-            case ORDEREDLIST: {
-                this.orderedlistPrinter.init();
-                orderedlistPrinter.print(b, s, l, ps);
-                break;
-            }
-            case UNORDEREDLIST: {
-                this.unorderedListPrinter.init();
-                unorderedListPrinter.print(b, s, l, ps);
-                break;
-            }
-            default: {
-                throw new NotImplementedException("No printer for type " + typeTag);
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AObjectPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AObjectPrinterFactory.java
deleted file mode 100644
index 1c2ba77..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AObjectPrinterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class AObjectPrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final AObjectPrinterFactory INSTANCE = new AObjectPrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return AObjectPrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AOrderedlistPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AOrderedlistPrinterFactory.java
deleted file mode 100644
index b95a072..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AOrderedlistPrinterFactory.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.om.pointables.PointableAllocator;
-import edu.uci.ics.asterix.om.pointables.base.DefaultOpenFieldType;
-import edu.uci.ics.asterix.om.pointables.base.IVisitablePointable;
-import edu.uci.ics.asterix.om.pointables.printer.json.APrintVisitor;
-import edu.uci.ics.asterix.om.types.AOrderedListType;
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.IAType;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.common.utils.Pair;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class AOrderedlistPrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    private AOrderedListType orderedlistType;
-
-    public AOrderedlistPrinterFactory(AOrderedListType orderedlistType) {
-        this.orderedlistType = orderedlistType;
-    }
-
-    @Override
-    public IPrinter createPrinter() {
-
-        PointableAllocator allocator = new PointableAllocator();
-        final IAType inputType = orderedlistType == null ? DefaultOpenFieldType
-                .getDefaultOpenFieldType(ATypeTag.ORDEREDLIST) : orderedlistType;
-        final IVisitablePointable listAccessor = allocator.allocateListValue(inputType);
-        final APrintVisitor printVisitor = new APrintVisitor();
-        final Pair<PrintStream, ATypeTag> arg = new Pair<PrintStream, ATypeTag>(null, null);
-
-        return new IPrinter() {
-
-            @Override
-            public void init() throws AlgebricksException {
-                arg.second = inputType.getTypeTag();
-            }
-
-            @Override
-            public void print(byte[] b, int start, int l, PrintStream ps) throws AlgebricksException {
-                try {
-                    listAccessor.set(b, start, l);
-                    arg.first = ps;
-                    listAccessor.accept(printVisitor, arg);
-                } catch (Exception ioe) {
-                    throw new AlgebricksException(ioe);
-                }
-            }
-        };
-    }
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APoint3DPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APoint3DPrinter.java
deleted file mode 100644
index 873ee61..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APoint3DPrinter.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class APoint3DPrinter implements IPrinter {
-
-    public static final APoint3DPrinter INSTANCE = new APoint3DPrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        ps.print("{ point3d: [");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
-        ps.print(", ");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 9));
-        ps.print(", ");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 17));
-        ps.print("]}");
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APoint3DPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APoint3DPrinterFactory.java
deleted file mode 100644
index 7105ad3..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APoint3DPrinterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class APoint3DPrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final APoint3DPrinterFactory INSTANCE = new APoint3DPrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return APoint3DPrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APointPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APointPrinter.java
deleted file mode 100644
index aad4758..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APointPrinter.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class APointPrinter implements IPrinter {
-
-    public static final APointPrinter INSTANCE = new APointPrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        ps.print("{ point: [");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
-        ps.print(", ");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 9));
-        ps.print("]}");
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APointPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APointPrinterFactory.java
deleted file mode 100644
index 36a9bf3..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APointPrinterFactory.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-
-public class APointPrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final APointPrinterFactory INSTANCE = new APointPrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return APointPrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APolygonPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APolygonPrinter.java
deleted file mode 100644
index 23eef9d..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APolygonPrinter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class APolygonPrinter implements IPrinter {
-
-    public static final APolygonPrinter INSTANCE = new APolygonPrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        short numberOfPoints = AInt16SerializerDeserializer.getShort(b, s + 1);
-        s += 3;
-
-        ps.print("{ polygon: [");
-
-        for (int i = 0; i < numberOfPoints; i++) {
-            if (i > 0)
-                ps.print(",");
-
-            ps.print("{ point: [");
-            ps.print(ADoubleSerializerDeserializer.getDouble(b, s));
-            ps.print(",");
-            ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 8));
-            ps.print("]}");
-
-            s += 16;
-        }
-
-        ps.print("]}");
-
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APolygonPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APolygonPrinterFactory.java
deleted file mode 100644
index 74c54d0..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/APolygonPrinterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class APolygonPrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final APolygonPrinterFactory INSTANCE = new APolygonPrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return APolygonPrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ARecordPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ARecordPrinterFactory.java
deleted file mode 100644
index ca0597c..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ARecordPrinterFactory.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.om.pointables.PointableAllocator;
-import edu.uci.ics.asterix.om.pointables.base.DefaultOpenFieldType;
-import edu.uci.ics.asterix.om.pointables.base.IVisitablePointable;
-import edu.uci.ics.asterix.om.pointables.printer.json.APrintVisitor;
-import edu.uci.ics.asterix.om.types.ARecordType;
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.IAType;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.common.utils.Pair;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class ARecordPrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    private final ARecordType recType;
-
-    public ARecordPrinterFactory(ARecordType recType) {
-        this.recType = recType;
-    }
-
-    @Override
-    public IPrinter createPrinter() {
-
-        PointableAllocator allocator = new PointableAllocator();
-        final IAType inputType = recType == null ? DefaultOpenFieldType.getDefaultOpenFieldType(ATypeTag.RECORD)
-                : recType;
-        final IVisitablePointable recAccessor = allocator.allocateRecordValue(inputType);
-        final APrintVisitor printVisitor = new APrintVisitor();
-        final Pair<PrintStream, ATypeTag> arg = new Pair<PrintStream, ATypeTag>(null, null);
-
-        return new IPrinter() {
-
-            @Override
-            public void init() throws AlgebricksException {
-                arg.second = inputType.getTypeTag();
-            }
-
-            @Override
-            public void print(byte[] b, int start, int l, PrintStream ps) throws AlgebricksException {
-                try {
-                    recAccessor.set(b, start, l);
-                    arg.first = ps;
-                    recAccessor.accept(printVisitor, arg);
-                } catch (Exception ioe) {
-                    throw new AlgebricksException(ioe);
-                }
-            }
-        };
-    }
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ARectanglePrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ARectanglePrinter.java
deleted file mode 100644
index e54b73b..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ARectanglePrinter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class ARectanglePrinter implements IPrinter {
-
-    public static final ARectanglePrinter INSTANCE = new ARectanglePrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        ps.print("{ rectangle: [");
-        ps.print("{ point: [");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
-        ps.print(", ");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 9));
-        ps.print("]}, { point: [");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 17));
-        ps.print(", ");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
-        ps.print("]}]}");
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ARectanglePrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ARectanglePrinterFactory.java
deleted file mode 100644
index 51f6f21..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ARectanglePrinterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class ARectanglePrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final ARectanglePrinterFactory INSTANCE = new ARectanglePrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return ARectanglePrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AStringPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AStringPrinter.java
deleted file mode 100644
index c7828fc..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AStringPrinter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.utils.WriteValueTools;
-
-public class AStringPrinter implements IPrinter {
-
-    public static final AStringPrinter INSTANCE = new AStringPrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        try {
-            WriteValueTools.writeUTF8String(b, s + 1, l - 1, ps);
-        } catch (IOException e) {
-            throw new AlgebricksException(e);
-        }
-    }
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AStringPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AStringPrinterFactory.java
deleted file mode 100644
index 9d76f35..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AStringPrinterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class AStringPrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final AStringPrinterFactory INSTANCE = new AStringPrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return AStringPrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ATimePrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ATimePrinter.java
deleted file mode 100644
index 53fad9f..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ATimePrinter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-
-public class ATimePrinter implements IPrinter {
-
-    public static final ATimePrinter INSTANCE = new ATimePrinter();
-
-    @Override
-    public void init() {
-
-    }
-
-    @Override
-    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        int time = AInt32SerializerDeserializer.getInt(b, s + 1);
-
-        ps.print("{ time: ");
-        ps.print(time);
-        ps.print("}");
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ATimePrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ATimePrinterFactory.java
deleted file mode 100644
index 8f05c69..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/ATimePrinterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class ATimePrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final ATimePrinterFactory INSTANCE = new ATimePrinterFactory();
-
-    @Override
-    public IPrinter createPrinter() {
-        return ATimePrinter.INSTANCE;
-    }
-
-}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AUnionPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AUnionPrinterFactory.java
deleted file mode 100644
index 393ad63..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AUnionPrinterFactory.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-import java.util.List;
-
-import edu.uci.ics.asterix.formats.nontagged.AqlJSONPrinterFactoryProvider;
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.AUnionType;
-import edu.uci.ics.asterix.om.types.IAType;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class AUnionPrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-
-    private AUnionType unionType;
-
-    public AUnionPrinterFactory(AUnionType unionType) {
-        this.unionType = unionType;
-    }
-
-    @Override
-    public IPrinter createPrinter() {
-
-        return new IPrinter() {
-
-            private IPrinter[] printers;
-            private List<IAType> unionList;
-
-            @Override
-            public void init() throws AlgebricksException {
-                unionList = unionType.getUnionList();
-                printers = new IPrinter[unionType.getUnionList().size()];
-                for (int i = 0; i < printers.length; i++) {
-                    printers[i] = (AqlJSONPrinterFactoryProvider.INSTANCE
-                            .getPrinterFactory(unionType.getUnionList().get(i))).createPrinter();
-                    printers[i].init();
-                }
-            }
-
-            @Override
-            public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-                ATypeTag tag = unionList.get(b[s + 1]).getTypeTag();
-                if (tag == ATypeTag.UNION)
-                    printers[b[s + 1]].print(b, s + 1, l, ps);
-                else {
-                    if (tag == ATypeTag.ANY)
-                        printers[b[s + 1]].print(b, s + 2, l, ps);
-                    else
-                        printers[b[s + 1]].print(b, s + 1, l, ps);
-                }
-            }
-        };
-    }
-
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AUnorderedlistPrinterFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AUnorderedlistPrinterFactory.java
deleted file mode 100644
index 9e1bdda..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/json/AUnorderedlistPrinterFactory.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package edu.uci.ics.asterix.dataflow.data.nontagged.printers.json;
-
-import java.io.PrintStream;
-
-import edu.uci.ics.asterix.om.pointables.PointableAllocator;
-import edu.uci.ics.asterix.om.pointables.base.DefaultOpenFieldType;
-import edu.uci.ics.asterix.om.pointables.base.IVisitablePointable;
-import edu.uci.ics.asterix.om.pointables.printer.json.APrintVisitor;
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.AUnorderedListType;
-import edu.uci.ics.asterix.om.types.IAType;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.common.utils.Pair;
-import edu.uci.ics.hyracks.algebricks.data.IPrinter;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-
-public class AUnorderedlistPrinterFactory implements IPrinterFactory {
-
-    private static final long serialVersionUID = 1L;
-    private AUnorderedListType unorderedlistType;
-
-    public AUnorderedlistPrinterFactory(AUnorderedListType unorderedlistType) {
-        this.unorderedlistType = unorderedlistType;
-    }
-
-    @Override
-    public IPrinter createPrinter() {
-
-        PointableAllocator allocator = new PointableAllocator();
-        final IAType inputType = unorderedlistType == null ? DefaultOpenFieldType
-                .getDefaultOpenFieldType(ATypeTag.UNORDEREDLIST) : unorderedlistType;
-        final IVisitablePointable listAccessor = allocator.allocateListValue(inputType);
-        final APrintVisitor printVisitor = new APrintVisitor();
-        final Pair<PrintStream, ATypeTag> arg = new Pair<PrintStream, ATypeTag>(null, null);
-
-        return new IPrinter() {
-
-            @Override
-            public void init() throws AlgebricksException {
-                arg.second = inputType.getTypeTag();
-            }
-
-            @Override
-            public void print(byte[] b, int start, int l, PrintStream ps) throws AlgebricksException {
-                try {
-                    listAccessor.set(b, start, l);
-                    arg.first = ps;
-                    listAccessor.accept(printVisitor, arg);
-                } catch (Exception ioe) {
-                    throw new AlgebricksException(ioe);
-                }
-            }
-        };
-    }
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/base/IDataFormat.java b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/base/IDataFormat.java
index 11f65dc..813c3a0 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/base/IDataFormat.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/base/IDataFormat.java
@@ -41,8 +41,6 @@
 
     public IPrinterFactoryProvider getPrinterFactoryProvider();
 
-    public IPrinterFactoryProvider getJSONPrinterFactoryProvider();
-
     public INullWriterFactory getNullWriterFactory();
 
     public Triple<ICopyEvaluatorFactory, ScalarFunctionCallExpression, IAType> partitioningEvaluatorFactory(
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlJSONPrinterFactoryProvider.java b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlJSONPrinterFactoryProvider.java
deleted file mode 100644
index b8c6ab0..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlJSONPrinterFactoryProvider.java
+++ /dev/null
@@ -1,123 +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.formats.nontagged;
-
-
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ABooleanPrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ACirclePrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADatePrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADateTimePrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADoublePrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADurationPrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AFloatPrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AInt16PrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AInt32PrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AInt64PrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AInt8PrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ALinePrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ANullPrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ANullableFieldPrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AObjectPrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AOrderedlistPrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.APoint3DPrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.APointPrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.APolygonPrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ARecordPrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ARectanglePrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AStringPrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ATimePrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AUnionPrinterFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AUnorderedlistPrinterFactory;
-import edu.uci.ics.asterix.om.types.AOrderedListType;
-import edu.uci.ics.asterix.om.types.ARecordType;
-import edu.uci.ics.asterix.om.types.AUnionType;
-import edu.uci.ics.asterix.om.types.AUnorderedListType;
-import edu.uci.ics.asterix.om.types.IAType;
-import edu.uci.ics.asterix.om.util.NonTaggedFormatUtil;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactoryProvider;
-
-public class AqlJSONPrinterFactoryProvider implements IPrinterFactoryProvider {
-
-    public static final AqlJSONPrinterFactoryProvider INSTANCE = new AqlJSONPrinterFactoryProvider();
-
-    private AqlJSONPrinterFactoryProvider() {
-    }
-
-    @Override
-    public IPrinterFactory getPrinterFactory(Object type) throws AlgebricksException {
-        IAType aqlType = (IAType) type;
-
-        if (aqlType != null) {
-            switch (aqlType.getTypeTag()) {
-                // case ANYTYPE:
-                // return AAnyTypePrinterFactory.INSTANCE;
-                case INT8:
-                    return AInt8PrinterFactory.INSTANCE;
-                case INT16:
-                    return AInt16PrinterFactory.INSTANCE;
-                case INT32:
-                    return AInt32PrinterFactory.INSTANCE;
-                case INT64:
-                    return AInt64PrinterFactory.INSTANCE;
-                case NULL:
-                    return ANullPrinterFactory.INSTANCE;
-                case BOOLEAN:
-                    return ABooleanPrinterFactory.INSTANCE;
-                case FLOAT:
-                    return AFloatPrinterFactory.INSTANCE;
-                case DOUBLE:
-                    return ADoublePrinterFactory.INSTANCE;
-                case TIME:
-                    return ATimePrinterFactory.INSTANCE;
-                case DATE:
-                    return ADatePrinterFactory.INSTANCE;
-                case DATETIME:
-                    return ADateTimePrinterFactory.INSTANCE;
-                case DURATION:
-                    return ADurationPrinterFactory.INSTANCE;
-                case POINT:
-                    return APointPrinterFactory.INSTANCE;
-                case POINT3D:
-                    return APoint3DPrinterFactory.INSTANCE;
-                case LINE:
-                    return ALinePrinterFactory.INSTANCE;
-                case POLYGON:
-                    return APolygonPrinterFactory.INSTANCE;
-                case CIRCLE:
-                    return ACirclePrinterFactory.INSTANCE;
-                case RECTANGLE:
-                    return ARectanglePrinterFactory.INSTANCE;
-                case STRING:
-                    return AStringPrinterFactory.INSTANCE;
-                case RECORD:
-                    return new ARecordPrinterFactory((ARecordType) aqlType);
-                case ORDEREDLIST:
-                    return new AOrderedlistPrinterFactory((AOrderedListType) aqlType);
-                case UNORDEREDLIST:
-                    return new AUnorderedlistPrinterFactory((AUnorderedListType) aqlType);
-                case UNION: {
-                    if (NonTaggedFormatUtil.isOptionalField((AUnionType) aqlType))
-                        return new ANullableFieldPrinterFactory((AUnionType) aqlType);
-                    else
-                        return new AUnionPrinterFactory((AUnionType) aqlType);
-                }
-            }
-        }
-        return AObjectPrinterFactory.INSTANCE;
-
-    }
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlResultSerializerFactoryProvider.java b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlResultSerializerFactoryProvider.java
deleted file mode 100644
index 4be608a..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlResultSerializerFactoryProvider.java
+++ /dev/null
@@ -1,78 +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.formats.nontagged;
-
-import java.io.PrintStream;
-import java.nio.BufferOverflowException;
-
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.data.IAWriter;
-import edu.uci.ics.hyracks.algebricks.data.IAWriterFactory;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-import edu.uci.ics.hyracks.algebricks.data.IResultSerializerFactoryProvider;
-import edu.uci.ics.hyracks.api.comm.IFrameTupleAccessor;
-import edu.uci.ics.hyracks.api.dataflow.value.IResultSerializer;
-import edu.uci.ics.hyracks.api.dataflow.value.IResultSerializerFactory;
-import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor;
-import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
-
-public class AqlResultSerializerFactoryProvider implements IResultSerializerFactoryProvider {
-    private static final long serialVersionUID = 1L;
-
-    public static final AqlResultSerializerFactoryProvider INSTANCE = new AqlResultSerializerFactoryProvider();
-
-    private AqlResultSerializerFactoryProvider() {
-    }
-
-    @Override
-    public IResultSerializerFactory getAqlResultSerializerFactoryProvider(final int[] fields,
-            final IPrinterFactory[] printerFactories, final IAWriterFactory writerFactory,
-            final RecordDescriptor inputRecordDesc) {
-        return new IResultSerializerFactory() {
-            private static final long serialVersionUID = 1L;
-
-            @Override
-            public IResultSerializer createResultSerializer(PrintStream printStream) {
-                final IAWriter writer = writerFactory.createWriter(fields, printStream, printerFactories,
-                        inputRecordDesc);
-
-                return new IResultSerializer() {
-                    private static final long serialVersionUID = 1L;
-
-                    @Override
-                    public void init() throws HyracksDataException {
-                        try {
-                            writer.init();
-                        } catch (AlgebricksException e) {
-                            throw new HyracksDataException(e);
-                        }
-                    }
-
-                    @Override
-                    public boolean appendTuple(IFrameTupleAccessor tAccess, int tIdx) throws HyracksDataException {
-                        try {
-                            writer.printTuple(tAccess, tIdx);
-                        } catch (BufferOverflowException e) {
-                            return false;
-                        } catch (AlgebricksException e) {
-                            throw new HyracksDataException(e);
-                        }
-                        return true;
-                    }
-                };
-            }
-        };
-    }
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ABinary.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ABinary.java
index 47e23fc..db9ac03 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ABinary.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ABinary.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -77,13 +74,4 @@
     public String toString() {
         return "ABinary";
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        json.put("ABinary", bytes);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ABitArray.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ABitArray.java
index a27b05e..4178b5a 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ABitArray.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ABitArray.java
@@ -14,10 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -133,17 +129,4 @@
         sb.append(" ]");
         return sb.toString();
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        JSONArray bitArray = new JSONArray();
-        for (int i = 0; i < intArray.length; i++) {
-            bitArray.put(intArray[i]);
-        }
-        json.put("ABitArray", bitArray);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ABoolean.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ABoolean.java
index 85c35b6..11b223a 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ABoolean.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ABoolean.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -74,13 +71,4 @@
     public int hash() {
         return bVal.hashCode();
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        json.put("ABoolean", bVal);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ACircle.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ACircle.java
index c7d946c..767f172 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ACircle.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ACircle.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -76,16 +73,4 @@
     public String toString() {
         return "ACircle: { center: " + center + ", radius: " + radius + "}";
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        JSONObject circle = new JSONObject();
-        circle.put("center", center);
-        circle.put("radius", radius);
-        json.put("ACircle", circle);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADate.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADate.java
index 0ef170e..097b736 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADate.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADate.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
 import edu.uci.ics.asterix.om.types.BuiltinType;
@@ -85,13 +82,4 @@
     public int getChrononTimeInDays() {
         return chrononTimeInDay;
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        json.put("ADate", chrononTimeInDay);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADateTime.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADateTime.java
index 081fa63..e72fd8f 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADateTime.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADateTime.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
 import edu.uci.ics.asterix.om.types.BuiltinType;
@@ -116,12 +113,4 @@
         return chrononTime;
     }
 
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        json.put("ADateTime", chrononTime);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADouble.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADouble.java
index 582e192..816b8be 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADouble.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADouble.java
@@ -14,9 +14,6 @@
  */

 package edu.uci.ics.asterix.om.base;

 

-import org.json.JSONException;

-import org.json.JSONObject;

-

 import edu.uci.ics.asterix.common.exceptions.AsterixException;

 import edu.uci.ics.asterix.om.types.BuiltinType;

 import edu.uci.ics.asterix.om.types.IAType;

@@ -73,12 +70,4 @@
         return hashCode();

     }

 

-    @Override

-    public JSONObject toJSON() throws JSONException {

-        JSONObject json = new JSONObject();

-

-        json.put("ADouble", value);

-

-        return json;

-    }

 }

diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADuration.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADuration.java
index 113751f..13f4a05 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADuration.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADuration.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
 import edu.uci.ics.asterix.om.types.BuiltinType;
@@ -112,15 +109,4 @@
         return sbder.toString();
     }
 
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        JSONObject duration = new JSONObject();
-        duration.put("months", chrononInMonth);
-        duration.put("milliseconds", chrononInMillisecond);
-        json.put("ADuration", duration);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AFloat.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AFloat.java
index 9804eb3..a66e198 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AFloat.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AFloat.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -72,13 +69,4 @@
     public String toString() {
         return "AFloat: {" + value + "}";
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        json.put("AFloat", value);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt16.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt16.java
index 2be714d..bd27f20 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt16.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt16.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -62,13 +59,4 @@
     public String toString() {
         return "AInt16: {" + value + "}";
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        json.put("AInt16", value);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt32.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt32.java
index 640bc0e..b656a57 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt32.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt32.java
@@ -14,9 +14,6 @@
  */

 package edu.uci.ics.asterix.om.base;

 

-import org.json.JSONException;

-import org.json.JSONObject;

-

 import edu.uci.ics.asterix.common.exceptions.AsterixException;

 import edu.uci.ics.asterix.om.types.BuiltinType;

 import edu.uci.ics.asterix.om.types.IAType;

@@ -87,13 +84,4 @@
     public int hash() {

         return hashCode();

     }

-

-    @Override

-    public JSONObject toJSON() throws JSONException {

-        JSONObject json = new JSONObject();

-

-        json.put("AInt32", value);

-

-        return json;

-    }

-}

+}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt64.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt64.java
index 769d492..193a4af 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt64.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt64.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -61,13 +58,4 @@
     public String toString() {
         return "AInt64: {" + value + "}";
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        json.put("AInt64", value);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt8.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt8.java
index 90135a3..87e5472 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt8.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInt8.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -61,13 +58,4 @@
     public String toString() {
         return "AInt8: {" + value + "}";
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        json.put("AInt8", value);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInterval.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInterval.java
index ff36b75..66a587a 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInterval.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AInterval.java
@@ -14,8 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
 import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -143,12 +141,4 @@
         return typetag;
     }
 
-    @Override
-    public JSONObject toJSON() {
-        /*
-         * TODO(madhusudancs): Stub implementation of toJSON method, this method should be removed in favor of new JSON
-         * print visitor based serializer.
-         */
-        return null;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ALine.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ALine.java
index dc420ed..0285825 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ALine.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ALine.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -69,16 +66,4 @@
     public String toString() {
         return "ALine: { p1: " + p1 + ", p2: " + p2 + "}";
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        JSONObject line = new JSONObject();
-        line.put("p1", p1);
-        line.put("p2", p2);
-        json.put("ALine", line);
-
-        return json;
-    }
 }
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ANull.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ANull.java
index baaa00a..be47b41 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ANull.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ANull.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -55,13 +52,4 @@
     public String toString() {
         return "null";
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        json.put("ANull", "null");
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AOrderedList.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AOrderedList.java
index 36a92f3..4f5effd 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AOrderedList.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AOrderedList.java
@@ -16,10 +16,6 @@
 
 import java.util.ArrayList;
 
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.AOrderedListType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -111,17 +107,4 @@
         sb.append(" ]");
         return sb.toString();
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        JSONArray list = new JSONArray();
-        for (IAObject v : values) {
-            list.put(v.toJSON());
-        }
-        json.put("AOrderedList", list);
-
-        return json;
-    }
 }
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/APoint.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/APoint.java
index 8bb44eb..8e261a2 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/APoint.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/APoint.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -69,16 +66,4 @@
     public String toString() {
         return "APoint: { x: " + x + ", y: " + y + " }";
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        JSONObject point = new JSONObject();
-        point.put("x", x);
-        point.put("y", y);
-        json.put("APoint", point);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/APoint3D.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/APoint3D.java
index d15139a..29ef6cd 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/APoint3D.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/APoint3D.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -75,17 +72,4 @@
     public String toString() {
         return "APoint3D: { x: " + x + ", y: " + y + ", z: " + z + " }";
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        JSONObject point = new JSONObject();
-        point.put("x", x);
-        point.put("y", y);
-        point.put("z", z);
-        json.put("APoint3D", point);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/APolygon.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/APolygon.java
index ed21378..29e3727 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/APolygon.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/APolygon.java
@@ -14,10 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -89,17 +85,4 @@
         sb.append(" ]");
         return sb.toString();
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        JSONArray polygon = new JSONArray();
-        for (int i = 0; i < points.length; i++) {
-            polygon.put(points[i].toJSON());
-        }
-        json.put("APolygon", polygon);
-
-        return json;
-    }
 }
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ARecord.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ARecord.java
index 0035289..0d1f578 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ARecord.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ARecord.java
@@ -14,10 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.asterix.om.visitors.IOMVisitor;
@@ -91,19 +87,4 @@
         sb.append(" }");
         return sb.toString();
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        JSONArray record = new JSONArray();
-        for (int i = 0; i < fields.length; i++) {
-            JSONObject item = new JSONObject();
-            item.put(type.getFieldNames()[i], fields[i]);
-            record.put(item);
-        }
-        json.put("ARecord", record);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ARectangle.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ARectangle.java
index d82d351..51f06bf 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ARectangle.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ARectangle.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -69,16 +66,4 @@
     public String toString() {
         return "ARectangle: { p1: " + p1 + ", p2: " + p2 + "}";
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        JSONObject rectangle = new JSONObject();
-        rectangle.put("p1", p1);
-        rectangle.put("p2", p2);
-        json.put("ARectangle", rectangle);
-
-        return json;
-    }
 }
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AString.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AString.java
index b1f2550..0f7c9c2 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AString.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AString.java
@@ -14,9 +14,6 @@
  */

 package edu.uci.ics.asterix.om.base;

 

-import org.json.JSONException;

-import org.json.JSONObject;

-

 import edu.uci.ics.asterix.common.exceptions.AsterixException;

 import edu.uci.ics.asterix.om.types.BuiltinType;

 import edu.uci.ics.asterix.om.types.IAType;

@@ -70,13 +67,4 @@
     public int hash() {

         return hashCode();

     }

-

-    @Override

-    public JSONObject toJSON() throws JSONException {

-        JSONObject json = new JSONObject();

-

-        json.put("AString", value);

-

-        return json;

-    }

 }

diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ATime.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ATime.java
index b97ed51..7b66cf9 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ATime.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ATime.java
@@ -14,9 +14,6 @@
  */
 package edu.uci.ics.asterix.om.base;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
 import edu.uci.ics.asterix.om.types.BuiltinType;
@@ -101,12 +98,4 @@
         return chrononTime;
     }
 
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        json.put("ATime", chrononTime);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AUnorderedList.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AUnorderedList.java
index 459ccf5..764d05b 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AUnorderedList.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AUnorderedList.java
@@ -16,10 +16,6 @@
 
 import java.util.ArrayList;
 
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.AUnorderedListType;
 import edu.uci.ics.asterix.om.types.IAType;
@@ -111,17 +107,4 @@
         sb.append(" ]");
         return sb.toString();
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject json = new JSONObject();
-
-        JSONArray list = new JSONArray();
-        for (IAObject v : values) {
-            list.put(v.toJSON());
-        }
-        json.put("AUnorderedList", list);
-
-        return json;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/IAObject.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/IAObject.java
index bfc0aba..463154b 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/IAObject.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/IAObject.java
@@ -17,12 +17,11 @@
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.types.IAType;
 import edu.uci.ics.asterix.om.visitors.IOMVisitor;
-import edu.uci.ics.hyracks.api.dataflow.value.JSONSerializable;
 
 /**
  * Represents an object in Asterix.
  */
-public interface IAObject extends JSONSerializable {
+public interface IAObject {
     public IAType getType();
 
     public void accept(IOMVisitor visitor) throws AsterixException;
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/json/AListPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/json/AListPrinter.java
deleted file mode 100644
index e0b3167..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/json/AListPrinter.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.om.pointables.printer.json;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.List;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-import edu.uci.ics.asterix.om.pointables.AListPointable;
-import edu.uci.ics.asterix.om.pointables.base.IVisitablePointable;
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.EnumDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.utils.Pair;
-
-/**
- * This class is to print the content of a list. It is ONLY visible to
- * APrintVisitor.
- */
-class AListPrinter {
-    private static String BEGIN = "{ unorderedlist: [";
-    private static String BEGIN_ORDERED = "{ orderedlist: [";
-    private static String END = " ]}";
-    private static String COMMA = ", ";
-
-    private final Pair<PrintStream, ATypeTag> itemVisitorArg = new Pair<PrintStream, ATypeTag>(null, null);
-    private String begin = BEGIN;
-
-    public AListPrinter(boolean ordered) {
-        if (ordered) {
-            begin = BEGIN_ORDERED;
-        }
-    }
-
-    public void printList(AListPointable listAccessor, PrintStream ps, APrintVisitor visitor) throws IOException,
-            AsterixException {
-        List<IVisitablePointable> itemTags = listAccessor.getItemTags();
-        List<IVisitablePointable> items = listAccessor.getItems();
-        itemVisitorArg.first = ps;
-
-        // print the beginning part
-        ps.print(begin);
-
-        // print item 0 to n-2
-        for (int i = 0; i < items.size() - 1; i++) {
-            printItem(visitor, itemTags, items, i);
-            // print the comma
-            ps.print(COMMA);
-        }
-
-        // print item n-1
-        if (items.size() > 0) {
-            printItem(visitor, itemTags, items, items.size() - 1);
-        }
-
-        // print the end part
-        ps.print(END);
-    }
-
-    private void printItem(APrintVisitor visitor, List<IVisitablePointable> itemTags, List<IVisitablePointable> items,
-            int i) throws AsterixException {
-        IVisitablePointable itemTypeTag = itemTags.get(i);
-        IVisitablePointable item = items.get(i);
-        ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(itemTypeTag.getByteArray()[itemTypeTag
-                .getStartOffset()]);
-        itemVisitorArg.second = item.getLength() <= 1 ? ATypeTag.NULL : typeTag;
-        item.accept(visitor, itemVisitorArg);
-    }
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/json/APrintVisitor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/json/APrintVisitor.java
deleted file mode 100644
index b2d5339..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/json/APrintVisitor.java
+++ /dev/null
@@ -1,185 +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.om.pointables.printer.json;
-
-import java.io.PrintStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ABooleanPrinter;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ACirclePrinter;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADatePrinter;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADateTimePrinter;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADoublePrinter;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ADurationPrinter;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AFloatPrinter;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AInt16Printer;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AInt32Printer;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AInt64Printer;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AInt8Printer;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ALinePrinter;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ANullPrinter;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.APoint3DPrinter;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.APointPrinter;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.APolygonPrinter;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ARectanglePrinter;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.AStringPrinter;
-import edu.uci.ics.asterix.dataflow.data.nontagged.printers.json.ATimePrinter;
-import edu.uci.ics.asterix.om.pointables.AFlatValuePointable;
-import edu.uci.ics.asterix.om.pointables.AListPointable;
-import edu.uci.ics.asterix.om.pointables.ARecordPointable;
-import edu.uci.ics.asterix.om.pointables.base.IVisitablePointable;
-import edu.uci.ics.asterix.om.pointables.visitor.IVisitablePointableVisitor;
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.NotImplementedException;
-import edu.uci.ics.hyracks.algebricks.common.utils.Pair;
-
-/**
- * This class is a IVisitablePointableVisitor implementation which recursively
- * visit a given record, list or flat value of a given type, and print it to a
- * PrintStream in adm format.
- */
-public class APrintVisitor implements IVisitablePointableVisitor<Void, Pair<PrintStream, ATypeTag>> {
-
-    private final Map<IVisitablePointable, ARecordPrinter> raccessorToPrinter = new HashMap<IVisitablePointable, ARecordPrinter>();
-    private final Map<IVisitablePointable, AListPrinter> laccessorToPrinter = new HashMap<IVisitablePointable, AListPrinter>();
-
-    @Override
-    public Void visit(AListPointable accessor, Pair<PrintStream, ATypeTag> arg) throws AsterixException {
-        AListPrinter printer = laccessorToPrinter.get(accessor);
-        if (printer == null) {
-            printer = new AListPrinter(accessor.ordered());
-            laccessorToPrinter.put(accessor, printer);
-        }
-        try {
-            printer.printList(accessor, arg.first, this);
-        } catch (Exception e) {
-            throw new AsterixException(e);
-        }
-        return null;
-    }
-
-    @Override
-    public Void visit(ARecordPointable accessor, Pair<PrintStream, ATypeTag> arg) throws AsterixException {
-        ARecordPrinter printer = raccessorToPrinter.get(accessor);
-        if (printer == null) {
-            printer = new ARecordPrinter();
-            raccessorToPrinter.put(accessor, printer);
-        }
-        try {
-            printer.printRecord(accessor, arg.first, this);
-        } catch (Exception e) {
-            throw new AsterixException(e);
-        }
-        return null;
-    }
-
-    @Override
-    public Void visit(AFlatValuePointable accessor, Pair<PrintStream, ATypeTag> arg) {
-        try {
-            byte[] b = accessor.getByteArray();
-            int s = accessor.getStartOffset();
-            int l = accessor.getLength();
-            PrintStream ps = arg.first;
-            ATypeTag typeTag = arg.second;
-            switch (typeTag) {
-                case INT8: {
-                    AInt8Printer.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case INT16: {
-                    AInt16Printer.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case INT32: {
-                    AInt32Printer.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case INT64: {
-                    AInt64Printer.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case NULL: {
-                    ANullPrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case BOOLEAN: {
-                    ABooleanPrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case FLOAT: {
-                    AFloatPrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case DOUBLE: {
-                    ADoublePrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case DATE: {
-                    ADatePrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case TIME: {
-                    ATimePrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case DATETIME: {
-                    ADateTimePrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case DURATION: {
-                    ADurationPrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case POINT: {
-                    APointPrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case POINT3D: {
-                    APoint3DPrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case LINE: {
-                    ALinePrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case POLYGON: {
-                    APolygonPrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case CIRCLE: {
-                    ACirclePrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case RECTANGLE: {
-                    ARectanglePrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                case STRING: {
-                    AStringPrinter.INSTANCE.print(b, s, l, ps);
-                    break;
-                }
-                default: {
-                    throw new NotImplementedException("No printer for type " + typeTag);
-                }
-            }
-            return null;
-        } catch (Exception e) {
-            throw new IllegalStateException(e);
-        }
-    }
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/json/ARecordPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/json/ARecordPrinter.java
deleted file mode 100644
index e15f9c0..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/printer/json/ARecordPrinter.java
+++ /dev/null
@@ -1,88 +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.om.pointables.printer.json;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.List;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-import edu.uci.ics.asterix.om.pointables.ARecordPointable;
-import edu.uci.ics.asterix.om.pointables.base.IVisitablePointable;
-import edu.uci.ics.asterix.om.types.ATypeTag;
-import edu.uci.ics.asterix.om.types.EnumDeserializer;
-import edu.uci.ics.hyracks.algebricks.common.utils.Pair;
-
-/**
- * This class is to print the content of a record. It is ONLY visible to
- * APrintVisitor.
- */
-class ARecordPrinter {
-    private static String LEFT_PAREN = "{ ";
-    private static String RIGHT_PAREN = " }";
-    private static String COMMA = ", ";
-    private static String COLON = ": ";
-
-    private final Pair<PrintStream, ATypeTag> nameVisitorArg = new Pair<PrintStream, ATypeTag>(null, ATypeTag.STRING);
-    private final Pair<PrintStream, ATypeTag> itemVisitorArg = new Pair<PrintStream, ATypeTag>(null, null);
-
-    public ARecordPrinter() {
-
-    }
-
-    public void printRecord(ARecordPointable recordAccessor, PrintStream ps, APrintVisitor visitor) throws IOException,
-            AsterixException {
-        List<IVisitablePointable> fieldNames = recordAccessor.getFieldNames();
-        List<IVisitablePointable> fieldTags = recordAccessor.getFieldTypeTags();
-        List<IVisitablePointable> fieldValues = recordAccessor.getFieldValues();
-
-        nameVisitorArg.first = ps;
-        itemVisitorArg.first = ps;
-
-        // print the beginning part
-        ps.print(LEFT_PAREN);
-
-        // print field 0 to n-2
-        for (int i = 0; i < fieldNames.size() - 1; i++) {
-            printField(ps, visitor, fieldNames, fieldTags, fieldValues, i);
-            // print the comma
-            ps.print(COMMA);
-        }
-
-        // print field n-1
-        if (fieldValues.size() > 0) {
-            printField(ps, visitor, fieldNames, fieldTags, fieldValues, fieldValues.size() - 1);
-        }
-
-        // print the end part
-        ps.print(RIGHT_PAREN);
-    }
-
-    private void printField(PrintStream ps, APrintVisitor visitor, List<IVisitablePointable> fieldNames,
-            List<IVisitablePointable> fieldTags, List<IVisitablePointable> fieldValues, int i) throws AsterixException {
-        IVisitablePointable itemTypeTag = fieldTags.get(i);
-        IVisitablePointable item = fieldValues.get(i);
-        ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(itemTypeTag.getByteArray()[itemTypeTag
-                .getStartOffset()]);
-        itemVisitorArg.second = item.getLength() <= 1 ? ATypeTag.NULL : typeTag;
-
-        // print field name
-        fieldNames.get(i).accept(visitor, nameVisitorArg);
-        ps.print(COLON);
-        // print field value
-        item.accept(visitor, itemVisitorArg);
-    }
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AOrderedListType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AOrderedListType.java
index 5620e4e..59423e2 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AOrderedListType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AOrderedListType.java
@@ -1,8 +1,5 @@
 package edu.uci.ics.asterix.om.types;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.om.base.IAObject;
 
 public class AOrderedListType extends AbstractCollectionType {
@@ -55,11 +52,4 @@
     public int hash() {
         return hashCode();
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException{
-        JSONObject type = new JSONObject();
-        type.put("type", itemType);
-        return type;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java
index 37452b3..82320e4 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java
@@ -22,10 +22,6 @@
 import java.util.Arrays;
 import java.util.List;
 
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.annotations.IRecordTypeAnnotation;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.base.IAObject;
@@ -274,24 +270,4 @@
         }
         return h;
     }
-
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject type = new JSONObject();
-        if (isOpen) {
-            type.put("open", true);
-        } else {
-            type.put("open", false);
-        }
-
-        JSONArray fields = new JSONArray();
-        for (int i = 0; i < fieldNames.length; i++) {
-            JSONObject field = new JSONObject();
-            field.put(fieldNames[i], fieldTypes[i].toJSON());
-            fields.put(field);
-        }
-
-        type.put("fields", fields);
-        return type;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AUnionType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AUnionType.java
index dc74b6e..1e70f15 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AUnionType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AUnionType.java
@@ -4,10 +4,6 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.base.IAObject;
 import edu.uci.ics.asterix.om.visitors.IOMVisitor;
@@ -31,7 +27,7 @@
     }
 
     public boolean isNullableType() {
-        return unionList.size() == 2 && unionList.get(0).equals(BuiltinType.ANULL);
+    	return unionList.size() == 2 && unionList.get(0).equals(BuiltinType.ANULL);
     }
 
     @Override
@@ -104,23 +100,4 @@
         return h;
     }
 
-    @Override
-    public JSONObject toJSON() throws JSONException {
-        JSONObject type = new JSONObject();
-        type.put("type", "UNION");
-
-        JSONArray fields = new JSONArray();
-
-        Iterator<IAType> iter = unionList.iterator();
-        if (iter.hasNext()) {
-            IAType t0 = iter.next();
-            fields.put(t0.toJSON());
-            while (iter.hasNext()) {
-                fields.put(iter.next().toJSON());
-            }
-        }
-
-        type.put("fields", fields);
-        return type;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AUnorderedListType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AUnorderedListType.java
index a62bd5b..c15dc49 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AUnorderedListType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/AUnorderedListType.java
@@ -1,8 +1,5 @@
 package edu.uci.ics.asterix.om.types;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.om.base.IAObject;
 
 public class AUnorderedListType extends AbstractCollectionType {
@@ -56,10 +53,4 @@
         return hashCode();
     }
 
-    @Override
-    public JSONObject toJSON() throws JSONException{
-        JSONObject type = new JSONObject();
-        type.put("type", itemType);
-        return type;
-    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/BuiltinType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/BuiltinType.java
index a70f15b..4d9cd7f 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/BuiltinType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/BuiltinType.java
@@ -1,8 +1,5 @@
 package edu.uci.ics.asterix.om.types;
 
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.base.IAObject;
 import edu.uci.ics.asterix.om.visitors.IOMVisitor;
@@ -44,13 +41,6 @@
         public String getConstructor() {
             return null;
         }
-
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "AsterixType");
-            return type;
-        }
     };
 
     public final static BuiltinType AINT8 = new LowerCaseConstructorType() {
@@ -71,13 +61,6 @@
         public String getTypeName() {
             return "int8";
         }
-
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "AInt8");
-            return type;
-        }
     };
 
     public final static BuiltinType AINT16 = new LowerCaseConstructorType() {
@@ -98,13 +81,6 @@
         public String getTypeName() {
             return "int16";
         }
-
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "AInt16");
-            return type;
-        }
     };
 
     public final static BuiltinType AINT32 = new LowerCaseConstructorType() {
@@ -125,13 +101,6 @@
         public String getTypeName() {
             return "int32";
         }
-
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "AInt32");
-            return type;
-        }
     };
 
     public static final BuiltinType AINT64 = new LowerCaseConstructorType() {
@@ -153,12 +122,6 @@
             return "int64";
         }
 
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "AInt64");
-            return type;
-        }
     };
 
     public final static BuiltinType ABINARY = new LowerCaseConstructorType() {
@@ -180,12 +143,6 @@
             return "binary";
         }
 
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "ABinary");
-            return type;
-        }
     };
 
     public final static BuiltinType AFLOAT = new LowerCaseConstructorType() {
@@ -207,12 +164,6 @@
             return "float";
         }
 
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "AFloat");
-            return type;
-        }
     };
 
     public final static BuiltinType ADOUBLE = new LowerCaseConstructorType() {
@@ -233,13 +184,6 @@
         public String getTypeName() {
             return "double";
         }
-
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "ADouble");
-            return type;
-        }
     };
 
     public final static BuiltinType ASTRING = new LowerCaseConstructorType() {
@@ -260,13 +204,6 @@
         public String getTypeName() {
             return "string";
         }
-
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "AString");
-            return type;
-        }
     };
 
     public final static BuiltinType ANULL = new LowerCaseConstructorType() {
@@ -288,12 +225,6 @@
             return "null";
         }
 
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "Null");
-            return type;
-        }
     };
 
     public final static BuiltinType ABOOLEAN = new LowerCaseConstructorType() {
@@ -315,12 +246,6 @@
             return "boolean";
         }
 
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "ABoolean");
-            return type;
-        }
     };
 
     public final static BuiltinType ATIME = new LowerCaseConstructorType() {
@@ -341,13 +266,6 @@
         public String getTypeName() {
             return "time";
         }
-
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "ATime");
-            return type;
-        }
     };
 
     public final static BuiltinType ADATE = new LowerCaseConstructorType() {
@@ -368,13 +286,6 @@
         public String getTypeName() {
             return "date";
         }
-
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "ADate");
-            return type;
-        }
     };
 
     public final static BuiltinType ADATETIME = new LowerCaseConstructorType() {
@@ -395,13 +306,6 @@
         public String getTypeName() {
             return "datetime";
         }
-
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "ADateTime");
-            return type;
-        }
     };
 
     public final static BuiltinType ADURATION = new LowerCaseConstructorType() {
@@ -423,12 +327,6 @@
             return "duration";
         }
 
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "ADuration");
-            return type;
-        }
     };
 
     public final static BuiltinType AINTERVAL = new LowerCaseConstructorType() {
@@ -450,10 +348,6 @@
             return "interval";
         }
 
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            return null;
-        }
     };
 
     public final static BuiltinType APOINT = new LowerCaseConstructorType() {
@@ -474,13 +368,6 @@
         public String getTypeName() {
             return "point";
         }
-
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "APoint");
-            return type;
-        }
     };
 
     public final static BuiltinType APOINT3D = new LowerCaseConstructorType() {
@@ -501,13 +388,6 @@
         public String getTypeName() {
             return "point3d";
         }
-
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "APoint3D");
-            return type;
-        }
     };
 
     public final static BuiltinType ALINE = new LowerCaseConstructorType() {
@@ -529,12 +409,6 @@
             return "line";
         }
 
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "ALINE");
-            return type;
-        }
     };
 
     public final static BuiltinType APOLYGON = new LowerCaseConstructorType() {
@@ -556,12 +430,6 @@
             return "polygon";
         }
 
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "APOLYGON");
-            return type;
-        }
     };
 
     public final static BuiltinType ACIRCLE = new LowerCaseConstructorType() {
@@ -583,12 +451,6 @@
             return "circle";
         }
 
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "ACIRCLE");
-            return type;
-        }
     };
 
     public final static BuiltinType ARECTANGLE = new LowerCaseConstructorType() {
@@ -610,12 +472,6 @@
             return "rectangle";
         }
 
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "ARECTANGLE");
-            return type;
-        }
     };
 
     public static final IAType ABITARRAY = new LowerCaseConstructorType() {
@@ -636,13 +492,6 @@
         public String getTypeName() {
             return "abitarray";
         }
-
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "ABitArray");
-            return type;
-        }
     };
 
     public static final IAType ANY = new BuiltinType() {
@@ -668,13 +517,6 @@
         public String getConstructor() {
             return null;
         }
-
-        @Override
-        public JSONObject toJSON() throws JSONException {
-            JSONObject type = new JSONObject();
-            type.put("type", "ANY");
-            return type;
-        }
     };
 
     public abstract String getConstructor();
@@ -746,4 +588,4 @@
         throw new AsterixException("No string translation for type: " + str + " .");
     }
 
-}
+}
\ No newline at end of file
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java
index f12ea91..a334893 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java
@@ -19,7 +19,6 @@
 import edu.uci.ics.asterix.formats.nontagged.AqlBinaryHashFunctionFactoryProvider;
 import edu.uci.ics.asterix.formats.nontagged.AqlBinaryHashFunctionFamilyProvider;
 import edu.uci.ics.asterix.formats.nontagged.AqlBinaryIntegerInspector;
-import edu.uci.ics.asterix.formats.nontagged.AqlJSONPrinterFactoryProvider;
 import edu.uci.ics.asterix.formats.nontagged.AqlNormalizedKeyComputerFactoryProvider;
 import edu.uci.ics.asterix.formats.nontagged.AqlPrinterFactoryProvider;
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
@@ -266,46 +265,51 @@
 
 public class NonTaggedDataFormat implements IDataFormat {
 
-    private static boolean registered = false;
+	private static boolean registered = false;
 
-    public static final NonTaggedDataFormat INSTANCE = new NonTaggedDataFormat();
+	public static final NonTaggedDataFormat INSTANCE = new NonTaggedDataFormat();
 
-    private static LogicalVariable METADATA_DUMMY_VAR = new LogicalVariable(-1);
+	private static LogicalVariable METADATA_DUMMY_VAR = new LogicalVariable(-1);
 
-    private static final HashMap<ATypeTag, IValueParserFactory> typeToValueParserFactMap = new HashMap<ATypeTag, IValueParserFactory>();
+	private static final HashMap<ATypeTag, IValueParserFactory> typeToValueParserFactMap = new HashMap<ATypeTag, IValueParserFactory>();
 
-    public static final String NON_TAGGED_DATA_FORMAT = "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat";
+	public static final String NON_TAGGED_DATA_FORMAT = "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat";
 
-    static {
-        typeToValueParserFactMap.put(ATypeTag.INT32, IntegerParserFactory.INSTANCE);
-        typeToValueParserFactMap.put(ATypeTag.FLOAT, FloatParserFactory.INSTANCE);
-        typeToValueParserFactMap.put(ATypeTag.DOUBLE, DoubleParserFactory.INSTANCE);
-        typeToValueParserFactMap.put(ATypeTag.INT64, LongParserFactory.INSTANCE);
-        typeToValueParserFactMap.put(ATypeTag.STRING, UTF8StringParserFactory.INSTANCE);
-    }
+	static {
+		typeToValueParserFactMap.put(ATypeTag.INT32,
+				IntegerParserFactory.INSTANCE);
+		typeToValueParserFactMap.put(ATypeTag.FLOAT,
+				FloatParserFactory.INSTANCE);
+		typeToValueParserFactMap.put(ATypeTag.DOUBLE,
+				DoubleParserFactory.INSTANCE);
+		typeToValueParserFactMap
+				.put(ATypeTag.INT64, LongParserFactory.INSTANCE);
+		typeToValueParserFactMap.put(ATypeTag.STRING,
+				UTF8StringParserFactory.INSTANCE);
+	}
 
-    public NonTaggedDataFormat() {
-    }
+	public NonTaggedDataFormat() {
+	}
 
-    public void registerRuntimeFunctions() throws AlgebricksException {
+	public void registerRuntimeFunctions() throws AlgebricksException {
 
-        if (registered) {
-            return;
-        }
-        registered = true;
+		if (registered) {
+			return;
+		}
+		registered = true;
 
-        if (FunctionManagerHolder.getFunctionManager() != null) {
-            return;
-        }
+		if (FunctionManagerHolder.getFunctionManager() != null) {
+			return;
+		}
 
-        List<IFunctionDescriptorFactory> temp = new ArrayList<IFunctionDescriptorFactory>();
+		List<IFunctionDescriptorFactory> temp = new ArrayList<IFunctionDescriptorFactory>();
 
-        // format-independent
-        temp.add(ContainsDescriptor.FACTORY);
-        temp.add(EndsWithDescriptor.FACTORY);
-        temp.add(StartsWithDescriptor.FACTORY);
-        temp.add(SubstringDescriptor.FACTORY);
-        temp.add(TidRunningAggregateDescriptor.FACTORY);
+		// format-independent
+		temp.add(ContainsDescriptor.FACTORY);
+		temp.add(EndsWithDescriptor.FACTORY);
+		temp.add(StartsWithDescriptor.FACTORY);
+		temp.add(SubstringDescriptor.FACTORY);
+		temp.add(TidRunningAggregateDescriptor.FACTORY);
 
         // format-dependent
         temp.add(AndDescriptor.FACTORY);
@@ -323,138 +327,138 @@
         temp.add(UnorderedListConstructorDescriptor.FACTORY);
         temp.add(EmbedTypeDescriptor.FACTORY);
 
-        temp.add(NumericAddDescriptor.FACTORY);
-        temp.add(NumericDivideDescriptor.FACTORY);
-        temp.add(NumericMultiplyDescriptor.FACTORY);
-        temp.add(NumericSubtractDescriptor.FACTORY);
-        temp.add(NumericModuloDescriptor.FACTORY);
-        temp.add(IsNullDescriptor.FACTORY);
-        temp.add(NotDescriptor.FACTORY);
-        temp.add(LenDescriptor.FACTORY);
-        temp.add(EmptyStreamAggregateDescriptor.FACTORY);
-        temp.add(NonEmptyStreamAggregateDescriptor.FACTORY);
-        temp.add(RangeDescriptor.FACTORY);
+		temp.add(NumericAddDescriptor.FACTORY);
+		temp.add(NumericDivideDescriptor.FACTORY);
+		temp.add(NumericMultiplyDescriptor.FACTORY);
+		temp.add(NumericSubtractDescriptor.FACTORY);
+		temp.add(NumericModuloDescriptor.FACTORY);
+		temp.add(IsNullDescriptor.FACTORY);
+		temp.add(NotDescriptor.FACTORY);
+		temp.add(LenDescriptor.FACTORY);
+		temp.add(EmptyStreamAggregateDescriptor.FACTORY);
+		temp.add(NonEmptyStreamAggregateDescriptor.FACTORY);
+		temp.add(RangeDescriptor.FACTORY);
 
-        temp.add(NumericAbsDescriptor.FACTORY);
-        temp.add(NumericCeilingDescriptor.FACTORY);
-        temp.add(NumericFloorDescriptor.FACTORY);
-        temp.add(NumericRoundDescriptor.FACTORY);
-        temp.add(NumericRoundHalfToEvenDescriptor.FACTORY);
-        temp.add(NumericRoundHalfToEven2Descriptor.FACTORY);
-        // String functions
-        temp.add(StringEqualDescriptor.FACTORY);
-        temp.add(StringStartWithDescrtiptor.FACTORY);
-        temp.add(StringEndWithDescrtiptor.FACTORY);
-        temp.add(StringMatchesDescriptor.FACTORY);
-        temp.add(StringLowerCaseDescriptor.FACTORY);
-        temp.add(StringMatchesWithFlagDescriptor.FACTORY);
-        temp.add(StringReplaceDescriptor.FACTORY);
-        temp.add(StringReplaceWithFlagsDescriptor.FACTORY);
-        temp.add(StringLengthDescriptor.FACTORY);
-        temp.add(Substring2Descriptor.FACTORY);
-        temp.add(SubstringBeforeDescriptor.FACTORY);
-        temp.add(SubstringAfterDescriptor.FACTORY);
-        temp.add(StringToCodePointDescriptor.FACTORY);
-        temp.add(CodePointToStringDescriptor.FACTORY);
-        temp.add(StringConcatDescriptor.FACTORY);
-        temp.add(StringJoinDescriptor.FACTORY);
+		temp.add(NumericAbsDescriptor.FACTORY);
+		temp.add(NumericCeilingDescriptor.FACTORY);
+		temp.add(NumericFloorDescriptor.FACTORY);
+		temp.add(NumericRoundDescriptor.FACTORY);
+		temp.add(NumericRoundHalfToEvenDescriptor.FACTORY);
+		temp.add(NumericRoundHalfToEven2Descriptor.FACTORY);
+		// String functions
+		temp.add(StringEqualDescriptor.FACTORY);
+		temp.add(StringStartWithDescrtiptor.FACTORY);
+		temp.add(StringEndWithDescrtiptor.FACTORY);
+		temp.add(StringMatchesDescriptor.FACTORY);
+		temp.add(StringLowerCaseDescriptor.FACTORY);
+		temp.add(StringMatchesWithFlagDescriptor.FACTORY);
+		temp.add(StringReplaceDescriptor.FACTORY);
+		temp.add(StringReplaceWithFlagsDescriptor.FACTORY);
+		temp.add(StringLengthDescriptor.FACTORY);
+		temp.add(Substring2Descriptor.FACTORY);
+		temp.add(SubstringBeforeDescriptor.FACTORY);
+		temp.add(SubstringAfterDescriptor.FACTORY);
+		temp.add(StringToCodePointDescriptor.FACTORY);
+		temp.add(CodePointToStringDescriptor.FACTORY);
+		temp.add(StringConcatDescriptor.FACTORY);
+		temp.add(StringJoinDescriptor.FACTORY);
 
-        // aggregates
-        temp.add(ListifyAggregateDescriptor.FACTORY);
-        temp.add(CountAggregateDescriptor.FACTORY);
-        temp.add(AvgAggregateDescriptor.FACTORY);
-        temp.add(LocalAvgAggregateDescriptor.FACTORY);
-        temp.add(GlobalAvgAggregateDescriptor.FACTORY);
-        temp.add(SumAggregateDescriptor.FACTORY);
-        temp.add(LocalSumAggregateDescriptor.FACTORY);
-        temp.add(MaxAggregateDescriptor.FACTORY);
-        temp.add(LocalMaxAggregateDescriptor.FACTORY);
-        temp.add(MinAggregateDescriptor.FACTORY);
-        temp.add(LocalMinAggregateDescriptor.FACTORY);
+		// aggregates
+		temp.add(ListifyAggregateDescriptor.FACTORY);
+		temp.add(CountAggregateDescriptor.FACTORY);
+		temp.add(AvgAggregateDescriptor.FACTORY);
+		temp.add(LocalAvgAggregateDescriptor.FACTORY);
+		temp.add(GlobalAvgAggregateDescriptor.FACTORY);
+		temp.add(SumAggregateDescriptor.FACTORY);
+		temp.add(LocalSumAggregateDescriptor.FACTORY);
+		temp.add(MaxAggregateDescriptor.FACTORY);
+		temp.add(LocalMaxAggregateDescriptor.FACTORY);
+		temp.add(MinAggregateDescriptor.FACTORY);
+		temp.add(LocalMinAggregateDescriptor.FACTORY);
 
-        // serializable aggregates
-        temp.add(SerializableCountAggregateDescriptor.FACTORY);
-        temp.add(SerializableAvgAggregateDescriptor.FACTORY);
-        temp.add(SerializableLocalAvgAggregateDescriptor.FACTORY);
-        temp.add(SerializableGlobalAvgAggregateDescriptor.FACTORY);
-        temp.add(SerializableSumAggregateDescriptor.FACTORY);
-        temp.add(SerializableLocalSumAggregateDescriptor.FACTORY);
+		// serializable aggregates
+		temp.add(SerializableCountAggregateDescriptor.FACTORY);
+		temp.add(SerializableAvgAggregateDescriptor.FACTORY);
+		temp.add(SerializableLocalAvgAggregateDescriptor.FACTORY);
+		temp.add(SerializableGlobalAvgAggregateDescriptor.FACTORY);
+		temp.add(SerializableSumAggregateDescriptor.FACTORY);
+		temp.add(SerializableLocalSumAggregateDescriptor.FACTORY);
 
-        // scalar aggregates
-        temp.add(ScalarCountAggregateDescriptor.FACTORY);
-        temp.add(ScalarAvgAggregateDescriptor.FACTORY);
-        temp.add(ScalarSumAggregateDescriptor.FACTORY);
-        temp.add(ScalarMaxAggregateDescriptor.FACTORY);
-        temp.add(ScalarMinAggregateDescriptor.FACTORY);
+		// scalar aggregates
+		temp.add(ScalarCountAggregateDescriptor.FACTORY);
+		temp.add(ScalarAvgAggregateDescriptor.FACTORY);
+		temp.add(ScalarSumAggregateDescriptor.FACTORY);
+		temp.add(ScalarMaxAggregateDescriptor.FACTORY);
+		temp.add(ScalarMinAggregateDescriptor.FACTORY);
 
-        // new functions - constructors
-        temp.add(ABooleanConstructorDescriptor.FACTORY);
-        temp.add(ANullConstructorDescriptor.FACTORY);
-        temp.add(AStringConstructorDescriptor.FACTORY);
-        temp.add(AInt8ConstructorDescriptor.FACTORY);
-        temp.add(AInt16ConstructorDescriptor.FACTORY);
-        temp.add(AInt32ConstructorDescriptor.FACTORY);
-        temp.add(AInt64ConstructorDescriptor.FACTORY);
-        temp.add(AFloatConstructorDescriptor.FACTORY);
-        temp.add(ADoubleConstructorDescriptor.FACTORY);
-        temp.add(APointConstructorDescriptor.FACTORY);
-        temp.add(APoint3DConstructorDescriptor.FACTORY);
-        temp.add(ALineConstructorDescriptor.FACTORY);
-        temp.add(APolygonConstructorDescriptor.FACTORY);
-        temp.add(ACircleConstructorDescriptor.FACTORY);
-        temp.add(ARectangleConstructorDescriptor.FACTORY);
-        temp.add(ATimeConstructorDescriptor.FACTORY);
-        temp.add(ADateConstructorDescriptor.FACTORY);
-        temp.add(ADateTimeConstructorDescriptor.FACTORY);
-        temp.add(ADurationConstructorDescriptor.FACTORY);
+		// new functions - constructors
+		temp.add(ABooleanConstructorDescriptor.FACTORY);
+		temp.add(ANullConstructorDescriptor.FACTORY);
+		temp.add(AStringConstructorDescriptor.FACTORY);
+		temp.add(AInt8ConstructorDescriptor.FACTORY);
+		temp.add(AInt16ConstructorDescriptor.FACTORY);
+		temp.add(AInt32ConstructorDescriptor.FACTORY);
+		temp.add(AInt64ConstructorDescriptor.FACTORY);
+		temp.add(AFloatConstructorDescriptor.FACTORY);
+		temp.add(ADoubleConstructorDescriptor.FACTORY);
+		temp.add(APointConstructorDescriptor.FACTORY);
+		temp.add(APoint3DConstructorDescriptor.FACTORY);
+		temp.add(ALineConstructorDescriptor.FACTORY);
+		temp.add(APolygonConstructorDescriptor.FACTORY);
+		temp.add(ACircleConstructorDescriptor.FACTORY);
+		temp.add(ARectangleConstructorDescriptor.FACTORY);
+		temp.add(ATimeConstructorDescriptor.FACTORY);
+		temp.add(ADateConstructorDescriptor.FACTORY);
+		temp.add(ADateTimeConstructorDescriptor.FACTORY);
+		temp.add(ADurationConstructorDescriptor.FACTORY);
 
-        // Spatial
-        temp.add(CreatePointDescriptor.FACTORY);
-        temp.add(CreateLineDescriptor.FACTORY);
-        temp.add(CreatePolygonDescriptor.FACTORY);
-        temp.add(CreateCircleDescriptor.FACTORY);
-        temp.add(CreateRectangleDescriptor.FACTORY);
-        temp.add(SpatialAreaDescriptor.FACTORY);
-        temp.add(SpatialDistanceDescriptor.FACTORY);
-        temp.add(SpatialIntersectDescriptor.FACTORY);
-        temp.add(CreateMBRDescriptor.FACTORY);
-        temp.add(SpatialCellDescriptor.FACTORY);
-        temp.add(PointXCoordinateAccessor.FACTORY);
-        temp.add(PointYCoordinateAccessor.FACTORY);
-        temp.add(CircleRadiusAccessor.FACTORY);
-        temp.add(CircleCenterAccessor.FACTORY);
-        temp.add(LineRectanglePolygonAccessor.FACTORY);
+		// Spatial
+		temp.add(CreatePointDescriptor.FACTORY);
+		temp.add(CreateLineDescriptor.FACTORY);
+		temp.add(CreatePolygonDescriptor.FACTORY);
+		temp.add(CreateCircleDescriptor.FACTORY);
+		temp.add(CreateRectangleDescriptor.FACTORY);
+		temp.add(SpatialAreaDescriptor.FACTORY);
+		temp.add(SpatialDistanceDescriptor.FACTORY);
+		temp.add(SpatialIntersectDescriptor.FACTORY);
+		temp.add(CreateMBRDescriptor.FACTORY);
+		temp.add(SpatialCellDescriptor.FACTORY);
+		temp.add(PointXCoordinateAccessor.FACTORY);
+		temp.add(PointYCoordinateAccessor.FACTORY);
+		temp.add(CircleRadiusAccessor.FACTORY);
+		temp.add(CircleCenterAccessor.FACTORY);
+		temp.add(LineRectanglePolygonAccessor.FACTORY);
 
-        // fuzzyjoin function
-        temp.add(FuzzyEqDescriptor.FACTORY);
-        temp.add(SubsetCollectionDescriptor.FACTORY);
-        temp.add(PrefixLenJaccardDescriptor.FACTORY);
+		// fuzzyjoin function
+		temp.add(FuzzyEqDescriptor.FACTORY);
+		temp.add(SubsetCollectionDescriptor.FACTORY);
+		temp.add(PrefixLenJaccardDescriptor.FACTORY);
 
-        temp.add(WordTokensDescriptor.FACTORY);
-        temp.add(HashedWordTokensDescriptor.FACTORY);
-        temp.add(CountHashedWordTokensDescriptor.FACTORY);
+		temp.add(WordTokensDescriptor.FACTORY);
+		temp.add(HashedWordTokensDescriptor.FACTORY);
+		temp.add(CountHashedWordTokensDescriptor.FACTORY);
 
-        temp.add(GramTokensDescriptor.FACTORY);
-        temp.add(HashedGramTokensDescriptor.FACTORY);
-        temp.add(CountHashedGramTokensDescriptor.FACTORY);
+		temp.add(GramTokensDescriptor.FACTORY);
+		temp.add(HashedGramTokensDescriptor.FACTORY);
+		temp.add(CountHashedGramTokensDescriptor.FACTORY);
 
-        temp.add(EditDistanceDescriptor.FACTORY);
-        temp.add(EditDistanceCheckDescriptor.FACTORY);
-        temp.add(EditDistanceStringIsFilterable.FACTORY);
-        temp.add(EditDistanceListIsFilterable.FACTORY);
+		temp.add(EditDistanceDescriptor.FACTORY);
+		temp.add(EditDistanceCheckDescriptor.FACTORY);
+		temp.add(EditDistanceStringIsFilterable.FACTORY);
+		temp.add(EditDistanceListIsFilterable.FACTORY);
 
-        temp.add(SimilarityJaccardDescriptor.FACTORY);
-        temp.add(SimilarityJaccardCheckDescriptor.FACTORY);
-        temp.add(SimilarityJaccardSortedDescriptor.FACTORY);
-        temp.add(SimilarityJaccardSortedCheckDescriptor.FACTORY);
-        temp.add(SimilarityJaccardPrefixDescriptor.FACTORY);
-        temp.add(SimilarityJaccardPrefixCheckDescriptor.FACTORY);
+		temp.add(SimilarityJaccardDescriptor.FACTORY);
+		temp.add(SimilarityJaccardCheckDescriptor.FACTORY);
+		temp.add(SimilarityJaccardSortedDescriptor.FACTORY);
+		temp.add(SimilarityJaccardSortedCheckDescriptor.FACTORY);
+		temp.add(SimilarityJaccardPrefixDescriptor.FACTORY);
+		temp.add(SimilarityJaccardPrefixCheckDescriptor.FACTORY);
 
-        temp.add(SwitchCaseDescriptor.FACTORY);
-        temp.add(RegExpDescriptor.FACTORY);
-        temp.add(InjectFailureDescriptor.FACTORY);
-        temp.add(CastRecordDescriptor.FACTORY);
-        temp.add(NotNullDescriptor.FACTORY);
+		temp.add(SwitchCaseDescriptor.FACTORY);
+		temp.add(RegExpDescriptor.FACTORY);
+		temp.add(InjectFailureDescriptor.FACTORY);
+		temp.add(CastRecordDescriptor.FACTORY);
+		temp.add(NotNullDescriptor.FACTORY);
 
         // Spatial and temporal type accessors
         temp.add(TemporalYearAccessor.FACTORY);
@@ -514,377 +518,425 @@
         FunctionManagerHolder.setFunctionManager(mgr);
     }
 
-    @Override
-    public IBinaryBooleanInspectorFactory getBinaryBooleanInspectorFactory() {
-        return AqlBinaryBooleanInspectorImpl.FACTORY;
-    }
+	@Override
+	public IBinaryBooleanInspectorFactory getBinaryBooleanInspectorFactory() {
+		return AqlBinaryBooleanInspectorImpl.FACTORY;
+	}
 
-    @Override
-    public IBinaryComparatorFactoryProvider getBinaryComparatorFactoryProvider() {
-        return AqlBinaryComparatorFactoryProvider.INSTANCE;
-    }
+	@Override
+	public IBinaryComparatorFactoryProvider getBinaryComparatorFactoryProvider() {
+		return AqlBinaryComparatorFactoryProvider.INSTANCE;
+	}
 
-    @Override
-    public IBinaryHashFunctionFactoryProvider getBinaryHashFunctionFactoryProvider() {
-        return AqlBinaryHashFunctionFactoryProvider.INSTANCE;
-    }
+	@Override
+	public IBinaryHashFunctionFactoryProvider getBinaryHashFunctionFactoryProvider() {
+		return AqlBinaryHashFunctionFactoryProvider.INSTANCE;
+	}
 
-    @Override
-    public ISerializerDeserializerProvider getSerdeProvider() {
-        return AqlSerializerDeserializerProvider.INSTANCE; // done
-    }
+	@Override
+	public ISerializerDeserializerProvider getSerdeProvider() {
+		return AqlSerializerDeserializerProvider.INSTANCE; // done
+	}
 
-    @Override
-    public ITypeTraitProvider getTypeTraitProvider() {
-        return AqlTypeTraitProvider.INSTANCE;
-    }
+	@Override
+	public ITypeTraitProvider getTypeTraitProvider() {
+		return AqlTypeTraitProvider.INSTANCE;
+	}
 
-    @SuppressWarnings("unchecked")
-    @Override
-    public ICopyEvaluatorFactory getFieldAccessEvaluatorFactory(ARecordType recType, String fldName, int recordColumn)
-            throws AlgebricksException {
-        String[] names = recType.getFieldNames();
-        int n = names.length;
-        for (int i = 0; i < n; i++) {
-            if (names[i].equals(fldName)) {
-                ICopyEvaluatorFactory recordEvalFactory = new ColumnAccessEvalFactory(recordColumn);
-                ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
-                DataOutput dos = abvs.getDataOutput();
-                try {
-                    AInt32 ai = new AInt32(i);
-                    AqlSerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(ai.getType()).serialize(ai,
-                            dos);
-                } catch (HyracksDataException e) {
-                    throw new AlgebricksException(e);
-                }
-                ICopyEvaluatorFactory fldIndexEvalFactory = new ConstantEvalFactory(Arrays.copyOf(abvs.getByteArray(),
-                        abvs.getLength()));
-                ICopyEvaluatorFactory evalFactory = new FieldAccessByIndexEvalFactory(recordEvalFactory,
-                        fldIndexEvalFactory, recType);
-                return evalFactory;
-            }
-        }
-        throw new AlgebricksException("Could not find field " + fldName + " in the schema.");
-    }
+	@SuppressWarnings("unchecked")
+	@Override
+	public ICopyEvaluatorFactory getFieldAccessEvaluatorFactory(
+			ARecordType recType, String fldName, int recordColumn)
+			throws AlgebricksException {
+		String[] names = recType.getFieldNames();
+		int n = names.length;
+		for (int i = 0; i < n; i++) {
+			if (names[i].equals(fldName)) {
+				ICopyEvaluatorFactory recordEvalFactory = new ColumnAccessEvalFactory(
+						recordColumn);
+				ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
+				DataOutput dos = abvs.getDataOutput();
+				try {
+					AInt32 ai = new AInt32(i);
+					AqlSerializerDeserializerProvider.INSTANCE
+							.getSerializerDeserializer(ai.getType()).serialize(
+									ai, dos);
+				} catch (HyracksDataException e) {
+					throw new AlgebricksException(e);
+				}
+				ICopyEvaluatorFactory fldIndexEvalFactory = new ConstantEvalFactory(
+						Arrays.copyOf(abvs.getByteArray(), abvs.getLength()));
+				ICopyEvaluatorFactory evalFactory = new FieldAccessByIndexEvalFactory(
+						recordEvalFactory, fldIndexEvalFactory, recType);
+				return evalFactory;
+			}
+		}
+		throw new AlgebricksException("Could not find field " + fldName
+				+ " in the schema.");
+	}
 
-    @SuppressWarnings("unchecked")
-    @Override
-    public ICopyEvaluatorFactory[] createMBRFactory(ARecordType recType, String fldName, int recordColumn, int dimension)
-            throws AlgebricksException {
-        ICopyEvaluatorFactory evalFactory = getFieldAccessEvaluatorFactory(recType, fldName, recordColumn);
-        int numOfFields = dimension * 2;
-        ICopyEvaluatorFactory[] evalFactories = new ICopyEvaluatorFactory[numOfFields];
+	@SuppressWarnings("unchecked")
+	@Override
+	public ICopyEvaluatorFactory[] createMBRFactory(ARecordType recType,
+			String fldName, int recordColumn, int dimension)
+			throws AlgebricksException {
+		ICopyEvaluatorFactory evalFactory = getFieldAccessEvaluatorFactory(
+				recType, fldName, recordColumn);
+		int numOfFields = dimension * 2;
+		ICopyEvaluatorFactory[] evalFactories = new ICopyEvaluatorFactory[numOfFields];
 
-        ArrayBackedValueStorage abvs1 = new ArrayBackedValueStorage();
-        DataOutput dos1 = abvs1.getDataOutput();
-        try {
-            AInt32 ai = new AInt32(dimension);
-            AqlSerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(ai.getType()).serialize(ai, dos1);
-        } catch (HyracksDataException e) {
-            throw new AlgebricksException(e);
-        }
-        ICopyEvaluatorFactory dimensionEvalFactory = new ConstantEvalFactory(Arrays.copyOf(abvs1.getByteArray(),
-                abvs1.getLength()));
+		ArrayBackedValueStorage abvs1 = new ArrayBackedValueStorage();
+		DataOutput dos1 = abvs1.getDataOutput();
+		try {
+			AInt32 ai = new AInt32(dimension);
+			AqlSerializerDeserializerProvider.INSTANCE
+					.getSerializerDeserializer(ai.getType())
+					.serialize(ai, dos1);
+		} catch (HyracksDataException e) {
+			throw new AlgebricksException(e);
+		}
+		ICopyEvaluatorFactory dimensionEvalFactory = new ConstantEvalFactory(
+				Arrays.copyOf(abvs1.getByteArray(), abvs1.getLength()));
 
-        for (int i = 0; i < numOfFields; i++) {
-            ArrayBackedValueStorage abvs2 = new ArrayBackedValueStorage();
-            DataOutput dos2 = abvs2.getDataOutput();
-            try {
-                AInt32 ai = new AInt32(i);
-                AqlSerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(ai.getType()).serialize(ai, dos2);
-            } catch (HyracksDataException e) {
-                throw new AlgebricksException(e);
-            }
-            ICopyEvaluatorFactory coordinateEvalFactory = new ConstantEvalFactory(Arrays.copyOf(abvs2.getByteArray(),
-                    abvs2.getLength()));
+		for (int i = 0; i < numOfFields; i++) {
+			ArrayBackedValueStorage abvs2 = new ArrayBackedValueStorage();
+			DataOutput dos2 = abvs2.getDataOutput();
+			try {
+				AInt32 ai = new AInt32(i);
+				AqlSerializerDeserializerProvider.INSTANCE
+						.getSerializerDeserializer(ai.getType()).serialize(ai,
+								dos2);
+			} catch (HyracksDataException e) {
+				throw new AlgebricksException(e);
+			}
+			ICopyEvaluatorFactory coordinateEvalFactory = new ConstantEvalFactory(
+					Arrays.copyOf(abvs2.getByteArray(), abvs2.getLength()));
 
-            evalFactories[i] = new CreateMBREvalFactory(evalFactory, dimensionEvalFactory, coordinateEvalFactory);
-        }
-        return evalFactories;
-    }
+			evalFactories[i] = new CreateMBREvalFactory(evalFactory,
+					dimensionEvalFactory, coordinateEvalFactory);
+		}
+		return evalFactories;
+	}
 
-    @SuppressWarnings("unchecked")
-    @Override
-    public Triple<ICopyEvaluatorFactory, ScalarFunctionCallExpression, IAType> partitioningEvaluatorFactory(
-            ARecordType recType, String fldName) throws AlgebricksException {
-        String[] names = recType.getFieldNames();
-        int n = names.length;
-        for (int i = 0; i < n; i++) {
-            if (names[i].equals(fldName)) {
-                ICopyEvaluatorFactory recordEvalFactory = new ColumnAccessEvalFactory(
-                        GlobalConfig.DEFAULT_INPUT_DATA_COLUMN);
-                ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
-                DataOutput dos = abvs.getDataOutput();
-                try {
-                    AInt32 ai = new AInt32(i);
-                    AqlSerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(ai.getType()).serialize(ai,
-                            dos);
-                } catch (HyracksDataException e) {
-                    throw new AlgebricksException(e);
-                }
-                ICopyEvaluatorFactory fldIndexEvalFactory = new ConstantEvalFactory(Arrays.copyOf(abvs.getByteArray(),
-                        abvs.getLength()));
-                ICopyEvaluatorFactory evalFactory = new FieldAccessByIndexEvalFactory(recordEvalFactory,
-                        fldIndexEvalFactory, recType);
-                IFunctionInfo finfoAccess = AsterixBuiltinFunctions
-                        .getAsterixFunctionInfo(AsterixBuiltinFunctions.FIELD_ACCESS_BY_INDEX);
+	@SuppressWarnings("unchecked")
+	@Override
+	public Triple<ICopyEvaluatorFactory, ScalarFunctionCallExpression, IAType> partitioningEvaluatorFactory(
+			ARecordType recType, String fldName) throws AlgebricksException {
+		String[] names = recType.getFieldNames();
+		int n = names.length;
+		for (int i = 0; i < n; i++) {
+			if (names[i].equals(fldName)) {
+				ICopyEvaluatorFactory recordEvalFactory = new ColumnAccessEvalFactory(
+						GlobalConfig.DEFAULT_INPUT_DATA_COLUMN);
+				ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
+				DataOutput dos = abvs.getDataOutput();
+				try {
+					AInt32 ai = new AInt32(i);
+					AqlSerializerDeserializerProvider.INSTANCE
+							.getSerializerDeserializer(ai.getType()).serialize(
+									ai, dos);
+				} catch (HyracksDataException e) {
+					throw new AlgebricksException(e);
+				}
+				ICopyEvaluatorFactory fldIndexEvalFactory = new ConstantEvalFactory(
+						Arrays.copyOf(abvs.getByteArray(), abvs.getLength()));
+				ICopyEvaluatorFactory evalFactory = new FieldAccessByIndexEvalFactory(
+						recordEvalFactory, fldIndexEvalFactory, recType);
+				IFunctionInfo finfoAccess = AsterixBuiltinFunctions
+						.getAsterixFunctionInfo(AsterixBuiltinFunctions.FIELD_ACCESS_BY_INDEX);
 
-                ScalarFunctionCallExpression partitionFun = new ScalarFunctionCallExpression(finfoAccess,
-                        new MutableObject<ILogicalExpression>(new VariableReferenceExpression(METADATA_DUMMY_VAR)),
-                        new MutableObject<ILogicalExpression>(new ConstantExpression(new AsterixConstantValue(
-                                new AInt32(i)))));
-                return new Triple<ICopyEvaluatorFactory, ScalarFunctionCallExpression, IAType>(evalFactory,
-                        partitionFun, recType.getFieldTypes()[i]);
-            }
-        }
-        throw new AlgebricksException("Could not find field " + fldName + " in the schema.");
-    }
+				ScalarFunctionCallExpression partitionFun = new ScalarFunctionCallExpression(
+						finfoAccess,
+						new MutableObject<ILogicalExpression>(
+								new VariableReferenceExpression(
+										METADATA_DUMMY_VAR)),
+						new MutableObject<ILogicalExpression>(
+								new ConstantExpression(
+										new AsterixConstantValue(new AInt32(i)))));
+				return new Triple<ICopyEvaluatorFactory, ScalarFunctionCallExpression, IAType>(
+						evalFactory, partitionFun, recType.getFieldTypes()[i]);
+			}
+		}
+		throw new AlgebricksException("Could not find field " + fldName
+				+ " in the schema.");
+	}
 
-    @Override
-    public IFunctionDescriptor resolveFunction(ILogicalExpression expr, IVariableTypeEnvironment context)
-            throws AlgebricksException {
-        FunctionIdentifier fnId = ((AbstractFunctionCallExpression) expr).getFunctionIdentifier();
-        IFunctionManager mgr = FunctionManagerHolder.getFunctionManager();
-        IFunctionDescriptor fd = mgr.lookupFunction(fnId);
-        if (fd == null) {
-            throw new AsterixRuntimeException("Unresolved function " + fnId);
-        }
-        typeInference(expr, fd, context);
-        return fd;
-    }
+	@Override
+	public IFunctionDescriptor resolveFunction(ILogicalExpression expr,
+			IVariableTypeEnvironment context) throws AlgebricksException {
+		FunctionIdentifier fnId = ((AbstractFunctionCallExpression) expr)
+				.getFunctionIdentifier();
+		IFunctionManager mgr = FunctionManagerHolder.getFunctionManager();
+		IFunctionDescriptor fd = mgr.lookupFunction(fnId);
+		if (fd == null) {
+			throw new AsterixRuntimeException("Unresolved function " + fnId);
+		}
+		typeInference(expr, fd, context);
+		return fd;
+	}
 
-    private void typeInference(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
-            throws AlgebricksException {
-        if (fd.getIdentifier().equals(AsterixBuiltinFunctions.LISTIFY)) {
-            AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr;
-            if (f.getArguments().size() == 0) {
-                ((ListifyAggregateDescriptor) fd).reset(new AOrderedListType(null, null));
-            } else {
-                IAType itemType = (IAType) context.getType(f.getArguments().get(0).getValue());
-                // Convert UNION types into ANY.
-                if (itemType instanceof AUnionType) {
-                    itemType = BuiltinType.ANY;
-                }
-                ((ListifyAggregateDescriptor) fd).reset(new AOrderedListType(itemType, null));
-            }
-        }
-        if (fd.getIdentifier().equals(AsterixBuiltinFunctions.CAST_RECORD)) {
-            ARecordType rt = (ARecordType) TypeComputerUtilities.getRequiredType((AbstractFunctionCallExpression) expr);
-            ARecordType it = (ARecordType) TypeComputerUtilities.getInputType((AbstractFunctionCallExpression) expr);
-            ((CastRecordDescriptor) fd).reset(rt, it);
-        }
-        if (fd.getIdentifier().equals(AsterixBuiltinFunctions.OPEN_RECORD_CONSTRUCTOR)) {
-            ARecordType rt = (ARecordType) context.getType(expr);
-            ((OpenRecordConstructorDescriptor) fd).reset(rt,
-                    computeOpenFields((AbstractFunctionCallExpression) expr, rt));
-        }
-        if (fd.getIdentifier().equals(AsterixBuiltinFunctions.CLOSED_RECORD_CONSTRUCTOR)) {
-            ((ClosedRecordConstructorDescriptor) fd).reset((ARecordType) context.getType(expr));
-        }
-        if (fd.getIdentifier().equals(AsterixBuiltinFunctions.ORDERED_LIST_CONSTRUCTOR)) {
-            ((OrderedListConstructorDescriptor) fd).reset((AOrderedListType) context.getType(expr));
-        }
-        if (fd.getIdentifier().equals(AsterixBuiltinFunctions.UNORDERED_LIST_CONSTRUCTOR)) {
-            ((UnorderedListConstructorDescriptor) fd).reset((AUnorderedListType) context.getType(expr));
-        }
-        if (fd.getIdentifier().equals(AsterixBuiltinFunctions.FIELD_ACCESS_BY_INDEX)) {
-            AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
-            IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue());
-            switch (t.getTypeTag()) {
-                case RECORD: {
-                    ARecordType recType = (ARecordType) t;
-                    ((FieldAccessByIndexDescriptor) fd).reset(recType);
-                    break;
-                }
-                case UNION: {
-                    AUnionType unionT = (AUnionType) t;
-                    if (unionT.isNullableType()) {
-                        IAType t2 = unionT.getUnionList().get(1);
-                        if (t2.getTypeTag() == ATypeTag.RECORD) {
-                            ARecordType recType = (ARecordType) t2;
-                            ((FieldAccessByIndexDescriptor) fd).reset(recType);
-                            break;
-                        }
-                    }
-                    throw new NotImplementedException("field-access-by-index for data of type " + t);
-                }
-                default: {
-                    throw new NotImplementedException("field-access-by-index for data of type " + t);
-                }
-            }
-        }
-    }
+	private void typeInference(ILogicalExpression expr, IFunctionDescriptor fd,
+			IVariableTypeEnvironment context) throws AlgebricksException {
+		if (fd.getIdentifier().equals(AsterixBuiltinFunctions.LISTIFY)) {
+			AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr;
+			if (f.getArguments().size() == 0) {
+				((ListifyAggregateDescriptor) fd).reset(new AOrderedListType(
+						null, null));
+			} else {
+				IAType itemType = (IAType) context.getType(f.getArguments()
+						.get(0).getValue());
+				// Convert UNION types into ANY.
+				if (itemType instanceof AUnionType) {
+					itemType = BuiltinType.ANY;
+				}
+				((ListifyAggregateDescriptor) fd).reset(new AOrderedListType(
+						itemType, null));
+			}
+		}
+		if (fd.getIdentifier().equals(AsterixBuiltinFunctions.CAST_RECORD)) {
+			ARecordType rt = (ARecordType) TypeComputerUtilities
+					.getRequiredType((AbstractFunctionCallExpression) expr);
+			ARecordType it = (ARecordType) TypeComputerUtilities
+					.getInputType((AbstractFunctionCallExpression) expr);
+			((CastRecordDescriptor) fd).reset(rt, it);
+		}
+		if (fd.getIdentifier().equals(
+				AsterixBuiltinFunctions.OPEN_RECORD_CONSTRUCTOR)) {
+			ARecordType rt = (ARecordType) context.getType(expr);
+			((OpenRecordConstructorDescriptor) fd)
+					.reset(rt,
+							computeOpenFields(
+									(AbstractFunctionCallExpression) expr, rt));
+		}
+		if (fd.getIdentifier().equals(
+				AsterixBuiltinFunctions.CLOSED_RECORD_CONSTRUCTOR)) {
+			((ClosedRecordConstructorDescriptor) fd)
+					.reset((ARecordType) context.getType(expr));
+		}
+		if (fd.getIdentifier().equals(
+				AsterixBuiltinFunctions.ORDERED_LIST_CONSTRUCTOR)) {
+			((OrderedListConstructorDescriptor) fd)
+					.reset((AOrderedListType) context.getType(expr));
+		}
+		if (fd.getIdentifier().equals(
+				AsterixBuiltinFunctions.UNORDERED_LIST_CONSTRUCTOR)) {
+			((UnorderedListConstructorDescriptor) fd)
+					.reset((AUnorderedListType) context.getType(expr));
+		}
+		if (fd.getIdentifier().equals(
+				AsterixBuiltinFunctions.FIELD_ACCESS_BY_INDEX)) {
+			AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
+			IAType t = (IAType) context.getType(fce.getArguments().get(0)
+					.getValue());
+			switch (t.getTypeTag()) {
+			case RECORD: {
+				ARecordType recType = (ARecordType) t;
+				((FieldAccessByIndexDescriptor) fd).reset(recType);
+				break;
+			}
+			case UNION: {
+				AUnionType unionT = (AUnionType) t;
+				if (unionT.isNullableType()) {
+					IAType t2 = unionT.getUnionList().get(1);
+					if (t2.getTypeTag() == ATypeTag.RECORD) {
+						ARecordType recType = (ARecordType) t2;
+						((FieldAccessByIndexDescriptor) fd).reset(recType);
+						break;
+					}
+				}
+				throw new NotImplementedException(
+						"field-access-by-index for data of type " + t);
+			}
+			default: {
+				throw new NotImplementedException(
+						"field-access-by-index for data of type " + t);
+			}
+			}
+		}
+	}
 
-    private boolean[] computeOpenFields(AbstractFunctionCallExpression expr, ARecordType recType) {
-        int n = expr.getArguments().size() / 2;
-        boolean[] open = new boolean[n];
-        for (int i = 0; i < n; i++) {
-            Mutable<ILogicalExpression> argRef = expr.getArguments().get(2 * i);
-            ILogicalExpression arg = argRef.getValue();
-            if (arg.getExpressionTag() == LogicalExpressionTag.CONSTANT) {
-                String fn = ((AString) ((AsterixConstantValue) ((ConstantExpression) arg).getValue()).getObject())
-                        .getStringValue();
-                open[i] = true;
-                for (String s : recType.getFieldNames()) {
-                    if (s.equals(fn)) {
-                        open[i] = false;
-                        break;
-                    }
-                }
-            } else {
-                open[i] = true;
-            }
-        }
-        return open;
-    }
+	private boolean[] computeOpenFields(AbstractFunctionCallExpression expr,
+			ARecordType recType) {
+		int n = expr.getArguments().size() / 2;
+		boolean[] open = new boolean[n];
+		for (int i = 0; i < n; i++) {
+			Mutable<ILogicalExpression> argRef = expr.getArguments().get(2 * i);
+			ILogicalExpression arg = argRef.getValue();
+			if (arg.getExpressionTag() == LogicalExpressionTag.CONSTANT) {
+				String fn = ((AString) ((AsterixConstantValue) ((ConstantExpression) arg)
+						.getValue()).getObject()).getStringValue();
+				open[i] = true;
+				for (String s : recType.getFieldNames()) {
+					if (s.equals(fn)) {
+						open[i] = false;
+						break;
+					}
+				}
+			} else {
+				open[i] = true;
+			}
+		}
+		return open;
+	}
 
-    @Override
-    public IPrinterFactoryProvider getPrinterFactoryProvider() {
-        return AqlPrinterFactoryProvider.INSTANCE;
-    }
+	@Override
+	public IPrinterFactoryProvider getPrinterFactoryProvider() {
+		return AqlPrinterFactoryProvider.INSTANCE;
+	}
 
-    @Override
-    public IPrinterFactoryProvider getJSONPrinterFactoryProvider() {
-        return AqlJSONPrinterFactoryProvider.INSTANCE;
-    }
+	@SuppressWarnings("unchecked")
+	@Override
+	public ICopyEvaluatorFactory getConstantEvalFactory(
+			IAlgebricksConstantValue value) throws AlgebricksException {
+		IAObject obj = null;
+		if (value.isNull()) {
+			obj = ANull.NULL;
+		} else if (value.isTrue()) {
+			obj = ABoolean.TRUE;
+		} else if (value.isFalse()) {
+			obj = ABoolean.FALSE;
+		} else {
+			AsterixConstantValue acv = (AsterixConstantValue) value;
+			obj = acv.getObject();
+		}
+		ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
+		DataOutput dos = abvs.getDataOutput();
+		try {
+			AqlSerializerDeserializerProvider.INSTANCE
+					.getSerializerDeserializer(obj.getType()).serialize(obj,
+							dos);
+		} catch (HyracksDataException e) {
+			throw new AlgebricksException(e);
+		}
+		return new ConstantEvalFactory(Arrays.copyOf(abvs.getByteArray(),
+				abvs.getLength()));
+	}
 
-    @SuppressWarnings("unchecked")
-    @Override
-    public ICopyEvaluatorFactory getConstantEvalFactory(IAlgebricksConstantValue value) throws AlgebricksException {
-        IAObject obj = null;
-        if (value.isNull()) {
-            obj = ANull.NULL;
-        } else if (value.isTrue()) {
-            obj = ABoolean.TRUE;
-        } else if (value.isFalse()) {
-            obj = ABoolean.FALSE;
-        } else {
-            AsterixConstantValue acv = (AsterixConstantValue) value;
-            obj = acv.getObject();
-        }
-        ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
-        DataOutput dos = abvs.getDataOutput();
-        try {
-            AqlSerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(obj.getType()).serialize(obj, dos);
-        } catch (HyracksDataException e) {
-            throw new AlgebricksException(e);
-        }
-        return new ConstantEvalFactory(Arrays.copyOf(abvs.getByteArray(), abvs.getLength()));
-    }
+	@Override
+	public IBinaryIntegerInspectorFactory getBinaryIntegerInspectorFactory() {
+		return AqlBinaryIntegerInspector.FACTORY;
+	}
 
-    @Override
-    public IBinaryIntegerInspectorFactory getBinaryIntegerInspectorFactory() {
-        return AqlBinaryIntegerInspector.FACTORY;
-    }
+	@Override
+	public ITupleParserFactory createTupleParser(ARecordType recType,
+			IParseFileSplitsDecl decl) {
+		if (decl.isDelimitedFileFormat()) {
+			int n = recType.getFieldTypes().length;
+			IValueParserFactory[] fieldParserFactories = new IValueParserFactory[n];
+			for (int i = 0; i < n; i++) {
+				ATypeTag tag = recType.getFieldTypes()[i].getTypeTag();
+				IValueParserFactory vpf = typeToValueParserFactMap.get(tag);
+				if (vpf == null) {
+					throw new NotImplementedException(
+							"No value parser factory for delimited fields of type "
+									+ tag);
+				}
+				fieldParserFactories[i] = vpf;
+			}
+			return new NtDelimitedDataTupleParserFactory(recType,
+					fieldParserFactories, decl.getDelimChar());
+		} else {
+			return new AdmSchemafullRecordParserFactory(recType);
+		}
+	}
 
-    @Override
-    public ITupleParserFactory createTupleParser(ARecordType recType, IParseFileSplitsDecl decl) {
-        if (decl.isDelimitedFileFormat()) {
-            int n = recType.getFieldTypes().length;
-            IValueParserFactory[] fieldParserFactories = new IValueParserFactory[n];
-            for (int i = 0; i < n; i++) {
-                ATypeTag tag = recType.getFieldTypes()[i].getTypeTag();
-                IValueParserFactory vpf = typeToValueParserFactMap.get(tag);
-                if (vpf == null) {
-                    throw new NotImplementedException("No value parser factory for delimited fields of type " + tag);
-                }
-                fieldParserFactories[i] = vpf;
-            }
-            return new NtDelimitedDataTupleParserFactory(recType, fieldParserFactories, decl.getDelimChar());
-        } else {
-            return new AdmSchemafullRecordParserFactory(recType);
-        }
-    }
+	@Override
+	public ITupleParserFactory createTupleParser(ARecordType recType,
+			boolean delimitedFormat, Character delimiter) {
+		if (delimitedFormat) {
+			int n = recType.getFieldTypes().length;
+			IValueParserFactory[] fieldParserFactories = new IValueParserFactory[n];
+			for (int i = 0; i < n; i++) {
+				ATypeTag tag = recType.getFieldTypes()[i].getTypeTag();
+				IValueParserFactory vpf = typeToValueParserFactMap.get(tag);
+				if (vpf == null) {
+					throw new NotImplementedException(
+							"No value parser factory for delimited fields of type "
+									+ tag);
+				}
+				fieldParserFactories[i] = vpf;
+			}
+			return new NtDelimitedDataTupleParserFactory(recType,
+					fieldParserFactories, delimiter);
+		} else {
+			return new AdmSchemafullRecordParserFactory(recType);
+		}
+	}
 
-    @Override
-    public ITupleParserFactory createTupleParser(ARecordType recType, boolean delimitedFormat, Character delimiter) {
-        if (delimitedFormat) {
-            int n = recType.getFieldTypes().length;
-            IValueParserFactory[] fieldParserFactories = new IValueParserFactory[n];
-            for (int i = 0; i < n; i++) {
-                ATypeTag tag = recType.getFieldTypes()[i].getTypeTag();
-                IValueParserFactory vpf = typeToValueParserFactMap.get(tag);
-                if (vpf == null) {
-                    throw new NotImplementedException("No value parser factory for delimited fields of type " + tag);
-                }
-                fieldParserFactories[i] = vpf;
-            }
-            return new NtDelimitedDataTupleParserFactory(recType, fieldParserFactories, delimiter);
-        } else {
-            return new AdmSchemafullRecordParserFactory(recType);
-        }
-    }
+	@Override
+	public INullWriterFactory getNullWriterFactory() {
+		return AqlNullWriterFactory.INSTANCE;
+	}
 
-    @Override
-    public INullWriterFactory getNullWriterFactory() {
-        return AqlNullWriterFactory.INSTANCE;
-    }
+	@Override
+	public IExpressionEvalSizeComputer getExpressionEvalSizeComputer() {
+		return new IExpressionEvalSizeComputer() {
+			@Override
+			public int getEvalSize(ILogicalExpression expr,
+					IVariableEvalSizeEnvironment env)
+					throws AlgebricksException {
+				switch (expr.getExpressionTag()) {
+				case CONSTANT: {
+					ConstantExpression c = (ConstantExpression) expr;
+					if (c == ConstantExpression.NULL) {
+						return 1;
+					} else if (c == ConstantExpression.FALSE
+							|| c == ConstantExpression.TRUE) {
+						return 2;
+					} else {
+						AsterixConstantValue acv = (AsterixConstantValue) c
+								.getValue();
+						IAObject o = acv.getObject();
+						switch (o.getType().getTypeTag()) {
+						case DOUBLE: {
+							return 9;
+						}
+						case BOOLEAN: {
+							return 2;
+						}
+						case NULL: {
+							return 1;
+						}
+						case INT32: {
+							return 5;
+						}
+						case INT64: {
+							return 9;
+						}
+						default: {
+							// TODO
+							return -1;
+						}
+						}
+					}
+				}
+				case FUNCTION_CALL: {
+					AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr;
+					if (f.getFunctionIdentifier().equals(
+							AsterixBuiltinFunctions.TID)) {
+						return 5;
+					} else {
+						// TODO
+						return -1;
+					}
+				}
+				default: {
+					// TODO
+					return -1;
+				}
+				}
+			}
+		};
+	}
 
-    @Override
-    public IExpressionEvalSizeComputer getExpressionEvalSizeComputer() {
-        return new IExpressionEvalSizeComputer() {
-            @Override
-            public int getEvalSize(ILogicalExpression expr, IVariableEvalSizeEnvironment env)
-                    throws AlgebricksException {
-                switch (expr.getExpressionTag()) {
-                    case CONSTANT: {
-                        ConstantExpression c = (ConstantExpression) expr;
-                        if (c == ConstantExpression.NULL) {
-                            return 1;
-                        } else if (c == ConstantExpression.FALSE || c == ConstantExpression.TRUE) {
-                            return 2;
-                        } else {
-                            AsterixConstantValue acv = (AsterixConstantValue) c.getValue();
-                            IAObject o = acv.getObject();
-                            switch (o.getType().getTypeTag()) {
-                                case DOUBLE: {
-                                    return 9;
-                                }
-                                case BOOLEAN: {
-                                    return 2;
-                                }
-                                case NULL: {
-                                    return 1;
-                                }
-                                case INT32: {
-                                    return 5;
-                                }
-                                case INT64: {
-                                    return 9;
-                                }
-                                default: {
-                                    // TODO
-                                    return -1;
-                                }
-                            }
-                        }
-                    }
-                    case FUNCTION_CALL: {
-                        AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr;
-                        if (f.getFunctionIdentifier().equals(AsterixBuiltinFunctions.TID)) {
-                            return 5;
-                        } else {
-                            // TODO
-                            return -1;
-                        }
-                    }
-                    default: {
-                        // TODO
-                        return -1;
-                    }
-                }
-            }
-        };
-    }
+	@Override
+	public INormalizedKeyComputerFactoryProvider getNormalizedKeyComputerFactoryProvider() {
+		return AqlNormalizedKeyComputerFactoryProvider.INSTANCE;
+	}
 
-    @Override
-    public INormalizedKeyComputerFactoryProvider getNormalizedKeyComputerFactoryProvider() {
-        return AqlNormalizedKeyComputerFactoryProvider.INSTANCE;
-    }
-
-    @Override
-    public IBinaryHashFunctionFamilyProvider getBinaryHashFunctionFamilyProvider() {
-        return AqlBinaryHashFunctionFamilyProvider.INSTANCE;
-    }
+	@Override
+	public IBinaryHashFunctionFamilyProvider getBinaryHashFunctionFamilyProvider() {
+		return AqlBinaryHashFunctionFamilyProvider.INSTANCE;
+	}
 
 }