-
public interface ShardingKey
Interface used to indicate that this object represents a sharding key. AShardingKey
instance is only guaranteed to be compatible with the data source instance that it was derived from. AShardingKey
is created usingShardingKey.Builder
.The following example illustrates the use of
ShardingKey.Builder
to create aShardingKey
:DataSource ds = new MyDataSource(); ShardingKey shardingKey = ds.createShardingKeyBuilder() .subkey("abc", JDBCType.VARCHAR) .subkey(94002, JDBCType.INTEGER) .build();
A
ShardingKey
is used for specifying aAdbaSessionProperty.SHARDING_KEY
or aAdbaSessionProperty.SHARDING_GROUP_KEY
. Databases that support composite sharding may use a * to specify a additional level of partitioning within to specify a additional level of partitioning within the shard.The following example illustrates the use of
ShardingKey.Builder
to create aAdbaSessionProperty.SHARDING_GROUP_KEY
for an eastern region with aAdbaSessionProperty.SHARDING_KEY
specified for the Pittsburgh branch office:DataSource ds = new MyDataSource(); ShardingKey superShardingKey = ds.shardingKeyBuilder() .subkey("EASTERN_REGION", AdbaType.VARCHAR) .build(); ShardingKey shardingKey = ds.shardingKeyBuilder() .subkey("PITTSBURGH_BRANCH", AdbaType.VARCHAR) .build(); Session con = ds.builder() .property(SHARDING_GROUP_KEY, superShardingKey) .property(SHARDING_KEY, shardingKey) .build();
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ShardingKey.Builder
A builder created from aDataSource
or object, used to create aShardingKey
with sub-keys of supported data types.
-