public BucketId getBucketId(DocumentId doc) {
        long location = doc.getScheme().getLocation();
        byte[] gid = doc.getGlobalId();
        long gidContribution = getGidContribution(gid);

        return new BucketId(64 - BucketId.COUNT_BITS, initialCount | (gidMask & gidContribution) | (locationMask & location));
    }
Get the bucket id for a given document.

@param doc The doc.
@return The bucket id.
document/src/main/java/com/yahoo/document/BucketIdFactory.java