Example usage for java.lang Iterable hashCode

List of usage examples for java.lang Iterable hashCode

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public native int hashCode();

Source Link

Document

Returns a hash code value for the object.

Usage

From source file:org.b3log.latke.repository.gae.GAERepository.java

@Override
@SuppressWarnings("unchecked")
public Map<String, JSONObject> get(final Iterable<String> ids) throws RepositoryException {
    LOGGER.log(Level.FINEST, "Getting with ids[{0}]", ids);

    final GAETransaction currentTransaction = TX.get();

    if (null == currentTransaction || !currentTransaction.hasUncommitted(ids)) {
        Map<String, JSONObject> ret;

        if (cacheEnabled) {
            final String cacheKey = CACHE_KEY_PREFIX + ids.hashCode();

            ret = (Map<String, JSONObject>) CACHE.get(cacheKey);
            if (null != ret) {
                LOGGER.log(Level.FINER, "Got objects[cacheKey={0}] from repository cache[name={1}]",
                        new Object[] { cacheKey, getName() });
                return ret;
            }/*  w ww  . ja  v a 2s .  c  om*/
        }

        final Set<Key> keys = new HashSet<Key>();

        for (final String id : ids) {
            final Key key = KeyFactory.createKey(DEFAULT_PARENT_KEY, getName(), id);

            keys.add(key);
        }

        ret = new HashMap<String, JSONObject>();

        final Map<Key, Entity> map = datastoreService.get(keys);

        for (final Entry<Key, Entity> entry : map.entrySet()) {
            ret.put(entry.getKey().getName(), entity2JSONObject(entry.getValue()));
        }

        LOGGER.log(Level.FINER, "Got objects[oIds={0}] from repository[name={1}]",
                new Object[] { ids, getName() });

        if (cacheEnabled) {
            final String cacheKey = CACHE_KEY_PREFIX + ids.hashCode();

            CACHE.putAsync(cacheKey, (Serializable) ret);
            LOGGER.log(Level.FINER, "Added objects[cacheKey={0}] in repository cache[{1}]",
                    new Object[] { cacheKey, getName() });
        }

        return ret;
    }

    // The returned value may be null if it has been set to null in the 
    // current transaction
    return currentTransaction.getUncommitted(ids);
}