Table extends LazyLoad { static String calculateMaxLabel(List<String> labels) { int maxLevel = 0; char category = '-'; for (String label : labels) { if (!StringUtils.isNullOrEmpty(label)) { char num = label.charAt(label.length() - 1); if (Character.isDigit(num) && num - '0' >= maxLevel) { if (num - '0' > maxLevel) { maxLevel = num - '0'; category = '-'; } if (label.length() == 1) { category = 'L'; continue; } for (int i = label.length() - 2; i >= 0; i--) { char c = label.charAt(i); if (Character.isLetter(c)) { c = Character.toUpperCase(c); if (category == '-') { category = c; } else if (category != c) { category = 'L'; } } } } } } if (category == '-' && maxLevel == 0) { return ""; } if (category == '-') { category = 'L'; } return category + "" + maxLevel; } Table(TableModel model, String project, Odps odps); @Override void reload(); void reload(TableModel model); String getName(); String getComment(); String getOwner(); Date getCreatedTime(); String getTableLabel(); List<String> getTableExtendedLabels(); String getTableID(); String getCryptoAlgoName(); String getMaxExtendedLabel(); String getMaxLabel(); Date getLastMetaModifiedTime(); String getProject(); boolean isVirtualView(); boolean isExternalTable(); String getViewText(); Date getLastDataModifiedTime(); long getSize(); long getRecordNum(); long getLife(); long getHubLifecycle(); TableSchema getSchema(); String getJsonSchema(); boolean isArchived(); boolean isTransactional(); long getPhysicalSize(); long getFileNum(); String getLocation(); String getStorageHandler(); String getResources(); Map<String, String> getSerDeProperties(); String getReserved(); ClusterInfo getClusterInfo(); Shard getShard(); RecordReader read(int limit); RecordReader read(PartitionSpec partition, List<String> columns, int limit); RecordReader read(PartitionSpec partition, List<String> columns, int limit, String timezone); static ClusterInfo parseClusterInfo(JsonObject jsonObject); void createPartition(PartitionSpec spec); void createPartition(PartitionSpec spec, boolean ifNotExists); void deletePartition(PartitionSpec spec); void deletePartition(PartitionSpec spec, boolean ifExists); List<PartitionSpec> getPartitionSpecs(); void createShards(long shardCount); Iterator<Partition> getPartitionIterator(); Iterator<Partition> getPartitionIterator(final PartitionSpec spec); List<Partition> getPartitions(); List<Partition> getPartitions(final PartitionSpec lowerBound,
                                       final PartitionSpec upperBound); Partition getPartition(PartitionSpec spec); boolean hasPartition(PartitionSpec spec); void truncate(); boolean isPartitioned();  }
@Test public void testMaxLabel() { assertEquals("", Table.calculateMaxLabel(Arrays.asList(new String[]{}))); assertEquals("", Table.calculateMaxLabel(Arrays.asList(new String[]{null, null, null}))); assertEquals("B2", Table.calculateMaxLabel(Arrays.asList(new String[]{"B2", ""}))); assertEquals("L2", Table.calculateMaxLabel(Arrays.asList(new String[]{"B2", "2"}))); assertEquals("B2", Table.calculateMaxLabel(Arrays.asList(new String[]{"B2", "B1"}))); assertEquals("C3", Table.calculateMaxLabel(Arrays.asList(new String[]{"B2", "C3"}))); assertEquals("B2", Table.calculateMaxLabel(Arrays.asList(new String[]{"B2", "B1"}))); assertEquals("C4", Table.calculateMaxLabel(Arrays.asList(new String[]{"C4", "S2"}))); assertEquals("L4", Table.calculateMaxLabel(Arrays.asList(new String[]{"C4", "B4", "S2"}))); }