diff options
Diffstat (limited to 'contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/MapRDBFormatMatcher.java')
-rw-r--r-- | contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/MapRDBFormatMatcher.java | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/MapRDBFormatMatcher.java b/contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/MapRDBFormatMatcher.java index 4a5d118ce..f16a2ce53 100644 --- a/contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/MapRDBFormatMatcher.java +++ b/contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/MapRDBFormatMatcher.java @@ -1,4 +1,4 @@ -/** +/* * 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 @@ -18,11 +18,21 @@ package org.apache.drill.exec.store.mapr.db; import java.io.IOException; +import java.util.List; +import com.mapr.fs.tables.TableProperties; +import org.apache.drill.exec.planner.logical.DrillTable; +import org.apache.drill.exec.planner.logical.DynamicDrillTable; +import org.apache.drill.exec.store.dfs.DrillFileSystem; +import org.apache.drill.exec.store.dfs.FileSelection; +import org.apache.drill.exec.store.dfs.FileSystemPlugin; +import org.apache.drill.exec.store.dfs.FormatSelection; import org.apache.drill.exec.store.mapr.TableFormatMatcher; import org.apache.drill.exec.store.mapr.TableFormatPlugin; import com.mapr.fs.MapRFileStatus; +import org.apache.drill.exec.store.mapr.db.binary.MapRDBBinaryTable; +import org.apache.hadoop.fs.Path; public class MapRDBFormatMatcher extends TableFormatMatcher { @@ -39,4 +49,26 @@ public class MapRDBFormatMatcher extends TableFormatMatcher { .getIsMarlinTable(); } + @Override + public DrillTable isReadable(DrillFileSystem fs, + FileSelection selection, FileSystemPlugin fsPlugin, + String storageEngineName, String userName) throws IOException { + + if (isFileReadable(fs, selection.getFirstPath(fs))) { + List<String> files = selection.getFiles(); + assert (files.size() == 1); + String tableName = files.get(0); + TableProperties props = getFormatPlugin().getMaprFS().getTableProperties(new Path(tableName)); + + if (props.getAttr().getJson()) { + return new DynamicDrillTable(fsPlugin, storageEngineName, userName, + new FormatSelection(getFormatPlugin().getConfig(), selection)); + } else { + FormatSelection formatSelection = new FormatSelection(getFormatPlugin().getConfig(), selection); + return new MapRDBBinaryTable(storageEngineName, fsPlugin, (MapRDBFormatPlugin) getFormatPlugin(), formatSelection); + } + } + return null; + } + } |