asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject [2/6] incubator-asterixdb git commit: Adding 'cleanjson' output format, along with implementation of lists.
Date Thu, 08 Oct 2015 16:45:00 GMT
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java
new file mode 100644
index 0000000..f8a2f8e
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.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

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java
new file mode 100644
index 0000000..7e4152f
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import java.io.PrintStream;
+
+import org.apache.asterix.om.pointables.PointableAllocator;
+import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
+import org.apache.asterix.om.pointables.base.IVisitablePointable;
+import org.apache.asterix.om.pointables.printer.json.lossless.APrintVisitor;
+import org.apache.asterix.om.types.AOrderedListType;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.common.utils.Pair;
+import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.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);
+                }
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinter.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinter.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinter.java
new file mode 100644
index 0000000..fb21c8d
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinter.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.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("] }");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinterFactory.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinterFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinterFactory.java
new file mode 100644
index 0000000..a6cd738
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinterFactory.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.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

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinter.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinter.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinter.java
new file mode 100644
index 0000000..8edf6d7
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinter.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.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("] }");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinterFactory.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinterFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinterFactory.java
new file mode 100644
index 0000000..53c2f42
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinterFactory.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.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

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinter.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinter.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinter.java
new file mode 100644
index 0000000..c94e19e
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinter.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.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("] }");
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinterFactory.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinterFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinterFactory.java
new file mode 100644
index 0000000..a808e8c
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinterFactory.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.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

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java
new file mode 100644
index 0000000..c4c1e23
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import java.io.PrintStream;
+
+import org.apache.asterix.om.pointables.PointableAllocator;
+import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
+import org.apache.asterix.om.pointables.base.IVisitablePointable;
+import org.apache.asterix.om.pointables.printer.json.lossless.APrintVisitor;
+import org.apache.asterix.om.types.ARecordType;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.common.utils.Pair;
+import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.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);
+                }
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinter.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinter.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinter.java
new file mode 100644
index 0000000..4393650
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinter.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.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("] } ] }");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinterFactory.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinterFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinterFactory.java
new file mode 100644
index 0000000..1fe5407
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinterFactory.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.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

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinter.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinter.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinter.java
new file mode 100644
index 0000000..55c285d
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinter.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.adm.PrintTools;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.data.IPrinter;
+
+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 {
+            PrintTools.writeUTF8StringAsJSON(b, s + 1, l - 1, ps);
+        } catch (IOException e) {
+            throw new AlgebricksException(e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinterFactory.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinterFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinterFactory.java
new file mode 100644
index 0000000..5f98719
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinterFactory.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.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

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinter.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinter.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinter.java
new file mode 100644
index 0000000..cd5fcc0
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinter.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.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("}");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinterFactory.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinterFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinterFactory.java
new file mode 100644
index 0000000..fed83c9
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinterFactory.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.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

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnionPrinterFactory.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnionPrinterFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnionPrinterFactory.java
new file mode 100644
index 0000000..6be1207
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnionPrinterFactory.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import java.io.PrintStream;
+import java.util.List;
+
+import org.apache.asterix.formats.nontagged.AqlLosslessJSONPrinterFactoryProvider;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.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] = (AqlLosslessJSONPrinterFactoryProvider.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);
+                }
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnorderedlistPrinterFactory.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnorderedlistPrinterFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnorderedlistPrinterFactory.java
new file mode 100644
index 0000000..cad45e1
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnorderedlistPrinterFactory.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import java.io.PrintStream;
+
+import org.apache.asterix.om.pointables.PointableAllocator;
+import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
+import org.apache.asterix.om.pointables.base.IVisitablePointable;
+import org.apache.asterix.om.pointables.printer.json.lossless.APrintVisitor;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.AUnorderedListType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.common.utils.Pair;
+import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.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);
+                }
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinter.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinter.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinter.java
new file mode 100644
index 0000000..d138678
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinter.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.data.IPrinter;
+
+public class AYearMonthDurationPrinter implements IPrinter {
+
+    public static final AYearMonthDurationPrinter INSTANCE = new AYearMonthDurationPrinter();
+
+    /* (non-Javadoc)
+     * @see org.apache.hyracks.algebricks.data.IPrinter#init()
+     */
+    @Override
+    public void init() throws AlgebricksException {
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.hyracks.algebricks.data.IPrinter#print(byte[], int, int, java.io.PrintStream)
+     */
+    @Override
+    public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
+
+        int months = AInt32SerializerDeserializer.getInt(b, s + 1);
+
+        ps.print("{ \"year-month-duration\": ");
+        ps.print(months);
+        ps.print("}");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinterFactory.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinterFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinterFactory.java
new file mode 100644
index 0000000..ca2201b
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinterFactory.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+
+import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.hyracks.algebricks.data.IPrinterFactory;
+
+public class AYearMonthDurationPrinterFactory implements IPrinterFactory {
+
+    private static final long serialVersionUID = 1L;
+    public static final AYearMonthDurationPrinterFactory INSTANCE = new AYearMonthDurationPrinterFactory();
+
+    /* (non-Javadoc)
+     * @see org.apache.hyracks.algebricks.data.IPrinterFactory#createPrinter()
+     */
+    @Override
+    public IPrinter createPrinter() {
+        return AYearMonthDurationPrinter.INSTANCE;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/formats/base/IDataFormat.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/formats/base/IDataFormat.java b/asterix-om/src/main/java/org/apache/asterix/formats/base/IDataFormat.java
index ffbcd20..8dcbb77 100644
--- a/asterix-om/src/main/java/org/apache/asterix/formats/base/IDataFormat.java
+++ b/asterix-om/src/main/java/org/apache/asterix/formats/base/IDataFormat.java
@@ -63,10 +63,12 @@ public interface IDataFormat {
     // QQQ Refactor: Make this accept an APIFramework.OutputFormat parameter
     public IPrinterFactoryProvider getADMPrinterFactoryProvider();
 
-    public IPrinterFactoryProvider getJSONPrinterFactoryProvider();
+    public IPrinterFactoryProvider getLosslessJSONPrinterFactoryProvider();
 
     public IPrinterFactoryProvider getCSVPrinterFactoryProvider();
 
+    public IPrinterFactoryProvider getCleanJSONPrinterFactoryProvider();
+
     public INullWriterFactory getNullWriterFactory();
 
     public Triple<ICopyEvaluatorFactory, ScalarFunctionCallExpression, IAType> partitioningEvaluatorFactory(

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCleanJSONPrinterFactoryProvider.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCleanJSONPrinterFactoryProvider.java b/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCleanJSONPrinterFactoryProvider.java
new file mode 100644
index 0000000..0f58aee
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCleanJSONPrinterFactoryProvider.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.formats.nontagged;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.adm.ABinaryPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.adm.AUUIDPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.adm.ShortWithoutTypeInfoPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ABooleanPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ACirclePrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ADatePrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ADateTimePrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ADayTimeDurationPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ADoublePrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ADurationPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AFloatPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AInt16PrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AInt32PrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AInt64PrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AInt8PrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AIntervalPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ALinePrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ANullPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ANullableFieldPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AObjectPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AOrderedlistPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.APoint3DPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.APointPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.APolygonPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ARecordPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ARectanglePrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AStringPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ATimePrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AUnionPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AUnorderedlistPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AYearMonthDurationPrinterFactory;
+import org.apache.asterix.om.types.AOrderedListType;
+import org.apache.asterix.om.types.ARecordType;
+import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.AUnorderedListType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.algebricks.data.IPrinterFactoryProvider;
+
+public class AqlCleanJSONPrinterFactoryProvider implements IPrinterFactoryProvider {
+
+    public static final AqlCleanJSONPrinterFactoryProvider INSTANCE = new AqlCleanJSONPrinterFactoryProvider();
+
+    private AqlCleanJSONPrinterFactoryProvider() {
+    }
+
+    @Override
+    public IPrinterFactory getPrinterFactory(Object type) throws AlgebricksException {
+        IAType aqlType = (IAType) type;
+
+        if (aqlType != null) {
+            switch (aqlType.getTypeTag()) {
+                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 YEARMONTHDURATION:
+                    return AYearMonthDurationPrinterFactory.INSTANCE;
+                case DAYTIMEDURATION:
+                    return ADayTimeDurationPrinterFactory.INSTANCE;
+                case INTERVAL:
+                    return AIntervalPrinterFactory.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 BINARY:
+                    return ABinaryPrinterFactory.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 (((AUnionType) aqlType).isNullableType())
+                        return new ANullableFieldPrinterFactory((AUnionType) aqlType);
+                    else
+                        return new AUnionPrinterFactory((AUnionType) aqlType);
+                }
+                case UUID: {
+                    return AUUIDPrinterFactory.INSTANCE;
+                }
+                case SHORTWITHOUTTYPEINFO:
+                    return ShortWithoutTypeInfoPrinterFactory.INSTANCE;
+                case ANY:
+                case BITARRAY:
+                case ENUM:
+                case SPARSERECORD:
+                case SYSTEM_NULL:
+                case TYPE:
+                case UINT16:
+                case UINT32:
+                case UINT64:
+                case UINT8:
+                case UUID_STRING:
+                    // These types are not intended to be printed to the user.
+                    break;
+            }
+        }
+        return AObjectPrinterFactory.INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlJSONPrinterFactoryProvider.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlJSONPrinterFactoryProvider.java b/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlJSONPrinterFactoryProvider.java
deleted file mode 100644
index 96dcbb5..0000000
--- a/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlJSONPrinterFactoryProvider.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.formats.nontagged;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ABinaryPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.AUUIDPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ShortWithoutTypeInfoPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.ABooleanPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.ACirclePrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.ADatePrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.ADateTimePrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.ADayTimeDurationPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.ADoublePrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.ADurationPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.AFloatPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.AInt16PrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.AInt32PrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.AInt64PrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.AInt8PrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.AIntervalPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.ALinePrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.ANullPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.ANullableFieldPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.AObjectPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.AOrderedlistPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.APoint3DPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.APointPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.APolygonPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.ARecordPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.ARectanglePrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.AStringPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.ATimePrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.AUnionPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.AUnorderedlistPrinterFactory;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.AYearMonthDurationPrinterFactory;
-import org.apache.asterix.om.types.AOrderedListType;
-import org.apache.asterix.om.types.ARecordType;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.AUnorderedListType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.data.IPrinterFactory;
-import org.apache.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 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 YEARMONTHDURATION:
-                    return AYearMonthDurationPrinterFactory.INSTANCE;
-                case DAYTIMEDURATION:
-                    return ADayTimeDurationPrinterFactory.INSTANCE;
-                case INTERVAL:
-                    return AIntervalPrinterFactory.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 BINARY:
-                    return ABinaryPrinterFactory.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 (((AUnionType) aqlType).isNullableType())
-                        return new ANullableFieldPrinterFactory((AUnionType) aqlType);
-                    else
-                        return new AUnionPrinterFactory((AUnionType) aqlType);
-                }
-                case UUID: {
-                    return AUUIDPrinterFactory.INSTANCE;
-                }
-                case SHORTWITHOUTTYPEINFO:
-                    return ShortWithoutTypeInfoPrinterFactory.INSTANCE;
-                case ANY:
-                case BITARRAY:
-                case ENUM:
-                case SPARSERECORD:
-                case SYSTEM_NULL:
-                case TYPE:
-                case UINT16:
-                case UINT32:
-                case UINT64:
-                case UINT8:
-                case UUID_STRING:
-                    // These types are not intended to be printed to the user.
-                    break;
-            }
-        }
-        return AObjectPrinterFactory.INSTANCE;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlLosslessJSONPrinterFactoryProvider.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlLosslessJSONPrinterFactoryProvider.java b/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlLosslessJSONPrinterFactoryProvider.java
new file mode 100644
index 0000000..012265a
--- /dev/null
+++ b/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlLosslessJSONPrinterFactoryProvider.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.formats.nontagged;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.adm.ABinaryPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.adm.AUUIDPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.adm.ShortWithoutTypeInfoPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ABooleanPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ACirclePrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ADatePrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ADateTimePrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ADayTimeDurationPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ADoublePrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ADurationPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AFloatPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AInt16PrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AInt32PrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AInt64PrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AInt8PrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AIntervalPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ALinePrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ANullPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ANullableFieldPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AObjectPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AOrderedlistPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.APoint3DPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.APointPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.APolygonPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ARecordPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ARectanglePrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AStringPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ATimePrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AUnionPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AUnorderedlistPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AYearMonthDurationPrinterFactory;
+import org.apache.asterix.om.types.AOrderedListType;
+import org.apache.asterix.om.types.ARecordType;
+import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.AUnorderedListType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.algebricks.data.IPrinterFactoryProvider;
+
+public class AqlLosslessJSONPrinterFactoryProvider implements IPrinterFactoryProvider {
+
+    public static final AqlLosslessJSONPrinterFactoryProvider INSTANCE = new AqlLosslessJSONPrinterFactoryProvider();
+
+    private AqlLosslessJSONPrinterFactoryProvider() {
+    }
+
+    @Override
+    public IPrinterFactory getPrinterFactory(Object type) throws AlgebricksException {
+        IAType aqlType = (IAType) type;
+
+        if (aqlType != null) {
+            switch (aqlType.getTypeTag()) {
+                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 YEARMONTHDURATION:
+                    return AYearMonthDurationPrinterFactory.INSTANCE;
+                case DAYTIMEDURATION:
+                    return ADayTimeDurationPrinterFactory.INSTANCE;
+                case INTERVAL:
+                    return AIntervalPrinterFactory.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 BINARY:
+                    return ABinaryPrinterFactory.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 (((AUnionType) aqlType).isNullableType())
+                        return new ANullableFieldPrinterFactory((AUnionType) aqlType);
+                    else
+                        return new AUnionPrinterFactory((AUnionType) aqlType);
+                }
+                case UUID: {
+                    return AUUIDPrinterFactory.INSTANCE;
+                }
+                case SHORTWITHOUTTYPEINFO:
+                    return ShortWithoutTypeInfoPrinterFactory.INSTANCE;
+                case ANY:
+                case BITARRAY:
+                case ENUM:
+                case SPARSERECORD:
+                case SYSTEM_NULL:
+                case TYPE:
+                case UINT16:
+                case UINT32:
+                case UINT64:
+                case UINT8:
+                case UUID_STRING:
+                    // These types are not intended to be printed to the user.
+                    break;
+            }
+        }
+        return AObjectPrinterFactory.INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/f4a1c3c6/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/AListPrinter.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/AListPrinter.java b/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/AListPrinter.java
deleted file mode 100644
index 54a3524..0000000
--- a/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/AListPrinter.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.asterix.om.pointables.printer.json;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.List;
-
-import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.om.pointables.AListVisitablePointable;
-import org.apache.asterix.om.pointables.base.IVisitablePointable;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
-import org.apache.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(AListVisitablePointable 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);
-    }
-}


Mime
View raw message