VHash
-
java.lang.Object
-
com.vertica.jdbc.kv.VHash
-
Deprecated. This feature is likely to stop working in a future release and to be removed as a result.
@Deprecated
public class VHash
extends java.lang.Object
Implementation of Vertica's hash function used for data segmentation on the cluster. For single-value hashing, use static methods. For multi-value hashing, instantiate the class and call the add methods to add each value (order matters).
Constructor Summary
| Constructor and Description |
|---|
| VHash() Deprecated. Creates an instance suitable for computing a hash of a chain of values, for use when a projection is segmented by multiple columns. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
| void | addBoolean(boolean v) Deprecated. adds hash of boolean value to the chain. |
| void | addBooleanNull() Deprecated. adds hash of boolean null value to the chain. |
| void | addBytes(byte[] v) Deprecated. adds hash of binary value to the chain. |
| void | addDate(java.util.Date v, java.util.Calendar c) Deprecated. adds hash of Date value to the chain. |
| void | addDate(java.sql.Date v, java.util.Calendar c) Deprecated. adds hash of Date value to the chain. |
| void | addDouble(double v) Deprecated. adds hash of double value to the chain. |
| void | addDoubleNull() Deprecated. adds hash of double null value to the chain. |
| void | addLong(long v) Deprecated. adds hash of long value to the chain. |
| void | addNull() Deprecated. Adds hash of null value to the chain. |
| void | addNumeric(java.math.BigDecimal src, int typemod) Deprecated. adds hash of numeric value to the chain |
| void | addString(java.lang.String v) Deprecated. adds hash of String value to the chain. |
| void | addTime(java.util.Date v, java.util.Calendar c) Deprecated. adds hash of Time value to the chain. |
| void | addTime(java.sql.Time v, java.util.Calendar c) Deprecated. adds hash of Time value to the chain. |
| void | addTimestamp(java.util.Date v, java.util.Calendar c) Deprecated. adds hash of Timestamp value to the chain. |
| void | addTimestamp(long v) Deprecated. adds hash of Timestamp value expressed as milliseconds since Jan 1, 1970 UTC to the chain. |
| void | addTimestamp(java.sql.Timestamp v, java.util.Calendar c) Deprecated. adds hash of Timestamp value to the chain. |
| void | addUUID(java.util.UUID v) Deprecated. adds hash of UUID value to the chain. |
| void | addUUIDNull() Deprecated. adds hash of null UUID to the chain. |
| long | getHash() Deprecated. returns the current hash value |
| static java.lang.String | getNodeFor(java.sql.Connection conn, java.lang.String schema, java.lang.String proj, long hashValue) Deprecated. Returns the name of the node that will be responsible for the provided value in the hash space for a given projection. |
| static java.lang.String | getNodeFor(java.lang.String getProjSegmentsOutput, long hashValue) Deprecated. Given a projection's get_projection_segments() output, this method will return the node that is responsible for the provided hashValue. |
| static long | hashBoolean(boolean v) Deprecated. compute hash of boolean value |
| static long | hashBooleanNull() Deprecated. compute hash of boolean null value |
| static long | hashBytes(byte[] b) Deprecated. compute hash of a binary value |
| static long | hashBytesNull() Deprecated. compute hash of a binary null value |
| static long | hashBytesNull(long input) Deprecated. compute hash of a binary null value |
| static long | hashDate(java.util.Date v) Deprecated. compute hash of java.util.Date value |
| static long | hashDate(java.sql.Date v) Deprecated. compute hash of java.sql.Date value |
| static long | hashDouble(double v) Deprecated. compute hash of double value |
| static long | hashDoubleNull() Deprecated. compute hash of double null value |
| static long | hashLong(long v) Deprecated. compute hash of long value |
| static long | hashNull() Deprecated. Compute hash of null value |
| static long | hashNull(long input) Deprecated. compute hash of null value. |
| static long | hashNumeric(java.math.BigDecimal src, int typemod) Deprecated. compute hash of a numeric value |
| static long | hashString(java.lang.String s) Deprecated. compute hash of String value |
| static long | hashStringNull() Deprecated. compute hash of String null value |
| static long | hashTime(java.sql.Time v) Deprecated. compute hash of Time value |
| static long | hashTimestamp(long java_ms) Deprecated. compute hash of Timestamp value expressed in milliseconds since Jan 1, 1970. |
| static long | hashTimestamp(java.sql.Timestamp v) Deprecated. compute hash of java.sql.Timestamp value |
| static long | hashUUID(java.util.UUID v, long input) Deprecated. compute hash of UUID value. |
| static long | hashUUIDNull() Deprecated. compute a hash of a null UUID value. |
| static long | hashUUIDNull(long input) Deprecated. compute a hash of a null UUID value. |
| void | reset() Deprecated. resets hash value for next chain. |
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
VHash
public VHash()
Deprecated. Creates an instance suitable for computing a hash of a chain of values, for use when a projection is segmented by multiple columns.
Method Detail
hashBooleanNull
public static long hashBooleanNull()
Deprecated. compute hash of boolean null value Returns long hash value
hashBoolean
public static long hashBoolean(boolean v)
Deprecated. compute hash of boolean value Parameters:v - boolean value to hash Returns long hash value
hashLong
public static long hashLong(long v)
Deprecated. compute hash of long value Parameters:v - long value to hash Returns long hash value
hashNull
public static long hashNull(long input)
Deprecated. compute hash of null value. First argument used to hash a list of values. Parameters:input - long value from previous hash function output Returns long hash value
hashNull
public static long hashNull()
Deprecated. Compute hash of null value Returns long hash value
hashUUID
public static long hashUUID(java.util.UUID v,
long input)
Deprecated. compute hash of UUID value. Parameters:v - fixed binary value to hashinput - variable input value to hash Returns long hash value
hashUUIDNull
public static long hashUUIDNull(long input)
Deprecated. compute a hash of a null UUID value. First argument used to hash a list of values. Parameters:input - long value from previous hash function output Returns The hash for null UUID.
hashUUIDNull
public static long hashUUIDNull()
Deprecated. compute a hash of a null UUID value. Returns The hash for null UUID.
hashDouble
public static long hashDouble(double v)
Deprecated. compute hash of double value Parameters:v - double value to hash Returns long hash value
hashDoubleNull
public static long hashDoubleNull()
Deprecated. compute hash of double null value Returns long hash value
hashTimestamp
public static long hashTimestamp(long java_ms)
Deprecated. compute hash of Timestamp value expressed in milliseconds since Jan 1, 1970. Parameters:java_ms - A number of milliseconds since Jan 1, 1970 GMT Returns long hash value
hashDate
public static long hashDate(java.util.Date v)
Deprecated. compute hash of java.util.Date value Parameters:v - Date value to hash Returns long hash value
hashDate
public static long hashDate(java.sql.Date v)
Deprecated. compute hash of java.sql.Date value Parameters:v - Date value to hash Returns long hash value
hashTimestamp
public static long hashTimestamp(java.sql.Timestamp v)
Deprecated. compute hash of java.sql.Timestamp value Parameters:v - Timestamp value to hash Returns long hash value
hashTime
public static long hashTime(java.sql.Time v)
Deprecated. compute hash of Time value Parameters:v - Time value to hash Returns long hash value
hashString
public static long hashString(java.lang.String s)
Deprecated. compute hash of String value Parameters:s - String value to hash Returns long hash value
hashStringNull
public static long hashStringNull()
Deprecated. compute hash of String null value Returns long hash value
hashBytesNull
public static long hashBytesNull()
Deprecated. compute hash of a binary null value Returns long hash value
hashBytesNull
public static long hashBytesNull(long input)
Deprecated. compute hash of a binary null value Parameters:input - long value from previous hash function output Returns long hash value
hashBytes
public static long hashBytes(byte[] b)
Deprecated. compute hash of a binary value Parameters:b - binary value to hash Returns long hash value
hashNumeric
public static long hashNumeric(java.math.BigDecimal src,
int typemod)
Deprecated. compute hash of a numeric value Parameters:src - Numeric value to hashtypemod - The precision and scale of the numeric. Returns long hash value
reset
public void reset()
Deprecated. resets hash value for next chain.
addNull
public void addNull()
Deprecated. Adds hash of null value to the chain. Use hashBooleanNull() to hash a boolean null.
addBoolean
public void addBoolean(boolean v)
Deprecated. adds hash of boolean value to the chain. Parameters:v - boolean value to hash
addBooleanNull
public void addBooleanNull()
Deprecated. adds hash of boolean null value to the chain.
addLong
public void addLong(long v)
Deprecated. adds hash of long value to the chain. Parameters:v - long value to hash
addUUID
public void addUUID(java.util.UUID v)
Deprecated. adds hash of UUID value to the chain. Parameters:v - fixed binary value to hash
addUUIDNull
public void addUUIDNull()
Deprecated. adds hash of null UUID to the chain.
addString
public void addString(java.lang.String v)
Deprecated. adds hash of String value to the chain. Parameters:v - String value to hash
addBytes
public void addBytes(byte[] v)
Deprecated. adds hash of binary value to the chain. Parameters:v - String value to hash
addTimestamp
public void addTimestamp(long v)
Deprecated. adds hash of Timestamp value expressed as milliseconds since Jan 1, 1970 UTC to the chain. Parameters:v - long value to hash
addDate
public void addDate(java.util.Date v,
java.util.Calendar c)
Deprecated. adds hash of Date value to the chain. Parameters:v - Date value to hashc - The calendar to providing a timezone context for v.
addDate
public void addDate(java.sql.Date v,
java.util.Calendar c)
Deprecated. adds hash of Date value to the chain. Parameters:v - Date value to hash.c - The calendar to providing a timezone context for v.
addTimestamp
public void addTimestamp(java.sql.Timestamp v,
java.util.Calendar c)
Deprecated. adds hash of Timestamp value to the chain. Parameters:v - Timestamp value to hashc - The calendar to providing a timezone context for v.
addTimestamp
public void addTimestamp(java.util.Date v,
java.util.Calendar c)
Deprecated. adds hash of Timestamp value to the chain. Parameters:v - Timestamp value to hashc - The calendar to providing a timezone context for v.
addTime
public void addTime(java.sql.Time v,
java.util.Calendar c)
Deprecated. adds hash of Time value to the chain. Parameters:v - Time value to hashc - The calendar to providing a timezone context for v. The date component of the calendar will influence the time due to DST.
addTime
public void addTime(java.util.Date v,
java.util.Calendar c)
Deprecated. adds hash of Time value to the chain. Parameters:v - Time value to hashc - The calendar to providing a timezone context for v. The date component of the calendar will influence the time due to DST.
addDouble
public void addDouble(double v)
Deprecated. adds hash of double value to the chain. Parameters:v - double value to hash
addDoubleNull
public void addDoubleNull()
Deprecated. adds hash of double null value to the chain.
addNumeric
public void addNumeric(java.math.BigDecimal src,
int typemod)
Deprecated. adds hash of numeric value to the chain Parameters:src - The numeric value to add to hash.typemod - The precision and scale of the numeric. Throws: java.lang.IllegalArgumentException - if src is too large to fit in a numeric.
getHash
public long getHash()
Deprecated. returns the current hash value Returns long value of hash
getNodeFor
public static java.lang.String getNodeFor(java.sql.Connection conn,
java.lang.String schema,
java.lang.String proj,
long hashValue)
throws java.sql.SQLException
Deprecated. Returns the name of the node that will be responsible for the provided value in the hash space for a given projection.
This method uses the provided Connection to call the get_projection_segments() SQL meta-function. It then relies on getNodeFor(String, long) to determine which node to use.
In situations where you need to compute many hashes for the same projection, it is would be much more efficient to call get_projection_segments() once via JDBC and then pass that output to getNodeFor(String, long) directly.
Caution: There is no guarantee that connecting to the node returned by this method will guarantee reduced intra-node traffic for a query or load based on the input hash value. While that is often true, the Vertica Optmizer may not always construct such a plan.
Additionally, no check is done to ensure that the input hash value was created in a manner that is consistent with the segmentation of the provided projection. This means, for example, if the projection is segmented by an INTEGER column and the caller provides a hashed DOUBLE PRECISION value, the answer may not be correct. Parameters:conn - A connection to a vertica database containing the projectionschema - The schema of the projectionproj - The name of the projectionhashValue - A hashed data value for this projection Returns The name of the node that is responsible for the provided hash value Throws: java.sql.SQLException - If a database error occurs java.lang.IllegalArgumentException - if the projection provided is not segmented by HASH(...) ALL NODES
getNodeFor
public static java.lang.String getNodeFor(java.lang.String getProjSegmentsOutput,
long hashValue)
Deprecated. Given a projection's get_projection_segments() output, this method will return the node that is responsible for the provided hashValue.
The get_projection_segments() SQL meta-function returns a list of the segment ranges each node is responsible for for a given projection. This method parses the output of that function and maps the provided hashValue to the range to determine a node name.
Caution: There is no guarantee that connecting to the node returned by this method will guarantee reduced intra-node traffic for a query or load based on the input hash value. While that is often true, the Vertica Optmizer may not always construct such a plan.
Additionally, no check is done to ensure that the input hash value was created in a manner that is consistent with the segmentation of the provided projection. This means, for example, if the projection is segmented by an INTEGER column and the caller provides a hashed DOUBLE PRECISION value, the answer may not be correct. Parameters:getProjSegmentsOutput - -- a String containing the return value of the get_projection_segments() SQL meta-function for a particular projection.hashValue - -- a hashed data value for the projection. Returns string identifying node. Throws: java.lang.IllegalArgumentException - if getProjSegmentsOutput is malformed in any way, either due to bad input or due to not using a properly segmented projection.