@Override public BatchingThreshold<E> copyWithZeroedValue() { return new NumericThreshold<E>(threshold, extractor); } }
@Override public BatchingThreshold<E> copyWithZeroedValue() { return new NumericThreshold<E>(threshold, extractor); } }
/** * Creates an ImmutableList containing only a single threshold which counts the number of * elements. This is helpful for when using ThresholdBatcher for the simple case, when the element * count is the only threshold. */ public static <E> List<BatchingThreshold<E>> create(long elementThreshold) { BatchingThreshold<E> batchingThreshold = new NumericThreshold<>( elementThreshold, new ElementCounter<E>() { @Override public long count(E e) { return 1; } }); return ImmutableList.of(batchingThreshold); } }
/** * Creates an ImmutableList containing only a single threshold which counts the number of * elements. This is helpful for when using ThresholdBatcher for the simple case, when the element * count is the only threshold. */ public static <E> List<BatchingThreshold<E>> create(long elementThreshold) { BatchingThreshold<E> batchingThreshold = new NumericThreshold<>( elementThreshold, new ElementCounter<E>() { @Override public long count(E e) { return 1; } }); return ImmutableList.of(batchingThreshold); } }
private ImmutableList<BatchingThreshold<Batch<RequestT, ResponseT>>> getThresholds( BatchingSettings batchingSettings) { ImmutableList.Builder<BatchingThreshold<Batch<RequestT, ResponseT>>> listBuilder = ImmutableList.builder(); if (batchingSettings.getElementCountThreshold() != null) { ElementCounter<Batch<RequestT, ResponseT>> elementCounter = new BatchElementCounter<>(batchingDescriptor); BatchingThreshold<Batch<RequestT, ResponseT>> countThreshold = new NumericThreshold<>(batchingSettings.getElementCountThreshold(), elementCounter); listBuilder.add(countThreshold); } if (batchingSettings.getRequestByteThreshold() != null) { ElementCounter<Batch<RequestT, ResponseT>> requestByteCounter = new BatchByteCounter<RequestT, ResponseT>(); BatchingThreshold<Batch<RequestT, ResponseT>> byteThreshold = new NumericThreshold<>(batchingSettings.getRequestByteThreshold(), requestByteCounter); listBuilder.add(byteThreshold); } return listBuilder.build(); } }
private ImmutableList<BatchingThreshold<Batch<RequestT, ResponseT>>> getThresholds( BatchingSettings batchingSettings) { ImmutableList.Builder<BatchingThreshold<Batch<RequestT, ResponseT>>> listBuilder = ImmutableList.builder(); if (batchingSettings.getElementCountThreshold() != null) { ElementCounter<Batch<RequestT, ResponseT>> elementCounter = new BatchElementCounter<>(batchingDescriptor); BatchingThreshold<Batch<RequestT, ResponseT>> countThreshold = new NumericThreshold<>(batchingSettings.getElementCountThreshold(), elementCounter); listBuilder.add(countThreshold); } if (batchingSettings.getRequestByteThreshold() != null) { ElementCounter<Batch<RequestT, ResponseT>> requestByteCounter = new BatchByteCounter<RequestT, ResponseT>(); BatchingThreshold<Batch<RequestT, ResponseT>> byteThreshold = new NumericThreshold<>(batchingSettings.getRequestByteThreshold(), requestByteCounter); listBuilder.add(byteThreshold); } return listBuilder.build(); } }