mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Move HashSplitting.Splitting.forSegments() method to HashSplitting interface, because interfaces could contain static methods since Java 8
This commit is contained in:
@@ -27,20 +27,18 @@ import static net.openhft.chronicle.core.Maths.isPowerOf2;
|
||||
|
||||
public interface HashSplitting extends Marshallable {
|
||||
|
||||
static HashSplitting forSegments(int segments) {
|
||||
assert segments > 0;
|
||||
if (segments == 1)
|
||||
return ForSingleSegment.INSTANCE;
|
||||
if (isPowerOf2(segments))
|
||||
return new ForPowerOf2Segments(segments);
|
||||
return new ForNonPowerOf2Segments(segments);
|
||||
}
|
||||
|
||||
int segmentIndex(long hash);
|
||||
long segmentHash(long hash);
|
||||
|
||||
class Splitting {
|
||||
static HashSplitting forSegments(int segments) {
|
||||
assert segments > 0;
|
||||
if (segments == 1)
|
||||
return ForSingleSegment.INSTANCE;
|
||||
if (isPowerOf2(segments))
|
||||
return new ForPowerOf2Segments(segments);
|
||||
return new ForNonPowerOf2Segments(segments);
|
||||
}
|
||||
}
|
||||
|
||||
enum ForSingleSegment implements HashSplitting, EnumMarshallable<ForSingleSegment> {
|
||||
INSTANCE;
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ public abstract class VanillaChronicleHash<K,
|
||||
keyDataAccess = keyBuilder.dataAccess();
|
||||
|
||||
actualSegments = privateAPI.actualSegments();
|
||||
hashSplitting = HashSplitting.Splitting.forSegments(actualSegments);
|
||||
hashSplitting = HashSplitting.forSegments(actualSegments);
|
||||
|
||||
chunkSize = privateAPI.chunkSize();
|
||||
maxChunksPerEntry = privateAPI.maxChunksPerEntry();
|
||||
|
||||
Reference in New Issue
Block a user