@Test public void combineThresholdExceeded() { RangeListFilter<Long, LongContent, LongRange> x = new RangeListFilter<>( ImmutableList.of(TestUtils.ZERO_ONE), false, Level.FINE, LongRangeHome.INSTANCE); RangeListFilter<Long, LongContent, LongRange> y = new RangeListFilter<>( ImmutableList.of(TestUtils.THREE_FOUR), false, Level.FINE, LongRangeHome.INSTANCE); RangeListFilter<Long, LongContent, LongRange> z = x.combine(y, 1, new LongContent(10)); Assert.assertEquals(new RangeListFilter<>( ImmutableList.of(TestUtils.ZERO_FOUR), true, Level.FINE, LongRangeHome.INSTANCE), z); }
public RangeListFilter<T, V, R> combine(RangeListFilter<T, V, R> higher, int threshold, V gapEstimate) { Preconditions.checkArgument(rangeList.size() <= threshold); Preconditions.checkArgument(higher.rangeList.size() <= threshold); int cmp = rangeList.get(rangeList.size() - 1).getEnd().compareTo( higher.rangeList.get(0).getStart()); int gapSignum = gapEstimate.isZero() ? 0 : 1; Preconditions.checkArgument((cmp < 0 & gapSignum >= 0) || (cmp == 0 & gapSignum == 0)); int concatenatedListSize = rangeList.size() + higher.rangeList.size() + gapSignum - 1; if (thresholdExceeded || higher.thresholdExceeded || concatenatedListSize > threshold) { if (concatenatedListSize > threshold & !thresholdExceeded & !higher.thresholdExceeded) { logger.log(thresholdExceededLogLevel, "Exceeded threshold {0} with input sizes" + " {1} and {2} and gapEstimate={3}.", new Object[] { threshold, rangeList.size(), higher.rangeList.size(), gapEstimate}); } return new RangeListFilter<T, V, R>(ImmutableList.of(rangeHome.of(rangeList.get(0).getStart(), higher.rangeList.get(higher.rangeList.size() - 1).getEnd())), true, thresholdExceededLogLevel, rangeHome); } List<R> list = new ArrayList<>(concatenatedListSize); if (gapSignum == 0) { list.addAll(rangeList); list.addAll(list.size() - 1, higher.rangeList); R lastLowerFilter = list.remove(list.size() - 1); assert rangeList.get(rangeList.size() - 1) == lastLowerFilter; list.set(rangeList.size() - 1, rangeHome.of(lastLowerFilter.getStart(), higher.rangeList.get(0).getEnd())); } else { list.addAll(rangeList); list.addAll(higher.rangeList); } return new RangeListFilter<T, V, R>( Collections.unmodifiableList(list), false, thresholdExceededLogLevel, rangeHome); }
RangeListFilter { public RangeListFilter<T, V, R> combine(RangeListFilter<T, V, R> higher, int threshold, V gapEstimate) { Preconditions.checkArgument(rangeList.size() <= threshold); Preconditions.checkArgument(higher.rangeList.size() <= threshold); int cmp = rangeList.get(rangeList.size() - 1).getEnd().compareTo( higher.rangeList.get(0).getStart()); int gapSignum = gapEstimate.isZero() ? 0 : 1; Preconditions.checkArgument((cmp < 0 & gapSignum >= 0) || (cmp == 0 & gapSignum == 0)); int concatenatedListSize = rangeList.size() + higher.rangeList.size() + gapSignum - 1; if (thresholdExceeded || higher.thresholdExceeded || concatenatedListSize > threshold) { if (concatenatedListSize > threshold & !thresholdExceeded & !higher.thresholdExceeded) { logger.log(thresholdExceededLogLevel, "Exceeded threshold {0} with input sizes" + " {1} and {2} and gapEstimate={3}.", new Object[] { threshold, rangeList.size(), higher.rangeList.size(), gapEstimate}); } return new RangeListFilter<T, V, R>(ImmutableList.of(rangeHome.of(rangeList.get(0).getStart(), higher.rangeList.get(higher.rangeList.size() - 1).getEnd())), true, thresholdExceededLogLevel, rangeHome); } List<R> list = new ArrayList<>(concatenatedListSize); if (gapSignum == 0) { list.addAll(rangeList); list.addAll(list.size() - 1, higher.rangeList); R lastLowerFilter = list.remove(list.size() - 1); assert rangeList.get(rangeList.size() - 1) == lastLowerFilter; list.set(rangeList.size() - 1, rangeHome.of(lastLowerFilter.getStart(), higher.rangeList.get(0).getEnd())); } else { list.addAll(rangeList); list.addAll(higher.rangeList); } return new RangeListFilter<T, V, R>( Collections.unmodifiableList(list), false, thresholdExceededLogLevel, rangeHome); } }
RangeListFilter { public RangeListFilter<T, V, R> combine(RangeListFilter<T, V, R> higher, int threshold, V gapEstimate) { Preconditions.checkArgument(rangeList.size() <= threshold); Preconditions.checkArgument(higher.rangeList.size() <= threshold); int cmp = rangeList.get(rangeList.size() - 1).getEnd().compareTo( higher.rangeList.get(0).getStart()); int gapSignum = gapEstimate.isZero() ? 0 : 1; Preconditions.checkArgument((cmp < 0 & gapSignum >= 0) || (cmp == 0 & gapSignum == 0)); int concatenatedListSize = rangeList.size() + higher.rangeList.size() + gapSignum - 1; if (thresholdExceeded || higher.thresholdExceeded || concatenatedListSize > threshold) { if (concatenatedListSize > threshold & !thresholdExceeded & !higher.thresholdExceeded) { logger.log(thresholdExceededLogLevel, "Exceeded threshold {0} with input sizes" + " {1} and {2} and gapEstimate={3}.", new Object[] { threshold, rangeList.size(), higher.rangeList.size(), gapEstimate}); } return new RangeListFilter<T, V, R>(ImmutableList.of(rangeHome.of(rangeList.get(0).getStart(), higher.rangeList.get(higher.rangeList.size() - 1).getEnd())), true, thresholdExceededLogLevel, rangeHome); } List<R> list = new ArrayList<>(concatenatedListSize); if (gapSignum == 0) { list.addAll(rangeList); list.addAll(list.size() - 1, higher.rangeList); R lastLowerFilter = list.remove(list.size() - 1); assert rangeList.get(rangeList.size() - 1) == lastLowerFilter; list.set(rangeList.size() - 1, rangeHome.of(lastLowerFilter.getStart(), higher.rangeList.get(0).getEnd())); } else { list.addAll(rangeList); list.addAll(higher.rangeList); } return new RangeListFilter<T, V, R>( Collections.unmodifiableList(list), false, thresholdExceededLogLevel, rangeHome); } RangeListFilter(List<R> rangeList, boolean thresholdExceeded,
      Level thresholdExceededLogLevel, RangeHome<T, V, R> rangeHome); }
RangeListFilter { public RangeListFilter<T, V, R> combine(RangeListFilter<T, V, R> higher, int threshold, V gapEstimate) { Preconditions.checkArgument(rangeList.size() <= threshold); Preconditions.checkArgument(higher.rangeList.size() <= threshold); int cmp = rangeList.get(rangeList.size() - 1).getEnd().compareTo( higher.rangeList.get(0).getStart()); int gapSignum = gapEstimate.isZero() ? 0 : 1; Preconditions.checkArgument((cmp < 0 & gapSignum >= 0) || (cmp == 0 & gapSignum == 0)); int concatenatedListSize = rangeList.size() + higher.rangeList.size() + gapSignum - 1; if (thresholdExceeded || higher.thresholdExceeded || concatenatedListSize > threshold) { if (concatenatedListSize > threshold & !thresholdExceeded & !higher.thresholdExceeded) { logger.log(thresholdExceededLogLevel, "Exceeded threshold {0} with input sizes" + " {1} and {2} and gapEstimate={3}.", new Object[] { threshold, rangeList.size(), higher.rangeList.size(), gapEstimate}); } return new RangeListFilter<T, V, R>(ImmutableList.of(rangeHome.of(rangeList.get(0).getStart(), higher.rangeList.get(higher.rangeList.size() - 1).getEnd())), true, thresholdExceededLogLevel, rangeHome); } List<R> list = new ArrayList<>(concatenatedListSize); if (gapSignum == 0) { list.addAll(rangeList); list.addAll(list.size() - 1, higher.rangeList); R lastLowerFilter = list.remove(list.size() - 1); assert rangeList.get(rangeList.size() - 1) == lastLowerFilter; list.set(rangeList.size() - 1, rangeHome.of(lastLowerFilter.getStart(), higher.rangeList.get(0).getEnd())); } else { list.addAll(rangeList); list.addAll(higher.rangeList); } return new RangeListFilter<T, V, R>( Collections.unmodifiableList(list), false, thresholdExceededLogLevel, rangeHome); } RangeListFilter(List<R> rangeList, boolean thresholdExceeded,
      Level thresholdExceededLogLevel, RangeHome<T, V, R> rangeHome); static Function<R, RangeListFilter<T, V, R>> creator(
      final Level thresholdExceededLogLevel, final RangeHome<T, V, R> rangeHome); RangeListFilter<T, V, R> combine(RangeListFilter<T, V, R> higher, int threshold, V gapEstimate); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); List<R> getRangeList(); R getRange(); boolean isThresholdExceeded(); }
RangeListFilter { public RangeListFilter<T, V, R> combine(RangeListFilter<T, V, R> higher, int threshold, V gapEstimate) { Preconditions.checkArgument(rangeList.size() <= threshold); Preconditions.checkArgument(higher.rangeList.size() <= threshold); int cmp = rangeList.get(rangeList.size() - 1).getEnd().compareTo( higher.rangeList.get(0).getStart()); int gapSignum = gapEstimate.isZero() ? 0 : 1; Preconditions.checkArgument((cmp < 0 & gapSignum >= 0) || (cmp == 0 & gapSignum == 0)); int concatenatedListSize = rangeList.size() + higher.rangeList.size() + gapSignum - 1; if (thresholdExceeded || higher.thresholdExceeded || concatenatedListSize > threshold) { if (concatenatedListSize > threshold & !thresholdExceeded & !higher.thresholdExceeded) { logger.log(thresholdExceededLogLevel, "Exceeded threshold {0} with input sizes" + " {1} and {2} and gapEstimate={3}.", new Object[] { threshold, rangeList.size(), higher.rangeList.size(), gapEstimate}); } return new RangeListFilter<T, V, R>(ImmutableList.of(rangeHome.of(rangeList.get(0).getStart(), higher.rangeList.get(higher.rangeList.size() - 1).getEnd())), true, thresholdExceededLogLevel, rangeHome); } List<R> list = new ArrayList<>(concatenatedListSize); if (gapSignum == 0) { list.addAll(rangeList); list.addAll(list.size() - 1, higher.rangeList); R lastLowerFilter = list.remove(list.size() - 1); assert rangeList.get(rangeList.size() - 1) == lastLowerFilter; list.set(rangeList.size() - 1, rangeHome.of(lastLowerFilter.getStart(), higher.rangeList.get(0).getEnd())); } else { list.addAll(rangeList); list.addAll(higher.rangeList); } return new RangeListFilter<T, V, R>( Collections.unmodifiableList(list), false, thresholdExceededLogLevel, rangeHome); } RangeListFilter(List<R> rangeList, boolean thresholdExceeded,
      Level thresholdExceededLogLevel, RangeHome<T, V, R> rangeHome); static Function<R, RangeListFilter<T, V, R>> creator(
      final Level thresholdExceededLogLevel, final RangeHome<T, V, R> rangeHome); RangeListFilter<T, V, R> combine(RangeListFilter<T, V, R> higher, int threshold, V gapEstimate); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); List<R> getRangeList(); R getRange(); boolean isThresholdExceeded();  }