asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Murtadha Hubail (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: [ASTERIXDB-2303][API] Fix 3-Byte Modified-Utf8 Printing
Date Tue, 27 Feb 2018 10:58:14 GMT
Murtadha Hubail has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/2429

Change subject: [ASTERIXDB-2303][API] Fix 3-Byte Modified-Utf8 Printing
......................................................................

[ASTERIXDB-2303][API] Fix 3-Byte Modified-Utf8 Printing

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

Details:
- Properly print 3-byte encoded modified-utf8 as utf8.
- Add test case.

Change-Id: I59e825c11ff750d5b651fb86712023c52e98367e
---
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/utf8/split.3.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/results/string/utf8/utf8.1.adm
M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
M asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/PrintTools.java
4 files changed, 38 insertions(+), 0 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/29/2429/1

diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/utf8/split.3.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/utf8/split.3.query.sqlpp
new file mode 100644
index 0000000..758d472
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/utf8/split.3.query.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+select value "and I thought my jokes were bad 😀. من اليسار إلى اليمين.
Coffee ☕";
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/utf8/utf8.1.adm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/utf8/utf8.1.adm
new file mode 100644
index 0000000..c5ab0a3
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/utf8/utf8.1.adm
@@ -0,0 +1 @@
+"and I thought my jokes were bad \ud83d\ude00. من اليسار إلى اليمين. Coffee
\u2615"
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index 4265163..9fc0b4b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -6445,6 +6445,11 @@
         <output-dir compare="Text">varlen-encoding</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="string">
+      <compilation-unit name="utf8">
+        <output-dir compare="Text">utf8</output-dir>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="subquery">
     <test-case FilePath="subquery">
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 b1039a5..d80ade2 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
@@ -357,6 +357,11 @@
                                     break;
                             }
                             break;
+                        case 3:
+                            writeAsUtf8(os, c);
+                            position += sz;
+                            sz = 0;
+                            break;
                     }
                     while (sz > 0) {
                         os.write(b[position]);
@@ -378,4 +383,12 @@
         os.write(HexPrinter.hex(c & 0x0f, HexPrinter.CASE.LOWER_CASE));
     }
 
+    private static void writeAsUtf8(OutputStream os, char c) throws IOException {
+        os.write('\\');
+        os.write('u');
+        os.write(HexPrinter.hex((c >>> 12) & 0x0f, HexPrinter.CASE.LOWER_CASE));
+        os.write(HexPrinter.hex((c >>> 8) & 0x0f, HexPrinter.CASE.LOWER_CASE));
+        os.write(HexPrinter.hex((c >>> 4) & 0x0f, HexPrinter.CASE.LOWER_CASE));
+        os.write(HexPrinter.hex(c & 0x0f, HexPrinter.CASE.LOWER_CASE));
+    }
 }

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2429
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I59e825c11ff750d5b651fb86712023c52e98367e
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Murtadha Hubail <mhubail@apache.org>

Mime
View raw message