@Test public void testFormatTableInfoSequenceId() { Path p0 = assertWriteAndReadSequenceId(0); StringBuilder sb = new StringBuilder(); for (int i = 0; i < FSTableDescriptors.WIDTH_OF_SEQUENCE_ID; i++) { sb.append("0"); } assertEquals(FSTableDescriptors.TABLEINFO_FILE_PREFIX + "." + sb.toString(), p0.getName()); Path p2 = assertWriteAndReadSequenceId(2); Path p10000 = assertWriteAndReadSequenceId(10000); Path p = new Path(p0.getParent(), FSTableDescriptors.TABLEINFO_FILE_PREFIX); FileStatus fs = new FileStatus(0, false, 0, 0, 0, p); FileStatus fs0 = new FileStatus(0, false, 0, 0, 0, p0); FileStatus fs2 = new FileStatus(0, false, 0, 0, 0, p2); FileStatus fs10000 = new FileStatus(0, false, 0, 0, 0, p10000); Comparator<FileStatus> comparator = FSTableDescriptors.TABLEINFO_FILESTATUS_COMPARATOR; assertTrue(comparator.compare(fs, fs0) > 0); assertTrue(comparator.compare(fs0, fs2) > 0); assertTrue(comparator.compare(fs2, fs10000) > 0); }
private static String formatTableInfoSequenceId(final int number) { byte [] b = new byte[WIDTH_OF_SEQUENCE_ID]; int d = Math.abs(number); for (int i = b.length - 1; i >= 0; i--) { b[i] = (byte)((d % 10) + '0'); d /= 10; } return Bytes.toString(b); }
FSTableDescriptors implements TableDescriptors { private static String formatTableInfoSequenceId(final int number) { byte [] b = new byte[WIDTH_OF_SEQUENCE_ID]; int d = Math.abs(number); for (int i = b.length - 1; i >= 0; i--) { b[i] = (byte)((d % 10) + '0'); d /= 10; } return Bytes.toString(b); } }
FSTableDescriptors implements TableDescriptors { private static String formatTableInfoSequenceId(final int number) { byte [] b = new byte[WIDTH_OF_SEQUENCE_ID]; int d = Math.abs(number); for (int i = b.length - 1; i >= 0; i--) { b[i] = (byte)((d % 10) + '0'); d /= 10; } return Bytes.toString(b); } FSTableDescriptors(final Configuration conf);  FSTableDescriptors(final FileSystem fs, final Path rootdir);  FSTableDescriptors(final FileSystem fs,
      final Path rootdir, final boolean fsreadonly); }
FSTableDescriptors implements TableDescriptors { private static String formatTableInfoSequenceId(final int number) { byte [] b = new byte[WIDTH_OF_SEQUENCE_ID]; int d = Math.abs(number); for (int i = b.length - 1; i >= 0; i--) { b[i] = (byte)((d % 10) + '0'); d /= 10; } return Bytes.toString(b); } FSTableDescriptors(final Configuration conf);  FSTableDescriptors(final FileSystem fs, final Path rootdir);  FSTableDescriptors(final FileSystem fs,
      final Path rootdir, final boolean fsreadonly); @Override HTableDescriptor get(final TableName tablename); @Override Map<String, HTableDescriptor> getAll(); @Override Map<String, HTableDescriptor> getByNamespace(String name); @Override void add(HTableDescriptor htd); @Override HTableDescriptor remove(final TableName tablename); boolean isTableInfoExists(TableName tableName); static FileStatus getTableInfoPath(FileSystem fs, Path tableDir); static HTableDescriptor getTableDescriptorFromFs(FileSystem fs,
      Path hbaseRootDir, TableName tableName); static HTableDescriptor getTableDescriptorFromFs(FileSystem fs, Path tableDir); void deleteTableDescriptorIfExists(TableName tableName); boolean createTableDescriptor(HTableDescriptor htd); boolean createTableDescriptor(HTableDescriptor htd, boolean forceCreation); boolean createTableDescriptorForTableDirectory(Path tableDir,
      HTableDescriptor htd, boolean forceCreation); }
FSTableDescriptors implements TableDescriptors { private static String formatTableInfoSequenceId(final int number) { byte [] b = new byte[WIDTH_OF_SEQUENCE_ID]; int d = Math.abs(number); for (int i = b.length - 1; i >= 0; i--) { b[i] = (byte)((d % 10) + '0'); d /= 10; } return Bytes.toString(b); } FSTableDescriptors(final Configuration conf);  FSTableDescriptors(final FileSystem fs, final Path rootdir);  FSTableDescriptors(final FileSystem fs,
      final Path rootdir, final boolean fsreadonly); @Override HTableDescriptor get(final TableName tablename); @Override Map<String, HTableDescriptor> getAll(); @Override Map<String, HTableDescriptor> getByNamespace(String name); @Override void add(HTableDescriptor htd); @Override HTableDescriptor remove(final TableName tablename); boolean isTableInfoExists(TableName tableName); static FileStatus getTableInfoPath(FileSystem fs, Path tableDir); static HTableDescriptor getTableDescriptorFromFs(FileSystem fs,
      Path hbaseRootDir, TableName tableName); static HTableDescriptor getTableDescriptorFromFs(FileSystem fs, Path tableDir); void deleteTableDescriptorIfExists(TableName tableName); boolean createTableDescriptor(HTableDescriptor htd); boolean createTableDescriptor(HTableDescriptor htd, boolean forceCreation); boolean createTableDescriptorForTableDirectory(Path tableDir,
      HTableDescriptor htd, boolean forceCreation);  }