Package oracle.jdbc.pool
Class OracleShardingKeyImpl
java.lang.Object
oracle.jdbc.pool.OracleShardingKeyImpl
- All Implemented Interfaces:
Comparable<OracleShardingKey>
,ShardingKey
,OracleShardingKey
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This class is used to decode the sharding keys that are stored in the DB tables using the standard Base 64 notation -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
-
Method Summary
Modifier and TypeMethodDescriptionint
Used to compare two OracleShardingKey keys.static List<OracleShardingKeyImpl>
decodeKeys
(InputStream keysData, ShardingMetadata metadata, boolean isSuperKey, boolean isKeyHigh) Builds a list of sharding keys from the key data available as input stream from the database sharding metadata table LOCAL_CHUNKS.Encodes the sharding key as per the standard Base 64 format to be added into the connect string during connection creation.boolean
Compares this ShardingKey with the specified Object for equalitylong
Returns the hash value of the Sharding key as per Oracle's internal hash function.int
hashCode()
Returns the hashcode for this sharding key object.boolean
Checks if the key is a super sharding keyboolean
isValid
(ShardingMetadata metadata) Checks if this sharding key is valid for the sharded database represented by the metadatavoid
markSuperShardingKey
(boolean isSuperShardingKey) Marks the key to be used as a super sharding keybyte[]
sha256Hash
(ShardingMetadata metadata) Computes the SHA-256 hash value of the Sharding key.long
shardKeyOraHash
(ShardingMetadata metadata) Computes the hash value of the Sharding key as per Oracle's internal hash function.toString()
toString
(Connection conn)
-
Constructor Details
-
OracleShardingKeyImpl
-
-
Method Details
-
markSuperShardingKey
public void markSuperShardingKey(boolean isSuperShardingKey) Marks the key to be used as a super sharding key- Parameters:
isSuperShardingKey
- if the key is to be used as a super sharding key
-
isSuperShardingKey
public boolean isSuperShardingKey()Checks if the key is a super sharding key- Returns:
- true if the key is a super sharding key
-
compareTo
Used to compare two OracleShardingKey keys. If the sharding keys are compound the corresponding sub-keys in two keys are compared.- Specified by:
compareTo
in interfaceComparable<OracleShardingKey>
- Parameters:
o
- ShardingKey to which this sharding key is to be compared.- Returns:
- -1, 0 or 1 as this ShardingKey is less than, equal to, or greater than the sharding key that is passed in as a method parameter
-
toString
-
toString
- Parameters:
conn
- to be used to get the string value if there is a subkey of type oracle.sql.TIMESTAMPLTZ- Returns:
- Comma separated string format of the sub keys that are a part of this Sharding Key
- Throws:
SQLException
-
equals
Compares this ShardingKey with the specified Object for equality -
hashCode
public int hashCode()Returns the hashcode for this sharding key object. For compound keys the hash code is computed considering hash codes of each of its sub key. -
encodeKeyinB64Format
Encodes the sharding key as per the standard Base 64 format to be added into the connect string during connection creation.- Parameters:
metadata
- Metadata of the sharded database which needs to be accessed. needed- Returns:
- Base 64 encoded sharding key
- Throws:
SQLException
-
shardKeyOraHash
Computes the hash value of the Sharding key as per Oracle's internal hash function.- Parameters:
metadata
- sharded database metadata- Returns:
- the hash value of the Sharding key
-
getShardingKeyOraHash
public long getShardingKeyOraHash()Returns the hash value of the Sharding key as per Oracle's internal hash function.- Returns:
- sharding key ora-hash value
-
sha256Hash
Computes the SHA-256 hash value of the Sharding key.- Parameters:
metadata
- sharded database metadata- Returns:
- the SHA-256 hash value of the Sharding key
-
isValid
Checks if this sharding key is valid for the sharded database represented by the metadata- Parameters:
metadata
- Sharded database metadata to be used during the validation of this key- Returns:
- true if the key is valid and conforms to the metadata
-
decodeKeys
public static List<OracleShardingKeyImpl> decodeKeys(InputStream keysData, ShardingMetadata metadata, boolean isSuperKey, boolean isKeyHigh) throws SQLException Builds a list of sharding keys from the key data available as input stream from the database sharding metadata table LOCAL_CHUNKS.- Parameters:
keysData
- Input stream containing the byte value of key or list of keys stored in the database table local_chunksmetadata
- Contains the sharding metadata information that is used to build the keys.isSuperKey
- true if the keys to be constructed are super sharding keys,false otherwiseisKeyHigh
- true if the sharding keys to be constructed indicate the higher boundary if the sharding type is RANGE based- Returns:
- List of sharding keys built.
- Throws:
SQLException
- if there is an exception while building the keys.
-