Package oracle.jdbc.pool
Class OracleShardingKeyImpl
- java.lang.Object
-
- oracle.jdbc.pool.OracleShardingKeyImpl
-
- All Implemented Interfaces:
Comparable<OracleShardingKey>
,ShardingKey
,OracleShardingKey
public class OracleShardingKeyImpl extends Object implements OracleShardingKey
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OracleShardingKeyImpl.Decoder
This class is used to decode the sharding keys that are stored in the DB tables using the standard Base 64 notation
-
Constructor Summary
Constructors Modifier Constructor Description protected
OracleShardingKeyImpl(OracleShardingKeyBuilderImpl builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(OracleShardingKey o)
Used to compare two OracleShardingKey keys.protected void
debug(Logger logger, Level level, Executable method, String msg)
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.String
encodeKeyinB64Format()
Encodes the sharding key as per the standard Base 64 format to be added into the connect string during connection creation.boolean
equals(Object otherObj)
Compares this ShardingKey with the specified Object for equalitylong
getShardingKeyOraHash()
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
isSuperShardingKey()
Checks if the 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 keylong
shardKeyOraHash(ShardingMetadata metadata)
Computes the hash value of the Sharding key as per Oracle's internal hash function.String
toString()
String
toString(Connection conn)
-
-
-
Constructor Detail
-
OracleShardingKeyImpl
protected OracleShardingKeyImpl(OracleShardingKeyBuilderImpl builder)
-
-
Method Detail
-
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 the key is a super sharding key- Returns:
- true if the key is a super sharding key
-
compareTo
public int compareTo(OracleShardingKey o)
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
public String toString()
- Overrides:
toString
in classObject
- Returns:
- Comma separated string format of the sub keys that are a part of this Sharding Key
- See Also:
Object.toString()
-
toString
public String toString(Connection conn) throws SQLException
- 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
public boolean equals(Object otherObj)
Compares this ShardingKey with the specified Object for equality- Overrides:
equals
in classObject
- Parameters:
otherObj
- Object to which this sharding key is to be compared.- Returns:
- true if and only if the specified Object is a OracleSharding key whose value is equal to this sharding key object.
- See Also:
Object.equals(java.lang.Object)
-
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.- Overrides:
hashCode
in classObject
- Returns:
- hashcode value for this sharding key
- See Also:
Object.hashCode()
-
encodeKeyinB64Format
public String encodeKeyinB64Format() throws SQLException
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
public long shardKeyOraHash(ShardingMetadata metadata)
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
-
isValid
public boolean isValid(ShardingMetadata metadata)
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.
-
debug
protected void debug(Logger logger, Level level, Executable method, String msg)
-
-