ASTERIXDB-1220: print nested values using visitors
- remove named printer classes
- remove redundancy between AObjectPrinterFactory and PrintVisitor
- remove redundant List- and RecordPrinters
- introduce AbstractPrintVisitor
Change-Id: I692c04dd1b3aa8e7adccfe960615f0fc2df6fe26
Reviewed-on: https://asterix-gerrit.ics.uci.edu/882
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/PrintTools.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/PrintTools.java
index 7dfb84d..5b5f53f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/PrintTools.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/PrintTools.java
@@ -108,6 +108,39 @@
}
}
+ public static void printYearMonthDurationString(byte[] b, int s, int l, PrintStream ps)
+ throws HyracksDataException {
+ final GregorianCalendarSystem gCalInstance = GregorianCalendarSystem.getInstance();
+ boolean positive = true;
+ int months = AInt32SerializerDeserializer.getInt(b, s + 1);
+
+ // set the negative flag. "||" is necessary in case that months field is not there (so it is 0)
+ if (months < 0) {
+ months *= -1;
+ positive = false;
+ }
+
+ int month = gCalInstance.getDurationMonth(months);
+ int year = gCalInstance.getDurationYear(months);
+
+ if (!positive) {
+ ps.print("-");
+ }
+ try {
+ ps.print("P");
+ if (year != 0) {
+ WriteValueTools.writeInt(year, ps);
+ ps.print("Y");
+ }
+ if (month != 0) {
+ WriteValueTools.writeInt(month, ps);
+ ps.print("M");
+ }
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ }
+
public static void printDurationString(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
boolean positive = true;
int months = AInt32SerializerDeserializer.getInt(b, s + 1);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABinaryBase64Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABinaryBase64Printer.java
deleted file mode 100644
index 0d02394..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABinaryBase64Printer.java
+++ /dev/null
@@ -1,53 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
-import org.apache.hyracks.util.bytes.Base64Printer;
-
-public class ABinaryBase64Printer implements IPrinter {
- private ABinaryBase64Printer() {
- }
-
- public static final ABinaryBase64Printer INSTANCE = new ABinaryBase64Printer();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- int validLength = ByteArrayPointable.getContentLength(b, s + 1);
- int start = s + 1 + ByteArrayPointable.getNumberBytesToStoreMeta(validLength);
- try {
- ps.print("base64(\"");
- Base64Printer.printBase64Binary(b, start, validLength, ps);
- ps.print("\")");
- } catch (IOException e) {
- throw new HyracksDataException(e);
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABinaryHexPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABinaryHexPrinterFactory.java
similarity index 76%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABinaryHexPrinter.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABinaryHexPrinterFactory.java
index 5e353c1..b5ac617 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABinaryHexPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABinaryHexPrinterFactory.java
@@ -23,22 +23,20 @@
import java.io.PrintStream;
import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.hyracks.algebricks.data.IPrinterFactory;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
import org.apache.hyracks.util.bytes.HexPrinter;
-public class ABinaryHexPrinter implements IPrinter {
- private ABinaryHexPrinter() {
+public class ABinaryHexPrinterFactory implements IPrinterFactory {
+ private static final long serialVersionUID = 1L;
+
+ private ABinaryHexPrinterFactory() {
}
- public static final ABinaryHexPrinter INSTANCE = new ABinaryHexPrinter();
+ public static final ABinaryHexPrinterFactory INSTANCE = new ABinaryHexPrinterFactory();
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
int validLength = ByteArrayPointable.getContentLength(b, s + 1);
int start = s + 1 + ByteArrayPointable.getNumberBytesToStoreMeta(validLength);
try {
@@ -48,6 +46,10 @@
} catch (IOException e) {
throw new HyracksDataException(e);
}
- }
+ };
+ @Override
+ public IPrinter createPrinter() {
+ return PRINTER;
+ }
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABinaryPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABinaryPrinterFactory.java
deleted file mode 100644
index 2155369..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABinaryPrinterFactory.java
+++ /dev/null
@@ -1,37 +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.dataflow.data.nontagged.printers.adm;
-
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.algebricks.data.IPrinterFactory;
-
-public class ABinaryPrinterFactory implements IPrinterFactory {
- private static final long serialVersionUID = 1L;
-
- private ABinaryPrinterFactory() {
- }
-
- public static final ABinaryPrinterFactory INSTANCE = new ABinaryPrinterFactory();
-
- @Override
- public IPrinter createPrinter() {
- return ABinaryHexPrinter.INSTANCE;
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABooleanPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABooleanPrinter.java
deleted file mode 100644
index 09b36bc..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABooleanPrinter.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print(ABooleanSerializerDeserializer.getBoolean(b, s + 1));
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABooleanPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABooleanPrinterFactory.java
index 7f719f1..511ea9f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABooleanPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ABooleanPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final ABooleanPrinterFactory INSTANCE = new ABooleanPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(ABooleanSerializerDeserializer.getBoolean(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return ABooleanPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ACirclePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ACirclePrinter.java
deleted file mode 100644
index f2d6904..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ACirclePrinter.java
+++ /dev/null
@@ -1,45 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("circle(\"");
- 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("\")");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ACirclePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ACirclePrinterFactory.java
index cfe9250..49cbf04 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ACirclePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ACirclePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,18 @@
private static final long serialVersionUID = 1L;
public static final ACirclePrinterFactory INSTANCE = new ACirclePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("circle(\"");
+ 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("\")");
+ };
+
@Override
public IPrinter createPrinter() {
- return ACirclePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADatePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADatePrinter.java
deleted file mode 100644
index 6f4d28d..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADatePrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class ADatePrinter implements IPrinter {
-
- public static final ADatePrinter INSTANCE = new ADatePrinter();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- ps.print("date(\"");
- PrintTools.printDateString(b, s, l, ps);
- ps.print("\")");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADatePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADatePrinterFactory.java
index e486966..eec4607 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADatePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADatePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADatePrinterFactory INSTANCE = new ADatePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("date(\"");
+ PrintTools.printDateString(b, s, l, ps);
+ ps.print("\")");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADatePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADateTimePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADateTimePrinter.java
deleted file mode 100644
index 6a9b77c..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADateTimePrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("datetime(\"");
- PrintTools.printDateTimeString(b, s, l, ps);
- ps.print("\")");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADateTimePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADateTimePrinterFactory.java
index 966ff29..5702a43 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADateTimePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADateTimePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADateTimePrinterFactory INSTANCE = new ADateTimePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("datetime(\"");
+ PrintTools.printDateTimeString(b, s, l, ps);
+ ps.print("\")");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADateTimePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADayTimeDurationPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADayTimeDurationPrinter.java
deleted file mode 100644
index 36a7711..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADayTimeDurationPrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class ADayTimeDurationPrinter implements IPrinter {
-
- public static final ADayTimeDurationPrinter INSTANCE = new ADayTimeDurationPrinter();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- ps.print("day-time-duration(\"");
- PrintTools.printDayTimeDurationString(b, s, l, ps);
- ps.print("\")");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADayTimeDurationPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADayTimeDurationPrinterFactory.java
index fe26a42..360b8f0 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADayTimeDurationPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADayTimeDurationPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADayTimeDurationPrinterFactory INSTANCE = new ADayTimeDurationPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("day-time-duration(\"");
+ PrintTools.printDayTimeDurationString(b, s, l, ps);
+ ps.print("\")");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADayTimeDurationPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADoublePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADoublePrinter.java
deleted file mode 100644
index 6b54394..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADoublePrinter.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1) + "d");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADoublePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADoublePrinterFactory.java
index 8baac2e..6103f7c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADoublePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADoublePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final ADoublePrinterFactory INSTANCE = new ADoublePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(ADoubleSerializerDeserializer.getDouble(b, s + 1) + "d");
+
@Override
public IPrinter createPrinter() {
- return ADoublePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADurationPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADurationPrinter.java
deleted file mode 100644
index 6fb27fb..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADurationPrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("duration(\"");
- PrintTools.printDurationString(b, s, l, ps);
- ps.print("\")");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADurationPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADurationPrinterFactory.java
index 5b64a6e..cd7c978 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADurationPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ADurationPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADurationPrinterFactory INSTANCE = new ADurationPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("duration(\"");
+ PrintTools.printDurationString(b, s, l, ps);
+ ps.print("\")");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADurationPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AFloatPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AFloatPrinter.java
deleted file mode 100644
index bd15ea1..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AFloatPrinter.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print(AFloatSerializerDeserializer.getFloat(b, s + 1) + "f");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AFloatPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AFloatPrinterFactory.java
index bcfb9df..372a027 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AFloatPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AFloatPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final AFloatPrinterFactory INSTANCE = new AFloatPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(AFloatSerializerDeserializer.getFloat(b, s + 1) + "f");
+
@Override
public IPrinter createPrinter() {
- return AFloatPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt16Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt16Printer.java
deleted file mode 100644
index e8b86df..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt16Printer.java
+++ /dev/null
@@ -1,49 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.algebricks.data.utils.WriteValueTools;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AInt16Printer implements IPrinter {
-
- private static final String SUFFIX_STRING = "i16";
-
- public static final AInt16Printer INSTANCE = new AInt16Printer();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- short i = AInt16SerializerDeserializer.getShort(b, s + 1);
- try {
- WriteValueTools.writeInt(i, ps);
- WriteValueTools.writeUTF8StringNoQuotes(SUFFIX_STRING, ps);
- } catch (IOException e) {
- throw new HyracksDataException(e);
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt16PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt16PrinterFactory.java
index d9094a0..2f02d93 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt16PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt16PrinterFactory.java
@@ -18,17 +18,32 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.algebricks.data.utils.WriteValueTools;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public class AInt16PrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
+ private static final String SUFFIX_STRING = "i16";
public static final AInt16PrinterFactory INSTANCE = new AInt16PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ try {
+ WriteValueTools.writeInt(AInt16SerializerDeserializer.getShort(b, s + 1), ps);
+ WriteValueTools.writeUTF8StringNoQuotes(SUFFIX_STRING, ps);
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ };
+
@Override
public IPrinter createPrinter() {
- return AInt16Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt32Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt32Printer.java
deleted file mode 100644
index 1f05cb7..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt32Printer.java
+++ /dev/null
@@ -1,49 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.algebricks.data.utils.WriteValueTools;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AInt32Printer implements IPrinter {
-
- private static final String SUFFIX_STRING = "i32";
-
- public static final AInt32Printer INSTANCE = new AInt32Printer();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- int d = AInt32SerializerDeserializer.getInt(b, s + 1);
- try {
- WriteValueTools.writeInt(d, ps);
- WriteValueTools.writeUTF8StringNoQuotes(SUFFIX_STRING, ps);
- } catch (IOException e) {
- throw new HyracksDataException(e);
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt32PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt32PrinterFactory.java
index da7935c..3bae963 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt32PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt32PrinterFactory.java
@@ -18,17 +18,32 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.algebricks.data.utils.WriteValueTools;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public class AInt32PrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
+ private static final String SUFFIX_STRING = "i32";
public static final AInt32PrinterFactory INSTANCE = new AInt32PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ try {
+ WriteValueTools.writeInt(AInt32SerializerDeserializer.getInt(b, s + 1), ps);
+ WriteValueTools.writeUTF8StringNoQuotes(SUFFIX_STRING, ps);
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ };
+
@Override
public IPrinter createPrinter() {
- return AInt32Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt64Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt64Printer.java
deleted file mode 100644
index 2ed8224..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt64Printer.java
+++ /dev/null
@@ -1,46 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.algebricks.data.utils.WriteValueTools;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- long d = AInt64SerializerDeserializer.getLong(b, s + 1);
- try {
- WriteValueTools.writeLong(d, ps);
- } catch (IOException e) {
- throw new HyracksDataException(e);
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt64PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt64PrinterFactory.java
index 27a61f7..0c00cee 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt64PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt64PrinterFactory.java
@@ -18,17 +18,30 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.algebricks.data.utils.WriteValueTools;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public class AInt64PrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
public static final AInt64PrinterFactory INSTANCE = new AInt64PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ try {
+ WriteValueTools.writeLong(AInt64SerializerDeserializer.getLong(b, s + 1), ps);
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ };
+
@Override
public IPrinter createPrinter() {
- return AInt64Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt8Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt8Printer.java
deleted file mode 100644
index 979d745..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt8Printer.java
+++ /dev/null
@@ -1,49 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.algebricks.data.utils.WriteValueTools;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AInt8Printer implements IPrinter {
-
- private static final String SUFFIX_STRING = "i8";
-
- public static final AInt8Printer INSTANCE = new AInt8Printer();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- byte o = AInt8SerializerDeserializer.getByte(b, s + 1);
- try {
- WriteValueTools.writeInt(o, ps);
- WriteValueTools.writeUTF8StringNoQuotes(SUFFIX_STRING, ps);
- } catch (IOException e) {
- throw new HyracksDataException(e);
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt8PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt8PrinterFactory.java
index 21b3c05..d1ba898 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt8PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AInt8PrinterFactory.java
@@ -18,17 +18,32 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.algebricks.data.utils.WriteValueTools;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public class AInt8PrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
+ private static final String SUFFIX_STRING = "i8";
public static final AInt8PrinterFactory INSTANCE = new AInt8PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ try {
+ WriteValueTools.writeInt(AInt8SerializerDeserializer.getByte(b, s + 1), ps);
+ WriteValueTools.writeUTF8StringNoQuotes(SUFFIX_STRING, ps);
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ };
+
@Override
public IPrinter createPrinter() {
- return AInt8Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AIntervalPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AIntervalPrinter.java
deleted file mode 100644
index da331f5..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AIntervalPrinter.java
+++ /dev/null
@@ -1,75 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AIntervalPrinter implements IPrinter {
-
- public static final AIntervalPrinter INSTANCE = new AIntervalPrinter();
-
- /* (non-Javadoc)
- * @see org.apache.hyracks.algebricks.data.IPrinter#init()
- */
- @Override
- public void init() {
- }
-
- /* (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 HyracksDataException {
- ps.print("interval(");
-
- byte typetag = AIntervalSerializerDeserializer.getIntervalTimeType(b, s + 1);
- int startOffset = AIntervalSerializerDeserializer.getIntervalStartOffset(b, s + 1) - 1;
- int startSize = AIntervalSerializerDeserializer.getStartSize(b, s + 1);
- int endOffset = AIntervalSerializerDeserializer.getIntervalEndOffset(b, s + 1) - 1;
- int endSize = AIntervalSerializerDeserializer.getEndSize(b, s + 1);
-
- IPrinter timeInstancePrinter;
- ATypeTag intervalType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(typetag);
- switch (intervalType) {
- case DATE:
- timeInstancePrinter = ADatePrinter.INSTANCE;
- break;
- case TIME:
- timeInstancePrinter = ATimePrinter.INSTANCE;
- break;
- case DATETIME:
- timeInstancePrinter = ADateTimePrinter.INSTANCE;
- break;
- default:
- throw new HyracksDataException("Unsupported internal time types in interval: " + typetag);
- }
-
- timeInstancePrinter.print(b, startOffset, startSize, ps);
- ps.print(", ");
- timeInstancePrinter.print(b, endOffset, endSize, ps);
-
- ps.print(")");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AIntervalPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AIntervalPrinterFactory.java
index 95dd10d..106b765 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AIntervalPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AIntervalPrinterFactory.java
@@ -18,17 +18,48 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public class AIntervalPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
public static final AIntervalPrinterFactory INSTANCE = new AIntervalPrinterFactory();
- @Override
- public IPrinter createPrinter() {
- return AIntervalPrinter.INSTANCE;
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("interval(");
+ byte typetag = AIntervalSerializerDeserializer.getIntervalTimeType(b, s + 1);
+ int startOffset = AIntervalSerializerDeserializer.getIntervalStartOffset(b, s + 1) - 1;
+ int startSize = AIntervalSerializerDeserializer.getStartSize(b, s + 1);
+ int endOffset = AIntervalSerializerDeserializer.getIntervalEndOffset(b, s + 1) - 1;
+ int endSize = AIntervalSerializerDeserializer.getEndSize(b, s + 1);
+ IPrinter timeInstancePrinter = getIPrinter(typetag);
+ timeInstancePrinter.print(b, startOffset, startSize, ps);
+ ps.print(", ");
+ timeInstancePrinter.print(b, endOffset, endSize, ps);
+ ps.print(")");
+ };
+
+ private static IPrinter getIPrinter(byte typetag) throws HyracksDataException {
+ switch (EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(typetag)) {
+ case DATE:
+ return ADatePrinterFactory.PRINTER;
+ case TIME:
+ return ATimePrinterFactory.PRINTER;
+ case DATETIME:
+ return ADateTimePrinterFactory.PRINTER;
+ default:
+ throw new HyracksDataException("Unsupported internal time types in interval: " + typetag);
+ }
}
+ @Override
+ public IPrinter createPrinter() {
+ return PRINTER;
+ }
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ALinePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ALinePrinter.java
deleted file mode 100644
index b42bc09..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ALinePrinter.java
+++ /dev/null
@@ -1,47 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("line(\"");
- 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(",");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
- ps.print("\")");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ALinePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ALinePrinterFactory.java
index 8cade11..d6b3e17 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ALinePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ALinePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,20 @@
private static final long serialVersionUID = 1L;
public static final ALinePrinterFactory INSTANCE = new ALinePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("line(\"");
+ 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(",");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
+ ps.print("\")");
+ };
+
@Override
public IPrinter createPrinter() {
- return ALinePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullPrinter.java
deleted file mode 100644
index 61b73fc..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullPrinter.java
+++ /dev/null
@@ -1,38 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("null");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullPrinterFactory.java
index e37c06a..d9cb1ff 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullPrinterFactory.java
@@ -18,6 +18,8 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +28,10 @@
private static final long serialVersionUID = 1L;
public static final ANullPrinterFactory INSTANCE = new ANullPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps.print("null");
+
@Override
public IPrinter createPrinter() {
- return ANullPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullableFieldPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullableFieldPrinterFactory.java
index 010e968..784bd0b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullableFieldPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullableFieldPrinterFactory.java
@@ -61,8 +61,6 @@
fieldPrinter.print(b, s, l, ps);
}
}
-
};
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinter.java
deleted file mode 100644
index 27aa754..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinter.java
+++ /dev/null
@@ -1,176 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- 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 MISSING:
- 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 YEARMONTHDURATION: {
- AYearMonthDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case DAYTIMEDURATION: {
- ADayTimeDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case INTERVAL: {
- AIntervalPrinter.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 RECTANGLE: {
- ARectanglePrinter.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 BINARY: {
- ABinaryHexPrinter.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;
- }
- case UUID: {
- AUUIDPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case SHORTWITHOUTTYPEINFO: {
- ShortWithoutTypeInfoPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case ANY:
- case BITARRAY:
- case ENUM:
- case SPARSERECORD:
- case SYSTEM_NULL:
- case TYPE:
- case UINT16:
- case UINT32:
- case UINT64:
- case UINT8:
- case UNION:
- // These are internal types and do not need a printer.
- throw new NotImplementedException("No printer for type " + typeTag);
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinterFactory.java
index 2a86f88..db3480d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinterFactory.java
@@ -18,17 +18,148 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.om.pointables.AListVisitablePointable;
+import org.apache.asterix.om.pointables.ARecordVisitablePointable;
+import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
+import org.apache.asterix.om.pointables.printer.IPrintVisitor;
+import org.apache.asterix.om.pointables.printer.adm.APrintVisitor;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.hyracks.algebricks.common.utils.Pair;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
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;
+ public static boolean printFlatValue(ATypeTag typeTag, byte[] b, int s, int l, PrintStream ps)
+ throws HyracksDataException {
+ switch (typeTag) {
+ case INT8:
+ AInt8PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INT16:
+ AInt16PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INT32:
+ AInt32PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INT64:
+ AInt64PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case MISSING:
+ case NULL:
+ ANullPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case BOOLEAN:
+ ABooleanPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case FLOAT:
+ AFloatPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DOUBLE:
+ ADoublePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DATE:
+ ADatePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case TIME:
+ ATimePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DATETIME:
+ ADateTimePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DURATION:
+ ADurationPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case YEARMONTHDURATION:
+ AYearMonthDurationPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DAYTIMEDURATION:
+ ADayTimeDurationPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INTERVAL:
+ AIntervalPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case POINT:
+ APointPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case POINT3D:
+ APoint3DPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case LINE:
+ ALinePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case POLYGON:
+ APolygonPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case RECTANGLE:
+ ARectanglePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case CIRCLE:
+ ACirclePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case STRING:
+ AStringPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case BINARY:
+ ABinaryHexPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case UUID:
+ AUUIDPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case SHORTWITHOUTTYPEINFO:
+ ShortWithoutTypeInfoPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ default:
+ return false;
+ }
}
+ @Override
+ public IPrinter createPrinter() {
+ final ARecordVisitablePointable rPointable = new ARecordVisitablePointable(
+ DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE);
+ final AListVisitablePointable olPointable = new AListVisitablePointable(
+ DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE);
+ final AListVisitablePointable ulPointable = new AListVisitablePointable(
+ DefaultOpenFieldType.NESTED_OPEN_AUNORDERED_LIST_TYPE);
+ final Pair<PrintStream, ATypeTag> streamTag = new Pair<>(null, null);
+
+ final IPrintVisitor visitor = new APrintVisitor();
+
+ return (byte[] b, int s, int l, PrintStream ps) -> {
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(b[s]);
+ if (!printFlatValue(typeTag, b, s, l, ps)) {
+ streamTag.first = ps;
+ streamTag.second = typeTag;
+ try {
+ switch (typeTag) {
+ case RECORD:
+ rPointable.set(b, s, l);
+ visitor.visit(rPointable, streamTag);
+ break;
+ case ORDEREDLIST:
+ olPointable.set(b, s, l);
+ visitor.visit(olPointable, streamTag);
+ break;
+ case UNORDEREDLIST:
+ ulPointable.set(b, s, l);
+ visitor.visit(ulPointable, streamTag);
+ break;
+ default:
+ throw new HyracksDataException("No printer for type " + typeTag);
+ }
+ } catch (AsterixException e) {
+ throw new HyracksDataException(e);
+ }
+ }
+ };
+ }
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AOrderedlistPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AOrderedlistPrinterFactory.java
index 7e8864f..36cab4e 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AOrderedlistPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AOrderedlistPrinterFactory.java
@@ -36,7 +36,7 @@
public class AOrderedlistPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
- private AOrderedListType orderedlistType;
+ private final AOrderedListType orderedlistType;
public AOrderedlistPrinterFactory(AOrderedListType orderedlistType) {
this.orderedlistType = orderedlistType;
@@ -44,16 +44,14 @@
@Override
public IPrinter createPrinter() {
-
- PointableAllocator allocator = new PointableAllocator();
- final IAType inputType = orderedlistType == null ? DefaultOpenFieldType
- .getDefaultOpenFieldType(ATypeTag.ORDEREDLIST) : orderedlistType;
+ final 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);
+ final Pair<PrintStream, ATypeTag> arg = new Pair<>(null, null);
return new IPrinter() {
-
@Override
public void init() {
arg.second = inputType.getTypeTag();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APoint3DPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APoint3DPrinter.java
deleted file mode 100644
index 5912cc4..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APoint3DPrinter.java
+++ /dev/null
@@ -1,45 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- 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("\")");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APoint3DPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APoint3DPrinterFactory.java
index 692e17c..cca84eb 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APoint3DPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APoint3DPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,18 @@
private static final long serialVersionUID = 1L;
public static final APoint3DPrinterFactory INSTANCE = new APoint3DPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ 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("\")");
+ };
+
@Override
public IPrinter createPrinter() {
- return APoint3DPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APointPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APointPrinter.java
deleted file mode 100644
index 56caf52..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APointPrinter.java
+++ /dev/null
@@ -1,43 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("point(\"");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
- ps.print(",");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 9));
- ps.print("\")");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APointPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APointPrinterFactory.java
index eba9ea8..ca0f8e9 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APointPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APointPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,16 @@
private static final long serialVersionUID = 1L;
public static final APointPrinterFactory INSTANCE = new APointPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("point(\"");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
+ ps.print(",");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 9));
+ ps.print("\")");
+ };
+
@Override
public IPrinter createPrinter() {
- return APointPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APolygonPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APolygonPrinter.java
deleted file mode 100644
index 2f592f8..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APolygonPrinter.java
+++ /dev/null
@@ -1,52 +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.dataflow.data.nontagged.printers.adm;
-
-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.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- 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(ADoubleSerializerDeserializer.getDouble(b, s));
- ps.print(",");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 8));
- s += 16;
- }
- ps.print("\")");
-
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APolygonPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APolygonPrinterFactory.java
index 3f4c7f1..9280fee 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APolygonPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/APolygonPrinterFactory.java
@@ -18,6 +18,10 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+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.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +30,24 @@
private static final long serialVersionUID = 1L;
public static final APolygonPrinterFactory INSTANCE = new APolygonPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ 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(ADoubleSerializerDeserializer.getDouble(b, s));
+ ps.print(",");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 8));
+ s += 16;
+ }
+ ps.print("\")");
+ };
+
@Override
public IPrinter createPrinter() {
- return APolygonPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARecordPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARecordPrinterFactory.java
index 7340db3..6d5180e 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARecordPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARecordPrinterFactory.java
@@ -44,16 +44,14 @@
@Override
public IPrinter createPrinter() {
-
- PointableAllocator allocator = new PointableAllocator();
+ final 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);
+ final Pair<PrintStream, ATypeTag> arg = new Pair<>(null, null);
return new IPrinter() {
-
@Override
public void init() {
arg.second = inputType.getTypeTag();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARectanglePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARectanglePrinter.java
deleted file mode 100644
index 54d3bf3..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARectanglePrinter.java
+++ /dev/null
@@ -1,47 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("rectangle(\"");
- 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(",");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
- ps.print("\")");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARectanglePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARectanglePrinterFactory.java
index 1ba973a..4d10048 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARectanglePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARectanglePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,20 @@
private static final long serialVersionUID = 1L;
public static final ARectanglePrinterFactory INSTANCE = new ARectanglePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("rectangle(\"");
+ 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(",");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
+ ps.print("\")");
+ };
+
@Override
public IPrinter createPrinter() {
- return ARectanglePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AStringPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AStringPrinter.java
deleted file mode 100644
index ac1f660..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AStringPrinter.java
+++ /dev/null
@@ -1,45 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- try {
- // ADM uses same escape semantics as JSON for strings
- PrintTools.writeUTF8StringAsJSON(b, s + 1, l - 1, ps);
- } catch (IOException e) {
- throw new HyracksDataException(e);
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AStringPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AStringPrinterFactory.java
index 729f962..c24b5bc 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AStringPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AStringPrinterFactory.java
@@ -18,17 +18,30 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public class AStringPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
public static final AStringPrinterFactory INSTANCE = new AStringPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ try {
+ // ADM uses same escape semantics as JSON for strings
+ PrintTools.writeUTF8StringAsJSON(b, s + 1, l - 1, ps);
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ };
+
@Override
public IPrinter createPrinter() {
- return AStringPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ATimePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ATimePrinter.java
deleted file mode 100644
index 987a666..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ATimePrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("time(\"");
- PrintTools.printTimeString(b, s, l, ps);
- ps.print("\")");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ATimePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ATimePrinterFactory.java
index 69abd41..f9ad18e 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ATimePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ATimePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ATimePrinterFactory INSTANCE = new ATimePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("time(\"");
+ PrintTools.printTimeString(b, s, l, ps);
+ ps.print("\")");
+ };
+
@Override
public IPrinter createPrinter() {
- return ATimePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUUIDPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUUIDPrinter.java
deleted file mode 100644
index 786984f..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUUIDPrinter.java
+++ /dev/null
@@ -1,44 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.om.base.AUUID;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AUUIDPrinter implements IPrinter {
-
- public static final AUUIDPrinter INSTANCE = new AUUIDPrinter();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- StringBuilder buf = new StringBuilder(AUUID.UUID_CHARS + 8);
- buf.append("uuid(\"");
- AUUID.appendLiteralOnly(b, s + 1, buf).append("\")");
- ps.print(buf.toString());
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUUIDPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUUIDPrinterFactory.java
index eeed0b8..41da3bd 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUUIDPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUUIDPrinterFactory.java
@@ -19,6 +19,9 @@
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.om.base.AUUID;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -28,9 +31,15 @@
public static final AUUIDPrinterFactory INSTANCE = new AUUIDPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ StringBuilder buf = new StringBuilder(AUUID.UUID_CHARS + 8);
+ buf.append("uuid(\"");
+ AUUID.appendLiteralOnly(b, s + 1, buf).append("\")");
+ ps.print(buf.toString());
+ };
+
@Override
public IPrinter createPrinter() {
- return AUUIDPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnionPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnionPrinterFactory.java
index 12baa16..17f82d1 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnionPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnionPrinterFactory.java
@@ -32,7 +32,6 @@
public class AUnionPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
-
private AUnionType unionType;
public AUnionPrinterFactory(AUnionType unionType) {
@@ -41,9 +40,7 @@
@Override
public IPrinter createPrinter() {
-
return new IPrinter() {
-
private IPrinter[] printers;
private List<IAType> unionList;
@@ -73,5 +70,4 @@
}
};
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnorderedlistPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnorderedlistPrinterFactory.java
index c185881..7d4c18a 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnorderedlistPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnorderedlistPrinterFactory.java
@@ -20,6 +20,7 @@
import java.io.PrintStream;
+import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.om.pointables.PointableAllocator;
import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
import org.apache.asterix.om.pointables.base.IVisitablePointable;
@@ -35,7 +36,7 @@
public class AUnorderedlistPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
- private AUnorderedListType unorderedlistType;
+ private final AUnorderedListType unorderedlistType;
public AUnorderedlistPrinterFactory(AUnorderedListType unorderedlistType) {
this.unorderedlistType = unorderedlistType;
@@ -43,16 +44,14 @@
@Override
public IPrinter createPrinter() {
-
- PointableAllocator allocator = new PointableAllocator();
+ final 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);
+ final Pair<PrintStream, ATypeTag> arg = new Pair<>(null, null);
return new IPrinter() {
-
@Override
public void init() {
arg.second = inputType.getTypeTag();
@@ -64,7 +63,7 @@
listAccessor.set(b, start, l);
arg.first = ps;
listAccessor.accept(printVisitor, arg);
- } catch (Exception e) {
+ } catch (AsterixException e) {
throw new HyracksDataException(e);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AYearMonthDurationPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AYearMonthDurationPrinter.java
deleted file mode 100644
index 41cf277..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AYearMonthDurationPrinter.java
+++ /dev/null
@@ -1,79 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.algebricks.data.utils.WriteValueTools;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AYearMonthDurationPrinter implements IPrinter {
-
- public static final AYearMonthDurationPrinter INSTANCE = new AYearMonthDurationPrinter();
- private static final GregorianCalendarSystem gCalInstance = GregorianCalendarSystem.getInstance();
-
- /* (non-Javadoc)
- * @see org.apache.hyracks.algebricks.data.IPrinter#init()
- */
- @Override
- public void init() {
- }
-
- /* (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 HyracksDataException {
- boolean positive = true;
- int months = AInt32SerializerDeserializer.getInt(b, s + 1);
-
- // set the negative flag. "||" is necessary in case that months field is not there (so it is 0)
- if (months < 0) {
- months *= -1;
- positive = false;
- }
-
- int month = gCalInstance.getDurationMonth(months);
- int year = gCalInstance.getDurationYear(months);
-
- ps.print("year-month-duration(\"");
- if (!positive) {
- ps.print("-");
- }
- try {
- ps.print("P");
- if (year != 0) {
- WriteValueTools.writeInt(year, ps);
- ps.print("Y");
- }
- if (month != 0) {
- WriteValueTools.writeInt(month, ps);
- ps.print("M");
- }
- ps.print("\")");
- } catch (IOException e) {
- throw new HyracksDataException(e);
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AYearMonthDurationPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AYearMonthDurationPrinterFactory.java
index ff16fb7..4f3782d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AYearMonthDurationPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AYearMonthDurationPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,12 +29,14 @@
private static final long serialVersionUID = 1L;
public static final AYearMonthDurationPrinterFactory INSTANCE = new AYearMonthDurationPrinterFactory();
- /* (non-Javadoc)
- * @see org.apache.hyracks.algebricks.data.IPrinterFactory#createPrinter()
- */
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("year-month-duration(\"");
+ PrintTools.printYearMonthDurationString(b, s, l, ps);
+ ps.print("\")");
+ };
+
@Override
public IPrinter createPrinter() {
- return AYearMonthDurationPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ShortWithoutTypeInfoPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ShortWithoutTypeInfoPrinter.java
deleted file mode 100644
index c373f53..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ShortWithoutTypeInfoPrinter.java
+++ /dev/null
@@ -1,46 +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.dataflow.data.nontagged.printers.adm;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.algebricks.data.utils.WriteValueTools;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.data.std.primitive.ShortPointable;
-
-public class ShortWithoutTypeInfoPrinter implements IPrinter {
-
- public static final ShortWithoutTypeInfoPrinter INSTANCE = new ShortWithoutTypeInfoPrinter();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- short d = ShortPointable.getShort(b, s);
- try {
- WriteValueTools.writeInt((int)d, ps);
- } catch (IOException e) {
- throw new HyracksDataException(e);
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ShortWithoutTypeInfoPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ShortWithoutTypeInfoPrinterFactory.java
index 35005f8..666fa0a 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ShortWithoutTypeInfoPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ShortWithoutTypeInfoPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.adm;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final ShortWithoutTypeInfoPrinterFactory INSTANCE = new ShortWithoutTypeInfoPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(ABooleanSerializerDeserializer.getBoolean(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return ShortWithoutTypeInfoPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABinaryHexPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABinaryHexPrinterFactory.java
similarity index 76%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABinaryHexPrinter.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABinaryHexPrinterFactory.java
index 707ca70..ad9de14 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABinaryHexPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABinaryHexPrinterFactory.java
@@ -23,22 +23,20 @@
import java.io.PrintStream;
import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.hyracks.algebricks.data.IPrinterFactory;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
import org.apache.hyracks.util.bytes.HexPrinter;
-public class ABinaryHexPrinter implements IPrinter {
- private ABinaryHexPrinter() {
+public class ABinaryHexPrinterFactory implements IPrinterFactory {
+ private static final long serialVersionUID = 1L;
+
+ private ABinaryHexPrinterFactory() {
}
- public static final ABinaryHexPrinter INSTANCE = new ABinaryHexPrinter();
+ public static final ABinaryHexPrinterFactory INSTANCE = new ABinaryHexPrinterFactory();
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
int validLength = ByteArrayPointable.getContentLength(b, s + 1);
int start = s + 1 + ByteArrayPointable.getNumberBytesToStoreMeta(validLength);
try {
@@ -46,6 +44,10 @@
} catch (IOException e) {
throw new HyracksDataException(e);
}
- }
+ };
+ @Override
+ public IPrinter createPrinter() {
+ return PRINTER;
+ }
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABinaryPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABinaryPrinterFactory.java
deleted file mode 100644
index 83a93fc..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABinaryPrinterFactory.java
+++ /dev/null
@@ -1,38 +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.dataflow.data.nontagged.printers.csv;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ABinaryHexPrinter;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.algebricks.data.IPrinterFactory;
-
-public class ABinaryPrinterFactory implements IPrinterFactory {
- private static final long serialVersionUID = 1L;
-
- private ABinaryPrinterFactory() {
- }
-
- public static final ABinaryPrinterFactory INSTANCE = new ABinaryPrinterFactory();
-
- @Override
- public IPrinter createPrinter() {
- return ABinaryHexPrinter.INSTANCE;
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABooleanPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABooleanPrinter.java
deleted file mode 100644
index 01f50d5..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABooleanPrinter.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print(ABooleanSerializerDeserializer.getBoolean(b, s + 1));
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABooleanPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABooleanPrinterFactory.java
index 43e7f8f..4aa6ccd 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABooleanPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ABooleanPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final ABooleanPrinterFactory INSTANCE = new ABooleanPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(ABooleanSerializerDeserializer.getBoolean(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return ABooleanPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ACirclePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ACirclePrinter.java
deleted file mode 100644
index 91a9aa9..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ACirclePrinter.java
+++ /dev/null
@@ -1,45 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("\"[ [");
- 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(" ]\"");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ACirclePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ACirclePrinterFactory.java
index 630e80c..423a963 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ACirclePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ACirclePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,18 @@
private static final long serialVersionUID = 1L;
public static final ACirclePrinterFactory INSTANCE = new ACirclePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"[ [");
+ 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(" ]\"");
+ };
+
@Override
public IPrinter createPrinter() {
- return ACirclePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADatePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADatePrinter.java
deleted file mode 100644
index e21f828..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADatePrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class ADatePrinter implements IPrinter {
-
- public static final ADatePrinter INSTANCE = new ADatePrinter();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- ps.print("\"");
- PrintTools.printDateString(b, s, l, ps);
- ps.print("\"");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADatePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADatePrinterFactory.java
index 09ee227..98db505 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADatePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADatePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADatePrinterFactory INSTANCE = new ADatePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"");
+ PrintTools.printDateString(b, s, l, ps);
+ ps.print("\"");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADatePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADateTimePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADateTimePrinter.java
deleted file mode 100644
index c5d97d9..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADateTimePrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("\"");
- PrintTools.printDateTimeString(b, s, l, ps);
- ps.print("\"");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADateTimePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADateTimePrinterFactory.java
index 13c5b90..bc52e50 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADateTimePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADateTimePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADateTimePrinterFactory INSTANCE = new ADateTimePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"");
+ PrintTools.printDateTimeString(b, s, l, ps);
+ ps.print("\"");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADateTimePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADayTimeDurationPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADayTimeDurationPrinter.java
deleted file mode 100644
index 6dc819b..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADayTimeDurationPrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class ADayTimeDurationPrinter implements IPrinter {
-
- public static final ADayTimeDurationPrinter INSTANCE = new ADayTimeDurationPrinter();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- ps.print("\"");
- PrintTools.printDayTimeDurationString(b, s, l, ps);
- ps.print("\")");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADayTimeDurationPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADayTimeDurationPrinterFactory.java
index 594ef2c..64c28de 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADayTimeDurationPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADayTimeDurationPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADayTimeDurationPrinterFactory INSTANCE = new ADayTimeDurationPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"");
+ PrintTools.printDayTimeDurationString(b, s, l, ps);
+ ps.print("\")");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADayTimeDurationPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADoublePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADoublePrinter.java
deleted file mode 100644
index 5ca2d6e..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADoublePrinter.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADoublePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADoublePrinterFactory.java
index e667eca..d08bae5 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADoublePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADoublePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final ADoublePrinterFactory INSTANCE = new ADoublePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return ADoublePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADurationPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADurationPrinter.java
deleted file mode 100644
index dbff71b..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADurationPrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("\"");
- PrintTools.printDurationString(b, s, l, ps);
- ps.print("\"");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADurationPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADurationPrinterFactory.java
index 3ba2faf..1eb797a 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADurationPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ADurationPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADurationPrinterFactory INSTANCE = new ADurationPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"");
+ PrintTools.printDurationString(b, s, l, ps);
+ ps.print("\"");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADurationPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AFloatPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AFloatPrinter.java
deleted file mode 100644
index 4d64b46..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AFloatPrinter.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print(AFloatSerializerDeserializer.getFloat(b, s + 1));
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AFloatPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AFloatPrinterFactory.java
index bbab5f3..ed2c2f4 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AFloatPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AFloatPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final AFloatPrinterFactory INSTANCE = new AFloatPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(AFloatSerializerDeserializer.getFloat(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return AFloatPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt16Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt16Printer.java
deleted file mode 100644
index 1349d98..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt16Printer.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- short i = AInt16SerializerDeserializer.getShort(b, s + 1);
- ps.print(i);
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt16PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt16PrinterFactory.java
index 45a6cec..8c6ec22 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt16PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt16PrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final AInt16PrinterFactory INSTANCE = new AInt16PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(AInt16SerializerDeserializer.getShort(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return AInt16Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt32Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt32Printer.java
deleted file mode 100644
index 01b6c02..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt32Printer.java
+++ /dev/null
@@ -1,40 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- int d = AInt32SerializerDeserializer.getInt(b, s + 1);
- ps.print(d);
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt32PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt32PrinterFactory.java
index 3a169b6..ef3f9d9 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt32PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt32PrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final AInt32PrinterFactory INSTANCE = new AInt32PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(AInt32SerializerDeserializer.getInt(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return AInt32Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt64Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt64Printer.java
deleted file mode 100644
index 5b05275..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt64Printer.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- long d = AInt64SerializerDeserializer.getLong(b, s + 1);
- ps.print(d);
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt64PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt64PrinterFactory.java
index 0e7cde9..403d0f4 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt64PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt64PrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final AInt64PrinterFactory INSTANCE = new AInt64PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(AInt64SerializerDeserializer.getLong(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return AInt64Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt8Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt8Printer.java
deleted file mode 100644
index 3e59811..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt8Printer.java
+++ /dev/null
@@ -1,40 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- byte o = AInt8SerializerDeserializer.getByte(b, s + 1);
- ps.print(o);
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt8PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt8PrinterFactory.java
index 3ce36a8..c9d4165 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt8PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AInt8PrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final AInt8PrinterFactory INSTANCE = new AInt8PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(AInt8SerializerDeserializer.getByte(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return AInt8Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AIntervalPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AIntervalPrinter.java
deleted file mode 100644
index ba74790..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AIntervalPrinter.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AIntervalPrinter implements IPrinter {
-
- public static final AIntervalPrinter INSTANCE = new AIntervalPrinter();
-
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- throw new HyracksDataException("'Interval' type unsupported for CSV output");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AIntervalPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AIntervalPrinterFactory.java
index a12d75c..7e1c1cb 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AIntervalPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AIntervalPrinterFactory.java
@@ -18,17 +18,23 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public class AIntervalPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
public static final AIntervalPrinterFactory INSTANCE = new AIntervalPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ throw new HyracksDataException("'Interval' type unsupported for CSV output");
+ };
+
@Override
public IPrinter createPrinter() {
- return AIntervalPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ALinePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ALinePrinter.java
deleted file mode 100644
index a500e58..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ALinePrinter.java
+++ /dev/null
@@ -1,47 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("\"[ [");
- 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(", ");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
- ps.print("] ]\"");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ALinePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ALinePrinterFactory.java
index cbbc462..929cec9 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ALinePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ALinePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,20 @@
private static final long serialVersionUID = 1L;
public static final ALinePrinterFactory INSTANCE = new ALinePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"[ [");
+ 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(", ");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
+ ps.print("] ]\"");
+ };
+
@Override
public IPrinter createPrinter() {
- return ALinePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullPrinterFactory.java
index 2e9c1dc..dcf98a0 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullPrinterFactory.java
@@ -18,6 +18,8 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +28,10 @@
private static final long serialVersionUID = 1L;
public static final ANullPrinterFactory INSTANCE = new ANullPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps.print("null");
+
@Override
public IPrinter createPrinter() {
- return ANullPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullableFieldPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullableFieldPrinterFactory.java
index f920080..deb6014 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullableFieldPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullableFieldPrinterFactory.java
@@ -64,5 +64,4 @@
};
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinter.java
deleted file mode 100644
index 09cd5ac..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinter.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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AObjectPrinter implements IPrinter {
-
- public static final AObjectPrinter INSTANCE = new AObjectPrinter();
-
- private IPrinter recordPrinter = new ARecordPrinterFactory(null).createPrinter();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- 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 MISSING:
- 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 YEARMONTHDURATION: {
- AYearMonthDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case DAYTIMEDURATION: {
- ADayTimeDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case INTERVAL:
- AIntervalPrinter.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;
- }
- case RECORD: {
- this.recordPrinter.init();
- recordPrinter.print(b, s, l, ps);
- break;
- }
- case ANY:
- case BINARY:
- case BITARRAY:
- case ENUM:
- case ORDEREDLIST:
- case SHORTWITHOUTTYPEINFO:
- case SPARSERECORD:
- case SYSTEM_NULL:
- case TYPE:
- case UINT16:
- case UINT32:
- case UINT64:
- case UINT8:
- case UNION:
- case UNORDEREDLIST:
- case UUID:
- throw new NotImplementedException("No printer for type " + typeTag);
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinterFactory.java
index 09bef1b..55c6fd4 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinterFactory.java
@@ -18,17 +18,132 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.om.pointables.ARecordVisitablePointable;
+import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
+import org.apache.asterix.om.pointables.printer.IPrintVisitor;
+import org.apache.asterix.om.pointables.printer.csv.APrintVisitor;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.hyracks.algebricks.common.utils.Pair;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
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;
+ public static boolean printFlatValue(ATypeTag typeTag, byte[] b, int s, int l, PrintStream ps)
+ throws HyracksDataException {
+ switch (typeTag) {
+ case INT8:
+ AInt8PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INT16:
+ AInt16PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INT32:
+ AInt32PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INT64:
+ AInt64PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case MISSING:
+ case NULL:
+ ANullPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case BOOLEAN:
+ ABooleanPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case FLOAT:
+ AFloatPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DOUBLE:
+ ADoublePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DATE:
+ ADatePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case TIME:
+ ATimePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DATETIME:
+ ADateTimePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DURATION:
+ ADurationPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case YEARMONTHDURATION:
+ AYearMonthDurationPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DAYTIMEDURATION:
+ ADayTimeDurationPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INTERVAL:
+ AIntervalPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case POINT:
+ APointPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case POINT3D:
+ APoint3DPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case LINE:
+ ALinePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case POLYGON:
+ APolygonPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case CIRCLE:
+ ACirclePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case RECTANGLE:
+ ARectanglePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case STRING:
+ AStringPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case BINARY:
+ ABinaryHexPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case UUID:
+ AUUIDPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ default:
+ return false;
+ }
}
+ @Override
+ public IPrinter createPrinter() {
+ final ARecordVisitablePointable rPointable = new ARecordVisitablePointable(
+ DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE);
+ final Pair<PrintStream, ATypeTag> streamTag = new Pair<>(null, null);
+
+ final IPrintVisitor visitor = new APrintVisitor();
+
+ return (byte[] b, int s, int l, PrintStream ps) -> {
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(b[s]);
+ if (!printFlatValue(typeTag, b, s, l, ps)) {
+ streamTag.first = ps;
+ streamTag.second = typeTag;
+ try {
+ switch (typeTag) {
+ case RECORD:
+ rPointable.set(b, s, l);
+ visitor.visit(rPointable, streamTag);
+ break;
+ default:
+ throw new HyracksDataException("No printer for type " + typeTag);
+ }
+ } catch (AsterixException e) {
+ throw new HyracksDataException(e);
+ }
+ }
+ };
+ }
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APoint3DPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APoint3DPrinter.java
deleted file mode 100644
index 296cb41..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APoint3DPrinter.java
+++ /dev/null
@@ -1,45 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("\"[");
- 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("]\"");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APoint3DPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APoint3DPrinterFactory.java
index 803e9cb..2839a8b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APoint3DPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APoint3DPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,18 @@
private static final long serialVersionUID = 1L;
public static final APoint3DPrinterFactory INSTANCE = new APoint3DPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"[");
+ 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("]\"");
+ };
+
@Override
public IPrinter createPrinter() {
- return APoint3DPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APointPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APointPrinter.java
deleted file mode 100644
index bab0ddd..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APointPrinter.java
+++ /dev/null
@@ -1,43 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("\"[");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
- ps.print(", ");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 9));
- ps.print("]\"");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APointPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APointPrinterFactory.java
index 2561a4e..60bd007 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APointPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APointPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,16 @@
private static final long serialVersionUID = 1L;
public static final APointPrinterFactory INSTANCE = new APointPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"[");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
+ ps.print(", ");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 9));
+ ps.print("]\"");
+ };
+
@Override
public IPrinter createPrinter() {
- return APointPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APolygonPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APolygonPrinter.java
deleted file mode 100644
index 493715a..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APolygonPrinter.java
+++ /dev/null
@@ -1,58 +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.dataflow.data.nontagged.printers.csv;
-
-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.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- short numberOfPoints = AInt16SerializerDeserializer.getShort(b, s + 1);
- s += 3;
-
- ps.print("\"[ ");
-
- for (int i = 0; i < numberOfPoints; i++) {
- if (i > 0)
- ps.print(", ");
-
- ps.print("[");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s));
- ps.print(", ");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 8));
- ps.print("]");
-
- s += 16;
- }
-
- ps.print(" ]\"");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APolygonPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APolygonPrinterFactory.java
index cc30b98..4df7676 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APolygonPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/APolygonPrinterFactory.java
@@ -18,6 +18,10 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+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.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +30,26 @@
private static final long serialVersionUID = 1L;
public static final APolygonPrinterFactory INSTANCE = new APolygonPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ short numberOfPoints = AInt16SerializerDeserializer.getShort(b, s + 1);
+ s += 3;
+ ps.print("\"[ ");
+ for (int i = 0; i < numberOfPoints; i++) {
+ if (i > 0) {
+ ps.print(", ");
+ }
+ ps.print("[");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s));
+ ps.print(", ");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 8));
+ ps.print("]");
+ s += 16;
+ }
+ ps.print(" ]\"");
+ };
+
@Override
public IPrinter createPrinter() {
- return APolygonPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARecordPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARecordPrinterFactory.java
index ad513a5..baeb526 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARecordPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARecordPrinterFactory.java
@@ -44,16 +44,14 @@
@Override
public IPrinter createPrinter() {
-
- PointableAllocator allocator = new PointableAllocator();
+ final 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);
+ final Pair<PrintStream, ATypeTag> arg = new Pair<>(null, null);
return new IPrinter() {
-
@Override
public void init() {
arg.second = inputType.getTypeTag();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARectanglePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARectanglePrinter.java
deleted file mode 100644
index 07449cf..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARectanglePrinter.java
+++ /dev/null
@@ -1,47 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("\"[ [");
- 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(", ");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
- ps.print("] ]\"");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARectanglePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARectanglePrinterFactory.java
index 13ec5d2..38a1c4f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARectanglePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARectanglePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,20 @@
private static final long serialVersionUID = 1L;
public static final ARectanglePrinterFactory INSTANCE = new ARectanglePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"[ [");
+ 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(", ");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
+ ps.print("] ]\"");
+ };
+
@Override
public IPrinter createPrinter() {
- return ARectanglePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AStringPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AStringPrinter.java
deleted file mode 100644
index 709929d..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AStringPrinter.java
+++ /dev/null
@@ -1,44 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- try {
- PrintTools.writeUTF8StringAsCSV(b, s + 1, l - 1, ps);
- } catch (IOException e) {
- throw new HyracksDataException(e);
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AStringPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AStringPrinterFactory.java
index 44f8c74..85925c9 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AStringPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AStringPrinterFactory.java
@@ -18,17 +18,29 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public class AStringPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
public static final AStringPrinterFactory INSTANCE = new AStringPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ try {
+ PrintTools.writeUTF8StringAsCSV(b, s + 1, l - 1, ps);
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ };
+
@Override
public IPrinter createPrinter() {
- return AStringPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ATimePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ATimePrinter.java
deleted file mode 100644
index dfd5501..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ATimePrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("\"");
- PrintTools.printTimeString(b, s, l, ps);
- ps.print("\"");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ATimePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ATimePrinterFactory.java
index 4a1fd5e..d328a2d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ATimePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ATimePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ATimePrinterFactory INSTANCE = new ATimePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"");
+ PrintTools.printTimeString(b, s, l, ps);
+ ps.print("\"");
+ };
+
@Override
public IPrinter createPrinter() {
- return ATimePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AUUIDPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AUUIDPrinter.java
deleted file mode 100644
index 34998e5..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AUUIDPrinter.java
+++ /dev/null
@@ -1,44 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.om.base.AUUID;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AUUIDPrinter implements IPrinter {
-
- public static final AUUIDPrinter INSTANCE = new AUUIDPrinter();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- StringBuilder buf = new StringBuilder(AUUID.UUID_CHARS + 2);
- buf.append('"');
- AUUID.appendLiteralOnly(b, s + 1, buf).append('"');
- ps.print(buf.toString());
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AUUIDPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AUUIDPrinterFactory.java
index e15e297..e4ecfea 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AUUIDPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AUUIDPrinterFactory.java
@@ -19,7 +19,9 @@
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.AUUIDPrinter;
+import java.io.PrintStream;
+
+import org.apache.asterix.om.base.AUUID;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -29,8 +31,15 @@
public static final AUUIDPrinterFactory INSTANCE = new AUUIDPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ StringBuilder buf = new StringBuilder(AUUID.UUID_CHARS + 2);
+ buf.append('"');
+ AUUID.appendLiteralOnly(b, s + 1, buf).append('"');
+ ps.print(buf.toString());
+ };
+
@Override
public IPrinter createPrinter() {
- return AUUIDPrinter.INSTANCE;
+ return PRINTER;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AUnionPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AUnionPrinterFactory.java
index 6fc691d..aa225be 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AUnionPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AUnionPrinterFactory.java
@@ -41,7 +41,6 @@
@Override
public IPrinter createPrinter() {
-
return new IPrinter() {
private IPrinter[] printers;
@@ -73,5 +72,4 @@
}
};
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AYearMonthDurationPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AYearMonthDurationPrinter.java
deleted file mode 100644
index 497bf3d..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AYearMonthDurationPrinter.java
+++ /dev/null
@@ -1,45 +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.dataflow.data.nontagged.printers.csv;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AYearMonthDurationPrinter implements IPrinter {
-
- public static final AYearMonthDurationPrinter INSTANCE = new AYearMonthDurationPrinter();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
-
- int months = AInt32SerializerDeserializer.getInt(b, s + 1);
-
- ps.print("{ \"year-month-duration\": ");
- ps.print(months);
- ps.print("}");
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AYearMonthDurationPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AYearMonthDurationPrinterFactory.java
index fc92b09..e650162 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AYearMonthDurationPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AYearMonthDurationPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,12 +29,14 @@
private static final long serialVersionUID = 1L;
public static final AYearMonthDurationPrinterFactory INSTANCE = new AYearMonthDurationPrinterFactory();
- /* (non-Javadoc)
- * @see org.apache.hyracks.algebricks.data.IPrinterFactory#createPrinter()
- */
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"year-month-duration\": ");
+ ps.print(AInt32SerializerDeserializer.getInt(b, s + 1));
+ ps.print("}");
+ };
+
@Override
public IPrinter createPrinter() {
- return AYearMonthDurationPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABinaryHexPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABinaryHexPrinterFactory.java
similarity index 76%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABinaryHexPrinter.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABinaryHexPrinterFactory.java
index 1bbf0f0..072f52f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABinaryHexPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABinaryHexPrinterFactory.java
@@ -23,23 +23,20 @@
import java.io.PrintStream;
import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.hyracks.algebricks.data.IPrinterFactory;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
import org.apache.hyracks.util.bytes.HexPrinter;
-public class ABinaryHexPrinter implements IPrinter {
- private ABinaryHexPrinter() {
+public class ABinaryHexPrinterFactory implements IPrinterFactory {
+ private static final long serialVersionUID = 1L;
+
+ private ABinaryHexPrinterFactory() {
}
- public static final ABinaryHexPrinter INSTANCE = new ABinaryHexPrinter();
+ public static final ABinaryHexPrinterFactory INSTANCE = new ABinaryHexPrinterFactory();
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
-
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
int validLength = ByteArrayPointable.getContentLength(b, s + 1);
int start = s + 1 + ByteArrayPointable.getNumberBytesToStoreMeta(validLength);
try {
@@ -49,6 +46,10 @@
} catch (IOException e) {
throw new HyracksDataException(e);
}
- }
+ };
+ @Override
+ public IPrinter createPrinter() {
+ return PRINTER;
+ }
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABinaryPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABinaryPrinterFactory.java
deleted file mode 100644
index aeee4cb..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABinaryPrinterFactory.java
+++ /dev/null
@@ -1,37 +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.dataflow.data.nontagged.printers.json.clean;
-
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.algebricks.data.IPrinterFactory;
-
-public class ABinaryPrinterFactory implements IPrinterFactory {
- private static final long serialVersionUID = 1L;
-
- private ABinaryPrinterFactory() {
- }
-
- public static final ABinaryPrinterFactory INSTANCE = new ABinaryPrinterFactory();
-
- @Override
- public IPrinter createPrinter() {
- return ABinaryHexPrinter.INSTANCE;
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABooleanPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABooleanPrinter.java
deleted file mode 100644
index 7f5327c..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABooleanPrinter.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print(ABooleanSerializerDeserializer.getBoolean(b, s + 1));
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABooleanPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABooleanPrinterFactory.java
index 108c9a8..ebc09a0 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABooleanPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ABooleanPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final ABooleanPrinterFactory INSTANCE = new ABooleanPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(ABooleanSerializerDeserializer.getBoolean(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return ABooleanPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ACirclePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ACirclePrinter.java
deleted file mode 100644
index 70b0ff8..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ACirclePrinter.java
+++ /dev/null
@@ -1,45 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("[ [");
- 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(" ]");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ACirclePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ACirclePrinterFactory.java
index 926003b..5381d2b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ACirclePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ACirclePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,18 @@
private static final long serialVersionUID = 1L;
public static final ACirclePrinterFactory INSTANCE = new ACirclePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("[ [");
+ 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(" ]");
+ };
+
@Override
public IPrinter createPrinter() {
- return ACirclePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADatePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADatePrinter.java
deleted file mode 100644
index 43ee994..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADatePrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class ADatePrinter implements IPrinter {
-
- public static final ADatePrinter INSTANCE = new ADatePrinter();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- ps.print("\"");
- PrintTools.printDateString(b, s, l, ps);
- ps.print("\"");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADatePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADatePrinterFactory.java
index 4a025cc..386240f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADatePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADatePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADatePrinterFactory INSTANCE = new ADatePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"");
+ PrintTools.printDateString(b, s, l, ps);
+ ps.print("\"");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADatePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADateTimePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADateTimePrinter.java
deleted file mode 100644
index 7c1a746..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADateTimePrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("\"");
- PrintTools.printDateTimeString(b, s, l, ps);
- ps.print("\"");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADateTimePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADateTimePrinterFactory.java
index a856adc..0d43543 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADateTimePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADateTimePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADateTimePrinterFactory INSTANCE = new ADateTimePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"");
+ PrintTools.printDateTimeString(b, s, l, ps);
+ ps.print("\"");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADateTimePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADayTimeDurationPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADayTimeDurationPrinter.java
deleted file mode 100644
index d7ce053..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADayTimeDurationPrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class ADayTimeDurationPrinter implements IPrinter {
-
- public static final ADayTimeDurationPrinter INSTANCE = new ADayTimeDurationPrinter();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- ps.print("\"");
- PrintTools.printDayTimeDurationString(b, s, l, ps);
- ps.print("\")");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADayTimeDurationPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADayTimeDurationPrinterFactory.java
index f00124b..1c39039 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADayTimeDurationPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADayTimeDurationPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADayTimeDurationPrinterFactory INSTANCE = new ADayTimeDurationPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"");
+ PrintTools.printDayTimeDurationString(b, s, l, ps);
+ ps.print("\")");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADayTimeDurationPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADoublePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADoublePrinter.java
deleted file mode 100644
index 07bf4fb..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADoublePrinter.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADoublePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADoublePrinterFactory.java
index fdea963..03088fb 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADoublePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADoublePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final ADoublePrinterFactory INSTANCE = new ADoublePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return ADoublePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADurationPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADurationPrinter.java
deleted file mode 100644
index 163fd26..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADurationPrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("\"");
- PrintTools.printDurationString(b, s, l, ps);
- ps.print("\"");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADurationPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADurationPrinterFactory.java
index da0ece3..e355fec 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADurationPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ADurationPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADurationPrinterFactory INSTANCE = new ADurationPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"");
+ PrintTools.printDurationString(b, s, l, ps);
+ ps.print("\"");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADurationPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AFloatPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AFloatPrinter.java
deleted file mode 100644
index 38937a4..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AFloatPrinter.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print(AFloatSerializerDeserializer.getFloat(b, s + 1));
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AFloatPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AFloatPrinterFactory.java
index 0067524..827ebec 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AFloatPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AFloatPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final AFloatPrinterFactory INSTANCE = new AFloatPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(AFloatSerializerDeserializer.getFloat(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return AFloatPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt16Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt16Printer.java
deleted file mode 100644
index 57aff95..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt16Printer.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- short i = AInt16SerializerDeserializer.getShort(b, s + 1);
- ps.print(i);
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt16PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt16PrinterFactory.java
index d87ac6c..4454aa6 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt16PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt16PrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final AInt16PrinterFactory INSTANCE = new AInt16PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(AInt16SerializerDeserializer.getShort(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return AInt16Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt32Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt32Printer.java
deleted file mode 100644
index 996be35..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt32Printer.java
+++ /dev/null
@@ -1,40 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- int d = AInt32SerializerDeserializer.getInt(b, s + 1);
- ps.print(d);
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt32PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt32PrinterFactory.java
index 87eaa8e..40bf33d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt32PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt32PrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final AInt32PrinterFactory INSTANCE = new AInt32PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(AInt32SerializerDeserializer.getInt(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return AInt32Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt64Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt64Printer.java
deleted file mode 100644
index 564e920..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt64Printer.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- long d = AInt64SerializerDeserializer.getLong(b, s + 1);
- ps.print(d);
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt64PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt64PrinterFactory.java
index e7c4f8f..5fe8e3a 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt64PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt64PrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final AInt64PrinterFactory INSTANCE = new AInt64PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(AInt64SerializerDeserializer.getLong(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return AInt64Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt8Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt8Printer.java
deleted file mode 100644
index 2ed1341..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt8Printer.java
+++ /dev/null
@@ -1,40 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- byte o = AInt8SerializerDeserializer.getByte(b, s + 1);
- ps.print(o);
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt8PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt8PrinterFactory.java
index c4acdff..a6c3c97 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt8PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AInt8PrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final AInt8PrinterFactory INSTANCE = new AInt8PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(AInt8SerializerDeserializer.getByte(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return AInt8Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AIntervalPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AIntervalPrinter.java
deleted file mode 100644
index 4eb1766..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AIntervalPrinter.java
+++ /dev/null
@@ -1,78 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ADatePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ADateTimePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ATimePrinter;
-import org.apache.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AIntervalPrinter implements IPrinter {
-
- public static final AIntervalPrinter INSTANCE = new AIntervalPrinter();
-
- /* (non-Javadoc)
- * @see org.apache.hyracks.algebricks.data.IPrinter#init()
- */
- @Override
- public void init() {
- }
-
- /* (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 HyracksDataException {
- ps.print("{ \"interval\": { \"start\": ");
-
- byte typetag = AIntervalSerializerDeserializer.getIntervalTimeType(b, s + 1);
- int startOffset = AIntervalSerializerDeserializer.getIntervalStartOffset(b, s + 1) - 1;
- int startSize = AIntervalSerializerDeserializer.getStartSize(b, s + 1);
- int endOffset = AIntervalSerializerDeserializer.getIntervalEndOffset(b, s + 1) - 1;
- int endSize = AIntervalSerializerDeserializer.getEndSize(b, s + 1);
-
- IPrinter timeInstancePrinter;
- ATypeTag intervalType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(typetag);
- switch (intervalType) {
- case DATE:
- timeInstancePrinter = ADatePrinter.INSTANCE;
- break;
- case TIME:
- timeInstancePrinter = ATimePrinter.INSTANCE;
- break;
- case DATETIME:
- timeInstancePrinter = ADateTimePrinter.INSTANCE;
- break;
- default:
- throw new HyracksDataException("Unsupported internal time types in interval: " + typetag);
- }
-
- timeInstancePrinter.print(b, startOffset, startSize, ps);
- ps.print(", \"end\": ");
- timeInstancePrinter.print(b, endOffset, endSize, ps);
-
- ps.print("}}");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AIntervalPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AIntervalPrinterFactory.java
index a0fdfe7..67208e3 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AIntervalPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AIntervalPrinterFactory.java
@@ -18,17 +18,48 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public class AIntervalPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
public static final AIntervalPrinterFactory INSTANCE = new AIntervalPrinterFactory();
- @Override
- public IPrinter createPrinter() {
- return AIntervalPrinter.INSTANCE;
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"interval\": { \"start\": ");
+ byte typetag = AIntervalSerializerDeserializer.getIntervalTimeType(b, s + 1);
+ int startOffset = AIntervalSerializerDeserializer.getIntervalStartOffset(b, s + 1) - 1;
+ int startSize = AIntervalSerializerDeserializer.getStartSize(b, s + 1);
+ int endOffset = AIntervalSerializerDeserializer.getIntervalEndOffset(b, s + 1) - 1;
+ int endSize = AIntervalSerializerDeserializer.getEndSize(b, s + 1);
+ IPrinter timeInstancePrinter = getIPrinter(typetag);
+ timeInstancePrinter.print(b, startOffset, startSize, ps);
+ ps.print(", \"end\": ");
+ timeInstancePrinter.print(b, endOffset, endSize, ps);
+ ps.print("}}");
+ };
+
+ private static IPrinter getIPrinter(byte typetag) throws HyracksDataException {
+ switch (EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(typetag)) {
+ case DATE:
+ return ADatePrinterFactory.PRINTER;
+ case TIME:
+ return ATimePrinterFactory.PRINTER;
+ case DATETIME:
+ return ADateTimePrinterFactory.PRINTER;
+ default:
+ throw new HyracksDataException("Unsupported internal time types in interval: " + typetag);
+ }
}
+ @Override
+ public IPrinter createPrinter() {
+ return PRINTER;
+ }
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ALinePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ALinePrinter.java
deleted file mode 100644
index 6b3ea36..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ALinePrinter.java
+++ /dev/null
@@ -1,47 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("[ [");
- 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(", ");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
- ps.print("] ]");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ALinePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ALinePrinterFactory.java
index 9624cf5..237be83 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ALinePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ALinePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,20 @@
private static final long serialVersionUID = 1L;
public static final ALinePrinterFactory INSTANCE = new ALinePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("[ [");
+ 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(", ");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
+ ps.print("] ]");
+ };
+
@Override
public IPrinter createPrinter() {
- return ALinePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullPrinter.java
deleted file mode 100644
index 7f0c362..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullPrinter.java
+++ /dev/null
@@ -1,38 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("null");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullPrinterFactory.java
index 828ae70..d1949b9 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullPrinterFactory.java
@@ -18,6 +18,8 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +28,10 @@
private static final long serialVersionUID = 1L;
public static final ANullPrinterFactory INSTANCE = new ANullPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps.print("null");
+
@Override
public IPrinter createPrinter() {
- return ANullPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullableFieldPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullableFieldPrinterFactory.java
index 24c8903..b2c13af 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullableFieldPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullableFieldPrinterFactory.java
@@ -31,7 +31,6 @@
public class ANullableFieldPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
-
private AUnionType unionType;
public ANullableFieldPrinterFactory(AUnionType unionType) {
@@ -61,8 +60,6 @@
fieldPrinter.print(b, s, l, ps);
}
}
-
};
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinter.java
deleted file mode 100644
index ee94187..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinter.java
+++ /dev/null
@@ -1,172 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- 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 MISSING:
- 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 YEARMONTHDURATION: {
- AYearMonthDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case DAYTIMEDURATION: {
- ADayTimeDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case INTERVAL: {
- AIntervalPrinter.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;
- }
- case BINARY: {
- ABinaryHexPrinter.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;
- }
- case UUID: {
- AUUIDPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case ANY:
- case BITARRAY:
- case ENUM:
- case SHORTWITHOUTTYPEINFO:
- case SPARSERECORD:
- case SYSTEM_NULL:
- case TYPE:
- case UINT16:
- case UINT32:
- case UINT64:
- case UINT8:
- case UNION:
- throw new NotImplementedException("No printer for type " + typeTag);
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinterFactory.java
index c85e8f2..8ef4a83 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinterFactory.java
@@ -18,17 +18,145 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.om.pointables.AListVisitablePointable;
+import org.apache.asterix.om.pointables.ARecordVisitablePointable;
+import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
+import org.apache.asterix.om.pointables.printer.IPrintVisitor;
+import org.apache.asterix.om.pointables.printer.json.clean.APrintVisitor;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.hyracks.algebricks.common.utils.Pair;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
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;
+ public static boolean printFlatValue(ATypeTag typeTag, byte[] b, int s, int l, PrintStream ps)
+ throws HyracksDataException {
+ switch (typeTag) {
+ case INT8:
+ AInt8PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INT16:
+ AInt16PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INT32:
+ AInt32PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INT64:
+ AInt64PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case MISSING:
+ case NULL:
+ ANullPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case BOOLEAN:
+ ABooleanPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case FLOAT:
+ AFloatPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DOUBLE:
+ ADoublePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DATE:
+ ADatePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case TIME:
+ ATimePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DATETIME:
+ ADateTimePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DURATION:
+ ADurationPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case YEARMONTHDURATION:
+ AYearMonthDurationPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DAYTIMEDURATION:
+ ADayTimeDurationPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INTERVAL:
+ AIntervalPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case POINT:
+ APointPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case POINT3D:
+ APoint3DPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case LINE:
+ ALinePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case POLYGON:
+ APolygonPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case CIRCLE:
+ ACirclePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case RECTANGLE:
+ ARectanglePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case STRING:
+ AStringPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case BINARY:
+ ABinaryHexPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case UUID:
+ AUUIDPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ default:
+ return false;
+ }
}
+ @Override
+ public IPrinter createPrinter() {
+ final ARecordVisitablePointable rPointable = new ARecordVisitablePointable(
+ DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE);
+ final AListVisitablePointable olPointable = new AListVisitablePointable(
+ DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE);
+ final AListVisitablePointable ulPointable = new AListVisitablePointable(
+ DefaultOpenFieldType.NESTED_OPEN_AUNORDERED_LIST_TYPE);
+ final Pair<PrintStream, ATypeTag> streamTag = new Pair<>(null, null);
+
+ final IPrintVisitor visitor = new APrintVisitor();
+
+ return (byte[] b, int s, int l, PrintStream ps) -> {
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(b[s]);
+ if (!printFlatValue(typeTag, b, s, l, ps)) {
+ streamTag.first = ps;
+ streamTag.second = typeTag;
+ try {
+ switch (typeTag) {
+ case RECORD:
+ rPointable.set(b, s, l);
+ visitor.visit(rPointable, streamTag);
+ break;
+ case ORDEREDLIST:
+ olPointable.set(b, s, l);
+ visitor.visit(olPointable, streamTag);
+ break;
+ case UNORDEREDLIST:
+ ulPointable.set(b, s, l);
+ visitor.visit(ulPointable, streamTag);
+ break;
+ default:
+ throw new HyracksDataException("No printer for type " + typeTag);
+ }
+ } catch (AsterixException e) {
+ throw new HyracksDataException(e);
+ }
+ }
+ };
+ }
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AOrderedlistPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AOrderedlistPrinterFactory.java
index d911594..f517009 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AOrderedlistPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AOrderedlistPrinterFactory.java
@@ -36,7 +36,7 @@
public class AOrderedlistPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
- private AOrderedListType orderedlistType;
+ private final AOrderedListType orderedlistType;
public AOrderedlistPrinterFactory(AOrderedListType orderedlistType) {
this.orderedlistType = orderedlistType;
@@ -44,16 +44,14 @@
@Override
public IPrinter createPrinter() {
-
- PointableAllocator allocator = new PointableAllocator();
- final IAType inputType = orderedlistType == null ? DefaultOpenFieldType
- .getDefaultOpenFieldType(ATypeTag.ORDEREDLIST) : orderedlistType;
+ final 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);
+ final Pair<PrintStream, ATypeTag> arg = new Pair<>(null, null);
return new IPrinter() {
-
@Override
public void init() {
arg.second = inputType.getTypeTag();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APoint3DPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APoint3DPrinter.java
deleted file mode 100644
index 4271695..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APoint3DPrinter.java
+++ /dev/null
@@ -1,45 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("[");
- 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("]");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APoint3DPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APoint3DPrinterFactory.java
index 6bd43ae..84f6f16 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APoint3DPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APoint3DPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,18 @@
private static final long serialVersionUID = 1L;
public static final APoint3DPrinterFactory INSTANCE = new APoint3DPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("[");
+ 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("]");
+ };
+
@Override
public IPrinter createPrinter() {
- return APoint3DPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APointPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APointPrinter.java
deleted file mode 100644
index 1a6b327..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APointPrinter.java
+++ /dev/null
@@ -1,43 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("[");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
- ps.print(", ");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 9));
- ps.print("]");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APointPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APointPrinterFactory.java
index 23cf4bf..b4f2979 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APointPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APointPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,16 @@
private static final long serialVersionUID = 1L;
public static final APointPrinterFactory INSTANCE = new APointPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("[");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
+ ps.print(", ");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 9));
+ ps.print("]");
+ };
+
@Override
public IPrinter createPrinter() {
- return APointPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APolygonPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APolygonPrinter.java
deleted file mode 100644
index 5e8aea8..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APolygonPrinter.java
+++ /dev/null
@@ -1,58 +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.dataflow.data.nontagged.printers.json.clean;
-
-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.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- short numberOfPoints = AInt16SerializerDeserializer.getShort(b, s + 1);
- s += 3;
-
- ps.print("[ ");
-
- for (int i = 0; i < numberOfPoints; i++) {
- if (i > 0)
- ps.print(", ");
-
- ps.print("[");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s));
- ps.print(", ");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 8));
- ps.print("]");
-
- s += 16;
- }
-
- ps.print(" ]");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APolygonPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APolygonPrinterFactory.java
index b725feb..b97bd7bc 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APolygonPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/APolygonPrinterFactory.java
@@ -18,6 +18,10 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+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.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +30,26 @@
private static final long serialVersionUID = 1L;
public static final APolygonPrinterFactory INSTANCE = new APolygonPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ short numberOfPoints = AInt16SerializerDeserializer.getShort(b, s + 1);
+ s += 3;
+ ps.print("[ ");
+ for (int i = 0; i < numberOfPoints; i++) {
+ if (i > 0) {
+ ps.print(", ");
+ }
+ ps.print("[");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s));
+ ps.print(", ");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 8));
+ ps.print("]");
+ s += 16;
+ }
+ ps.print(" ]");
+ };
+
@Override
public IPrinter createPrinter() {
- return APolygonPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARecordPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARecordPrinterFactory.java
index bf459e3..af2dff3 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARecordPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARecordPrinterFactory.java
@@ -44,16 +44,14 @@
@Override
public IPrinter createPrinter() {
-
- PointableAllocator allocator = new PointableAllocator();
+ final 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);
+ final Pair<PrintStream, ATypeTag> arg = new Pair<>(null, null);
return new IPrinter() {
-
@Override
public void init() {
arg.second = inputType.getTypeTag();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARectanglePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARectanglePrinter.java
deleted file mode 100644
index 73a9e5d..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARectanglePrinter.java
+++ /dev/null
@@ -1,47 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("[ [");
- 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(", ");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
- ps.print("] ]");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARectanglePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARectanglePrinterFactory.java
index 5fcf690..2e66326 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARectanglePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARectanglePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,20 @@
private static final long serialVersionUID = 1L;
public static final ARectanglePrinterFactory INSTANCE = new ARectanglePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("[ [");
+ 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(", ");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
+ ps.print("] ]");
+ };
+
@Override
public IPrinter createPrinter() {
- return ARectanglePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AStringPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AStringPrinter.java
deleted file mode 100644
index de59073..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AStringPrinter.java
+++ /dev/null
@@ -1,44 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- try {
- PrintTools.writeUTF8StringAsJSON(b, s + 1, l - 1, ps);
- } catch (IOException e) {
- throw new HyracksDataException(e);
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AStringPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AStringPrinterFactory.java
index 3a57ae9..f06b743 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AStringPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AStringPrinterFactory.java
@@ -18,17 +18,29 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public class AStringPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
public static final AStringPrinterFactory INSTANCE = new AStringPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ try {
+ PrintTools.writeUTF8StringAsJSON(b, s + 1, l - 1, ps);
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ };
+
@Override
public IPrinter createPrinter() {
- return AStringPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ATimePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ATimePrinter.java
deleted file mode 100644
index cda475d..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ATimePrinter.java
+++ /dev/null
@@ -1,42 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("\"");
- PrintTools.printTimeString(b, s, l, ps);
- ps.print("\"");
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ATimePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ATimePrinterFactory.java
index 11436ea..5729c33 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ATimePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ATimePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ATimePrinterFactory INSTANCE = new ATimePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("\"");
+ PrintTools.printTimeString(b, s, l, ps);
+ ps.print("\"");
+ };
+
@Override
public IPrinter createPrinter() {
- return ATimePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUUIDPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUUIDPrinter.java
deleted file mode 100644
index 3990dd4..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUUIDPrinter.java
+++ /dev/null
@@ -1,44 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.om.base.AUUID;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AUUIDPrinter implements IPrinter {
-
- public static final AUUIDPrinter INSTANCE = new AUUIDPrinter();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- StringBuilder buf = new StringBuilder(AUUID.UUID_CHARS + 2);
- buf.append('"');
- AUUID.appendLiteralOnly(b, s + 1, buf).append('"');
- ps.print(buf.toString());
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUUIDPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUUIDPrinterFactory.java
index eeda0e2..f1c853f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUUIDPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUUIDPrinterFactory.java
@@ -19,7 +19,9 @@
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.AUUIDPrinter;
+import java.io.PrintStream;
+
+import org.apache.asterix.om.base.AUUID;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -29,8 +31,15 @@
public static final AUUIDPrinterFactory INSTANCE = new AUUIDPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ StringBuilder buf = new StringBuilder(AUUID.UUID_CHARS + 2);
+ buf.append('"');
+ AUUID.appendLiteralOnly(b, s + 1, buf).append('"');
+ ps.print(buf.toString());
+ };
+
@Override
public IPrinter createPrinter() {
- return AUUIDPrinter.INSTANCE;
+ return PRINTER;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUnionPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUnionPrinterFactory.java
index d19035e..9a2e630 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUnionPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUnionPrinterFactory.java
@@ -32,7 +32,6 @@
public class AUnionPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
-
private AUnionType unionType;
public AUnionPrinterFactory(AUnionType unionType) {
@@ -41,9 +40,7 @@
@Override
public IPrinter createPrinter() {
-
return new IPrinter() {
-
private IPrinter[] printers;
private List<IAType> unionList;
@@ -73,5 +70,4 @@
}
};
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUnorderedlistPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUnorderedlistPrinterFactory.java
index 3c4bcb5..a5c9d00 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUnorderedlistPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AUnorderedlistPrinterFactory.java
@@ -35,7 +35,7 @@
public class AUnorderedlistPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
- private AUnorderedListType unorderedlistType;
+ private final AUnorderedListType unorderedlistType;
public AUnorderedlistPrinterFactory(AUnorderedListType unorderedlistType) {
this.unorderedlistType = unorderedlistType;
@@ -43,16 +43,14 @@
@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);
+ final Pair<PrintStream, ATypeTag> arg = new Pair<>(null, null);
return new IPrinter() {
-
@Override
public void init() {
arg.second = inputType.getTypeTag();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AYearMonthDurationPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AYearMonthDurationPrinter.java
deleted file mode 100644
index 2620afc..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AYearMonthDurationPrinter.java
+++ /dev/null
@@ -1,51 +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.dataflow.data.nontagged.printers.json.clean;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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() {
- }
-
- /* (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 HyracksDataException {
-
- int months = AInt32SerializerDeserializer.getInt(b, s + 1);
-
- ps.print("{ \"year-month-duration\": ");
- ps.print(months);
- ps.print("}");
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AYearMonthDurationPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AYearMonthDurationPrinterFactory.java
index 16886db..81abdc0 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AYearMonthDurationPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AYearMonthDurationPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.clean;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,12 +29,14 @@
private static final long serialVersionUID = 1L;
public static final AYearMonthDurationPrinterFactory INSTANCE = new AYearMonthDurationPrinterFactory();
- /* (non-Javadoc)
- * @see org.apache.hyracks.algebricks.data.IPrinterFactory#createPrinter()
- */
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"year-month-duration\": ");
+ ps.print(AInt32SerializerDeserializer.getInt(b, s + 1));
+ ps.print("}");
+ };
+
@Override
public IPrinter createPrinter() {
- return AYearMonthDurationPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABinaryHexPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABinaryHexPrinterFactory.java
similarity index 78%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABinaryHexPrinter.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABinaryHexPrinterFactory.java
index 74f3353..153574c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABinaryHexPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABinaryHexPrinterFactory.java
@@ -23,22 +23,17 @@
import java.io.PrintStream;
import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.hyracks.algebricks.data.IPrinterFactory;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
import org.apache.hyracks.util.bytes.HexPrinter;
-public class ABinaryHexPrinter implements IPrinter {
- private ABinaryHexPrinter() {
- }
+public class ABinaryHexPrinterFactory implements IPrinterFactory {
+ private static final long serialVersionUID = 1L;
- public static final ABinaryHexPrinter INSTANCE = new ABinaryHexPrinter();
+ public static final ABinaryHexPrinterFactory INSTANCE = new ABinaryHexPrinterFactory();
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
int validLength = ByteArrayPointable.getContentLength(b, s + 1);
int start = s + 1 + ByteArrayPointable.getNumberBytesToStoreMeta(validLength);
try {
@@ -48,5 +43,10 @@
} catch (IOException e) {
throw new HyracksDataException(e);
}
+ };
+
+ @Override
+ public IPrinter createPrinter() {
+ return PRINTER;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABinaryPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABinaryPrinterFactory.java
deleted file mode 100644
index 65c4fad..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABinaryPrinterFactory.java
+++ /dev/null
@@ -1,37 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.algebricks.data.IPrinterFactory;
-
-public class ABinaryPrinterFactory implements IPrinterFactory {
- private static final long serialVersionUID = 1L;
-
- private ABinaryPrinterFactory() {
- }
-
- public static final ABinaryPrinterFactory INSTANCE = new ABinaryPrinterFactory();
-
- @Override
- public IPrinter createPrinter() {
- return ABinaryHexPrinter.INSTANCE;
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABooleanPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABooleanPrinter.java
deleted file mode 100644
index aa94664..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABooleanPrinter.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print(ABooleanSerializerDeserializer.getBoolean(b, s + 1));
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABooleanPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABooleanPrinterFactory.java
index 8315212..b65897b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABooleanPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ABooleanPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final ABooleanPrinterFactory INSTANCE = new ABooleanPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) ->
+ ps.print(ABooleanSerializerDeserializer.getBoolean(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return ABooleanPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ACirclePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ACirclePrinter.java
deleted file mode 100644
index eb42de6..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ACirclePrinter.java
+++ /dev/null
@@ -1,45 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("{ \"circle\": [ { \"point\": [");
- 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(" ] }");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ACirclePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ACirclePrinterFactory.java
index 83cf09d..5ec854d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ACirclePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ACirclePrinterFactory.java
@@ -18,6 +18,9 @@
*/
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.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,18 @@
private static final long serialVersionUID = 1L;
public static final ACirclePrinterFactory INSTANCE = new ACirclePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"circle\": [ { \"point\": [");
+ 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(" ] }");
+ };
+
@Override
public IPrinter createPrinter() {
- return ACirclePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADatePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADatePrinter.java
deleted file mode 100644
index c9a2beb..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADatePrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class ADatePrinter implements IPrinter {
-
- public static final ADatePrinter INSTANCE = new ADatePrinter();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- ps.print("{ \"date\": \"");
- PrintTools.printDateString(b, s, l, ps);
- ps.print("\" }");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADatePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADatePrinterFactory.java
index 55c4493..4a43fbc 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADatePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADatePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADatePrinterFactory INSTANCE = new ADatePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"date\": \"");
+ PrintTools.printDateString(b, s, l, ps);
+ ps.print("\" }");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADatePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADateTimePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADateTimePrinter.java
deleted file mode 100644
index 78f75d8..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADateTimePrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("{ \"datetime\": \"");
- PrintTools.printDateTimeString(b, s, l, ps);
- ps.print("\" }");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADateTimePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADateTimePrinterFactory.java
index af12e42..cd5ae8f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADateTimePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADateTimePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADateTimePrinterFactory INSTANCE = new ADateTimePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"datetime\": \"");
+ PrintTools.printDateTimeString(b, s, l, ps);
+ ps.print("\" }");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADateTimePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADayTimeDurationPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADayTimeDurationPrinter.java
deleted file mode 100644
index 4730cd9..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADayTimeDurationPrinter.java
+++ /dev/null
@@ -1,42 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class ADayTimeDurationPrinter implements IPrinter {
-
- public static final ADayTimeDurationPrinter INSTANCE = new ADayTimeDurationPrinter();
-
- @Override
- public void init() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- ps.print("{ \"day-time-duration\": ");
- PrintTools.printDayTimeDurationString(b, s, l, ps);
- ps.print("}");
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADayTimeDurationPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADayTimeDurationPrinterFactory.java
index e28f3aa..028ed20 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADayTimeDurationPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADayTimeDurationPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADayTimeDurationPrinterFactory INSTANCE = new ADayTimeDurationPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"day-time-duration\": ");
+ PrintTools.printDayTimeDurationString(b, s, l, ps);
+ ps.print("}");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADayTimeDurationPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADoublePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADoublePrinter.java
deleted file mode 100644
index 3175670..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADoublePrinter.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADoublePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADoublePrinterFactory.java
index 7bb3461..a14a16f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADoublePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADoublePrinterFactory.java
@@ -18,6 +18,9 @@
*/
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.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final ADoublePrinterFactory INSTANCE = new ADoublePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return ADoublePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADurationPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADurationPrinter.java
deleted file mode 100644
index 3b5a1a2..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADurationPrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("{ \"duration\": \"");
- PrintTools.printDurationString(b, s, l, ps);
- ps.print("\" }");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADurationPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADurationPrinterFactory.java
index 29d0388..a4844fc 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADurationPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ADurationPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ADurationPrinterFactory INSTANCE = new ADurationPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"duration\": \"");
+ PrintTools.printDurationString(b, s, l, ps);
+ ps.print("\" }");
+ };
+
@Override
public IPrinter createPrinter() {
- return ADurationPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AFloatPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AFloatPrinter.java
deleted file mode 100644
index ddbe830..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AFloatPrinter.java
+++ /dev/null
@@ -1,39 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print(AFloatSerializerDeserializer.getFloat(b, s + 1));
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AFloatPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AFloatPrinterFactory.java
index c5e93fb..987dbd8 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AFloatPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AFloatPrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,11 @@
private static final long serialVersionUID = 1L;
public static final AFloatPrinterFactory INSTANCE = new AFloatPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps
+ .print(AFloatSerializerDeserializer.getFloat(b, s + 1));
+
@Override
public IPrinter createPrinter() {
- return AFloatPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt16Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt16Printer.java
deleted file mode 100644
index a791cf0..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt16Printer.java
+++ /dev/null
@@ -1,42 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- short i = AInt16SerializerDeserializer.getShort(b, s + 1);
-
- ps.print("{ \"int16\": ");
- ps.print(i);
- ps.print(" }");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt16PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt16PrinterFactory.java
index 903b59a..17a9e60 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt16PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt16PrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final AInt16PrinterFactory INSTANCE = new AInt16PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"int16\": ");
+ ps.print(AInt16SerializerDeserializer.getShort(b, s + 1));
+ ps.print(" }");
+ };
+
@Override
public IPrinter createPrinter() {
- return AInt16Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt32Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt32Printer.java
deleted file mode 100644
index 437208b..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt32Printer.java
+++ /dev/null
@@ -1,43 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- int d = AInt32SerializerDeserializer.getInt(b, s + 1);
-
- ps.print("{ \"int32\": ");
- ps.print(d);
- ps.print(" }");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt32PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt32PrinterFactory.java
index 383552e..cc7d861 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt32PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt32PrinterFactory.java
@@ -18,6 +18,9 @@
*/
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.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final AInt32PrinterFactory INSTANCE = new AInt32PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"int32\": ");
+ ps.print(AInt32SerializerDeserializer.getInt(b, s + 1));
+ ps.print(" }");
+ };
+
@Override
public IPrinter createPrinter() {
- return AInt32Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt64Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt64Printer.java
deleted file mode 100644
index f77ab29..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt64Printer.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- long d = AInt64SerializerDeserializer.getLong(b, s + 1);
- ps.print("{ \"int64\": ");
- ps.print(d);
- ps.print(" }");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt64PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt64PrinterFactory.java
index 4ebb974..81347a5 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt64PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt64PrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final AInt64PrinterFactory INSTANCE = new AInt64PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"int64\": ");
+ ps.print(AInt64SerializerDeserializer.getLong(b, s + 1));
+ ps.print(" }");
+ };
+
@Override
public IPrinter createPrinter() {
- return AInt64Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt8Printer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt8Printer.java
deleted file mode 100644
index f4fa7d8..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt8Printer.java
+++ /dev/null
@@ -1,43 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- byte o = AInt8SerializerDeserializer.getByte(b, s + 1);
-
- ps.print("{ \"int8\": ");
- ps.print(o);
- ps.print(" }");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt8PrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt8PrinterFactory.java
index a5d409a..5b3368f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt8PrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AInt8PrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final AInt8PrinterFactory INSTANCE = new AInt8PrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"int8\": ");
+ ps.print(AInt8SerializerDeserializer.getByte(b, s + 1));
+ ps.print(" }");
+ };
+
@Override
public IPrinter createPrinter() {
- return AInt8Printer.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AIntervalPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AIntervalPrinter.java
deleted file mode 100644
index 596cac9..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AIntervalPrinter.java
+++ /dev/null
@@ -1,78 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ADatePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ADateTimePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ATimePrinter;
-import org.apache.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AIntervalPrinter implements IPrinter {
-
- public static final AIntervalPrinter INSTANCE = new AIntervalPrinter();
-
- /* (non-Javadoc)
- * @see org.apache.hyracks.algebricks.data.IPrinter#init()
- */
- @Override
- public void init() {
- }
-
- /* (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 HyracksDataException {
- ps.print("{ \"interval\": { \"start\": ");
-
- byte typetag = AIntervalSerializerDeserializer.getIntervalTimeType(b, s + 1);
- int startOffset = AIntervalSerializerDeserializer.getIntervalStartOffset(b, s + 1) - 1;
- int startSize = AIntervalSerializerDeserializer.getStartSize(b, s + 1);
- int endOffset = AIntervalSerializerDeserializer.getIntervalEndOffset(b, s + 1) - 1;
- int endSize = AIntervalSerializerDeserializer.getEndSize(b, s + 1);
-
- IPrinter timeInstancePrinter;
- ATypeTag intervalType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(typetag);
- switch (intervalType) {
- case DATE:
- timeInstancePrinter = ADatePrinter.INSTANCE;
- break;
- case TIME:
- timeInstancePrinter = ATimePrinter.INSTANCE;
- break;
- case DATETIME:
- timeInstancePrinter = ADateTimePrinter.INSTANCE;
- break;
- default:
- throw new HyracksDataException("Unsupported internal time types in interval: " + typetag);
- }
-
- timeInstancePrinter.print(b, startOffset, startSize, ps);
- ps.print(", \"end\": ");
- timeInstancePrinter.print(b, endOffset, endSize, ps);
-
- ps.print("}}");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AIntervalPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AIntervalPrinterFactory.java
index 7dc9326..9c1a4ad 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AIntervalPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AIntervalPrinterFactory.java
@@ -18,17 +18,48 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public class AIntervalPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
public static final AIntervalPrinterFactory INSTANCE = new AIntervalPrinterFactory();
- @Override
- public IPrinter createPrinter() {
- return AIntervalPrinter.INSTANCE;
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"interval\": { \"start\": ");
+ byte typetag = AIntervalSerializerDeserializer.getIntervalTimeType(b, s + 1);
+ int startOffset = AIntervalSerializerDeserializer.getIntervalStartOffset(b, s + 1) - 1;
+ int startSize = AIntervalSerializerDeserializer.getStartSize(b, s + 1);
+ int endOffset = AIntervalSerializerDeserializer.getIntervalEndOffset(b, s + 1) - 1;
+ int endSize = AIntervalSerializerDeserializer.getEndSize(b, s + 1);
+ IPrinter timeInstancePrinter = getIPrinter(typetag);
+ timeInstancePrinter.print(b, startOffset, startSize, ps);
+ ps.print(", \"end\": ");
+ timeInstancePrinter.print(b, endOffset, endSize, ps);
+ ps.print("}}");
+ };
+
+ private static IPrinter getIPrinter(byte typetag) throws HyracksDataException {
+ switch (EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(typetag)) {
+ case DATE:
+ return ADatePrinterFactory.PRINTER;
+ case TIME:
+ return ATimePrinterFactory.PRINTER;
+ case DATETIME:
+ return ADateTimePrinterFactory.PRINTER;
+ default:
+ throw new HyracksDataException("Unsupported internal time types in interval: " + typetag);
+ }
}
+ @Override
+ public IPrinter createPrinter() {
+ return PRINTER;
+ }
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ALinePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ALinePrinter.java
deleted file mode 100644
index 8dce1e8..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ALinePrinter.java
+++ /dev/null
@@ -1,48 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- 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("] } ] }");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ALinePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ALinePrinterFactory.java
index 2cac3c0..fa9f116 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ALinePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ALinePrinterFactory.java
@@ -18,6 +18,9 @@
*/
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.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,21 @@
private static final long serialVersionUID = 1L;
public static final ALinePrinterFactory INSTANCE = new ALinePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ 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("] } ] }");
+ };
+
@Override
public IPrinter createPrinter() {
- return ALinePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullPrinter.java
deleted file mode 100644
index d9fd638..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullPrinter.java
+++ /dev/null
@@ -1,38 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("null");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullPrinterFactory.java
index fb7aca3..82c7d36 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullPrinterFactory.java
@@ -18,6 +18,8 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+import java.io.PrintStream;
+
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +28,10 @@
private static final long serialVersionUID = 1L;
public static final ANullPrinterFactory INSTANCE = new ANullPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> ps.print("null");
+
@Override
public IPrinter createPrinter() {
- return ANullPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullableFieldPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullableFieldPrinterFactory.java
index a4f4200..c7e51ce 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullableFieldPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullableFieldPrinterFactory.java
@@ -31,7 +31,6 @@
public class ANullableFieldPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
-
private AUnionType unionType;
public ANullableFieldPrinterFactory(AUnionType unionType) {
@@ -61,8 +60,6 @@
fieldPrinter.print(b, s, l, ps);
}
}
-
};
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinter.java
deleted file mode 100644
index 1acbc06..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinter.java
+++ /dev/null
@@ -1,172 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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() {
- }
-
- @Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- 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 MISSING:
- 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 YEARMONTHDURATION: {
- AYearMonthDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case DAYTIMEDURATION: {
- ADayTimeDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case INTERVAL: {
- AIntervalPrinter.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;
- }
- case BINARY: {
- ABinaryHexPrinter.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;
- }
- case UUID: {
- AUUIDPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case ANY:
- case BITARRAY:
- case ENUM:
- case SHORTWITHOUTTYPEINFO:
- case SPARSERECORD:
- case SYSTEM_NULL:
- case TYPE:
- case UINT16:
- case UINT32:
- case UINT64:
- case UINT8:
- case UNION:
- throw new NotImplementedException("No printer for type " + typeTag);
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java
index 52b1c34..20a89bd 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java
@@ -18,17 +18,145 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+import java.io.PrintStream;
+
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.om.pointables.AListVisitablePointable;
+import org.apache.asterix.om.pointables.ARecordVisitablePointable;
+import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
+import org.apache.asterix.om.pointables.printer.IPrintVisitor;
+import org.apache.asterix.om.pointables.printer.json.lossless.APrintVisitor;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.hyracks.algebricks.common.utils.Pair;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
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;
+ public static boolean printFlatValue(ATypeTag typeTag, byte[] b, int s, int l, PrintStream ps)
+ throws HyracksDataException {
+ switch (typeTag) {
+ case INT8:
+ AInt8PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INT16:
+ AInt16PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INT32:
+ AInt32PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INT64:
+ AInt64PrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case MISSING:
+ case NULL:
+ ANullPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case BOOLEAN:
+ ABooleanPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case FLOAT:
+ AFloatPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DOUBLE:
+ ADoublePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DATE:
+ ADatePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case TIME:
+ ATimePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DATETIME:
+ ADateTimePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DURATION:
+ ADurationPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case YEARMONTHDURATION:
+ AYearMonthDurationPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case DAYTIMEDURATION:
+ ADayTimeDurationPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case INTERVAL:
+ AIntervalPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case POINT:
+ APointPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case POINT3D:
+ APoint3DPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case LINE:
+ ALinePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case POLYGON:
+ APolygonPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case CIRCLE:
+ ACirclePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case RECTANGLE:
+ ARectanglePrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case STRING:
+ AStringPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case BINARY:
+ ABinaryHexPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ case UUID:
+ AUUIDPrinterFactory.PRINTER.print(b, s, l, ps);
+ return true;
+ default:
+ return false;
+ }
}
+ @Override
+ public IPrinter createPrinter() {
+ final ARecordVisitablePointable rPointable = new ARecordVisitablePointable(
+ DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE);
+ final AListVisitablePointable olPointable = new AListVisitablePointable(
+ DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE);
+ final AListVisitablePointable ulPointable = new AListVisitablePointable(
+ DefaultOpenFieldType.NESTED_OPEN_AUNORDERED_LIST_TYPE);
+ final Pair<PrintStream, ATypeTag> streamTag = new Pair<>(null, null);
+
+ final IPrintVisitor visitor = new APrintVisitor();
+
+ return (byte[] b, int s, int l, PrintStream ps) -> {
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(b[s]);
+ if (!printFlatValue(typeTag, b, s, l, ps)) {
+ streamTag.first = ps;
+ streamTag.second = typeTag;
+ try {
+ switch (typeTag) {
+ case RECORD:
+ rPointable.set(b, s, l);
+ visitor.visit(rPointable, streamTag);
+ break;
+ case ORDEREDLIST:
+ olPointable.set(b, s, l);
+ visitor.visit(olPointable, streamTag);
+ break;
+ case UNORDEREDLIST:
+ ulPointable.set(b, s, l);
+ visitor.visit(ulPointable, streamTag);
+ break;
+ default:
+ throw new HyracksDataException("No printer for type " + typeTag);
+ }
+ } catch (AsterixException e) {
+ throw new HyracksDataException(e);
+ }
+ }
+ };
+ }
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java
index c3d6e76..54092f8 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java
@@ -36,7 +36,7 @@
public class AOrderedlistPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
- private AOrderedListType orderedlistType;
+ private final AOrderedListType orderedlistType;
public AOrderedlistPrinterFactory(AOrderedListType orderedlistType) {
this.orderedlistType = orderedlistType;
@@ -44,16 +44,14 @@
@Override
public IPrinter createPrinter() {
-
PointableAllocator allocator = new PointableAllocator();
- final IAType inputType = orderedlistType == null ? DefaultOpenFieldType
- .getDefaultOpenFieldType(ATypeTag.ORDEREDLIST) : orderedlistType;
+ 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);
+ final Pair<PrintStream, ATypeTag> arg = new Pair<>(null, null);
return new IPrinter() {
-
@Override
public void init() {
arg.second = inputType.getTypeTag();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinter.java
deleted file mode 100644
index 7d47713..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinter.java
+++ /dev/null
@@ -1,45 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- 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("] }");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinterFactory.java
index be87f7c..78eec0c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APoint3DPrinterFactory.java
@@ -18,6 +18,9 @@
*/
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.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,18 @@
private static final long serialVersionUID = 1L;
public static final APoint3DPrinterFactory INSTANCE = new APoint3DPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ 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("] }");
+ };
+
@Override
public IPrinter createPrinter() {
- return APoint3DPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinter.java
deleted file mode 100644
index cce6983..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinter.java
+++ /dev/null
@@ -1,43 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("{ \"point\": [");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
- ps.print(", ");
- ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 9));
- ps.print("] }");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinterFactory.java
index 5ebe4bb..b563262 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APointPrinterFactory.java
@@ -18,6 +18,9 @@
*/
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.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,16 @@
private static final long serialVersionUID = 1L;
public static final APointPrinterFactory INSTANCE = new APointPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"point\": [");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
+ ps.print(", ");
+ ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 9));
+ ps.print("] }");
+ };
+
@Override
public IPrinter createPrinter() {
- return APointPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinter.java
deleted file mode 100644
index c1495c4..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinter.java
+++ /dev/null
@@ -1,59 +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.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.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- 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("] }");
-
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinterFactory.java
index 0a50695..4506fb7 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/APolygonPrinterFactory.java
@@ -18,6 +18,10 @@
*/
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.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +30,26 @@
private static final long serialVersionUID = 1L;
public static final APolygonPrinterFactory INSTANCE = new APolygonPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ 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("] }");
+ };
+
@Override
public IPrinter createPrinter() {
- return APolygonPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java
index ab52e86..e2ffa2c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java
@@ -44,16 +44,14 @@
@Override
public IPrinter createPrinter() {
-
- PointableAllocator allocator = new PointableAllocator();
+ final 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);
+ final Pair<PrintStream, ATypeTag> arg = new Pair<>(null, null);
return new IPrinter() {
-
@Override
public void init() {
arg.second = inputType.getTypeTag();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinter.java
deleted file mode 100644
index ce203c3..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinter.java
+++ /dev/null
@@ -1,48 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- 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("] } ] }");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinterFactory.java
index d31c358..27d4642 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARectanglePrinterFactory.java
@@ -18,6 +18,9 @@
*/
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.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,21 @@
private static final long serialVersionUID = 1L;
public static final ARectanglePrinterFactory INSTANCE = new ARectanglePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ 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("] } ] }");
+ };
+
@Override
public IPrinter createPrinter() {
- return ARectanglePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinter.java
deleted file mode 100644
index f1835ad..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinter.java
+++ /dev/null
@@ -1,44 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- try {
- PrintTools.writeUTF8StringAsJSON(b, s + 1, l - 1, ps);
- } catch (IOException e) {
- throw new HyracksDataException(e);
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinterFactory.java
index 1487f33..b5cf503 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AStringPrinterFactory.java
@@ -18,17 +18,29 @@
*/
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.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public class AStringPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
public static final AStringPrinterFactory INSTANCE = new AStringPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ try {
+ PrintTools.writeUTF8StringAsJSON(b, s + 1, l - 1, ps);
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ };
+
@Override
public IPrinter createPrinter() {
- return AStringPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinter.java
deleted file mode 100644
index aefb2b0..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinter.java
+++ /dev/null
@@ -1,41 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("{ \"time\": \"");
- PrintTools.printTimeString(b, s, l, ps);
- ps.print("\" }");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinterFactory.java
index abd4d93..327a680 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ATimePrinterFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
+import java.io.PrintStream;
+
+import org.apache.asterix.dataflow.data.nontagged.printers.PrintTools;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,9 +29,14 @@
private static final long serialVersionUID = 1L;
public static final ATimePrinterFactory INSTANCE = new ATimePrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"time\": \"");
+ PrintTools.printTimeString(b, s, l, ps);
+ ps.print("\" }");
+ };
+
@Override
public IPrinter createPrinter() {
- return ATimePrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUUIDPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUUIDPrinter.java
deleted file mode 100644
index d20c8ad..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUUIDPrinter.java
+++ /dev/null
@@ -1,43 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.om.base.AUUID;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AUUIDPrinter implements IPrinter {
-
- public static final AUUIDPrinter INSTANCE = new AUUIDPrinter();
-
- @Override
- public void init() {
- }
-
- public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
- StringBuilder buf = new StringBuilder(AUUID.UUID_CHARS + 2);
- buf.append('"');
- AUUID.appendLiteralOnly(b, s + 1, buf).append('"');
- ps.print(buf.toString());
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUUIDPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUUIDPrinterFactory.java
index 707d78c..2366a98 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUUIDPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUUIDPrinterFactory.java
@@ -19,7 +19,9 @@
package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.AUUIDPrinter;
+import java.io.PrintStream;
+
+import org.apache.asterix.om.base.AUUID;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -29,9 +31,15 @@
public static final AUUIDPrinterFactory INSTANCE = new AUUIDPrinterFactory();
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ StringBuilder buf = new StringBuilder(AUUID.UUID_CHARS + 2);
+ buf.append('"');
+ AUUID.appendLiteralOnly(b, s + 1, buf).append('"');
+ ps.print(buf.toString());
+ };
+
@Override
public IPrinter createPrinter() {
- return AUUIDPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnionPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnionPrinterFactory.java
index a0435c6..15bdfed 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnionPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnionPrinterFactory.java
@@ -41,9 +41,7 @@
@Override
public IPrinter createPrinter() {
-
return new IPrinter() {
-
private IPrinter[] printers;
private List<IAType> unionList;
@@ -73,5 +71,4 @@
}
};
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnorderedlistPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnorderedlistPrinterFactory.java
index c77115b..8251f45 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnorderedlistPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AUnorderedlistPrinterFactory.java
@@ -35,7 +35,7 @@
public class AUnorderedlistPrinterFactory implements IPrinterFactory {
private static final long serialVersionUID = 1L;
- private AUnorderedListType unorderedlistType;
+ private final AUnorderedListType unorderedlistType;
public AUnorderedlistPrinterFactory(AUnorderedListType unorderedlistType) {
this.unorderedlistType = unorderedlistType;
@@ -43,16 +43,14 @@
@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);
+ final Pair<PrintStream, ATypeTag> arg = new Pair<>(null, null);
return new IPrinter() {
-
@Override
public void init() {
arg.second = inputType.getTypeTag();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinter.java
deleted file mode 100644
index 7e4d176..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinter.java
+++ /dev/null
@@ -1,51 +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.dataflow.data.nontagged.printers.json.lossless;
-
-import java.io.PrintStream;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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() {
- }
-
- /* (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 HyracksDataException {
-
- int months = AInt32SerializerDeserializer.getInt(b, s + 1);
-
- ps.print("{ \"year-month-duration\": ");
- ps.print(months);
- ps.print("}");
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinterFactory.java
index ca2201b..bafab7c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AYearMonthDurationPrinterFactory.java
@@ -18,6 +18,9 @@
*/
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.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -26,12 +29,14 @@
private static final long serialVersionUID = 1L;
public static final AYearMonthDurationPrinterFactory INSTANCE = new AYearMonthDurationPrinterFactory();
- /* (non-Javadoc)
- * @see org.apache.hyracks.algebricks.data.IPrinterFactory#createPrinter()
- */
+ public static final IPrinter PRINTER = (byte[] b, int s, int l, PrintStream ps) -> {
+ ps.print("{ \"year-month-duration\": ");
+ ps.print(AInt32SerializerDeserializer.getInt(b, s + 1));
+ ps.print("}");
+ };
+
@Override
public IPrinter createPrinter() {
- return AYearMonthDurationPrinter.INSTANCE;
+ return PRINTER;
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlADMPrinterFactoryProvider.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlADMPrinterFactoryProvider.java
index d9db6de..5f1854d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlADMPrinterFactoryProvider.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlADMPrinterFactoryProvider.java
@@ -18,7 +18,7 @@
*/
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.ABinaryHexPrinterFactory;
import org.apache.asterix.dataflow.data.nontagged.printers.adm.ABooleanPrinterFactory;
import org.apache.asterix.dataflow.data.nontagged.printers.adm.ACirclePrinterFactory;
import org.apache.asterix.dataflow.data.nontagged.printers.adm.ADatePrinterFactory;
@@ -116,7 +116,7 @@
case STRING:
return AStringPrinterFactory.INSTANCE;
case BINARY:
- return ABinaryPrinterFactory.INSTANCE;
+ return ABinaryHexPrinterFactory.INSTANCE;
case RECORD:
return new ARecordPrinterFactory((ARecordType) aqlType);
case ORDEREDLIST:
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCleanJSONPrinterFactoryProvider.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCleanJSONPrinterFactoryProvider.java
index 6220dde..9cf9f8e 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCleanJSONPrinterFactoryProvider.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCleanJSONPrinterFactoryProvider.java
@@ -20,7 +20,7 @@
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.ABinaryPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ABinaryHexPrinterFactory;
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;
@@ -116,7 +116,7 @@
case STRING:
return AStringPrinterFactory.INSTANCE;
case BINARY:
- return ABinaryPrinterFactory.INSTANCE;
+ return ABinaryHexPrinterFactory.INSTANCE;
case RECORD:
return new ARecordPrinterFactory((ARecordType) aqlType);
case ORDEREDLIST:
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlLosslessJSONPrinterFactoryProvider.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlLosslessJSONPrinterFactoryProvider.java
index 1950685..370a47b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlLosslessJSONPrinterFactoryProvider.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlLosslessJSONPrinterFactoryProvider.java
@@ -20,7 +20,7 @@
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.ABinaryPrinterFactory;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ABinaryHexPrinterFactory;
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;
@@ -116,7 +116,7 @@
case STRING:
return AStringPrinterFactory.INSTANCE;
case BINARY:
- return ABinaryPrinterFactory.INSTANCE;
+ return ABinaryHexPrinterFactory.INSTANCE;
case RECORD:
return new ARecordPrinterFactory((ARecordType) aqlType);
case ORDEREDLIST:
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/ABoolean.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/ABoolean.java
index 6907334..7e64cb5 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/ABoolean.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/ABoolean.java
@@ -18,29 +18,32 @@
*/
package org.apache.asterix.om.base;
-import org.json.JSONException;
-import org.json.JSONObject;
-
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.visitors.IOMVisitor;
+import org.json.JSONException;
+import org.json.JSONObject;
public final class ABoolean implements IAObject {
- public static ABoolean TRUE = new ABoolean(true);
- public static ABoolean FALSE = new ABoolean(false);
+ public static final ABoolean TRUE = new ABoolean(true);
+ public static final ABoolean FALSE = new ABoolean(false);
private final Boolean bVal;
private ABoolean(boolean b) {
- bVal = new Boolean(b);
+ bVal = Boolean.valueOf(b);
}
public Boolean getBoolean() {
return bVal;
}
+ public ABoolean valueOf(boolean b) {
+ return b ? TRUE : FALSE;
+ }
+
@Override
public IAType getType() {
return BuiltinType.ABOOLEAN;
@@ -51,12 +54,9 @@
return "ABoolean: {" + bVal + "}";
}
+ @Override
public boolean equals(Object obj) {
- if (!(obj instanceof ABoolean)) {
- return false;
- } else {
- return bVal.equals(((ABoolean) obj).getBoolean());
- }
+ return obj == this;
}
@Override
@@ -81,10 +81,6 @@
@Override
public JSONObject toJSON() throws JSONException {
- JSONObject json = new JSONObject();
-
- json.put("ABoolean", bVal);
-
- return json;
+ return new JSONObject().put("ABoolean", bVal);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/AListPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AListPrinter.java
similarity index 73%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/AListPrinter.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AListPrinter.java
index 826c465..704d06e 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/AListPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AListPrinter.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.asterix.om.pointables.printer.json.clean;
+package org.apache.asterix.om.pointables.printer;
import java.io.IOException;
import java.io.PrintStream;
@@ -31,45 +31,45 @@
import org.apache.hyracks.algebricks.common.utils.Pair;
/**
- * This class is to print the content of a list. It is ONLY visible to
- * APrintVisitor.
+ * This class is to print the content of a list.
*/
-class AListPrinter {
- private static String BEGIN = "[ ";
- private static String END = " ]";
- private static String COMMA = ", ";
+public class AListPrinter {
+ private final String startList;
+ private final String endList;
+ private final String separator;
- private final Pair<PrintStream, ATypeTag> itemVisitorArg = new Pair<PrintStream, ATypeTag>(null, null);
+ private final Pair<PrintStream, ATypeTag> itemVisitorArg = new Pair<>(null, null);
- public AListPrinter(boolean ordered) {
+ public AListPrinter(String startList, String endList, String separator) {
+ this.startList = startList;
+ this.endList = endList;
+ this.separator = separator;
}
- public void printList(AListVisitablePointable listAccessor, PrintStream ps, APrintVisitor visitor)
+ public void printList(AListVisitablePointable listAccessor, PrintStream ps, IPrintVisitor visitor)
throws IOException, AsterixException {
List<IVisitablePointable> itemTags = listAccessor.getItemTags();
List<IVisitablePointable> items = listAccessor.getItems();
itemVisitorArg.first = ps;
- // print the beginning part
- ps.print(BEGIN);
+ ps.print(startList);
// print item 0 to n-2
- for (int i = 0; i < items.size() - 1; i++) {
+ final int size = items.size();
+ for (int i = 0; i < size - 1; i++) {
printItem(visitor, itemTags, items, i);
- // print the comma
- ps.print(COMMA);
+ ps.print(separator);
}
// print item n-1
- if (items.size() > 0) {
- printItem(visitor, itemTags, items, items.size() - 1);
+ if (size > 0) {
+ printItem(visitor, itemTags, items, size - 1);
}
- // print the end part
- ps.print(END);
+ ps.print(endList);
}
- private void printItem(APrintVisitor visitor, List<IVisitablePointable> itemTags, List<IVisitablePointable> items,
+ private void printItem(IPrintVisitor visitor, List<IVisitablePointable> itemTags, List<IVisitablePointable> items,
int i) throws AsterixException {
IVisitablePointable itemTypeTag = itemTags.get(i);
IVisitablePointable item = items.get(i);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/ARecordPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/ARecordPrinter.java
similarity index 68%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/ARecordPrinter.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/ARecordPrinter.java
index fb7d6e1..cfcd8b7 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/ARecordPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/ARecordPrinter.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.asterix.om.pointables.printer.json.lossless;
+package org.apache.asterix.om.pointables.printer;
import java.io.IOException;
import java.io.PrintStream;
@@ -31,23 +31,26 @@
import org.apache.hyracks.algebricks.common.utils.Pair;
/**
- * This class is to print the content of a record. It is ONLY visible to
- * APrintVisitor.
+ * This class is to print the content of a record.
*/
-class ARecordPrinter {
- private static String LEFT_PAREN = "{ ";
- private static String RIGHT_PAREN = " }";
- private static String COMMA = ", ";
- private static String COLON = ": ";
+public class ARecordPrinter {
+ private final String startRecord;
+ private final String endRecord;
+ private final String fieldSeparator;
+ private final String fieldNameSeparator;
- 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);
+ private final Pair<PrintStream, ATypeTag> nameVisitorArg = new Pair<>(null, ATypeTag.STRING);
+ private final Pair<PrintStream, ATypeTag> itemVisitorArg = new Pair<>(null, null);
- public ARecordPrinter() {
-
+ public ARecordPrinter(final String startRecord, final String endRecord, final String fieldSeparator,
+ final String fieldNameSeparator) {
+ this.startRecord = startRecord;
+ this.endRecord = endRecord;
+ this.fieldSeparator = fieldSeparator;
+ this.fieldNameSeparator = fieldNameSeparator;
}
- public void printRecord(ARecordVisitablePointable recordAccessor, PrintStream ps, APrintVisitor visitor)
+ public void printRecord(ARecordVisitablePointable recordAccessor, PrintStream ps, IPrintVisitor visitor)
throws IOException, AsterixException {
List<IVisitablePointable> fieldNames = recordAccessor.getFieldNames();
List<IVisitablePointable> fieldTags = recordAccessor.getFieldTypeTags();
@@ -56,26 +59,24 @@
nameVisitorArg.first = ps;
itemVisitorArg.first = ps;
- // print the beginning part
- ps.print(LEFT_PAREN);
+ ps.print(startRecord);
// print field 0 to n-2
- for (int i = 0; i < fieldNames.size() - 1; i++) {
+ final int size = fieldNames.size();
+ for (int i = 0; i < size - 1; i++) {
printField(ps, visitor, fieldNames, fieldTags, fieldValues, i);
- // print the comma
- ps.print(COMMA);
+ ps.print(fieldSeparator);
}
// print field n-1
- if (fieldValues.size() > 0) {
- printField(ps, visitor, fieldNames, fieldTags, fieldValues, fieldValues.size() - 1);
+ if (size > 0) {
+ printField(ps, visitor, fieldNames, fieldTags, fieldValues, size - 1);
}
- // print the end part
- ps.print(RIGHT_PAREN);
+ ps.print(endRecord);
}
- private void printField(PrintStream ps, APrintVisitor visitor, List<IVisitablePointable> fieldNames,
+ private void printField(PrintStream ps, IPrintVisitor visitor, List<IVisitablePointable> fieldNames,
List<IVisitablePointable> fieldTags, List<IVisitablePointable> fieldValues, int i) throws AsterixException {
IVisitablePointable itemTypeTag = fieldTags.get(i);
IVisitablePointable item = fieldValues.get(i);
@@ -83,9 +84,11 @@
.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);
+ if (fieldNameSeparator != null) {
+ // print field name
+ fieldNames.get(i).accept(visitor, nameVisitorArg);
+ ps.print(fieldNameSeparator);
+ }
// print field value
item.accept(visitor, itemVisitorArg);
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AbstractPrintVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AbstractPrintVisitor.java
new file mode 100644
index 0000000..82fe048
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AbstractPrintVisitor.java
@@ -0,0 +1,93 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.om.pointables.AFlatValuePointable;
+import org.apache.asterix.om.pointables.AListVisitablePointable;
+import org.apache.asterix.om.pointables.ARecordVisitablePointable;
+import org.apache.asterix.om.pointables.base.IVisitablePointable;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.hyracks.algebricks.common.utils.Pair;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public abstract class AbstractPrintVisitor implements IPrintVisitor {
+ private final Map<IVisitablePointable, ARecordPrinter> raccessorToPrinter = new HashMap<>();
+ private final Map<IVisitablePointable, AListPrinter> laccessorToPrinter = new HashMap<>();
+
+ @Override
+ public Void visit(AListVisitablePointable accessor, Pair<PrintStream, ATypeTag> arg) throws AsterixException {
+ AListPrinter printer = laccessorToPrinter.get(accessor);
+ if (printer == null) {
+ printer = createListPrinter(accessor);
+ laccessorToPrinter.put(accessor, printer);
+ }
+ try {
+ printer.printList(accessor, arg.first, this);
+ } catch (IOException e) {
+ throw new AsterixException(e);
+ }
+ return null;
+ }
+
+ @Override
+ public Void visit(ARecordVisitablePointable accessor, Pair<PrintStream, ATypeTag> arg) throws AsterixException {
+ ARecordPrinter printer = raccessorToPrinter.get(accessor);
+ if (printer == null) {
+ printer = createRecordPrinter(accessor);
+ raccessorToPrinter.put(accessor, printer);
+ }
+ try {
+ printer.printRecord(accessor, arg.first, this);
+ } catch (IOException e) {
+ throw new AsterixException(e);
+ }
+ return null;
+ }
+
+ @Override
+ public Void visit(AFlatValuePointable accessor, Pair<PrintStream, ATypeTag> arg) throws AsterixException {
+ try {
+ byte[] b = accessor.getByteArray();
+ int s = accessor.getStartOffset();
+ int l = accessor.getLength();
+ PrintStream ps = arg.first;
+ ATypeTag typeTag = arg.second;
+ if (!printFlatValue(typeTag, b, s, l, ps)) {
+ throw new AsterixException("No printer for type " + typeTag);
+ }
+ return null;
+ } catch (HyracksDataException e) {
+ throw new AsterixException(e);
+ }
+ }
+
+ protected abstract AListPrinter createListPrinter(AListVisitablePointable accessor) throws AsterixException;
+
+ protected abstract ARecordPrinter createRecordPrinter(ARecordVisitablePointable accessor) throws AsterixException;
+
+ protected abstract boolean printFlatValue(ATypeTag typeTag, byte[] b, int s, int l, PrintStream ps)
+ throws HyracksDataException;
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/IPrintVisitor.java
similarity index 63%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullPrinter.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/IPrintVisitor.java
index 38d6bf8..353d89f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/IPrintVisitor.java
@@ -16,23 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.asterix.dataflow.data.nontagged.printers.csv;
+package org.apache.asterix.om.pointables.printer;
+
+import org.apache.asterix.om.pointables.visitor.IVisitablePointableVisitor;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.hyracks.algebricks.common.utils.Pair;
import java.io.PrintStream;
-import org.apache.hyracks.algebricks.data.IPrinter;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-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 HyracksDataException {
- ps.print("null");
- }
+public interface IPrintVisitor extends IVisitablePointableVisitor<Void, Pair<PrintStream, ATypeTag>> {
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/AListPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/AListPrinter.java
deleted file mode 100644
index afa3fb7..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/AListPrinter.java
+++ /dev/null
@@ -1,89 +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.adm;
-
-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 LEFT_PAREN = "{{ ";
- private static String RIGHT_PAREN = " }}";
- private static String LEFT_PAREN_ORDERED = "[ ";
- private static String RIGHT_PAREN_ORDERED = " ]";
- private static String COMMA = ", ";
-
- private final Pair<PrintStream, ATypeTag> itemVisitorArg = new Pair<PrintStream, ATypeTag>(null, null);
- private String leftParen = LEFT_PAREN;
- private String rightParen = RIGHT_PAREN;
-
- public AListPrinter(boolean ordered) {
- if (ordered) {
- leftParen = LEFT_PAREN_ORDERED;
- rightParen = RIGHT_PAREN_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(leftParen);
-
- // 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(rightParen);
- }
-
- 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/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/APrintVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/APrintVisitor.java
index cd91c09..532f8c5 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/APrintVisitor.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/APrintVisitor.java
@@ -19,203 +19,36 @@
package org.apache.asterix.om.pointables.printer.adm;
-import java.io.IOException;
import java.io.PrintStream;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ABinaryHexPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ABooleanPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ACirclePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ADatePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ADateTimePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ADayTimeDurationPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ADoublePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ADurationPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.AFloatPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.AInt16Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.AInt32Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.AInt64Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.AInt8Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.AIntervalPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ALinePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ANullPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.APoint3DPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.APointPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.APolygonPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ARectanglePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.AStringPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ATimePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.AUUIDPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.AYearMonthDurationPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ShortWithoutTypeInfoPrinter;
-import org.apache.asterix.om.pointables.AFlatValuePointable;
+import org.apache.asterix.dataflow.data.nontagged.printers.adm.AObjectPrinterFactory;
import org.apache.asterix.om.pointables.AListVisitablePointable;
import org.apache.asterix.om.pointables.ARecordVisitablePointable;
-import org.apache.asterix.om.pointables.base.IVisitablePointable;
-import org.apache.asterix.om.pointables.visitor.IVisitablePointableVisitor;
+import org.apache.asterix.om.pointables.printer.AListPrinter;
+import org.apache.asterix.om.pointables.printer.ARecordPrinter;
+import org.apache.asterix.om.pointables.printer.AbstractPrintVisitor;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.common.utils.Pair;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
/**
* 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>();
-
+public class APrintVisitor extends AbstractPrintVisitor {
@Override
- public Void visit(AListVisitablePointable 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 (IOException e) {
- throw new AsterixException(e);
- }
- return null;
+ protected AListPrinter createListPrinter(AListVisitablePointable accessor) {
+ return accessor.ordered() ? new AListPrinter("[ ", " ]", ", ") : new AListPrinter("{{ ", " }}", ", ");
}
@Override
- public Void visit(ARecordVisitablePointable 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 (IOException e) {
- throw new AsterixException(e);
- }
- return null;
+ protected ARecordPrinter createRecordPrinter(ARecordVisitablePointable accessor) {
+ return new ARecordPrinter("{ ", " }", ", ", ": ");
}
@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 MISSING:
- 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 YEARMONTHDURATION: {
- AYearMonthDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case DAYTIMEDURATION: {
- ADayTimeDurationPrinter.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;
- }
- case BINARY: {
- ABinaryHexPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case INTERVAL: {
- AIntervalPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case UUID: {
- AUUIDPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case SHORTWITHOUTTYPEINFO: {
- ShortWithoutTypeInfoPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- default: {
- throw new NotImplementedException("No printer for type " + typeTag);
- }
- }
- return null;
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
+ protected boolean printFlatValue(ATypeTag typeTag, byte[] b, int s, int l, PrintStream ps)
+ throws HyracksDataException {
+ return AObjectPrinterFactory.printFlatValue(typeTag, b, s, l, ps);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/ARecordPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/ARecordPrinter.java
deleted file mode 100644
index ef14e3e..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/ARecordPrinter.java
+++ /dev/null
@@ -1,92 +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.adm;
-
-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.ARecordVisitablePointable;
-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 record. It is ONLY visible to
- * APrintVisitor.
- */
-class ARecordPrinter {
- private static String LEFT_BRACE = "{ ";
- private static String RIGHT_BRACE = " }";
- 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(ARecordVisitablePointable 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_BRACE);
-
- // 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_BRACE);
- }
-
- 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/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java
index 306ed99..926d9f0 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java
@@ -19,195 +19,37 @@
package org.apache.asterix.om.pointables.printer.csv;
-import java.io.IOException;
import java.io.PrintStream;
-import java.util.HashMap;
-import java.util.Map;
import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ShortWithoutTypeInfoPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.ABinaryHexPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.ABooleanPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.ACirclePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.ADatePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.ADateTimePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.ADayTimeDurationPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.ADoublePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.ADurationPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.AFloatPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.AInt16Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.AInt32Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.AInt64Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.AInt8Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.ALinePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.ANullPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.APoint3DPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.APointPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.APolygonPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.ARectanglePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.AStringPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.ATimePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.AUUIDPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.csv.AYearMonthDurationPrinter;
-import org.apache.asterix.om.pointables.AFlatValuePointable;
+import org.apache.asterix.dataflow.data.nontagged.printers.csv.AObjectPrinterFactory;
import org.apache.asterix.om.pointables.AListVisitablePointable;
import org.apache.asterix.om.pointables.ARecordVisitablePointable;
-import org.apache.asterix.om.pointables.base.IVisitablePointable;
-import org.apache.asterix.om.pointables.visitor.IVisitablePointableVisitor;
+import org.apache.asterix.om.pointables.printer.AListPrinter;
+import org.apache.asterix.om.pointables.printer.ARecordPrinter;
+import org.apache.asterix.om.pointables.printer.AbstractPrintVisitor;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.common.utils.Pair;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
/**
* 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 CSV format.
*/
-public class APrintVisitor implements IVisitablePointableVisitor<Void, Pair<PrintStream, ATypeTag>> {
-
- private final Map<IVisitablePointable, ARecordPrinter> raccessorToPrinter = new HashMap<IVisitablePointable, ARecordPrinter>();
-
- private int level = 0;
-
+public class APrintVisitor extends AbstractPrintVisitor {
@Override
- public Void visit(AListVisitablePointable accessor, Pair<PrintStream, ATypeTag> arg) throws AsterixException {
+ protected AListPrinter createListPrinter(AListVisitablePointable accessor) throws AsterixException {
throw new AsterixException("'List' type unsupported for CSV output");
}
@Override
- public Void visit(ARecordVisitablePointable accessor, Pair<PrintStream, ATypeTag> arg) throws AsterixException {
- ARecordPrinter printer = raccessorToPrinter.get(accessor);
- if (printer == null) {
- printer = new ARecordPrinter();
- raccessorToPrinter.put(accessor, printer);
- }
- if (level > 0) {
- throw new AsterixException("Nested 'Record' instances unsupported for CSV output");
- }
-
- try {
- level++;
- printer.printRecord(accessor, arg.first, this);
- level--;
- } catch (IOException e) {
- throw new AsterixException(e);
- }
- return null;
+ protected ARecordPrinter createRecordPrinter(ARecordVisitablePointable accessor) {
+ return new ARecordPrinter("", "", ",", 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 MISSING:
- 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;
- }
- case BINARY: {
- ABinaryHexPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case YEARMONTHDURATION: {
- AYearMonthDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case DAYTIMEDURATION: {
- ADayTimeDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case UUID: {
- AUUIDPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case SHORTWITHOUTTYPEINFO: {
- ShortWithoutTypeInfoPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- default: {
- throw new NotImplementedException("No printer for type " + typeTag);
- }
- }
- return null;
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
+ protected boolean printFlatValue(ATypeTag typeTag, byte[] b, int s, int l, PrintStream ps)
+ throws HyracksDataException {
+ return AObjectPrinterFactory.printFlatValue(typeTag, b, s, l, ps);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/ARecordPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/ARecordPrinter.java
deleted file mode 100644
index 5388837..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/ARecordPrinter.java
+++ /dev/null
@@ -1,81 +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.csv;
-
-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.ARecordVisitablePointable;
-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 record. It is ONLY visible to
- * APrintVisitor.
- */
-class ARecordPrinter {
- // QQQ Might we want to make this a configurable delimiter?
- private static String COMMA = ",";
-
- 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(ARecordVisitablePointable 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 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);
- }
- }
-
- 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 value
- item.accept(visitor, itemVisitorArg);
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/APrintVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/APrintVisitor.java
index 81677f1..76768aa 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/APrintVisitor.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/APrintVisitor.java
@@ -19,203 +19,36 @@
package org.apache.asterix.om.pointables.printer.json.clean;
-import java.io.IOException;
import java.io.PrintStream;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ShortWithoutTypeInfoPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ABinaryHexPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ABooleanPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ACirclePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ADatePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ADateTimePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ADayTimeDurationPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ADoublePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ADurationPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AFloatPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AInt16Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AInt32Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AInt64Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AInt8Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AIntervalPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ALinePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ANullPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.APoint3DPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.APointPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.APolygonPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ARectanglePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AStringPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ATimePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AUUIDPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AYearMonthDurationPrinter;
-import org.apache.asterix.om.pointables.AFlatValuePointable;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.AObjectPrinterFactory;
import org.apache.asterix.om.pointables.AListVisitablePointable;
import org.apache.asterix.om.pointables.ARecordVisitablePointable;
-import org.apache.asterix.om.pointables.base.IVisitablePointable;
-import org.apache.asterix.om.pointables.visitor.IVisitablePointableVisitor;
+import org.apache.asterix.om.pointables.printer.AListPrinter;
+import org.apache.asterix.om.pointables.printer.ARecordPrinter;
+import org.apache.asterix.om.pointables.printer.AbstractPrintVisitor;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.common.utils.Pair;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
/**
* 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 Clean JSON 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>();
-
+public class APrintVisitor extends AbstractPrintVisitor {
@Override
- public Void visit(AListVisitablePointable 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 (IOException e) {
- throw new AsterixException(e);
- }
- return null;
+ protected AListPrinter createListPrinter(AListVisitablePointable accessor) {
+ return new AListPrinter("[ ", " ]", ", ");
}
@Override
- public Void visit(ARecordVisitablePointable 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 (IOException e) {
- throw new AsterixException(e);
- }
- return null;
+ protected ARecordPrinter createRecordPrinter(ARecordVisitablePointable accessor) {
+ return new ARecordPrinter("{ ", " }", ", ", ": ");
}
@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 MISSING:
- 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 INTERVAL: {
- AIntervalPrinter.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;
- }
- case BINARY: {
- ABinaryHexPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case YEARMONTHDURATION: {
- AYearMonthDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case DAYTIMEDURATION: {
- ADayTimeDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case UUID: {
- AUUIDPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case SHORTWITHOUTTYPEINFO: {
- ShortWithoutTypeInfoPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- default: {
- throw new NotImplementedException("No printer for type " + typeTag);
- }
- }
- return null;
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
+ protected boolean printFlatValue(ATypeTag typeTag, byte[] b, int s, int l, PrintStream ps)
+ throws HyracksDataException {
+ return AObjectPrinterFactory.printFlatValue(typeTag, b, s, l, ps);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/ARecordPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/ARecordPrinter.java
deleted file mode 100644
index 6644f3a..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/ARecordPrinter.java
+++ /dev/null
@@ -1,92 +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.clean;
-
-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.ARecordVisitablePointable;
-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 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(ARecordVisitablePointable 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/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/AListPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/AListPrinter.java
deleted file mode 100644
index 3b6310a..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/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.lossless;
-
-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);
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/APrintVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/APrintVisitor.java
index c0f3d59..7587bd4 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/APrintVisitor.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/APrintVisitor.java
@@ -19,203 +19,37 @@
package org.apache.asterix.om.pointables.printer.json.lossless;
-import java.io.IOException;
import java.io.PrintStream;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ShortWithoutTypeInfoPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ABinaryHexPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ABooleanPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ACirclePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ADatePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ADateTimePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ADayTimeDurationPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ADoublePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ADurationPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AFloatPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AInt16Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AInt32Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AInt64Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AInt8Printer;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AIntervalPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ALinePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ANullPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.APoint3DPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.APointPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.APolygonPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ARectanglePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AStringPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ATimePrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AUUIDPrinter;
-import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AYearMonthDurationPrinter;
-import org.apache.asterix.om.pointables.AFlatValuePointable;
+import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.AObjectPrinterFactory;
import org.apache.asterix.om.pointables.AListVisitablePointable;
import org.apache.asterix.om.pointables.ARecordVisitablePointable;
-import org.apache.asterix.om.pointables.base.IVisitablePointable;
-import org.apache.asterix.om.pointables.visitor.IVisitablePointableVisitor;
+import org.apache.asterix.om.pointables.printer.AListPrinter;
+import org.apache.asterix.om.pointables.printer.ARecordPrinter;
+import org.apache.asterix.om.pointables.printer.AbstractPrintVisitor;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.common.utils.Pair;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
/**
* 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 JSON 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>();
-
+public class APrintVisitor extends AbstractPrintVisitor {
@Override
- public Void visit(AListVisitablePointable 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 (IOException e) {
- throw new AsterixException(e);
- }
- return null;
+ protected AListPrinter createListPrinter(AListVisitablePointable accessor) {
+ return accessor.ordered() ? new AListPrinter("{ \"orderedlist\": [ ", " ] }", ", ")
+ : new AListPrinter("{ \"unorderedlist\": [ ", " ] }", ", ");
}
@Override
- public Void visit(ARecordVisitablePointable 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 (IOException e) {
- throw new AsterixException(e);
- }
- return null;
+ protected ARecordPrinter createRecordPrinter(ARecordVisitablePointable accessor) {
+ return new ARecordPrinter("{ ", " }", ", ", ": ");
}
@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 MISSING:
- 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 INTERVAL: {
- AIntervalPrinter.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;
- }
- case BINARY: {
- ABinaryHexPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case YEARMONTHDURATION: {
- AYearMonthDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case DAYTIMEDURATION: {
- ADayTimeDurationPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case UUID: {
- AUUIDPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- case SHORTWITHOUTTYPEINFO: {
- ShortWithoutTypeInfoPrinter.INSTANCE.print(b, s, l, ps);
- break;
- }
- default: {
- throw new NotImplementedException("No printer for type " + typeTag);
- }
- }
- return null;
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
+ protected boolean printFlatValue(ATypeTag typeTag, byte[] b, int s, int l, PrintStream ps)
+ throws HyracksDataException {
+ return AObjectPrinterFactory.printFlatValue(typeTag, b, s, l, ps);
}
}
diff --git a/asterixdb/asterix-om/src/test/java/org/apache/asterix/dataflow/data/nontagged/printers/ABinaryPrinterTest.java b/asterixdb/asterix-om/src/test/java/org/apache/asterix/dataflow/data/nontagged/printers/ABinaryPrinterTest.java
index 97d4ccf..8c54423 100644
--- a/asterixdb/asterix-om/src/test/java/org/apache/asterix/dataflow/data/nontagged/printers/ABinaryPrinterTest.java
+++ b/asterixdb/asterix-om/src/test/java/org/apache/asterix/dataflow/data/nontagged/printers/ABinaryPrinterTest.java
@@ -27,7 +27,7 @@
import javax.xml.bind.DatatypeConverter;
-import org.apache.asterix.dataflow.data.nontagged.printers.adm.ABinaryHexPrinter;
+import org.apache.asterix.dataflow.data.nontagged.printers.adm.ABinaryHexPrinterFactory;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
import org.junit.Test;
@@ -48,7 +48,7 @@
PrintStream ps = new PrintStream(baos);
byte[] bytes = generateABinaryBytesByStringContent(input);
- ABinaryHexPrinter.INSTANCE.print(bytes, 0, bytes.length, ps);
+ ABinaryHexPrinterFactory.PRINTER.print(bytes, 0, bytes.length, ps);
String pureHex = baos.toString();
assertTrue(pureHex.startsWith("hex("));
diff --git a/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IPrinter.java b/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IPrinter.java
index 99161eb..2ccb450 100644
--- a/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IPrinter.java
+++ b/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IPrinter.java
@@ -22,8 +22,10 @@
import org.apache.hyracks.api.exceptions.HyracksDataException;
+@FunctionalInterface
public interface IPrinter {
- void init() throws HyracksDataException;
+ default void init() throws HyracksDataException {
+ }
void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException;
}