public static int hash()

in adb3client/src/main/java/com/alibaba/cloud/analyticdb/adb3client/util/ShardUtil.java [57:93]


	public static int hash(Object obj) {
		if (obj == null) {
			return NULL_HASH_CODE;
		} else {
			if (obj instanceof String) {
				byte[] value = ((String) obj).getBytes(UTF8);
				int result = 1;
				for (int i = 0; i < value.length; i++) {
					result = 31 * result + value[i];
				}
				return result;
			} else if (obj instanceof byte[]) {
				return Arrays.hashCode((byte[]) obj);
			} else if (obj instanceof Boolean) {
				return (Boolean) obj ? 1 : 0;
			} else if (obj instanceof Byte || obj instanceof Integer || obj instanceof Short) {
				return (int) obj;
			} else if (obj instanceof Date) {
				long time = ((Date) obj).getTime();
				int result = (int) (time ^ (time >>> 32));
				return result;
			} else if (obj instanceof Long) {
				long longVal = (Long) obj;
				return (int) (longVal ^ (longVal >>> 32));
			} else if (obj.getClass().isArray()) {
				int hash = 0;
				int length = Array.getLength(obj);
				for (int i = 0; i < length; ++i) {
					Object child = Array.get(obj, i);
					hash = hash * 31 + (child == null ? 0 : hash(child));
				}
				return hash;
			} else {
				return hash(String.valueOf(obj));
			}
		}
	}