Class OracleShardingKeyImpl

java.lang.Object
oracle.jdbc.pool.OracleShardingKeyImpl
All Implemented Interfaces:
Comparable<OracleShardingKey>, ShardingKey, OracleShardingKey

public class OracleShardingKeyImpl extends Object implements OracleShardingKey
  • Constructor Details

  • 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

      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 interface Comparable<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 class Object
      Returns:
      Comma separated string format of the sub keys that are a part of this Sharding Key
      See Also:
    • 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 class Object
      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:
    • 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 class Object
      Returns:
      hashcode value for this sharding key
      See Also:
    • 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
    • sha256Hash

      public byte[] sha256Hash(ShardingMetadata metadata)
      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

      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_chunks
      metadata - 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 otherwise
      isKeyHigh - 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.