Search in sources :

Example 1 with Funnel

use of com.google.common.hash.Funnel in project GeoGig by boundlessgeo.

the class HashObject method _call.

/**
     * Hashes a RevObject using a SHA1 hasher.
     * 
     * @return a new ObjectId created from the hash of the RevObject.
     */
@Override
protected ObjectId _call() {
    Preconditions.checkState(object != null, "Object has not been set.");
    final Hasher hasher = ObjectId.HASH_FUNCTION.newHasher();
    @SuppressWarnings("unchecked") final Funnel<RevObject> funnel = (Funnel<RevObject>) FUNNELS[object.getType().value()];
    funnel.funnel(object, hasher);
    final byte[] rawKey = hasher.hash().asBytes();
    final ObjectId id = ObjectId.createNoClone(rawKey);
    return id;
}
Also used : Funnel(com.google.common.hash.Funnel) Hasher(com.google.common.hash.Hasher) RevObject(org.locationtech.geogig.api.RevObject) ObjectId(org.locationtech.geogig.api.ObjectId)

Aggregations

Funnel (com.google.common.hash.Funnel)1 Hasher (com.google.common.hash.Hasher)1 ObjectId (org.locationtech.geogig.api.ObjectId)1 RevObject (org.locationtech.geogig.api.RevObject)1