Example usage for com.google.common.cache Weigher interface-usage

List of usage examples for com.google.common.cache Weigher interface-usage

Introduction

In this page you can find the example usage for com.google.common.cache Weigher interface-usage.

Usage

From source file org.jabylon.resources.persistence.internal.PropertySizeWeigher.java

/**
 * @author jutzig.dev@googlemail.com
 *
 */
public class PropertySizeWeigher implements Weigher<CDOID, PropertyFile> {

From source file com.google.gerrit.httpd.plugins.ResourceWeigher.java

class ResourceWeigher implements Weigher<ResourceKey, Resource> {
    @Override
    public int weigh(ResourceKey key, Resource value) {
        return key.weigh() + value.weigh();
    }
}

From source file com.google.gerrit.httpd.resources.ResourceWeigher.java

public class ResourceWeigher implements Weigher<ResourceKey, Resource> {
    @Override
    public int weigh(ResourceKey key, Resource value) {
        return key.weigh() + value.weigh();
    }
}

From source file com.google.gerrit.server.patch.IntraLineWeigher.java

/** Approximates memory usage for IntralineDiff in bytes of memory used. */
public class IntraLineWeigher implements Weigher<IntraLineDiffKey, IntraLineDiff> {
    @Override
    public int weigh(IntraLineDiffKey key, IntraLineDiff value) {
        return 16 + 8 * 8 + 2 * 36 // Size of IntraLineDiffKey, 64 bit JVM
                + 16 + 2 * 8 + 16 + 8 + 4 + 20 // Size of IntraLineDiff, 64 bit JVM

From source file com.google.gerrit.server.patch.PatchListWeigher.java

/** Approximates memory usage for PatchList in bytes of memory used. */
public class PatchListWeigher implements Weigher<PatchListKey, PatchList> {
    @Override
    public int weigh(PatchListKey key, PatchList value) {
        int size = 16 + 4 * 8 + 2 * 36 // Size of PatchListKey, 64 bit JVM
                + 16 + 3 * 8 + 3 * 4 + 20; // Size of PatchList, 64 bit JVM

From source file com.google.gerrit.server.patch.DiffSummaryWeigher.java

/** Computes memory usage for {@link DiffSummary} in bytes of memory used. */
public class DiffSummaryWeigher implements Weigher<DiffSummaryKey, DiffSummary> {

    @Override
    public int weigh(DiffSummaryKey key, DiffSummary value) {
        int size = 16 + 4 * 8 + 2 * 36 // Size of DiffSummaryKey, 64 bit JVM

From source file com.yobidrive.diskmap.needles.NeedleWeighter.java

public class NeedleWeighter implements Weigher<NeedlePointer, Needle> {

    public int weigh(NeedlePointer pointer, Needle needle) {
        return NeedlePointer.POINTERSIZE + Needle.NEEDLEOVERHEAD
                + (needle.getKeyBytes() == null ? 0 : needle.getKeyBytes().length)
                + (needle.getVersion() == null ? 0 : needle.getVersion().toBytes().length) + needle.getSize() + 100; // google cache entry overhead

From source file com.yobidrive.diskmap.needles.NeedleHeaderWeighter.java

public class NeedleHeaderWeighter implements Weigher<NeedlePointer, NeedleHeader> {

    public int weigh(NeedlePointer pointer, NeedleHeader needle) {
        return NeedlePointer.POINTERSIZE + (needle.getKeyBytes() == null ? 0 : needle.getKeyBytes().length)
                + (needle.getVersion() == null ? 0 : needle.getVersion().toBytes().length) + 100; // google cache entry overhead
    }

From source file com.yobidrive.diskmap.buckets.NeedlePointerWeighter.java

public class NeedlePointerWeighter implements Weigher<Long, NeedlePointer> {

    public int weigh(Long bucket, NeedlePointer pointer) {
        return NeedlePointer.POINTERSIZE + 8 // inner long size
                + 140; // 140: estimated cache hash map overhead
    }

From source file com.bazaarvoice.dropwizard.caching.CachedResponseWeigher.java

/**
 * Weigher that attempts to estimate the size of the cached response in bytes.
 */
public class CachedResponseWeigher implements Weigher<String, CachedResponse> {
    private static final int CHAR_BYTES = 2;
    public static final CachedResponseWeigher INSTANCE = new CachedResponseWeigher();