keith-turner commented on a change in pull request #1471: Create TabletFile for 
use in TabletMetadata. Closes #1396
URL: https://github.com/apache/accumulo/pull/1471#discussion_r366538530
 
 

 ##########
 File path: 
core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletFile.java
 ##########
 @@ -0,0 +1,136 @@
+/*
+ * 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.accumulo.core.metadata.schema;
+
+import java.util.Objects;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.data.TableId;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.Text;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * Object representing a tablet file entry in the metadata table. Keeps a 
string of the exact entry
+ * of what is in the metadata table for the column qualifier of the
+ * {@link 
org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.DataFileColumnFamily}
+ * <p>
+ * As of 2.1, Tablet file paths should now be only absolute URIs with the 
removal of relative paths
+ * in Upgrader9to10.upgradeRelativePaths()
+ */
+public class TabletFile implements Comparable<TabletFile> {
+  // parts of an absolute URI, like 
"hdfs://1.2.3.4/accumulo/tables/2a/t-0003/C0004.rf"
+  private final String volume; // hdfs://1.2.3.4/accumulo
+  private final TableId tableId; // 2a
+  private final String tabletDir; // t-0003
+  private final String fileName; // C0004.rf
+  private final String metadataEntry;
+  private final Path metaPath;
+  private final String normalizedPath;
+
+  public TabletFile(String metadataEntry) {
+    this.metadataEntry = Objects.requireNonNull(metadataEntry);
+    String errorMsg = " is missing/invalid from tablet file metadata entry: " 
+ metadataEntry;
+
+    this.metaPath = new Path(metadataEntry);
+
+    // use Path object to step backwards from the filename through all the 
parts
+    this.fileName = metaPath.getName();
+    MetadataSchema.TabletsSection.ServerColumnFamily.validateDirCol(fileName);
+
+    Path tabletDirPath = Objects.requireNonNull(metaPath.getParent(), "Tablet 
dir" + errorMsg);
 
 Review comment:
   There is a lot of string concatenation (which causes object allocation) for 
error messages that will usually never be seen in this method.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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