drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [06/27] git commit: DRILL-1086: invalidate PStore to drop a view in case it is not in the underlying fs
Date Sun, 27 Jul 2014 18:46:52 GMT
DRILL-1086: invalidate PStore to drop a view in case it is not in the underlying fs


Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/9ed654bf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/9ed654bf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/9ed654bf

Branch: refs/heads/master
Commit: 9ed654bffba9934f2d480ff5206581a29b3ef80c
Parents: 6e24423
Author: Hanifi Gunes <hgunes@maprtech.com>
Authored: Mon Jul 21 11:46:49 2014 -0700
Committer: Aditya Kishore <aditya@maprtech.com>
Committed: Thu Jul 24 16:16:02 2014 -0700

----------------------------------------------------------------------
 .../exec/store/dfs/WorkspaceSchemaFactory.java  | 27 +++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/9ed654bf/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/WorkspaceSchemaFactory.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/WorkspaceSchemaFactory.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/WorkspaceSchemaFactory.java
index 54781b4..4b42660 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/WorkspaceSchemaFactory.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/WorkspaceSchemaFactory.java
@@ -193,16 +193,37 @@ public class WorkspaceSchemaFactory implements ExpandingConcurrentMap.MapValueFa
       this.session = session;
     }
 
-    private Set<String> getViews(){
+    private Set<String> getViews() {
       Set<String> viewSet = Sets.newHashSet();
       if(knownViews != null) {
-        for(Map.Entry<String, String> e : knownViews){
-          viewSet.add(e.getKey());
+        String viewName;
+        for(Map.Entry<String, String> e : knownViews) {
+          viewName = e.getKey();
+          if (hasView(viewName)) {
+            viewSet.add(viewName);
+          } else if (knownViews != null) {
+            knownViews.delete(viewName);
+          }
         }
       }
       return viewSet;
     }
 
+    /**
+     * Checks whether underlying filesystem has the view.
+     * @param viewName view name
+     * @return true if storage has the view, false otherwise.
+     */
+    public boolean hasView(String viewName) {
+      List<DotDrillFile> files = null;
+      try {
+        files = DotDrillUtil.getDotDrills(fs, new Path(config.getLocation()), viewName, DotDrillType.VIEW);
+      } catch (Exception e) {
+        logger.warn("Failure while trying to check view[{}].", viewName,  e);
+      }
+      return files!=null && files.size()>0;
+    }
+
     @Override
     public Set<String> getTableNames() {
       return Sets.union(tables.keySet(), getViews());


Mime
View raw message