@Test public void testSuffixes() { assertEquals(new Path("2a/t-0003/C0004.rf"), FileRef.extractSuffix(new Path("hdfs: assertEquals(new Path("2a/t-0003/C0004.rf"), FileRef.extractSuffix(new Path("hdfs: assertEquals(new Path("2a/t-0003"), FileRef.extractSuffix(new Path("hdfs: assertEquals(new Path("2a/t-0003"), FileRef.extractSuffix(new Path("hdfs: testBadTableSuffix("t-0003/C0004.rf"); testBadTableSuffix("../t-0003/C0004.rf"); testBadTableSuffix("2a/t-0003"); testBadTableSuffix("2a/t-0003/C0004.rf"); testBadTableSuffix("2a/t-0003/C0004.rf"); testBadTableSuffix("hdfs: testBadTableSuffix("hdfs: testBadTableSuffix("hdfs: }
static Path extractSuffix(Path path) { String pstr = path.toString(); int index = pstr.lastIndexOf(FileType.TABLE.getDirectory()); if (index < 0) throw new IllegalArgumentException("Invalid table path " + pstr); try { Path parent = path.getParent().getParent(); if (!parent.getName().equals(FileType.TABLE.getDirectory()) && !parent.getParent().getName().equals(FileType.TABLE.getDirectory())) throw new IllegalArgumentException("Invalid table path " + pstr); } catch (NullPointerException npe) { throw new IllegalArgumentException("Invalid table path " + pstr); } return new Path(pstr.substring(index + FileType.TABLE.getDirectory().length() + 1)); }
FileRef implements Ample.FileMeta, Comparable<FileRef> { static Path extractSuffix(Path path) { String pstr = path.toString(); int index = pstr.lastIndexOf(FileType.TABLE.getDirectory()); if (index < 0) throw new IllegalArgumentException("Invalid table path " + pstr); try { Path parent = path.getParent().getParent(); if (!parent.getName().equals(FileType.TABLE.getDirectory()) && !parent.getParent().getName().equals(FileType.TABLE.getDirectory())) throw new IllegalArgumentException("Invalid table path " + pstr); } catch (NullPointerException npe) { throw new IllegalArgumentException("Invalid table path " + pstr); } return new Path(pstr.substring(index + FileType.TABLE.getDirectory().length() + 1)); } }
FileRef implements Ample.FileMeta, Comparable<FileRef> { static Path extractSuffix(Path path) { String pstr = path.toString(); int index = pstr.lastIndexOf(FileType.TABLE.getDirectory()); if (index < 0) throw new IllegalArgumentException("Invalid table path " + pstr); try { Path parent = path.getParent().getParent(); if (!parent.getName().equals(FileType.TABLE.getDirectory()) && !parent.getParent().getName().equals(FileType.TABLE.getDirectory())) throw new IllegalArgumentException("Invalid table path " + pstr); } catch (NullPointerException npe) { throw new IllegalArgumentException("Invalid table path " + pstr); } return new Path(pstr.substring(index + FileType.TABLE.getDirectory().length() + 1)); } FileRef(String metaReference, Path fullReference);  FileRef(String path); }
FileRef implements Ample.FileMeta, Comparable<FileRef> { static Path extractSuffix(Path path) { String pstr = path.toString(); int index = pstr.lastIndexOf(FileType.TABLE.getDirectory()); if (index < 0) throw new IllegalArgumentException("Invalid table path " + pstr); try { Path parent = path.getParent().getParent(); if (!parent.getName().equals(FileType.TABLE.getDirectory()) && !parent.getParent().getName().equals(FileType.TABLE.getDirectory())) throw new IllegalArgumentException("Invalid table path " + pstr); } catch (NullPointerException npe) { throw new IllegalArgumentException("Invalid table path " + pstr); } return new Path(pstr.substring(index + FileType.TABLE.getDirectory().length() + 1)); } FileRef(String metaReference, Path fullReference);  FileRef(String path); @Override String toString(); @Override Path path(); @Override Text meta(); @Override int compareTo(FileRef o); @Override int hashCode(); @Override boolean equals(Object obj); }
FileRef implements Ample.FileMeta, Comparable<FileRef> { static Path extractSuffix(Path path) { String pstr = path.toString(); int index = pstr.lastIndexOf(FileType.TABLE.getDirectory()); if (index < 0) throw new IllegalArgumentException("Invalid table path " + pstr); try { Path parent = path.getParent().getParent(); if (!parent.getName().equals(FileType.TABLE.getDirectory()) && !parent.getParent().getName().equals(FileType.TABLE.getDirectory())) throw new IllegalArgumentException("Invalid table path " + pstr); } catch (NullPointerException npe) { throw new IllegalArgumentException("Invalid table path " + pstr); } return new Path(pstr.substring(index + FileType.TABLE.getDirectory().length() + 1)); } FileRef(String metaReference, Path fullReference);  FileRef(String path); @Override String toString(); @Override Path path(); @Override Text meta(); @Override int compareTo(FileRef o); @Override int hashCode(); @Override boolean equals(Object obj);  }