paul-rogers commented on a change in pull request #1618: DRILL-6950: Row 
set-based scan framework
URL: https://github.com/apache/drill/pull/1618#discussion_r251218793
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/scan/file/FileMetadata.java
 ##########
 @@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+package org.apache.drill.exec.physical.impl.scan.file;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.hadoop.fs.Path;
+
+/**
+ * Specify the file name and optional selection root. If the selection root
+ * is provided, then partitions are defined as the portion of the file name
+ * that is not also part of the selection root. That is, if selection root is
+ * /a/b and the file path is /a/b/c/d.csv, then dir0 is c.
+ */
+
+public class FileMetadata {
+
+  private final Path filePath;
+  private final String[] dirPath;
+
+  public FileMetadata(Path filePath, Path selectionRoot) {
+    this.filePath = filePath;
+
+    // If the data source is not a file, no file metadata is available.
+
+    if (selectionRoot == null || filePath == null) {
+      dirPath = null;
+      return;
+    }
+
+    // If the query is against a single file, selection root and file path
+    // will be identical, oddly.
+
+    Path rootPath = Path.getPathWithoutSchemeAndAuthority(selectionRoot);
+    Path bareFilePath = Path.getPathWithoutSchemeAndAuthority(filePath);
+    if (rootPath.equals(bareFilePath)) {
+      dirPath = null;
+      return;
+    }
+
+    // Result of splitting /x/y is ["", "x", "y"], so ignore first.
+
+    String[] r = rootPath.toString().split("/");
 
 Review comment:
   Looks like this was added 10 months ago; after I wrote the code here which 
was based on the earlier version. Using the new version passed the tests for 
this class, so went ahead and made the change. The code is now simpler.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to