Example usage for java.lang Object hashCode

List of usage examples for java.lang Object hashCode

Introduction

In this page you can find the example usage for java.lang Object hashCode.

Prototype

@HotSpotIntrinsicCandidate
public native int hashCode();

Source Link

Document

Returns a hash code value for the object.

Usage

From source file:com.axiomine.largecollections.util.LargeCollection.java

protected void initializeBloomFilter() {
    this.myFunnel = new Funnel() {
        public void funnel(Object obj, PrimitiveSink into) {
            into.putInt(obj.hashCode());
        }/*ww  w.  j a  v  a2  s . c  o m*/
    };
    float defaultFalsePositives = 0.03f;
    if (!StringUtils.isBlank(System.getProperty(LargeCollection.OVERRIDE_BF_FPP))) {
        String fpp = System.getProperty(LargeCollection.OVERRIDE_BF_FPP);
        try {
            float f = Float.parseFloat(fpp);
            if (f <= 0 || f > 0.2) {
                throw new RuntimeException(
                        "Bloom filter false postives probability range should be between 0 (excluded) and 0.2 (included), provided value = "
                                + f);
            } else {
                defaultFalsePositives = f;
            }
        } catch (Exception ex) {
            throw Throwables.propagate(ex);
        }
    }
    this.bloomFilter = BloomFilter.create(myFunnel, this.bloomFilterSize, defaultFalsePositives);
}

From source file:com.twelvemonkeys.util.ObjectAbstractTestCase.java

public void testObjectHashCodeEqualsSelfHashCode() {
    Object obj = makeObject();
    assertEquals("hashCode should be repeatable", obj.hashCode(), obj.hashCode());
}

From source file:com.jcraft.weirdx.res.XResource.java

public boolean equals(Object o) {
    if (o == null || id != o.hashCode())
        return false;
    if (!(o instanceof XResource))
        return true;
    if (!(o instanceof Key)) {
        return rtype == ((XResource) o).rtype;
    }// w  w w  .java 2  s . c o  m
    Key key = (Key) o;
    if (key.clss == 0) {
        return rtype == key.rtype;
    } else if (key.clss == RC_ANY) {
        return true;
    } else {
        return (rtype & key.clss) != 0;
    }
}

From source file:FastCache.java

int bucketId(Object key) {
    return java.lang.Math.abs(key.hashCode() % mBuckets.length);
}

From source file:IntMap.java

/**
 * Expands the property table/*from  ww w .  j a v a2s . c  o m*/
 */
private void resize(int newSize) {
    Object[] newKeys = new Object[newSize];
    int[] newValues = new int[newSize];

    int mask = _mask = newKeys.length - 1;

    Object[] keys = _keys;
    int values[] = _values;

    for (int i = keys.length - 1; i >= 0; i--) {
        Object key = keys[i];

        if (key == null || key == DELETED)
            continue;

        int hash = key.hashCode() % mask & mask;

        while (true) {
            if (newKeys[hash] == null) {
                newKeys[hash] = key;
                newValues[hash] = values[i];
                break;
            }

            hash = (hash + 1) % mask;
        }
    }

    _keys = newKeys;
    _values = newValues;
}

From source file:com.curl.orb.servlet.NewInstanceServlet.java

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    super.doPost(request, response);
    NewInstanceRequest newInstanceRequest = (NewInstanceRequest) InstanceManagementUtil.getRequest(request);
    try {/*from  ww  w  .  ja  v  a2  s .co m*/
        String className = newInstanceRequest.getClassName();
        Class<?> cls = Class.forName(className);
        // security
        RemoteServiceAnnotationChecker.check(cls, environment);
        // new instance
        HttpSession session = request.getSession(false);
        if (session == null)
            session = request.getSession(true);
        Object obj = InstanceManagementUtil.newInstance(cls,
                switchRemoteObject(newInstanceRequest.getArguments(), session));

        // NOTE: objectId is HttpSession.getId() + Object.hashCode()
        String objectId = session.getId() + (new StringBuilder(String.valueOf(obj.hashCode()))).toString();
        session.setAttribute(objectId, obj);
        InstanceManagementUtil.setResponse(request, objectId, null);
        // debug
        (LogFactory.getLog(getClass())).debug("Request new instance");
    }
    // IOException, SerializerException ...etc
    catch (Exception e) {
        InstanceManagementUtil.setResponse(request, e, null);
    }
}

From source file:org.apache.isis.core.runtime.persistence.adaptermanager.PojoAdapterHashMap.java

public void add(final Object pojo, final ObjectAdapter adapter) {
    adapterByPojoMap.put(key(pojo), adapter);
    if (LOG.isDebugEnabled()) {
        LOG.debug("add adapter: #" + Long.toHexString(pojo.hashCode()) + " -> #"
                + Long.toHexString(adapter.hashCode()));
    }/*from   w w w.  ja  v  a 2s  .  com*/
    // log at end so that if toString needs adapters they're in maps.
    if (adapter.isResolved()) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("add " + new ToString(pojo) + " as " + adapter);
        }
    }
}

From source file:net.sourceforge.jabm.spring.SimulationScope.java

@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
    if (logger.isDebugEnabled())
        logger.debug("Looking up bean " + name);
    Object result = boundObjects.get(name);
    if (result == null) {
        result = objectFactory.getObject();
        boundObjects.put(name, result);/*from   www.ja  v  a 2s .  c  om*/
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Returning " + result + " with hash " + result.hashCode() + " for " + name);
    }
    return result;
}

From source file:com.taobao.common.store.util.MyMBeanServer.java

/**
 * MBean/*from ww w .j  a va 2  s  . c  o m*/
 * 
 * @param o
 * @param name
 */
public void registMBean(final Object o, final String name) {
    // MBean
    if (null != mbs) {
        try {
            mbs.registerMBean(o, new ObjectName(o.getClass().getPackage().getName() + ":type="
                    + o.getClass().getSimpleName()
                    + (null == name ? (",id=" + o.hashCode()) : (",name=" + name + "-" + o.hashCode()))));
        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
    }
}

From source file:org.largecollections.CacheSetWithUnqHashCode.java

public boolean contains(Object key) {
    if (this.bloomFilter.mightContain(key.hashCode())) {
        K v = serdeUtils.deserializeValue(db.get(Integer.toString(key.hashCode()).getBytes()));
        if (v != null) {
            return true;
        }//  w  ww  .  jav  a2 s.c o  m
    }

    return false;
}