mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Cody tidy and optimise the tracing code.
This commit is contained in:
@@ -163,7 +163,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public void initTransients() {
|
||||
throwExceptionIfClosed();
|
||||
super.initTransients();
|
||||
|
||||
super.initTransients();
|
||||
initOwnTransients();
|
||||
}
|
||||
|
||||
@@ -171,7 +172,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
ChronicleHashResources resources, ChronicleHashCorruption.Listener corruptionListener,
|
||||
ChronicleHashCorruptionImpl corruption) throws IOException {
|
||||
throwExceptionIfClosed();
|
||||
basicRecover(resources, corruptionListener, corruption);
|
||||
|
||||
basicRecover(resources, corruptionListener, corruption);
|
||||
try (IterationContext<K, V, ?> iterationContext = iterationContext()) {
|
||||
iterationContext.recoverSegments(corruptionListener, corruption);
|
||||
}
|
||||
@@ -216,25 +218,29 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public Class<K> keyClass() {
|
||||
throwExceptionIfClosed();
|
||||
return (Class<K>) keyClass;
|
||||
|
||||
return (Class<K>) keyClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type keyType() {
|
||||
throwExceptionIfClosed();
|
||||
return keyClass;
|
||||
|
||||
return keyClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<V> valueClass() {
|
||||
throwExceptionIfClosed();
|
||||
return (Class<V>) valueClass;
|
||||
|
||||
return (Class<V>) valueClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type valueType() {
|
||||
throwExceptionIfClosed();
|
||||
return valueClass;
|
||||
|
||||
return valueClass;
|
||||
}
|
||||
|
||||
private long tiersUsed() {
|
||||
@@ -248,14 +254,15 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public int remainingAutoResizes() {
|
||||
throwExceptionIfClosed();
|
||||
return (int) (maxTiers() - tiersUsed());
|
||||
|
||||
return (int) (maxTiers() - tiersUsed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public short percentageFreeSpace() {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
double totalUsed = 0;
|
||||
double totalUsed = 0;
|
||||
double totalSize = 0;
|
||||
|
||||
try (IterationContext<K, V, ?> c = iterationContext()) {
|
||||
@@ -320,13 +327,15 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public int hashCode() {
|
||||
throwExceptionIfClosed();
|
||||
return mapHashCode();
|
||||
|
||||
return mapHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
throwExceptionIfClosed();
|
||||
return mapEquals(obj);
|
||||
|
||||
return mapEquals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -342,7 +351,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public String toIdentityString() {
|
||||
throwExceptionIfClosed();
|
||||
if (identityString == null)
|
||||
|
||||
if (identityString == null)
|
||||
identityString = makeIdentityString();
|
||||
return identityString;
|
||||
}
|
||||
@@ -360,7 +370,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public void clear() {
|
||||
throwExceptionIfClosed();
|
||||
forEachEntry(c -> c.context().remove(c));
|
||||
|
||||
forEachEntry(c -> c.context().remove(c));
|
||||
}
|
||||
|
||||
public final long readValueSize(Bytes entry) {
|
||||
@@ -371,7 +382,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
|
||||
public void alignReadPosition(Bytes entry) {
|
||||
throwExceptionIfClosed();
|
||||
long positionAddr = entry.addressForRead(entry.readPosition());
|
||||
|
||||
long positionAddr = entry.addressForRead(entry.readPosition());
|
||||
long skip = alignAddr(positionAddr, alignment) - positionAddr;
|
||||
if (skip > 0)
|
||||
entry.readSkip(skip);
|
||||
@@ -535,7 +547,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public V get(Object key) {
|
||||
throwExceptionIfClosed();
|
||||
return defaultEntryOperationsAndMethods ? optimizedGet(key, null) : defaultGet(key);
|
||||
|
||||
return defaultEntryOperationsAndMethods ? optimizedGet(key, null) : defaultGet(key);
|
||||
}
|
||||
|
||||
final V defaultGet(Object key) {
|
||||
@@ -709,7 +722,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public V getUsing(K key, V usingValue) {
|
||||
throwExceptionIfClosed();
|
||||
return defaultEntryOperationsAndMethods ? optimizedGet(key, usingValue) :
|
||||
|
||||
return defaultEntryOperationsAndMethods ? optimizedGet(key, usingValue) :
|
||||
defaultGetUsing(key, usingValue);
|
||||
}
|
||||
|
||||
@@ -724,7 +738,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public V acquireUsing(K key, V usingValue) {
|
||||
throwExceptionIfClosed();
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
return acquireUsingBody(q, usingValue);
|
||||
}
|
||||
}
|
||||
@@ -738,7 +753,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public V putIfAbsent(K key, V value) {
|
||||
throwExceptionIfClosed();
|
||||
checkValue(value);
|
||||
|
||||
checkValue(value);
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
methods.putIfAbsent(q, q.inputValueDataAccess().getData(value), q.defaultReturnValue());
|
||||
return q.defaultReturnValue().returnValue();
|
||||
@@ -748,7 +764,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public boolean remove(Object key, Object value) {
|
||||
throwExceptionIfClosed();
|
||||
if (value == null)
|
||||
|
||||
if (value == null)
|
||||
return false; // ConcurrentHashMap compatibility
|
||||
V v = checkValue(value);
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
@@ -759,7 +776,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public boolean replace(K key, V oldValue, V newValue) {
|
||||
throwExceptionIfClosed();
|
||||
checkValue(oldValue);
|
||||
|
||||
checkValue(oldValue);
|
||||
checkValue(newValue);
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
return methods.replace(
|
||||
@@ -770,7 +788,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public V replace(K key, V value) {
|
||||
throwExceptionIfClosed();
|
||||
checkValue(value);
|
||||
|
||||
checkValue(value);
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
methods.replace(q, q.inputValueDataAccess().getData(value), q.defaultReturnValue());
|
||||
return q.defaultReturnValue().returnValue();
|
||||
@@ -780,7 +799,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
throwExceptionIfClosed();
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
return methods.containsKey(q);
|
||||
}
|
||||
}
|
||||
@@ -788,7 +808,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
throwExceptionIfClosed();
|
||||
checkValue(value);
|
||||
|
||||
checkValue(value);
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
Data<V> valueData = q.inputValueDataAccess().getData(value);
|
||||
InstanceReturnValue<V> returnValue =
|
||||
@@ -801,7 +822,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
throwExceptionIfClosed();
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
InstanceReturnValue<V> returnValue =
|
||||
removeReturnsNull ? NullReturnValue.get() : q.defaultReturnValue();
|
||||
methods.remove(q, returnValue);
|
||||
@@ -813,7 +835,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
public V merge(K key, V value,
|
||||
BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
|
||||
throwExceptionIfClosed();
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
methods.merge(q, q.inputValueDataAccess().getData(value), remappingFunction,
|
||||
q.defaultReturnValue());
|
||||
return q.defaultReturnValue().returnValue();
|
||||
@@ -823,7 +846,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
|
||||
throwExceptionIfClosed();
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
methods.compute(q, remappingFunction, q.defaultReturnValue());
|
||||
return q.defaultReturnValue().returnValue();
|
||||
}
|
||||
@@ -832,7 +856,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
@Override
|
||||
public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
|
||||
throwExceptionIfClosed();
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
methods.computeIfAbsent(q, mappingFunction, q.defaultReturnValue());
|
||||
return q.defaultReturnValue().returnValue();
|
||||
}
|
||||
@@ -842,7 +867,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
public V computeIfPresent(K key,
|
||||
BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
|
||||
throwExceptionIfClosed();
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
|
||||
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
|
||||
methods.computeIfPresent(q, remappingFunction, q.defaultReturnValue());
|
||||
return q.defaultReturnValue().returnValue();
|
||||
}
|
||||
@@ -850,7 +876,8 @@ public class VanillaChronicleMap<K, V, R>
|
||||
|
||||
public void verifyTierCountersAreaData() {
|
||||
throwExceptionIfClosed();
|
||||
for (int i = 0; i < actualSegments; i++) {
|
||||
|
||||
for (int i = 0; i < actualSegments; i++) {
|
||||
try (MapSegmentContext<K, V, ?> c = segmentContext(i)) {
|
||||
Method verifyTierCountersAreaData =
|
||||
c.getClass().getMethod("verifyTierCountersAreaData");
|
||||
|
||||
Reference in New Issue
Block a user