asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "abdullah alamoudi (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: Improve Error Handling in Feeds
Date Tue, 15 Mar 2016 15:36:59 GMT
abdullah alamoudi has uploaded a new change for review.

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

Change subject: Improve Error Handling in Feeds
......................................................................

Improve Error Handling in Feeds

This change separate parse exceptions from IOExceptions and
handle each differently. The responsibility of handling
IOExceptions falls on the datasource reader while records which
that couldn't be parsed end up added to the records log file.

Change-Id: I08d89229e33c91532b1038ba9f7a372f7ca1fdb5
---
M .gitignore
M asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordReader.java
M asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedRecordDataFlowController.java
M asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedTupleForwarder.java
M asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/couchbase/CouchbaseReader.java
M asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/HDFSRecordReader.java
M asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/rss/RSSRecordReader.java
M asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/stream/AbstractStreamRecordReader.java
M asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/twitter/TwitterPullRecordReader.java
M asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/twitter/TwitterPushRecordReader.java
M asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/AInputStream.java
M asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/AInputStreamReader.java
M asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/BasicInputStream.java
M asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/LocalFileSystemInputStream.java
M asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/SocketInputStream.java
M asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/provider/HDFSInputStreamProvider.java
M asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/provider/TwitterFirehoseInputStreamProvider.java
M asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataConstants.java
M asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
M asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
20 files changed, 148 insertions(+), 31 deletions(-)


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

diff --git a/.gitignore b/.gitignore
index f8e0b2d..cd497b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,7 @@
 asterix-app/parserts/
 asterix-app/opt_parserts/
 asterix-app/runtime_parserts/
+asterix-app/data/csv/beer.csv
 asterix-installer/ittest/
 asterix-installer/repliationtest/
 build
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordReader.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordReader.java
index 769db19..fe3942d 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordReader.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/api/IRecordReader.java
@@ -72,4 +72,9 @@
      * progress and errors
      */
     public void setFeedLogManager(FeedLogManager feedLogManager);
+
+    /**
+     * gives the record reader a chance to recover from IO errors during feed intake
+     */
+    public boolean handleException(Throwable th);
 }
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedRecordDataFlowController.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedRecordDataFlowController.java
index 3408af9..b1f219c 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedRecordDataFlowController.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedRecordDataFlowController.java
@@ -63,11 +63,16 @@
                     continue;
                 }
                 tb.reset();
-                dataParser.parse(record, tb.getDataOutput());
+                try {
+                    dataParser.parse(record, tb.getDataOutput());
+                } catch (Exception e) {
+                    feedLogManager.logRecord(record.toString(), ExternalDataConstants.ERROR_PARSE_RECORD);
+                    continue;
+                }
                 tb.addFieldEndOffset();
                 if (tb.getSize() > tupleForwarder.getMaxRecordSize()) {
                     // log
-                    feedLogManager.logRecord(record.toString(), ExternalDataConstants.LARGE_RECORD_ERROR_MESSAGE);
+                    feedLogManager.logRecord(record.toString(), ExternalDataConstants.ERROR_LARGE_RECORD);
                     continue;
                 }
                 tupleForwarder.addTuple(tb);
@@ -144,6 +149,7 @@
 
     @Override
     public boolean handleException(Throwable th) {
-        return true;
+        // This is not a parser record. most likely, this error happened in the record reader.
+        return recordReader.handleException(th);
     }
 }
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedTupleForwarder.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedTupleForwarder.java
index 926022c..c9b7ee2 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedTupleForwarder.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedTupleForwarder.java
@@ -82,7 +82,7 @@
     public void addTuple(ArrayTupleBuilder tb) throws HyracksDataException {
         if (tb.getSize() > maxRecordSize) {
             try {
-                feedLogManager.logRecord(tb.toString(), ExternalDataConstants.LARGE_RECORD_ERROR_MESSAGE);
+                feedLogManager.logRecord(tb.toString(), ExternalDataConstants.ERROR_LARGE_RECORD);
             } catch (IOException e) {
                 throw new HyracksDataException(e);
             }
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/couchbase/CouchbaseReader.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/couchbase/CouchbaseReader.java
index fe59aad..32411f5 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/couchbase/CouchbaseReader.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/couchbase/CouchbaseReader.java
@@ -262,4 +262,9 @@
     @Override
     public void setFeedLogManager(FeedLogManager feedLogManager) {
     }
+
+    @Override
+    public boolean handleException(Throwable th) {
+        return false;
+    }
 }
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/HDFSRecordReader.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/HDFSRecordReader.java
index b162a02..f4ebff2 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/HDFSRecordReader.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/hdfs/HDFSRecordReader.java
@@ -124,8 +124,9 @@
                     FileStatus fileStatus = hdfs.getFileStatus(new Path(fileName));
                     // Skip if not the same file stored in the files snapshot
                     if (fileStatus.getModificationTime() != snapshot.get(currentSplitIndex).getLastModefiedTime()
-                            .getTime())
+                            .getTime()) {
                         continue;
+                    }
                 }
 
                 reader.close();
@@ -192,4 +193,9 @@
     @Override
     public void setController(IDataFlowController controller) {
     }
+
+    @Override
+    public boolean handleException(Throwable th) {
+        return false;
+    }
 }
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/rss/RSSRecordReader.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/rss/RSSRecordReader.java
index 1af8695..c03e9e0 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/rss/RSSRecordReader.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/rss/RSSRecordReader.java
@@ -145,6 +145,11 @@
     @Override
     public void setController(IDataFlowController controller) {
     }
+
+    @Override
+    public boolean handleException(Throwable th) {
+        return false;
+    }
 }
 
 class FetcherEventListenerImpl implements FetcherListener {
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/stream/AbstractStreamRecordReader.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/stream/AbstractStreamRecordReader.java
index 2d6d8ea..f60e60d 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/stream/AbstractStreamRecordReader.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/stream/AbstractStreamRecordReader.java
@@ -97,4 +97,9 @@
         this.feedLogManager = feedLogManager;
         reader.setFeedLogManager(feedLogManager);
     }
+
+    @Override
+    public boolean handleException(Throwable th) {
+        return reader.handleException(th);
+    }
 }
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/twitter/TwitterPullRecordReader.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/twitter/TwitterPullRecordReader.java
index 617bc39..f0e9594 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/twitter/TwitterPullRecordReader.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/twitter/TwitterPullRecordReader.java
@@ -107,4 +107,9 @@
     @Override
     public void setController(IDataFlowController controller) {
     }
+
+    @Override
+    public boolean handleException(Throwable th) {
+        return false;
+    }
 }
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/twitter/TwitterPushRecordReader.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/twitter/TwitterPushRecordReader.java
index 19f156c..0397150 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/twitter/TwitterPushRecordReader.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/record/reader/twitter/TwitterPushRecordReader.java
@@ -133,4 +133,9 @@
     @Override
     public void setController(IDataFlowController controller) {
     }
+
+    @Override
+    public boolean handleException(Throwable th) {
+        return false;
+    }
 }
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/AInputStream.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/AInputStream.java
index 469e866..3715bde 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/AInputStream.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/AInputStream.java
@@ -37,4 +37,6 @@
 
     // TODO: Find a better way to send notifications
     public abstract void setFeedLogManager(FeedLogManager logManager);
+
+    public abstract boolean handleException(Throwable th);
 }
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/AInputStreamReader.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/AInputStreamReader.java
index 89008aa..644d3e0 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/AInputStreamReader.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/AInputStreamReader.java
@@ -92,4 +92,8 @@
         System.arraycopy(charBuffer.array(), 0, cbuf, offset, charBuffer.position());
         return charBuffer.position();
     }
+
+    public boolean handleException(Throwable th) {
+        return in.handleException(th);
+    }
 }
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/BasicInputStream.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/BasicInputStream.java
index 5b654eb..33e2044 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/BasicInputStream.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/BasicInputStream.java
@@ -99,4 +99,9 @@
     @Override
     public void setController(AbstractFeedDataFlowController controller) {
     }
+
+    @Override
+    public boolean handleException(Throwable th) {
+        return false;
+    }
 }
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/LocalFileSystemInputStream.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/LocalFileSystemInputStream.java
index 8dcd5b6..8785fdd 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/LocalFileSystemInputStream.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/LocalFileSystemInputStream.java
@@ -28,8 +28,10 @@
 import org.apache.asterix.external.util.FeedLogManager;
 import org.apache.asterix.external.util.FileSystemWatcher;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.log4j.Logger;
 
 public class LocalFileSystemInputStream extends AInputStream {
+    private static final Logger LOGGER = Logger.getLogger(LocalFileSystemInputStream.class.getName());
     private final FileSystemWatcher watcher;
     private FileInputStream in;
     private byte lastByte;
@@ -138,4 +140,18 @@
     public void configure(Map<String, String> configuration) throws IOException {
         watcher.init();
     }
+
+    @Override
+    public boolean handleException(Throwable th) {
+        if (th instanceof IOException) {
+            try {
+                watcher.init();
+            } catch (IOException e) {
+                LOGGER.warn("Failed to initialize watcher during failure recovery", e);
+                return false;
+            }
+            return true;
+        }
+        return false;
+    }
 }
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/SocketInputStream.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/SocketInputStream.java
index 67c4493..579b19b 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/SocketInputStream.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/SocketInputStream.java
@@ -172,4 +172,9 @@
     public void setController(AbstractFeedDataFlowController controller) {
         this.controller = controller;
     }
+
+    @Override
+    public boolean handleException(Throwable th) {
+        return false;
+    }
 }
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/provider/HDFSInputStreamProvider.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/provider/HDFSInputStreamProvider.java
index bf9653d..64a1d8f 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/provider/HDFSInputStreamProvider.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/provider/HDFSInputStreamProvider.java
@@ -129,6 +129,11 @@
         @Override
         public void setController(AbstractFeedDataFlowController controller) {
         }
+
+        @Override
+        public boolean handleException(Throwable th) {
+            return HDFSInputStreamProvider.this.handleException(th);
+        }
     }
 
     @Override
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/provider/TwitterFirehoseInputStreamProvider.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/provider/TwitterFirehoseInputStreamProvider.java
index cd4a3c1..bdb4ce3 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/provider/TwitterFirehoseInputStreamProvider.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/provider/TwitterFirehoseInputStreamProvider.java
@@ -121,6 +121,11 @@
         @Override
         public void setController(AbstractFeedDataFlowController controller) {
         }
+
+        @Override
+        public boolean handleException(Throwable th) {
+            return false;
+        }
     }
 
     private static class DataProvider implements Runnable {
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataConstants.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataConstants.java
index 4b2826c..41f1015 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataConstants.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataConstants.java
@@ -205,5 +205,6 @@
      * Expected parameter values
      */
     public static final String PARAMETER_OF_SIZE_ONE = "Value of size 1";
-    public static final String LARGE_RECORD_ERROR_MESSAGE = "Record is too large";
+    public static final String ERROR_LARGE_RECORD = "Record is too large";
+    public static final String ERROR_PARSE_RECORD = "Parser failed to parse record";
 }
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
b/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
index 2e3b8ec..b40a0c4 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
@@ -35,14 +35,13 @@
 import java.util.LinkedList;
 
 import org.apache.asterix.external.dataflow.AbstractFeedDataFlowController;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 
 public class FileSystemWatcher {
 
     private static Logger LOGGER = Logger.getLogger(FileSystemWatcher.class.getName());
-    private final WatchService watcher;
+    private WatchService watcher;
     private final HashMap<WatchKey, Path> keys;
     private final LinkedList<File> files = new LinkedList<File>();
     private Iterator<File> it;
@@ -55,7 +54,6 @@
     private AbstractFeedDataFlowController controller;
 
     public FileSystemWatcher(Path inputResource, String expression, boolean isFeed) throws
IOException {
-        this.watcher = isFeed ? FileSystems.getDefault().newWatchService() : null;
         this.keys = isFeed ? new HashMap<WatchKey, Path>() : null;
         this.expression = expression;
         this.path = inputResource;
@@ -66,12 +64,21 @@
         this.logManager = feedLogManager;
     }
 
-    public void init() throws IOException {
+    public synchronized void init() throws IOException {
         LinkedList<Path> dirs = null;
         dirs = new LinkedList<Path>();
         LocalFileSystemUtils.traverse(files, path.toFile(), expression, dirs);
         it = files.iterator();
         if (isFeed) {
+            keys.clear();
+            if (watcher != null) {
+                try {
+                    watcher.close();
+                } catch (IOException e) {
+                    LOGGER.warn("Failed to close watcher service", e);
+                }
+            }
+            watcher = FileSystems.getDefault().newWatchService();
             for (Path path : dirs) {
                 register(path);
             }
@@ -117,7 +124,7 @@
         return (WatchEvent<T>) event;
     }
 
-    private void handleEvents(WatchKey key) {
+    private void handleEvents(WatchKey key) throws IOException {
         // get dir associated with the key
         Path dir = keys.get(key);
         if (dir == null) {
@@ -135,6 +142,9 @@
                 if (LOGGER.isEnabledFor(Level.WARN)) {
                     LOGGER.warn("Overflow event. Some events might have been missed");
                 }
+                // need to read and validate all files.
+                //TODO: use btrees for all logs
+                init();
                 continue;
             }
 
@@ -164,6 +174,7 @@
         if (!done) {
             if (watcher != null) {
                 watcher.close();
+                watcher = null;
             }
             if (logManager != null) {
                 if (current != null) {
@@ -197,7 +208,7 @@
         return false;
     }
 
-    public boolean hasNext() throws HyracksDataException {
+    public boolean hasNext() throws IOException {
         if (it.hasNext()) {
             return true;
         }
@@ -214,6 +225,7 @@
         while (key != null) {
             handleEvents(key);
             if (endOfEvents(key)) {
+                close();
                 return false;
             }
             key = watcher.poll();
@@ -229,12 +241,18 @@
                 if (LOGGER.isEnabledFor(Level.WARN)) {
                     LOGGER.warn("Feed Closed");
                 }
-                return false;
+                if (watcher == null) {
+                    return false;
+                }
+                continue;
             } catch (ClosedWatchServiceException e) {
                 if (LOGGER.isEnabledFor(Level.WARN)) {
                     LOGGER.warn("The watcher has exited");
                 }
-                return false;
+                if (watcher == null) {
+                    return false;
+                }
+                continue;
             }
             handleEvents(key);
             if (endOfEvents(key)) {
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
b/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
index 2882083..44a8101 100644
--- a/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
@@ -847,8 +847,9 @@
 
     private boolean parseExpression(ExprTreeHolder tree, boolean full) throws IOException
{
         TokenType tt;
-        if (!parseLogicalORExpression(tree))
+        if (!parseLogicalORExpression(tree)) {
             return false;
+        }
         if ((tt = lexer.peekToken()) == TokenType.LEX_QMARK) {
             lexer.consumeToken();
             ExprTreeHolder treeL = tree;
@@ -880,8 +881,9 @@
     // | LogicalORExpression '||' LogicalANDExpression
 
     private boolean parseLogicalORExpression(ExprTreeHolder tree) throws IOException {
-        if (!parseLogicalANDExpression(tree))
+        if (!parseLogicalANDExpression(tree)) {
             return false;
+        }
         while ((lexer.peekToken()) == TokenType.LEX_LOGICAL_OR) {
             ExprTreeHolder treeL = tree;
             ExprTreeHolder treeR = mutableExprPool.get();
@@ -902,8 +904,9 @@
     // LogicalANDExpression .= InclusiveORExpression
     // | LogicalANDExpression '&&' InclusiveORExpression
     private boolean parseLogicalANDExpression(ExprTreeHolder tree) throws IOException {
-        if (!parseInclusiveORExpression(tree))
+        if (!parseInclusiveORExpression(tree)) {
             return false;
+        }
         while ((lexer.peekToken()) == TokenType.LEX_LOGICAL_AND) {
             ExprTreeHolder treeL = tree;
             ExprTreeHolder treeR = mutableExprPool.get();
@@ -924,8 +927,9 @@
     // InclusiveORExpression .= ExclusiveORExpression
     // | InclusiveORExpression '|' ExclusiveORExpression
     public boolean parseInclusiveORExpression(ExprTreeHolder tree) throws IOException {
-        if (!parseExclusiveORExpression(tree))
+        if (!parseExclusiveORExpression(tree)) {
             return false;
+        }
         while ((lexer.peekToken()) == TokenType.LEX_BITWISE_OR) {
             ExprTreeHolder treeL = tree;
             ExprTreeHolder treeR = mutableExprPool.get();
@@ -946,8 +950,9 @@
     // ExclusiveORExpression .= ANDExpression
     // | ExclusiveORExpression '^' ANDExpression
     private boolean parseExclusiveORExpression(ExprTreeHolder tree) throws IOException {
-        if (!parseANDExpression(tree))
+        if (!parseANDExpression(tree)) {
             return false;
+        }
         while ((lexer.peekToken()) == TokenType.LEX_BITWISE_XOR) {
             lexer.consumeToken();
             ExprTreeHolder treeL = tree;
@@ -968,8 +973,9 @@
     // ANDExpression .= EqualityExpression
     // | ANDExpression '&' EqualityExpression
     private boolean parseANDExpression(ExprTreeHolder tree) throws IOException {
-        if (!parseEqualityExpression(tree))
+        if (!parseEqualityExpression(tree)) {
             return false;
+        }
         while ((lexer.peekToken()) == TokenType.LEX_BITWISE_AND) {
             ExprTreeHolder treeL = tree;
             ExprTreeHolder treeR = mutableExprPool.get();
@@ -995,8 +1001,9 @@
     private boolean parseEqualityExpression(ExprTreeHolder tree) throws IOException {
         TokenType tt;
         int op = Operation.OpKind_NO_OP;
-        if (!parseRelationalExpression(tree))
+        if (!parseRelationalExpression(tree)) {
             return false;
+        }
         tt = lexer.peekToken();
         while (tt == TokenType.LEX_EQUAL || tt == TokenType.LEX_NOT_EQUAL || tt == TokenType.LEX_META_EQUAL
                 || tt == TokenType.LEX_META_NOT_EQUAL) {
@@ -1040,8 +1047,9 @@
     // | RelationalExpression '>=' ShiftExpression
     private boolean parseRelationalExpression(ExprTreeHolder tree) throws IOException {
         TokenType tt;
-        if (!parseShiftExpression(tree))
+        if (!parseShiftExpression(tree)) {
             return false;
+        }
         tt = lexer.peekToken();
         while (tt == TokenType.LEX_LESS_THAN || tt == TokenType.LEX_GREATER_THAN || tt ==
TokenType.LEX_LESS_OR_EQUAL
                 || tt == TokenType.LEX_GREATER_OR_EQUAL) {
@@ -1084,8 +1092,9 @@
     // | ShiftExpression '>>' AdditiveExpression
     // | ShiftExpression '>>>' AditiveExpression
     private boolean parseShiftExpression(ExprTreeHolder tree) throws IOException {
-        if (!parseAdditiveExpression(tree))
+        if (!parseAdditiveExpression(tree)) {
             return false;
+        }
 
         TokenType tt = lexer.peekToken();
         while (tt == TokenType.LEX_LEFT_SHIFT || tt == TokenType.LEX_RIGHT_SHIFT || tt ==
TokenType.LEX_URIGHT_SHIFT) {
@@ -1126,8 +1135,9 @@
     // | AdditiveExpression '+' MultiplicativeExpression
     // | AdditiveExpression '-' MultiplicativeExpression
     private boolean parseAdditiveExpression(ExprTreeHolder tree) throws IOException {
-        if (!parseMultiplicativeExpression(tree))
+        if (!parseMultiplicativeExpression(tree)) {
             return false;
+        }
 
         TokenType tt = lexer.peekToken();
         while (tt == TokenType.LEX_PLUS || tt == TokenType.LEX_MINUS) {
@@ -1155,8 +1165,9 @@
     // | MultiplicativeExpression '/' UnaryExpression
     // | MultiplicativeExpression '%' UnaryExpression
     private boolean parseMultiplicativeExpression(ExprTreeHolder tree) throws IOException
{
-        if (!parseUnaryExpression(tree))
+        if (!parseUnaryExpression(tree)) {
             return false;
+        }
 
         TokenType tt = lexer.peekToken();
         while (tt == TokenType.LEX_MULTIPLY || tt == TokenType.LEX_DIVIDE || tt == TokenType.LEX_MODULUS)
{
@@ -1238,8 +1249,9 @@
     // | PostfixExpression '[' Expression ']'
     private boolean parsePostfixExpression(ExprTreeHolder tree) throws IOException {
         TokenType tt;
-        if (!parsePrimaryExpression(tree))
+        if (!parsePrimaryExpression(tree)) {
             return false;
+        }
         while ((tt = lexer.peekToken()) == TokenType.LEX_OPEN_BOX || tt == TokenType.LEX_SELECTION)
{
             ExprTreeHolder treeL = tree;
             ExprTreeHolder treeR = mutableExprPool.get();
@@ -1460,9 +1472,9 @@
             // the next token must be a ',' or a ')'
             // or it can be a ';' if using old ClassAd semantics
             tt = lexer.peekToken();
-            if (tt == TokenType.LEX_COMMA || (tt == TokenType.LEX_SEMICOLON && false))
+            if (tt == TokenType.LEX_COMMA || (tt == TokenType.LEX_SEMICOLON && false))
{
                 lexer.consumeToken();
-            else if (tt != TokenType.LEX_CLOSE_PAREN) {
+            } else if (tt != TokenType.LEX_CLOSE_PAREN) {
                 argList.clear();
                 throw new HyracksDataException(
                         "expected LEX_COMMA or LEX_CLOSE_PAREN but got " + String.valueOf(Lexer.strLexToken(tt)));
@@ -1488,8 +1500,9 @@
     public boolean parseClassAd(ClassAd ad, boolean full) throws IOException {
         TokenType tt;
         ad.clear();
-        if ((tt = lexer.consumeToken()) != TokenType.LEX_OPEN_BOX)
+        if ((tt = lexer.consumeToken()) != TokenType.LEX_OPEN_BOX) {
             return false;
+        }
         tt = lexer.peekToken();
         TokenValue tv = tokenValuePool.get();
         ExprTreeHolder tree = mutableExprPool.get();
@@ -1587,9 +1600,9 @@
 
             // the next token must be a ',' or a '}'
             tt = lexer.peekToken();
-            if (tt == TokenType.LEX_COMMA)
+            if (tt == TokenType.LEX_COMMA) {
                 lexer.consumeToken();
-            else if (tt != TokenType.LEX_CLOSE_BRACE) {
+            } else if (tt != TokenType.LEX_CLOSE_BRACE) {
                 throw new HyracksDataException("while parsing expression list:  expected
"
                         + "LEX_CLOSE_BRACE or LEX_COMMA but got " + Lexer.strLexToken(tt));
             }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I08d89229e33c91532b1038ba9f7a372f7ca1fdb5
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: abdullah alamoudi <bamousaa@gmail.com>

Mime
View raw message