
io.timeandspace.smoothie.PoorHashCodeDistributionOccasion Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smoothie-map Show documentation
Show all versions of smoothie-map Show documentation
Map implementation with low footprint and no latency spikes
The newest version!
/* if Tracking hashCodeDistribution */
/*
* Copyright (C) The SmoothieMap Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.timeandspace.smoothie;
import io.timeandspace.collect.Equivalence;
import io.timeandspace.collect.map.KeyValue;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.function.ToLongFunction;
import static io.timeandspace.smoothie.Utils.verifyNonNull;
/**
* An event object representing a poor hash code distribution occasion in some SmoothieMap. It is
* passed into a callback provided via {@link SmoothieMapBuilder#reportPoorHashCodeDistribution} for
* monitoring.
*
* It's possible to remove entries from the iterator of the iterable returned from {@link
* #getEntries()} method (if present) to actively protect against malicious key flooding (hash DoS
* attack).
*
* @param the map key type
* @param the map value type
* @see SmoothieMapBuilder#reportPoorHashCodeDistribution
*/
public final class PoorHashCodeDistributionOccasion {
enum Type {
TOO_LARGE_INFLATED_SEGMENT,
TOO_MANY_SKEWED_SEGMENT_SPLITS
}
private final Type type;
private final SmoothieMap map;
private final String message;
private final Supplier
© 2015 - 2025 Weber Informatics LLC | Privacy Policy