This is an automated email from the ASF dual-hosted git repository.

mblow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git

commit 39c5df054213ab38b86a1194a32ecf5993468505
Author: Ali Alsuliman <[email protected]>
AuthorDate: Sun Apr 26 22:24:59 2020 -0700

    [ASTERIXDB-2713][EXT] Change the name of the new adapter parameter for 
escaping
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    Change the name of the new parameter "quote-escape" to just "escape".
    
    Change-Id: I3b51fa317bf327fbad18b32f0fd45e47e853ca50
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/6023
    Integration-Tests: Jenkins <[email protected]>
    Tested-by: Jenkins <[email protected]>
    Reviewed-by: Till Westmann <[email protected]>
---
 .../reader/stream/QuotedLineRecordReader.java      | 16 +++++++--------
 .../external/util/ExternalDataConstants.java       |  2 +-
 .../asterix/external/util/ExternalDataUtils.java   | 23 +++++++++++-----------
 3 files changed, 19 insertions(+), 22 deletions(-)

diff --git 
a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/stream/QuotedLineRecordReader.java
 
b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/stream/QuotedLineRecordReader.java
index c6e78b0..e6e8ae0 100644
--- 
a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/stream/QuotedLineRecordReader.java
+++ 
b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/stream/QuotedLineRecordReader.java
@@ -37,7 +37,7 @@ import org.apache.hyracks.api.exceptions.IWarningCollector;
 public class QuotedLineRecordReader extends LineRecordReader {
 
     private char quote;
-    private char quoteEscape;
+    private char escape;
     private boolean prevCharEscape;
     private int readLength;
     private boolean inQuote;
@@ -54,7 +54,7 @@ public class QuotedLineRecordReader extends LineRecordReader {
         String quoteString = config.get(ExternalDataConstants.KEY_QUOTE);
         ExternalDataUtils.validateQuote(quoteString);
         this.quote = quoteString.charAt(0);
-        this.quoteEscape = ExternalDataUtils.validateGetQuoteEscape(config);
+        this.escape = ExternalDataUtils.validateGetEscape(config);
     }
 
     @Override
@@ -117,7 +117,7 @@ public class QuotedLineRecordReader extends 
LineRecordReader {
                 }
                 boolean maybeInQuote = false;
                 for (; bufferPosn < bufferLength; ++bufferPosn) {
-                    if (inputBuffer[bufferPosn] == quote && quoteEscape == 
quote) {
+                    if (inputBuffer[bufferPosn] == quote && escape == quote) {
                         inQuote |= maybeInQuote;
                         prevCharEscape |= maybeInQuote;
                     }
@@ -135,18 +135,16 @@ public class QuotedLineRecordReader extends 
LineRecordReader {
                         prevCharCR = (inputBuffer[bufferPosn] == 
ExternalDataConstants.CR);
                         // if this is an opening quote, mark it
                         inQuote = inputBuffer[bufferPosn] == quote && 
!prevCharEscape;
-                        // the quoteEscape != quote is for making an opening 
quote not an escape
-                        prevCharEscape =
-                                inputBuffer[bufferPosn] == quoteEscape && 
!prevCharEscape && quoteEscape != quote;
+                        // the escape != quote is for making an opening quote 
not an escape
+                        prevCharEscape = inputBuffer[bufferPosn] == escape && 
!prevCharEscape && escape != quote;
                     } else {
-                        // if quote == quoteEscape and current char is quote, 
then it could be closing or escaping
+                        // if quote == escape and current char is quote, then 
it could be closing or escaping
                         if (inputBuffer[bufferPosn] == quote && 
!prevCharEscape) {
                             // this is most likely a closing quote. the 
outcome depends on the next char
                             inQuote = false;
                             maybeInQuote = true;
                         }
-                        prevCharEscape =
-                                inputBuffer[bufferPosn] == quoteEscape && 
!prevCharEscape && quoteEscape != quote;
+                        prevCharEscape = inputBuffer[bufferPosn] == escape && 
!prevCharEscape && escape != quote;
                     }
                 }
                 readLength = bufferPosn - startPosn;
diff --git 
a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataConstants.java
 
b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataConstants.java
index 7d1cdc0..ce95435 100644
--- 
a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataConstants.java
+++ 
b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataConstants.java
@@ -71,7 +71,7 @@ public class ExternalDataConstants {
     public static final String KEY_LOCAL_SOCKET_PATH = "local-socket-path";
     public static final String KEY_FORMAT = "format";
     public static final String KEY_QUOTE = "quote";
-    public static final String KEY_QUOTE_ESCAPE = "quote-escape";
+    public static final String KEY_ESCAPE = "escape";
     public static final String KEY_PARSER = "parser";
     public static final String KEY_DATASET_RECORD = "dataset-record";
     public static final String KEY_HIVE_SERDE = "hive-serde";
diff --git 
a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
 
b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
index b1f11c9..409b69b 100644
--- 
a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
+++ 
b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
@@ -82,13 +82,13 @@ public class ExternalDataUtils {
         return quote;
     }
 
-    public static char validateGetQuoteEscape(Map<String, String> 
configuration) throws HyracksDataException {
-        String quoteEscapeValue = 
configuration.get(ExternalDataConstants.KEY_QUOTE_ESCAPE);
-        if (quoteEscapeValue == null) {
+    public static char validateGetEscape(Map<String, String> configuration) 
throws HyracksDataException {
+        String escapeValue = 
configuration.get(ExternalDataConstants.KEY_ESCAPE);
+        if (escapeValue == null) {
             return ExternalDataConstants.ESCAPE;
         }
-        validateQuoteEscape(quoteEscapeValue);
-        return quoteEscapeValue.charAt(0);
+        validateEscape(escapeValue);
+        return escapeValue.charAt(0);
     }
 
     public static void validateDataParserParameters(Map<String, String> 
configuration) throws AsterixException {
@@ -331,11 +331,11 @@ public class ExternalDataUtils {
             if (format.equals(ExternalDataConstants.FORMAT_CSV)) {
                 configuration.putIfAbsent(ExternalDataConstants.KEY_DELIMITER, 
ExternalDataConstants.DEFAULT_DELIMITER);
                 configuration.putIfAbsent(ExternalDataConstants.KEY_QUOTE, 
ExternalDataConstants.DEFAULT_QUOTE);
-                
configuration.putIfAbsent(ExternalDataConstants.KEY_QUOTE_ESCAPE, 
ExternalDataConstants.DEFAULT_QUOTE);
+                configuration.putIfAbsent(ExternalDataConstants.KEY_ESCAPE, 
ExternalDataConstants.DEFAULT_QUOTE);
             } else if (format.equals(ExternalDataConstants.FORMAT_TSV)) {
                 configuration.putIfAbsent(ExternalDataConstants.KEY_DELIMITER, 
ExternalDataConstants.TAB_STR);
                 configuration.putIfAbsent(ExternalDataConstants.KEY_QUOTE, 
ExternalDataConstants.NULL_STR);
-                
configuration.putIfAbsent(ExternalDataConstants.KEY_QUOTE_ESCAPE, 
ExternalDataConstants.NULL_STR);
+                configuration.putIfAbsent(ExternalDataConstants.KEY_ESCAPE, 
ExternalDataConstants.NULL_STR);
             }
         }
     }
@@ -396,7 +396,7 @@ public class ExternalDataUtils {
         }
         char delimiter = validateGetDelimiter(configuration);
         validateGetQuote(configuration, delimiter);
-        validateGetQuoteEscape(configuration);
+        validateGetEscape(configuration);
         String value = configuration.get(KEY_REDACT_WARNINGS);
         if (value != null && !isBoolean(value)) {
             throw new RuntimeDataException(ErrorCode.INVALID_REQ_PARAM_VAL, 
KEY_REDACT_WARNINGS, value);
@@ -425,10 +425,9 @@ public class ExternalDataUtils {
         }
     }
 
-    private static void validateQuoteEscape(String quoteEsc) throws 
RuntimeDataException {
-        if (quoteEsc.length() != 1) {
-            throw new 
RuntimeDataException(ErrorCode.PARSER_INVALID_CHAR_LENGTH, quoteEsc,
-                    ExternalDataConstants.KEY_QUOTE_ESCAPE);
+    private static void validateEscape(String esc) throws RuntimeDataException 
{
+        if (esc.length() != 1) {
+            throw new 
RuntimeDataException(ErrorCode.PARSER_INVALID_CHAR_LENGTH, esc, 
ExternalDataConstants.KEY_ESCAPE);
         }
     }
 

Reply via email to