mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Revert 'Make working with new bytes' and a couple of fixes
This commit is contained in:
@@ -256,12 +256,17 @@ abstract class AbstractChannelReplicator implements Closeable {
|
||||
|
||||
public void closeResources() {
|
||||
isClosed = true;
|
||||
// context.close();
|
||||
executorService.shutdown();
|
||||
|
||||
|
||||
try {
|
||||
executorService.awaitTermination(5, TimeUnit.MILLISECONDS);
|
||||
if (!executorService.awaitTermination(5, TimeUnit.MILLISECONDS)) {
|
||||
executorService.shutdownNow();
|
||||
try {
|
||||
executorService.awaitTermination(10, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("", e);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
executorService.shutdownNow();
|
||||
try {
|
||||
|
||||
@@ -49,7 +49,7 @@ public interface MapAbsentEntry<K, V> extends HashAbsentEntry<K> {
|
||||
* operation are not met
|
||||
* @see MapEntryOperations#insert(MapAbsentEntry, Data)
|
||||
*/
|
||||
void doInsert(Data<V, ?> value);
|
||||
void doInsert(Data<V> value);
|
||||
|
||||
/**
|
||||
* Returns the <i>default</i> (or <i>nil</i>) value, that should be inserted into the map in
|
||||
@@ -63,5 +63,5 @@ public interface MapAbsentEntry<K, V> extends HashAbsentEntry<K> {
|
||||
* @see MapEntryOperations#defaultValue(MapAbsentEntry)
|
||||
*/
|
||||
@NotNull
|
||||
Data<V, ?> defaultValue();
|
||||
Data<V> defaultValue();
|
||||
}
|
||||
|
||||
@@ -55,5 +55,5 @@ public interface MapContext<K, V, R> extends HashContext<K>, MapEntryOperations<
|
||||
* @param value the value object to wrap
|
||||
* @return the value as {@code Data}
|
||||
*/
|
||||
Data<V, ?> wrapValueAsValue(V value);
|
||||
Data<V> wrapValueAsValue(V value);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public interface MapEntry<K, V> extends HashEntry<K> {
|
||||
* Returns the entry value.
|
||||
*/
|
||||
@NotNull
|
||||
Data<V, ?> value();
|
||||
Data<V> value();
|
||||
|
||||
/**
|
||||
* Replaces the entry's value with the given {@code newValue}.
|
||||
@@ -51,7 +51,7 @@ public interface MapEntry<K, V> extends HashEntry<K> {
|
||||
* @throws IllegalStateException if some locking/state conditions required to perform replace
|
||||
* operation are not met
|
||||
*/
|
||||
void doReplaceValue(Data<V, ?> newValue);
|
||||
void doReplaceValue(Data<V> newValue);
|
||||
|
||||
/**
|
||||
* Removes the entry from the map.
|
||||
|
||||
@@ -130,7 +130,7 @@ public interface MapEntryOperations<K, V, R> {
|
||||
* @throws RuntimeException if value replacement was unconditionally unsuccessful due
|
||||
* to any reason
|
||||
*/
|
||||
default R replaceValue(@NotNull MapEntry<K, V> entry, Data<V, ?> newValue) {
|
||||
default R replaceValue(@NotNull MapEntry<K, V> entry, Data<V> newValue) {
|
||||
entry.doReplaceValue(newValue);
|
||||
return null;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public interface MapEntryOperations<K, V, R> {
|
||||
* operation are not met
|
||||
* @throws RuntimeException if insertion was unconditionally unsuccessful due to any reason
|
||||
*/
|
||||
default R insert(@NotNull MapAbsentEntry<K, V> absentEntry, Data<V, ?> value) {
|
||||
default R insert(@NotNull MapAbsentEntry<K, V> absentEntry, Data<V> value) {
|
||||
absentEntry.doInsert(value);
|
||||
return null;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public interface MapEntryOperations<K, V, R> {
|
||||
*
|
||||
* @implNote simply delegates to {@link MapAbsentEntry#defaultValue()}.
|
||||
*/
|
||||
default Data<V, ?> defaultValue(@NotNull MapAbsentEntry<K, V> absentEntry) {
|
||||
default Data<V> defaultValue(@NotNull MapAbsentEntry<K, V> absentEntry) {
|
||||
return absentEntry.defaultValue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public interface MapMethods<K, V, R> {
|
||||
* q.insert(q.absentEntry(), value);
|
||||
* }}</pre>
|
||||
*/
|
||||
default void put(MapQueryContext<K, V, R> q, Data<V, ?> value, ReturnValue<V> returnValue) {
|
||||
default void put(MapQueryContext<K, V, R> q, Data<V> value, ReturnValue<V> returnValue) {
|
||||
// We cannot read the previous value under read lock, because then we will need
|
||||
// to release the read lock -> acquire write lock, the value might be updated in
|
||||
// between, that will break ConcurrentMap.put() atomicity guarantee. So, we acquire
|
||||
@@ -108,7 +108,7 @@ public interface MapMethods<K, V, R> {
|
||||
* }</pre>
|
||||
*/
|
||||
default void putIfAbsent(MapQueryContext<K, V, R> q,
|
||||
Data<V, ?> value, ReturnValue<V> returnValue) {
|
||||
Data<V> value, ReturnValue<V> returnValue) {
|
||||
if (tryReturnCurrentValueIfPresent(q, returnValue))
|
||||
return;
|
||||
// Key is absent
|
||||
@@ -234,7 +234,7 @@ public interface MapMethods<K, V, R> {
|
||||
*
|
||||
* @return if the entry was removed
|
||||
*/
|
||||
default boolean remove(MapQueryContext<K, V, R> q, Data<V, ?> value) {
|
||||
default boolean remove(MapQueryContext<K, V, R> q, Data<V> value) {
|
||||
// remove(key, value) should find the entry & remove most of the time,
|
||||
// so don't try to check key presence and value equivalence under read lock first,
|
||||
// as in putIfAbsent()/acquireUsing(), start with update lock:
|
||||
@@ -263,7 +263,7 @@ public interface MapMethods<K, V, R> {
|
||||
* }}</pre>
|
||||
*/
|
||||
default void replace(MapQueryContext<K, V, R> q,
|
||||
Data<V, ?> value, ReturnValue<V> returnValue) {
|
||||
Data<V> value, ReturnValue<V> returnValue) {
|
||||
// replace(key, value) should find the key & put the value most of the time,
|
||||
// so don't try to check key presence under read lock first,
|
||||
// as in putIfAbsent()/acquireUsing(), start with update lock:
|
||||
@@ -294,7 +294,7 @@ public interface MapMethods<K, V, R> {
|
||||
* @return if the entry was replaced
|
||||
*/
|
||||
default boolean replace(MapQueryContext<K, V, R> q,
|
||||
Data<V, ?> oldValue, Data<V, ?> newValue) {
|
||||
Data<V> oldValue, Data<V> newValue) {
|
||||
// replace(key, old, new) should find the entry & put new value most of the time,
|
||||
// so don't try to check key presence and value equivalence under read lock first,
|
||||
// as in putIfAbsent()/acquireUsing(), start with update lock:
|
||||
@@ -337,7 +337,7 @@ public interface MapMethods<K, V, R> {
|
||||
V oldValue = entry != null ? entry.value().get() : null;
|
||||
V newValue = remappingFunction.apply(q.queriedKey().get(), oldValue);
|
||||
if (newValue != null) {
|
||||
Data<V, ?> newValueData = q.wrapValueAsValue(newValue);
|
||||
Data<V> newValueData = q.wrapValueAsValue(newValue);
|
||||
if (entry != null) {
|
||||
q.replaceValue(entry, newValueData);
|
||||
} else {
|
||||
@@ -409,11 +409,11 @@ public interface MapMethods<K, V, R> {
|
||||
* returnValue.returnValue(entry.value());
|
||||
* }</pre>
|
||||
*/
|
||||
default void merge(MapQueryContext<K, V, R> q, Data<V, ?> value,
|
||||
default void merge(MapQueryContext<K, V, R> q, Data<V> value,
|
||||
BiFunction<? super V, ? super V, ? extends V> remappingFunction,
|
||||
ReturnValue<V> returnValue) {
|
||||
q.updateLock().lock();
|
||||
Data<V, ?> newValueData;
|
||||
Data<V> newValueData;
|
||||
MapEntry<K, V> entry = q.entry();
|
||||
if (entry != null) {
|
||||
V oldValue = entry.value().get();
|
||||
|
||||
@@ -22,5 +22,5 @@ import net.openhft.chronicle.hash.Data;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface ReturnValue<V> {
|
||||
void returnValue(@NotNull Data<V, ?> value);
|
||||
void returnValue(@NotNull Data<V> value);
|
||||
}
|
||||
|
||||
@@ -555,7 +555,7 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ExternalMapQueryContext<K, V, ?> queryContext(Data<K, ?> key) {
|
||||
public ExternalMapQueryContext<K, V, ?> queryContext(Data<K> key) {
|
||||
throw new UnsupportedOperationException("Contexts are not supported by stateless clients");
|
||||
}
|
||||
|
||||
|
||||
@@ -171,18 +171,18 @@ public class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super
|
||||
}
|
||||
|
||||
void initQueryContext() {
|
||||
queryCxt = new ThreadLocal<CompiledMapQueryContext<K, KI, MKI, V, VI, MVI, R, ?>>() {
|
||||
queryCxt = new ThreadLocal<CompiledMapQueryContext<K, KI, MKI, V, VI, MVI, R>>() {
|
||||
@Override
|
||||
protected CompiledMapQueryContext<K, KI, MKI, V, VI, MVI, R, ?> initialValue() {
|
||||
protected CompiledMapQueryContext<K, KI, MKI, V, VI, MVI, R> initialValue() {
|
||||
return new CompiledMapQueryContext<>(VanillaChronicleMap.this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void initIterationContext() {
|
||||
iterCxt = new ThreadLocal<CompiledMapIterationContext<K, KI, MKI, V, VI, MVI, R, ?>>() {
|
||||
iterCxt = new ThreadLocal<CompiledMapIterationContext<K, KI, MKI, V, VI, MVI, R>>() {
|
||||
@Override
|
||||
protected CompiledMapIterationContext<K, KI, MKI, V, VI, MVI, R, ?> initialValue() {
|
||||
protected CompiledMapIterationContext<K, KI, MKI, V, VI, MVI, R> initialValue() {
|
||||
return new CompiledMapIterationContext<>(VanillaChronicleMap.this);
|
||||
}
|
||||
};
|
||||
@@ -335,23 +335,23 @@ public class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super
|
||||
return valueSize;
|
||||
}
|
||||
|
||||
private CompiledMapQueryContext<K, KI, MKI, V, VI, MVI, R, ?> q() {
|
||||
return (CompiledMapQueryContext<K, KI, MKI, V, VI, MVI, R, ?>) queryCxt.get();
|
||||
private CompiledMapQueryContext<K, KI, MKI, V, VI, MVI, R> q() {
|
||||
return (CompiledMapQueryContext<K, KI, MKI, V, VI, MVI, R>) queryCxt.get();
|
||||
}
|
||||
|
||||
public QueryContextInterface<K, V, R> mapContext() {
|
||||
CompiledMapQueryContext<K, KI, MKI, V, VI, MVI, R, ?> q = q().getContext();
|
||||
CompiledMapQueryContext<K, KI, MKI, V, VI, MVI, R> q = q().getContext();
|
||||
q.initUsed(true);
|
||||
return q;
|
||||
}
|
||||
|
||||
private CompiledMapIterationContext<K, KI, MKI, V, VI, MVI, R, ?> i() {
|
||||
return (CompiledMapIterationContext<K, KI, MKI, V, VI, MVI, R, ?>) iterCxt.get();
|
||||
private CompiledMapIterationContext<K, KI, MKI, V, VI, MVI, R> i() {
|
||||
return (CompiledMapIterationContext<K, KI, MKI, V, VI, MVI, R>) iterCxt.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IterationContextInterface<K, V> iterationContext() {
|
||||
CompiledMapIterationContext<K, KI, MKI, V, VI, MVI, R, ?> c = i().getContext();
|
||||
CompiledMapIterationContext<K, KI, MKI, V, VI, MVI, R> c = i().getContext();
|
||||
c.initUsed(true);
|
||||
return c;
|
||||
}
|
||||
@@ -368,7 +368,7 @@ public class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public QueryContextInterface<K, V, R> queryContext(Data<K, ?> key) {
|
||||
public QueryContextInterface<K, V, R> queryContext(Data<K> key) {
|
||||
QueryContextInterface<K, V, R> q = mapContext();
|
||||
q.initInputKey(key);
|
||||
return q;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+1219
-1269
File diff suppressed because it is too large
Load Diff
+2040
-2086
File diff suppressed because it is too large
Load Diff
@@ -6,19 +6,19 @@ import net.openhft.chronicle.map.ExternalMapQueryContext;
|
||||
import net.openhft.chronicle.map.MapKeyContext;
|
||||
import net.openhft.chronicle.map.impl.ret.InstanceReturnValue;
|
||||
import net.openhft.chronicle.map.impl.ret.UsableReturnValue;
|
||||
import net.openhft.chronicle.map.impl.value.instance.ValueInitableData;
|
||||
import net.openhft.chronicle.map.impl.data.instance.ValueInitableData;
|
||||
|
||||
public interface QueryContextInterface<K, V, R> extends ExternalMapQueryContext<K, V, R> {
|
||||
|
||||
void initInputKey(Data<K, ?> inputKey);
|
||||
void initInputKey(Data<K> inputKey);
|
||||
|
||||
KeyInitableData<K, ?> inputKeyInstanceValue();
|
||||
KeyInitableData<K> inputKeyInstanceValue();
|
||||
|
||||
InstanceReturnValue<V> defaultReturnValue();
|
||||
|
||||
UsableReturnValue<V> usingReturnValue();
|
||||
|
||||
ValueInitableData<V, ?> inputValueInstanceValue();
|
||||
ValueInitableData<V> inputValueInstanceValue();
|
||||
|
||||
MapKeyContext<K, V> deprecatedMapKeyContext();
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.openhft.chronicle.map.impl.data.instance;
|
||||
|
||||
import net.openhft.chronicle.hash.Data;
|
||||
|
||||
public interface ValueInitableData<V> extends Data<V> {
|
||||
|
||||
void initValue(V value);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package net.openhft.chronicle.map.impl.value.instance;
|
||||
|
||||
import net.openhft.chronicle.hash.Data;
|
||||
|
||||
public interface ValueInitableData<V, T> extends Data<V, T> {
|
||||
|
||||
void initValue(V value);
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public interface MapRemoteOperations<K, V, R> {
|
||||
* @param q the remote operation context
|
||||
* @param newValue the new value to put
|
||||
*/
|
||||
default void put(MapRemoteQueryContext<K, V, R> q, Data<V, ?> newValue) {
|
||||
default void put(MapRemoteQueryContext<K, V, R> q, Data<V> newValue) {
|
||||
MapReplicableEntry<K, V> entry = q.entry();
|
||||
if (entry != null) {
|
||||
if (decideOnRemoteModification(entry, q) == ACCEPT) {
|
||||
|
||||
@@ -20,7 +20,6 @@ package net.openhft.chronicle.map.replication;
|
||||
|
||||
import net.openhft.chronicle.hash.Data;
|
||||
import net.openhft.chronicle.hash.replication.HashRemoteQueryContext;
|
||||
import net.openhft.chronicle.hash.replication.RemoteOperationContext;
|
||||
import net.openhft.chronicle.hash.serialization.SizeMarshaller;
|
||||
import net.openhft.chronicle.map.ChronicleMap;
|
||||
import net.openhft.chronicle.map.ChronicleMapBuilder;
|
||||
@@ -54,5 +53,5 @@ public interface MapRemoteQueryContext<K, V, R> extends MapQueryContext<K, V, R>
|
||||
*
|
||||
* @return dummy value of all zeros, of the minimum possible size.
|
||||
*/
|
||||
Data<V, ?> dummyZeroValue();
|
||||
Data<V> dummyZeroValue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user