Class OracleShardingKeyImpl

    • 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
    • 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.
      static java.util.List<OracleShardingKeyImpl> decodeKeys​(java.io.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.
      java.lang.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​(java.lang.Object otherObj)
      Compares this ShardingKey with the specified Object for equality
      long 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 key is a super sharding key
      boolean isValid​(ShardingMetadata metadata)
      Checks if this sharding key is valid for the sharded database represented by the metadata
      void markSuperShardingKey​(boolean isSuperShardingKey)
      Marks the key to be used as a super sharding key
      byte[] 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.
      java.lang.String toString()  
      java.lang.String toString​(java.sql.Connection conn)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • 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 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 java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        Comma separated string format of the sub keys that are a part of this Sharding Key
        See Also:
        Object.toString()
      • toString

        public java.lang.String toString​(java.sql.Connection conn)
                                  throws java.sql.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:
        java.sql.SQLException
      • equals

        public boolean equals​(java.lang.Object otherObj)
        Compares this ShardingKey with the specified Object for equality
        Overrides:
        equals in class java.lang.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:
        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 class java.lang.Object
        Returns:
        hashcode value for this sharding key
        See Also:
        Object.hashCode()
      • encodeKeyinB64Format

        public java.lang.String encodeKeyinB64Format()
                                              throws java.sql.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:
        java.sql.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 java.util.List<OracleShardingKeyImpl> decodeKeys​(java.io.InputStream keysData,
                                                                       ShardingMetadata metadata,
                                                                       boolean isSuperKey,
                                                                       boolean isKeyHigh)
                                                                throws java.sql.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:
        java.sql.SQLException - if there is an exception while building the keys.