Get database sharding values.

@param logicTable logic table
@return database sharding values
357493
public static Collection<Comparable<?>> getDatabaseShardingValues(final String logicTable) {
        return null == HINT_MANAGER_HOLDER.get() ? Collections.<Comparable<?>>emptyList() : HINT_MANAGER_HOLDER.get().databaseShardingValues.get(logicTable);
    }
891409
public String getTableName() {

        recordLog("----" + ThreadContext.getShardKey() + "\t" +
                getTableName(orMapping.getTable(), (Number) ThreadContext.getShardKey()));
        Number shardKey = ThreadContext.getShardKey();
        return getTableName(orMapping.getTable(), shardKey);
    }
948243
@Override
  public OperationHandle getColumns(SessionHandle sessionHandle, String catalogName,
      String schemaName, String tableName, String columnName) throws HiveSQLException {
    return cliService.getColumns(sessionHandle, catalogName, schemaName, tableName, columnName);
  }
300377
@SuppressWarnings("unchecked")
    public static <T> Set<T> getTableValue(final Table table) {
        final Object value = table.getValue();
        Set<T> idsReturn;
        if (value == null) {
            idsReturn = Collections.emptySet();
        } else if (value instanceof Collection) {
            final Collection<T> ids = (Collection<T>) value;
            idsReturn = ids.stream().filter(Objects::nonNull).collect(Collectors.toSet());
        } else {
            final T id = (T) value;
            idsReturn = Collections.singleton(id);
        }
        return idsReturn;
    }
744156
public Collection<String> getDataSourceNames(final String shardingSchemaName) {
        return schemaGroup.containsKey(shardingSchemaName) ? schemaGroup.get(shardingSchemaName) : Collections.<String>emptyList();
    }
673785
public Map<String, Set<String>> getDataSourceLogicTablesMap(final Collection<String> dataSourceNames) {
        Map<String, Set<String>> result = new HashMap<>();
        for (String each : dataSourceNames) {
            Set<String> logicTableNames = getLogicTableNames(each);
            if (!logicTableNames.isEmpty()) {
                result.put(each, logicTableNames);
            }
        }
        return result;
    }
329799
@SneakyThrows
    public TableMetaData load(final String logicTableName, final ShardingRule shardingRule) {
        return tableMetaDataLoader.load(logicTableName, shardingRule);
    }
1295752
@SneakyThrows
    public Optional<ShardingEncryptor> getShardingEncryptor(final int columnIndex) {
        return shardingEncryptorEngine.getShardingEncryptor(getTableName(columnIndex), resultSetMetaData.getColumnName(columnIndex));
    }
1362398
public java.util.List<String> getLogicalResourceIds() {
        if (logicalResourceIds == null) {
            logicalResourceIds = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return logicalResourceIds;
    }
1156441
public String toSQL(final MasterSlaveRule masterSlaveRule, final ShardingDataSourceMetaData shardingDataSourceMetaData) {
        StringBuilder result = new StringBuilder();
        for (Object each : segments) {
            if (each instanceof SchemaPlaceholder) {
                result.append(shardingDataSourceMetaData.getActualDataSourceMetaData(masterSlaveRule.getMasterDataSourceName()).getSchemaName());
            } else {
                result.append(each);
            }
        }
        return result.toString();
    }
1240692
public TableMetaData load(final String logicTableName, final ShardingRule shardingRule) throws SQLException {
        List<TableMetaData> actualTableMetaDataList = load(getDataNodeGroups(logicTableName, shardingRule), shardingRule.getShardingDataSourceNames());
        checkUniformed(logicTableName, actualTableMetaDataList);
        return actualTableMetaDataList.iterator().next();
    }
40715
public String getBindingActualTable(final String dataSource, final String logicTable, final String otherActualTable) {
        int index = -1;
        for (TableRule each : tableRules) {
            index = each.findActualTableIndex(dataSource, otherActualTable);
            if (-1 != index) {
                break;
            }
        }
        if (-1 == index) {
            throw new ShardingConfigurationException("Actual table [%s].[%s] is not in table config", dataSource, otherActualTable);
        }
        for (TableRule each : tableRules) {
            if (each.getLogicTable().equals(logicTable.toLowerCase())) {
                return each.getActualDataNodes().get(index).getTableName().toLowerCase();
            }
        }
        throw new ShardingConfigurationException("Cannot find binding actual table, data source: %s, logic table: %s, other actual table: %s", dataSource, logicTable, otherActualTable);
    }
1262025
private boolean objectIsChangingShards(DBObject dbObj, Map<String, String> currScalarMap) {
        if (!m_tableDef.isSharded()) {
            return false;
        }
        
        // If object had no prior sharding-field value, it is considered in shard 0.
        int oldShardNumber = 0;
        String shardingFieldName = m_tableDef.getShardingField().getName();
        String currShardFieldValue = currScalarMap.get(shardingFieldName);
        if (currShardFieldValue != null) {
            oldShardNumber = m_tableDef.computeShardNumber(Utils.dateFromString(currShardFieldValue));
        }
        
        // Propagate old sharding-field value if not being updated now.
        int newShardNumber = m_tableDef.getShardNumber(dbObj);
        String newShardFieldValue = dbObj.getFieldValue(shardingFieldName);
        if (newShardFieldValue == null && currShardFieldValue != null) {
            dbObj.addFieldValue(shardingFieldName, currShardFieldValue);
            return false;
        }
        
        // May or may not be moving to a new shard.
        return oldShardNumber != newShardNumber;
    }
1215419
public static HiveTable getHiveTable(Table table) {
    State tableProps = getTableProps(table);
    State storageProps = getStorageProps(table.getSd());
    State serDeProps = getSerDeProps(table.getSd().getSerdeInfo());
    HiveTable hiveTable = new HiveTable.Builder().withDbName(table.getDbName()).withTableName(table.getTableName())
        .withPartitionKeys(getColumns(table.getPartitionKeys())).withProps(tableProps).withStorageProps(storageProps)
        .withSerdeProps(serDeProps).build();
    if (table.getCreateTime() > 0) {
      hiveTable.setCreateTime(table.getCreateTime());
    }
    if (table.getSd().getCols() != null) {
      hiveTable.setColumns(getColumns(table.getSd().getCols()));
    }
    if (table.getSd().getBucketCols() != null) {
      hiveTable.setBucketColumns(table.getSd().getBucketCols());
    }
    return hiveTable;
  }
600849
private Set<String> getShardedLinkValues(String objID, FieldDefinition linkDef, Set<Integer> shardNums) {
        Set<String> values = new HashSet<String>();
        if (shardNums.size() == 0) {
            return values;
        }
        
        // Construct row keys for the link's possible Terms records.
        Set<String> termRowKeys = new HashSet<String>();
        for (Integer shardNumber : shardNums) {
            termRowKeys.add(shardedLinkTermRowKey(linkDef, objID, shardNumber));
        }
        TableDefinition tableDef = linkDef.getTableDef();
        String termStore = termsStoreName(tableDef);
        Tenant tenant = Tenant.getTenant(tableDef);
        for(DRow row: DBService.instance(tenant).getRows(termStore, termRowKeys)) {
            for(DColumn column: row.getAllColumns(1024)) {
                values.add(column.getName());
            }
        }
        return values;
    }
317530
public AqlQueryOptions shardIds(final String... shardIds) {
		getOptions().getShardIds().addAll(Arrays.asList(shardIds));
		return this;
	}
1218132
public void addTableShardingValue(final String logicTable, final Comparable<?> value) {
        tableShardingValues.put(logicTable, value);
        databaseShardingOnly = false;
    }