Example usage for java.util Arrays hashCode

List of usage examples for java.util Arrays hashCode

Introduction

In this page you can find the example usage for java.util Arrays hashCode.

Prototype

public static int hashCode(Object a[]) 

Source Link

Document

Returns a hash code based on the contents of the specified array.

Usage

From source file:sadl.models.pdrta.PDRTAInput.java

@Override
public int hashCode() {

    final int prime = 31;
    int result = 1;
    result = prime * result + Arrays.hashCode(histoBorders);
    result = prime * result + Arrays.hashCode(histoSizes);
    result = prime * result + ((inp == null) ? 0 : inp.hashCode());
    result = prime * result + maxTimeDelay;
    result = prime * result + minTimeDelay;
    result = prime * result + ((tails == null) ? 0 : tails.hashCode());
    return result;
}

From source file:com.opengamma.analytics.financial.interestrate.MultipleYieldCurveFinderDataBundle.java

@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + _derivatives.hashCode();
    result = prime * result + ((_knownCurves == null) ? 0 : _knownCurves.hashCode());
    result = prime * result + Arrays.hashCode(_marketValues);
    result = prime * result + _unknownCurveInterpolators.hashCode();
    result = prime * result + _unknownCurveNodePoints.hashCode();
    result = prime * result + (_useFiniteDifferenceByDefault ? 1231 : 1237);
    result = prime * result + _fxMatrix.hashCode();
    return result;
}

From source file:jsat.distributions.empirical.MyKernelDensityEstimator.java

@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + Arrays.hashCode(X);
    long temp;/*from   w  w w  .  j av a2 s .  co  m*/
    temp = Double.doubleToLongBits(mean());
    result = prime * result + (int) (temp ^ (temp >>> 32));
    temp = Double.doubleToLongBits(getBandwith());
    result = prime * result + (int) (temp ^ (temp >>> 32));
    result = prime * result + ((k == null) ? 0 : k.hashCode());
    temp = Double.doubleToLongBits(sumOFWeights);
    result = prime * result + (int) (temp ^ (temp >>> 32));
    result = prime * result + Arrays.hashCode(weights);
    return result;
}

From source file:com.opengamma.analytics.financial.instrument.payment.CouponOISDefinition.java

@Override
public int hashCode() {
    final int prime = 31;
    int result = super.hashCode();
    result = prime * result + Arrays.hashCode(_fixingPeriodAccrualFactor);
    result = prime * result + Arrays.hashCode(_fixingPeriodDate);
    result = prime * result + _index.hashCode();
    return result;
}

From source file:org.apache.hadoop.hbase.util.MultiThreadedAction.java

/**
 * Verifies the result from get or scan using the dataGenerator (that was presumably
 * also used to generate said result)./* ww  w.  ja  v a 2s  . c o  m*/
 * @param verifyValues verify that values in the result make sense for row/cf/column combination
 * @param verifyCfAndColumnIntegrity verify that cf/column set in the result is complete. Note
 *                                   that to use this multiPut should be used, or verification
 *                                   has to happen after writes, otherwise there can be races.
 * @return
 */
public boolean verifyResultAgainstDataGenerator(Result result, boolean verifyValues,
        boolean verifyCfAndColumnIntegrity) {
    String rowKeyStr = Bytes.toString(result.getRow());

    // See if we have any data at all.
    if (result.isEmpty()) {
        LOG.error("Error checking data for key [" + rowKeyStr + "], no data returned");
        return false;
    }

    if (!verifyValues && !verifyCfAndColumnIntegrity) {
        return true; // as long as we have something, we are good.
    }

    // See if we have all the CFs.
    byte[][] expectedCfs = dataGenerator.getColumnFamilies();
    if (verifyCfAndColumnIntegrity && (expectedCfs.length != result.getMap().size())) {
        LOG.error(
                "Error checking data for key [" + rowKeyStr + "], bad family count: " + result.getMap().size());
        return false;
    }

    // Verify each column family from get in the result.
    for (byte[] cf : result.getMap().keySet()) {
        String cfStr = Bytes.toString(cf);
        Map<byte[], byte[]> columnValues = result.getFamilyMap(cf);
        if (columnValues == null) {
            LOG.error("Error checking data for key [" + rowKeyStr + "], no data for family [" + cfStr + "]]");
            return false;
        }

        Map<String, MutationType> mutateInfo = null;
        if (verifyCfAndColumnIntegrity || verifyValues) {
            if (!columnValues.containsKey(MUTATE_INFO)) {
                LOG.error("Error checking data for key [" + rowKeyStr + "], column family [" + cfStr
                        + "], column [" + Bytes.toString(MUTATE_INFO) + "]; value is not found");
                return false;
            }

            long cfHash = Arrays.hashCode(cf);
            // Verify deleted columns, and make up column counts if deleted
            byte[] mutateInfoValue = columnValues.remove(MUTATE_INFO);
            mutateInfo = parseMutateInfo(mutateInfoValue);
            for (Map.Entry<String, MutationType> mutate : mutateInfo.entrySet()) {
                if (mutate.getValue() == MutationType.DELETE) {
                    byte[] column = Bytes.toBytes(mutate.getKey());
                    long columnHash = Arrays.hashCode(column);
                    long hashCode = cfHash + columnHash;
                    if (hashCode % 2 == 0) {
                        if (columnValues.containsKey(column)) {
                            LOG.error("Error checking data for key [" + rowKeyStr + "], column family [" + cfStr
                                    + "], column [" + mutate.getKey() + "]; should be deleted");
                            return false;
                        }
                        byte[] hashCodeBytes = Bytes.toBytes(hashCode);
                        columnValues.put(column, hashCodeBytes);
                    }
                }
            }

            // Verify increment
            if (!columnValues.containsKey(INCREMENT)) {
                LOG.error("Error checking data for key [" + rowKeyStr + "], column family [" + cfStr
                        + "], column [" + Bytes.toString(INCREMENT) + "]; value is not found");
                return false;
            }
            long currentValue = Bytes.toLong(columnValues.remove(INCREMENT));
            if (verifyValues) {
                long amount = mutateInfo.isEmpty() ? 0 : cfHash;
                long originalValue = Arrays.hashCode(result.getRow());
                long extra = currentValue - originalValue;
                if (extra != 0 && (amount == 0 || extra % amount != 0)) {
                    LOG.error("Error checking data for key [" + rowKeyStr + "], column family [" + cfStr
                            + "], column [increment], extra [" + extra + "], amount [" + amount + "]");
                    return false;
                }
                if (amount != 0 && extra != amount) {
                    LOG.warn("Warning checking data for key [" + rowKeyStr + "], column family [" + cfStr
                            + "], column [increment], incremented [" + (extra / amount) + "] times");
                }
            }

            // See if we have correct columns.
            if (verifyCfAndColumnIntegrity
                    && !dataGenerator.verify(result.getRow(), cf, columnValues.keySet())) {
                String colsStr = "";
                for (byte[] col : columnValues.keySet()) {
                    if (colsStr.length() > 0) {
                        colsStr += ", ";
                    }
                    colsStr += "[" + Bytes.toString(col) + "]";
                }
                LOG.error("Error checking data for key [" + rowKeyStr + "], bad columns for family [" + cfStr
                        + "]: " + colsStr);
                return false;
            }
            // See if values check out.
            if (verifyValues) {
                for (Map.Entry<byte[], byte[]> kv : columnValues.entrySet()) {
                    String column = Bytes.toString(kv.getKey());
                    MutationType mutation = mutateInfo.get(column);
                    boolean verificationNeeded = true;
                    byte[] bytes = kv.getValue();
                    if (mutation != null) {
                        boolean mutationVerified = true;
                        long columnHash = Arrays.hashCode(kv.getKey());
                        long hashCode = cfHash + columnHash;
                        byte[] hashCodeBytes = Bytes.toBytes(hashCode);
                        if (mutation == MutationType.APPEND) {
                            int offset = bytes.length - hashCodeBytes.length;
                            mutationVerified = offset > 0 && Bytes.equals(hashCodeBytes, 0,
                                    hashCodeBytes.length, bytes, offset, hashCodeBytes.length);
                            if (mutationVerified) {
                                int n = 1;
                                while (true) {
                                    int newOffset = offset - hashCodeBytes.length;
                                    if (newOffset < 0 || !Bytes.equals(hashCodeBytes, 0, hashCodeBytes.length,
                                            bytes, newOffset, hashCodeBytes.length)) {
                                        break;
                                    }
                                    offset = newOffset;
                                    n++;
                                }
                                if (n > 1) {
                                    LOG.warn("Warning checking data for key [" + rowKeyStr
                                            + "], column family [" + cfStr + "], column [" + column
                                            + "], appended [" + n + "] times");
                                }
                                byte[] dest = new byte[offset];
                                System.arraycopy(bytes, 0, dest, 0, offset);
                                bytes = dest;
                            }
                        } else if (hashCode % 2 == 0) { // checkAndPut
                            mutationVerified = Bytes.equals(bytes, hashCodeBytes);
                            verificationNeeded = false;
                        }
                        if (!mutationVerified) {
                            LOG.error("Error checking data for key [" + rowKeyStr
                                    + "], mutation checking failed for column family [" + cfStr + "], column ["
                                    + column + "]; mutation [" + mutation + "], hashCode [" + hashCode
                                    + "], verificationNeeded [" + verificationNeeded + "]");
                            return false;
                        }
                    } // end of mutation checking
                    if (verificationNeeded && !dataGenerator.verify(result.getRow(), cf, kv.getKey(), bytes)) {
                        LOG.error("Error checking data for key [" + rowKeyStr + "], column family [" + cfStr
                                + "], column [" + column + "], mutation [" + mutation + "]; value of length "
                                + bytes.length);
                        return false;
                    }
                }
            }
        }
    }
    return true;
}

From source file:org.teiid.test.teiid4441.FTPClientFactory.java

@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((this.parentDirectory == null) ? 0 : this.parentDirectory.hashCode());
    result = prime * result + ((this.username == null) ? 0 : this.username.hashCode());
    result = prime * result + ((this.password == null) ? 0 : this.password.hashCode());
    result = prime * result + ((this.host == null) ? 0 : this.host.hashCode());
    result = prime * result + ((this.controlEncoding == null) ? 0 : this.controlEncoding.hashCode());
    result = prime * result + ((this.connectTimeout == null) ? 0 : this.connectTimeout.hashCode());
    result = prime * result + ((this.dataTimeout == null) ? 0 : this.dataTimeout.hashCode());
    result = prime * result + ((this.defaultTimeout == null) ? 0 : this.defaultTimeout.hashCode());
    result = prime * result + this.port;
    result = prime * result + this.fileType;
    result = prime * result + this.clientMode;
    result = prime * result + this.bufferSize;
    if (this.isFtps) {
        result = prime * result + ((this.authValue == null) ? 0 : this.authValue.hashCode());
        result = prime * result + ((this.protocol == null) ? 0 : this.protocol.hashCode());
        result = prime * result + ((this.execProt == null) ? 0 : this.execProt.hashCode());
        result = prime * result + ((this.useClientMode == null) ? 0 : this.useClientMode.hashCode());
        result = prime * result + ((this.sessionCreation == null) ? 0 : this.sessionCreation.hashCode());
        result = prime * result + ((this.needClientAuth == null) ? 0 : this.needClientAuth.hashCode());
        result = prime * result + ((this.wantsClientAuth == null) ? 0 : this.wantsClientAuth.hashCode());
        result = prime * result + ((this.implicit) ? 1231 : 1237);
        result = prime * result + ((this.cipherSuites == null) ? 0 : Arrays.hashCode(this.cipherSuites));
        result = prime * result + ((this.protocols == null) ? 0 : Arrays.hashCode(this.protocols));
    }//from www.ja va2  s.  co m
    return result;
}

From source file:org.broadleafcommerce.openadmin.dto.Entity.java

@Override
public int hashCode() {
    int result = type != null ? Arrays.hashCode(type) : 0;
    result = 31 * result + (properties != null ? Arrays.hashCode(properties) : 0);
    result = 31 * result + (isDirty ? 1 : 0);
    result = 31 * result + (deployDate != null ? deployDate.hashCode() : 0);
    result = 31 * result + (isDeleted != null ? isDeleted.hashCode() : 0);
    result = 31 * result + (isInactive != null ? isInactive.hashCode() : 0);
    result = 31 * result + (isActive != null ? isActive.hashCode() : 0);
    result = 31 * result + (multiPartAvailableOnThread ? 1 : 0);
    result = 31 * result + (isValidationFailure ? 1 : 0);
    result = 31 * result + (validationErrors != null ? validationErrors.hashCode() : 0);
    result = 31 * result + (pMap != null ? pMap.hashCode() : 0);
    return result;
}

From source file:org.parosproxy.paros.network.HttpBody.java

@Override
public int hashCode() {
    return 31 + Arrays.hashCode(body);
}

From source file:com.opengamma.analytics.math.curve.ArraysDoublesCurve.java

@Override
public int hashCode() {
    final int prime = 31;
    int result = super.hashCode();
    result = prime * result + Arrays.hashCode(_xData);
    result = prime * result + Arrays.hashCode(_yData);
    return result;
}

From source file:com.chinamobile.bcbsp.ml.math.DenseDoubleVector.java

@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + Arrays.hashCode(vector);
    return result;
}