diff --git a/src/main/java/net/openhft/chronicle/hash/ChronicleHash.java b/src/main/java/net/openhft/chronicle/hash/ChronicleHash.java index 6e633fc8e..9aa567076 100644 --- a/src/main/java/net/openhft/chronicle/hash/ChronicleHash.java +++ b/src/main/java/net/openhft/chronicle/hash/ChronicleHash.java @@ -48,12 +48,6 @@ public interface ChronicleHash, EQC extends ExternalH long longSize(); - /** - * @deprecated use {@link #queryContext} instead - */ - @Deprecated - C context(K key); - /** * @return the class of {@code } */ diff --git a/src/main/java/net/openhft/chronicle/map/AbstractChronicleMap.java b/src/main/java/net/openhft/chronicle/map/AbstractChronicleMap.java index 6787259e9..dc7f9e481 100644 --- a/src/main/java/net/openhft/chronicle/map/AbstractChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/AbstractChronicleMap.java @@ -37,22 +37,24 @@ interface AbstractChronicleMap extends ChronicleMap, Serializable { @Override default R getMapped(K key, @NotNull SerializableFunction function) { requireNonNull(function); - try (MapKeyContext c = context(key)) { - return c.containsKey() ? function.apply(c.get()) : null; + try (ExternalMapQueryContext c = queryContext(key)) { + MapEntry entry = c.entry(); + return entry != null ? function.apply(entry.value().get()) : null; } } @Override default V putMapped(K key, @NotNull UnaryOperator unaryOperator) { requireNonNull(unaryOperator); - try (MapKeyContext c = context(key)) { + try (ExternalMapQueryContext c = queryContext(key)) { // putMapped() should find a value, update & put most of the time, // so don't try to check key presence under read lock first, // as in putIfAbsent()/acquireUsing(), start with update lock: c.updateLock().lock(); - if (c.containsKey()) { - V newValue = unaryOperator.update(c.get()); - c.put(newValue); + MapEntry entry = c.entry(); + if (entry != null) { + V newValue = unaryOperator.update(entry.value().get()); + c.replaceValue(entry, c.wrapValueAsData(newValue)); return newValue; } else { return null; diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ChronicleMap.java index 59f5e33a4..bbd8545b8 100755 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMap.java @@ -19,7 +19,6 @@ package net.openhft.chronicle.map; import net.openhft.chronicle.hash.ChronicleHash; -import net.openhft.chronicle.hash.ExternalHashQueryContext; import net.openhft.chronicle.hash.function.SerializableFunction; import net.openhft.chronicle.hash.serialization.BytesReader; import net.openhft.lang.io.Bytes; @@ -34,8 +33,6 @@ import java.io.Serializable; import java.lang.Object; import java.util.Map; import java.util.concurrent.ConcurrentMap; -import java.util.function.Consumer; -import java.util.function.Predicate; /** * Extension of {@link ConcurrentMap} interface, stores the data off-heap. @@ -142,13 +139,8 @@ public interface ChronicleMap */ V acquireUsing(@NotNull K key, V usingValue); - /** - * @deprecated this method has incoherent, unclear semantics. Use {@link #queryContext(Object)} - * instead - */ - @Deprecated @NotNull - MapKeyContext acquireContext(@NotNull K key, @NotNull V usingValue); + net.openhft.chronicle.core.io.Closeable acquireContext(@NotNull K key, @NotNull V usingValue); /** * Apply a mapping to the value returned by a key and return a result. A read lock is assumed. @@ -208,7 +200,7 @@ public interface ChronicleMap * * {@link ChronicleMap#getUsing(Object, Object) } * {@link ChronicleMap#acquireUsing(Object, Object) } - * {@link ChronicleMap#acquireContext(Object, Object) } + * {@link ChronicleMap#acquireContext(Object, Object)} * * for example like this : * @@ -232,8 +224,8 @@ public interface ChronicleMap * following methods : * * {@link ChronicleMap#getUsing(Object, Object) } - * {@link ChronicleMap#acquireUsing(Object, Object) } - * {@link ChronicleMap#acquireContext(Object, Object) } + * {@link ChronicleMap#acquireUsing(Object, Object)} + * {@link ChronicleMap#acquireContext(Object, Object)} * * for example like this : * diff --git a/src/main/java/net/openhft/chronicle/map/ReplicationHubFindByName.java b/src/main/java/net/openhft/chronicle/map/ReplicationHubFindByName.java index c932b8f55..e26aa5084 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicationHubFindByName.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicationHubFindByName.java @@ -70,12 +70,20 @@ class ReplicationHubFindByName implements FindByName { int withChannelId = nextFreeChannel.incrementAndGet(); - try (MapKeyContext c = map.context(config.name)) { + try (ExternalMapQueryContext c = + map.queryContext(config.name)) { c.updateLock().lock(); MapInstanceBuilder value = config.replicatedViaChannel(replicationHub.createChannel(withChannelId)); - boolean added = !c.containsKey(); - c.put(value); + boolean added; + MapEntry entry = c.entry(); + if (entry != null) { + c.replaceValue(entry, c.wrapValueAsData(value)); + added = false; + } else { + c.insert(c.absentEntry(), c.wrapValueAsData(value)); + added = true; + } if (added) { // establish the new map based on this channel ID diff --git a/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java b/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java index 5975cfceb..3d6feeec5 100644 --- a/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java @@ -542,11 +542,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon return fetchLong(LONG_SIZE); } - @Override - public MapKeyContext context(K key) { - throw new UnsupportedOperationException("Contexts are not supported by stateless clients"); - } - @NotNull @Override public ExternalMapQueryContext queryContext(K key) { @@ -598,7 +593,7 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon @NotNull @Override - public MapKeyContext acquireContext(@NotNull K key, @NotNull V usingValue) { + public net.openhft.chronicle.core.io.Closeable acquireContext(@NotNull K key, @NotNull V usingValue) { throw new UnsupportedOperationException("Contexts are not supported by stateless clients"); } diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index f34995c24..c5d24879b 100755 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -18,6 +18,7 @@ package net.openhft.chronicle.map; +import net.openhft.chronicle.core.io.Closeable; import net.openhft.chronicle.hash.Data; import net.openhft.chronicle.hash.KeyContext; import net.openhft.chronicle.hash.impl.VanillaChronicleHash; @@ -203,11 +204,6 @@ public class VanillaChronicleMap context(K key) { - return queryContext(key).deprecatedMapKeyContext(); - } - @Override public int actualSegments() { return actualSegments; @@ -279,16 +275,15 @@ public class VanillaChronicleMap acquireContext(K key, V usingValue) { + public final Closeable acquireContext(@NotNull K key, @NotNull V usingValue) { QueryContextInterface q = queryContext(key); // TODO optimize to update lock in certain cases try { q.writeLock().lock(); acquireUsingBody(q, usingValue); - return q.deprecatedMapAcquireContext(); + return q.acquireHandle(); } catch (Throwable e) { try { q.close(); @@ -298,7 +293,7 @@ public class VanillaChronicleMap void checkAcquiredUsing(V acquired, V using) { if (acquired != using) { throw new IllegalArgumentException("acquire*() MUST reuse the given " + @@ -348,7 +343,7 @@ public class VanillaChronicleMap i() { return (CompiledMapIterationContext) iterCxt.get(); } diff --git a/src/main/java/net/openhft/chronicle/map/WriteThroughEntry.java b/src/main/java/net/openhft/chronicle/map/WriteThroughEntry.java index 7a1083cfd..175e92ce2 100644 --- a/src/main/java/net/openhft/chronicle/map/WriteThroughEntry.java +++ b/src/main/java/net/openhft/chronicle/map/WriteThroughEntry.java @@ -30,9 +30,7 @@ class WriteThroughEntry extends AbstractMap.SimpleEntry { @Override public V setValue(V value) { - try (MapKeyContext c = map.context(getKey())) { - c.put(value); - } + map.put(getKey(), value); return super.setValue(value); } } diff --git a/src/main/java/net/openhft/chronicle/map/impl/MapQueryContext.java b/src/main/java/net/openhft/chronicle/map/impl/MapQueryContext.java index 3365306f5..cdc1e0f80 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/MapQueryContext.java +++ b/src/main/java/net/openhft/chronicle/map/impl/MapQueryContext.java @@ -96,7 +96,7 @@ nested = { WrappedValueInstanceData.class, DeprecatedMapKeyContextOnQuery.class, - DeprecatedMapAcquireContextOnQuery.class, + AcquireHandle.class, DefaultReturnValue.class, UsingReturnValue.class, }) diff --git a/src/main/java/net/openhft/chronicle/map/impl/QueryContextInterface.java b/src/main/java/net/openhft/chronicle/map/impl/QueryContextInterface.java index 6fff8179e..0f957361d 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/QueryContextInterface.java +++ b/src/main/java/net/openhft/chronicle/map/impl/QueryContextInterface.java @@ -1,12 +1,13 @@ package net.openhft.chronicle.map.impl; +import net.openhft.chronicle.core.io.Closeable; import net.openhft.chronicle.hash.Data; import net.openhft.chronicle.hash.impl.value.instance.KeyInitableData; 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.data.instance.ValueInitableData; +import net.openhft.chronicle.map.impl.data.instance.ValueInitializableData; public interface QueryContextInterface extends ExternalMapQueryContext { @@ -18,11 +19,11 @@ public interface QueryContextInterface extends ExternalMapQueryContext< UsableReturnValue usingReturnValue(); - ValueInitableData inputValueInstanceValue(); + ValueInitializableData inputValueInstanceValue(); MapKeyContext deprecatedMapKeyContext(); - - MapKeyContext deprecatedMapAcquireContext(); + + Closeable acquireHandle(); void initTheSegmentIndex(int segmentIndex); diff --git a/src/main/java/net/openhft/chronicle/map/impl/ReplicatedMapQueryContext.java b/src/main/java/net/openhft/chronicle/map/impl/ReplicatedMapQueryContext.java index 595972ea8..4a2c3561a 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/ReplicatedMapQueryContext.java +++ b/src/main/java/net/openhft/chronicle/map/impl/ReplicatedMapQueryContext.java @@ -38,7 +38,6 @@ import net.openhft.chronicle.map.impl.stage.data.DummyValueZeroData; import net.openhft.chronicle.map.impl.stage.data.bytes.*; import net.openhft.chronicle.map.impl.stage.data.instance.InputValueInstanceData; import net.openhft.chronicle.map.impl.stage.data.instance.WrappedValueInstanceData; -import net.openhft.chronicle.map.impl.stage.entry.MapEntryStages; import net.openhft.chronicle.map.impl.stage.entry.ReplicatedMapEntryStages; import net.openhft.chronicle.map.impl.stage.input.MapInputBytesValues; import net.openhft.chronicle.map.impl.stage.input.ReplicatedInput; @@ -102,7 +101,7 @@ nested = { WrappedValueInstanceData.class, DeprecatedMapKeyContextOnQuery.class, - DeprecatedMapAcquireContextOnQuery.class, + AcquireHandle.class, DefaultReturnValue.class, UsingReturnValue.class, diff --git a/src/main/java/net/openhft/chronicle/map/impl/data/instance/ValueInitableData.java b/src/main/java/net/openhft/chronicle/map/impl/data/instance/ValueInitializableData.java similarity index 68% rename from src/main/java/net/openhft/chronicle/map/impl/data/instance/ValueInitableData.java rename to src/main/java/net/openhft/chronicle/map/impl/data/instance/ValueInitializableData.java index 10990223f..744766235 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/data/instance/ValueInitableData.java +++ b/src/main/java/net/openhft/chronicle/map/impl/data/instance/ValueInitializableData.java @@ -2,7 +2,7 @@ package net.openhft.chronicle.map.impl.data.instance; import net.openhft.chronicle.hash.Data; -public interface ValueInitableData extends Data { +public interface ValueInitializableData extends Data { void initValue(V value); } diff --git a/src/main/java/net/openhft/chronicle/map/impl/stage/data/bytes/EntryValueBytesData.java b/src/main/java/net/openhft/chronicle/map/impl/stage/data/bytes/EntryValueBytesData.java index 7a8629ce1..da964a722 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/stage/data/bytes/EntryValueBytesData.java +++ b/src/main/java/net/openhft/chronicle/map/impl/stage/data/bytes/EntryValueBytesData.java @@ -34,7 +34,6 @@ public class EntryValueBytesData extends AbstractData { @StageRef MapEntryStages entry; @StageRef CheckOnEachPublicOperation checkOnEachPublicOperation; - @Stage("CachedEntryValue") private V cachedEntryValue; @Stage("CachedEntryValue") private boolean cachedEntryValueRead = false; diff --git a/src/main/java/net/openhft/chronicle/map/impl/stage/data/instance/InputValueInstanceData.java b/src/main/java/net/openhft/chronicle/map/impl/stage/data/instance/InputValueInstanceData.java index 4b3aaf4bb..4a22856f0 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/stage/data/instance/InputValueInstanceData.java +++ b/src/main/java/net/openhft/chronicle/map/impl/stage/data/instance/InputValueInstanceData.java @@ -20,7 +20,7 @@ package net.openhft.chronicle.map.impl.stage.data.instance; import net.openhft.chronicle.hash.impl.CopyingInstanceData; import net.openhft.chronicle.hash.serialization.internal.MetaBytesInterop; -import net.openhft.chronicle.map.impl.data.instance.ValueInitableData; +import net.openhft.chronicle.map.impl.data.instance.ValueInitializableData; import net.openhft.chronicle.map.impl.stage.map.ValueBytesInterop; import net.openhft.lang.io.DirectBytes; import net.openhft.sg.Stage; @@ -29,7 +29,7 @@ import net.openhft.sg.Staged; @Staged public abstract class InputValueInstanceData> - extends CopyingInstanceData implements ValueInitableData { + extends CopyingInstanceData implements ValueInitializableData { @StageRef ValueBytesInterop vi; diff --git a/src/main/java/net/openhft/chronicle/map/impl/stage/query/AcquireHandle.java b/src/main/java/net/openhft/chronicle/map/impl/stage/query/AcquireHandle.java new file mode 100644 index 000000000..ca468a5fa --- /dev/null +++ b/src/main/java/net/openhft/chronicle/map/impl/stage/query/AcquireHandle.java @@ -0,0 +1,48 @@ +/* + * Copyright 2015 Higher Frequency Trading + * + * http://www.higherfrequencytrading.com + * + * 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 net.openhft.chronicle.map.impl.stage.query; + +import net.openhft.chronicle.core.io.Closeable; +import net.openhft.chronicle.hash.Data; +import net.openhft.chronicle.hash.impl.stage.hash.CheckOnEachPublicOperation; +import net.openhft.chronicle.hash.locks.InterProcessLock; +import net.openhft.chronicle.map.MapEntry; +import net.openhft.chronicle.map.MapKeyContext; +import net.openhft.chronicle.map.impl.stage.entry.MapEntryStages; +import net.openhft.chronicle.map.impl.stage.ret.UsingReturnValue; +import net.openhft.lang.io.Bytes; +import net.openhft.sg.StageRef; +import net.openhft.sg.Staged; +import org.jetbrains.annotations.NotNull; + +@Staged +public class AcquireHandle implements Closeable { + + @StageRef CheckOnEachPublicOperation checkOnEachPublicOperation; + @StageRef MapEntryStages e; + @StageRef MapQuery q; + @StageRef UsingReturnValue usingReturn; + + @Override + public void close() { + checkOnEachPublicOperation.checkOnEachPublicOperation(); + q.replaceValue(q.entry(), q.wrapValueAsData(usingReturn.returnValue())); + q.close(); + } +} diff --git a/src/main/java/net/openhft/chronicle/map/impl/stage/query/DeprecatedMapAcquireContextOnQuery.java b/src/main/java/net/openhft/chronicle/map/impl/stage/query/DeprecatedMapAcquireContextOnQuery.java deleted file mode 100644 index 8575c31a2..000000000 --- a/src/main/java/net/openhft/chronicle/map/impl/stage/query/DeprecatedMapAcquireContextOnQuery.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2015 Higher Frequency Trading - * - * http://www.higherfrequencytrading.com - * - * 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 net.openhft.chronicle.map.impl.stage.query; - -import net.openhft.chronicle.hash.Data; -import net.openhft.chronicle.hash.impl.stage.hash.CheckOnEachPublicOperation; -import net.openhft.chronicle.hash.locks.InterProcessLock; -import net.openhft.chronicle.map.MapEntry; -import net.openhft.chronicle.map.MapKeyContext; -import net.openhft.chronicle.map.impl.stage.entry.MapEntryStages; -import net.openhft.chronicle.map.impl.stage.ret.UsingReturnValue; -import net.openhft.lang.io.Bytes; -import net.openhft.sg.StageRef; -import net.openhft.sg.Staged; -import org.jetbrains.annotations.NotNull; - -@Staged -public class DeprecatedMapAcquireContextOnQuery implements MapKeyContext { - - @StageRef CheckOnEachPublicOperation checkOnEachPublicOperation; - @StageRef MapEntryStages e; - @StageRef MapQuery q; - @StageRef UsingReturnValue usingReturn; - - @Override - public long valueOffset() { - checkOnEachPublicOperation.checkOnEachPublicOperation(); - return e.valueOffset; - } - - @Override - public long valueSize() { - checkOnEachPublicOperation.checkOnEachPublicOperation(); - return e.valueSize; - } - - @Override - public boolean valueEqualTo(V value) { - checkOnEachPublicOperation.checkOnEachPublicOperation(); - return Data.bytesEquivalent(e.entryValue, q.wrapValueAsData(value)); - } - - @Override - public V get() { - assert containsKey(); - return usingReturn.returnValue(); - } - - @Override - public V getUsing(V usingValue) { - return containsKey() ? q.value().getUsing(usingValue) : null; - } - - @Override - public boolean put(V newValue) { - checkOnEachPublicOperation.checkOnEachPublicOperation(); - updateLock().lock(); - MapEntry entry = q.entry(); - if (entry != null) { - q.replaceValue(entry, q.wrapValueAsData(newValue)); - } else { - q.insert(q.absentEntry(), q.wrapValueAsData(newValue)); - } - return true; - } - - @NotNull - @Override - public K key() { - checkOnEachPublicOperation.checkOnEachPublicOperation(); - return q.queriedKey().get(); - } - - @NotNull - @Override - public Bytes entry() { - checkOnEachPublicOperation.checkOnEachPublicOperation(); - return e.entryBytes; - } - - @Override - public long keyOffset() { - checkOnEachPublicOperation.checkOnEachPublicOperation(); - return e.keyOffset; - } - - @Override - public long keySize() { - checkOnEachPublicOperation.checkOnEachPublicOperation(); - return e.keySize; - } - - @Override - public boolean containsKey() { - checkOnEachPublicOperation.checkOnEachPublicOperation(); - return q.entry() != null; - } - - @Override - public boolean remove() { - checkOnEachPublicOperation.checkOnEachPublicOperation(); - updateLock().lock(); - MapEntry entry = q.entry(); - if (entry != null) { - q.remove(entry); - return true; - } else { - return false; - } - } - - @Override - public void close() { - checkOnEachPublicOperation.checkOnEachPublicOperation(); - put(usingReturn.returnValue()); - q.close(); - } - - @NotNull - @Override - public InterProcessLock readLock() { - return q.readLock(); - } - - @NotNull - @Override - public InterProcessLock updateLock() { - return q.updateLock(); - } - - @NotNull - @Override - public InterProcessLock writeLock() { - return q.writeLock(); - } -} diff --git a/src/main/java/net/openhft/chronicle/map/impl/stage/query/MapQuery.java b/src/main/java/net/openhft/chronicle/map/impl/stage/query/MapQuery.java index 5c301ba06..06a362796 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/stage/query/MapQuery.java +++ b/src/main/java/net/openhft/chronicle/map/impl/stage/query/MapQuery.java @@ -50,7 +50,7 @@ public abstract class MapQuery extends HashQuery @StageRef MapEntryStages e; @StageRef SearchAllocatedChunks allocatedChunks; @StageRef public DeprecatedMapKeyContextOnQuery deprecatedMapKeyContext; - @StageRef public DeprecatedMapAcquireContextOnQuery deprecatedMapAcquireContext; + @StageRef public AcquireHandle acquireHandle; @StageRef public InputValueInstanceData inputValueInstanceValue; diff --git a/src/main/java/net/openhft/chronicle/set/SetFromMap.java b/src/main/java/net/openhft/chronicle/set/SetFromMap.java index 64bb56252..56d8d825b 100644 --- a/src/main/java/net/openhft/chronicle/set/SetFromMap.java +++ b/src/main/java/net/openhft/chronicle/set/SetFromMap.java @@ -123,11 +123,6 @@ class SetFromMap extends AbstractSet return m.longSize(); } - @Override - public KeyContext context(E key) { - return m.context(key); - } - @Override public Class keyClass() { return m.keyClass(); diff --git a/src/test/java/eg/TestNesterInterfaceMarshal.java b/src/test/java/eg/TestNesterInterfaceMarshal.java index 6cbf38ff5..c015c0114 100644 --- a/src/test/java/eg/TestNesterInterfaceMarshal.java +++ b/src/test/java/eg/TestNesterInterfaceMarshal.java @@ -1,11 +1,10 @@ package eg; +import net.openhft.chronicle.core.io.Closeable; import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig; import net.openhft.chronicle.map.ChronicleMap; import net.openhft.chronicle.map.ChronicleMapBuilder; -import net.openhft.chronicle.map.MapKeyContext; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import java.net.InetSocketAddress; @@ -51,8 +50,7 @@ public class TestNesterInterfaceMarshal { TestInstrumentVOInterface intrumentVOInterface = map.newValueInstance(); - try (MapKeyContext wc = map.acquireContext - ("KEY1", intrumentVOInterface)) { + try (Closeable c = map.acquireContext("KEY1", intrumentVOInterface)) { intrumentVOInterface.setSymbol("Flyer"); intrumentVOInterface.setCurrencyCode("USA"); intrumentVOInterface.setSizeOfInstrumentIDArray(2); diff --git a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java index 5445c9717..d8f548666 100644 --- a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java +++ b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java @@ -396,7 +396,8 @@ public class CHMUseCasesTest { try (ChronicleMap chm = newInstance(builder)) { BondVOInterface bondVO = chm.newValueInstance(); - try (MapKeyContext wc = chm.acquireContext("369604103", bondVO)) { + try (net.openhft.chronicle.core.io.Closeable c = + chm.acquireContext("369604103", bondVO)) { bondVO.setIssueDate(parseYYYYMMDD("20130915")); bondVO.setMaturityDate(parseYYYYMMDD("20140915")); bondVO.setCoupon(5.0 / 100); // 5.0% @@ -658,7 +659,7 @@ public class CHMUseCasesTest { CharSequence using = map.newValueInstance(); - try (MapKeyContext wc = map.acquireContext("1", using)) { + try (net.openhft.chronicle.core.io.Closeable c = map.acquireContext("1", using)) { assertTrue(using instanceof StringBuilder); ((StringBuilder) using).append("Hello World"); } @@ -679,9 +680,8 @@ public class CHMUseCasesTest { try (ChronicleMap map = newInstance(builder)) { - try (MapKeyContext c = map.context("1")) { - IntValue value = c.get(); - assertNull(value); + try (ExternalMapQueryContext c = map.queryContext("1")) { + assertNull(c.entry()); } assertEquals(null, map.get("1")); @@ -704,7 +704,7 @@ public class CHMUseCasesTest { IntValue using = map.newKeyInstance(); using.setValue(1); - try (MapKeyContext c = map.acquireContext(using, "")) { + try (Closeable c = map.acquireContext(using, "")) { assertTrue(using instanceof IntValue); using.setValue(1); } @@ -731,7 +731,7 @@ public class CHMUseCasesTest { StringBuilder using = map.newValueInstance(); - try (MapKeyContext rc = map.acquireContext(key, using)) { + try (net.openhft.chronicle.core.io.Closeable c = map.acquireContext(key, using)) { using.append("Hello"); } @@ -756,13 +756,13 @@ public class CHMUseCasesTest { CharSequence using = map.newValueInstance(); - try (MapKeyContext rc = map.acquireContext(key, using)) { + try (net.openhft.chronicle.core.io.Closeable c = map.acquireContext(key, using)) { key.setValue(3); ((StringBuilder) using).append("Hello"); } key.setValue(2); - try (MapKeyContext rc = map.acquireContext(key, using)) { + try (net.openhft.chronicle.core.io.Closeable c = map.acquireContext(key, using)) { ((StringBuilder) using).append("World"); } @@ -789,7 +789,7 @@ public class CHMUseCasesTest { ByteBufferBytes value = new ByteBufferBytes(ByteBuffer.allocate(10)); value.limit(0); - try (MapKeyContext rc = map.acquireContext(key, value)) { + try (net.openhft.chronicle.core.io.Closeable c = map.acquireContext(key, value)) { assertTrue(key instanceof IntValue); assertTrue(value instanceof CharSequence); } @@ -831,9 +831,10 @@ public class CHMUseCasesTest { mapChecks(); StringBuilder sb = new StringBuilder(); - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - StringValue v = rc.get(); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + StringValue v = entry.value().get(); assertEquals("11", v.getValue()); v.getUsingValue(sb); assertEquals("11", sb.toString()); @@ -841,9 +842,10 @@ public class CHMUseCasesTest { mapChecks(); - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - StringValue v = rc.get(); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + StringValue v = entry.value().get(); assertEquals("22", v.getValue()); v.getUsingValue(sb); assertEquals("22", sb.toString()); @@ -851,9 +853,10 @@ public class CHMUseCasesTest { mapChecks(); - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - StringValue v = rc.get(); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + StringValue v = entry.value().get(); assertEquals("11", v.getValue()); v.getUsingValue(sb); assertEquals("11", sb.toString()); @@ -861,25 +864,27 @@ public class CHMUseCasesTest { mapChecks(); - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - StringValue v = rc.get(); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + StringValue v = entry.value().get(); assertEquals("22", v.getValue()); v.getUsingValue(sb); assertEquals("22", sb.toString()); } key1.setValue("3"); - try (MapKeyContext rc = map.context(key1)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + assertNotNull(c.absentEntry()); } key2.setValue("4"); - try (MapKeyContext rc = map.context(key2)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + assertNotNull(c.absentEntry()); } - try (MapKeyContext wc = map.acquireContext(key1, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value1)) { assertEquals("", value1.getValue()); value1.getUsingValue(sb); assertEquals("", sb.toString()); @@ -889,7 +894,8 @@ public class CHMUseCasesTest { mapChecks(); - try (MapKeyContext wc = map.acquireContext(key1, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value2)) { assertEquals("123", value2.getValue()); value2.setValue(value2.getValue() + '4'); assertEquals("1234", value2.getValue()); @@ -897,14 +903,16 @@ public class CHMUseCasesTest { mapChecks(); - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals("1234", rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals("1234", entry.value().get().getValue()); } mapChecks(); - try (MapKeyContext wc = map.acquireContext(key2, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value2)) { assertEquals("", value2.getValue()); value2.getUsingValue(sb); assertEquals("", sb.toString()); @@ -914,7 +922,8 @@ public class CHMUseCasesTest { mapChecks(); - try (MapKeyContext wc = map.acquireContext(key2, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value1)) { assertEquals("123", value1.getValue()); value1.setValue(value1.getValue() + '4'); assertEquals("1234", value1.getValue()); @@ -922,9 +931,10 @@ public class CHMUseCasesTest { mapChecks(); - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals("1234", rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals("1234", entry.value().get().getValue()); } mapChecks(); @@ -1250,25 +1260,30 @@ public class CHMUseCasesTest { ByteBuffer valueA = ByteBuffer.allocateDirect(8); ByteBuffer valueB = ByteBuffer.allocate(8); // assertBBEquals(value1, valueA); - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertBBEquals(value1, rc.getUsing(valueA)); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertBBEquals(value1, entry.value().getUsing(valueA)); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertBBEquals(value2, rc.getUsing(valueA)); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertBBEquals(value2, entry.value().getUsing(valueA)); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertBBEquals(value1, rc.getUsing(valueB)); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertBBEquals(value1, entry.value().getUsing(valueB)); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertBBEquals(value2, rc.getUsing(valueB)); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertBBEquals(value2, entry.value().getUsing(valueB)); } - try (MapKeyContext wc = map.acquireContext(key1, valueA)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, valueA)) { assertBBEquals(value1, valueA); appendMode(valueA); valueA.clear(); @@ -1282,21 +1297,23 @@ public class CHMUseCasesTest { value1.flip(); - try (MapKeyContext wc = map.acquireContext(key1, valueB)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, valueB)) { assertBBEquals(value1, valueB); appendMode(valueB); valueB.putShort((short) 12345); valueB.flip(); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); ByteBuffer bb1 = ByteBuffer.allocate(8); bb1.put(value1); bb1.putShort((short) 12345); bb1.flip(); - assertBBEquals(bb1, rc.getUsing(valueA)); + assertBBEquals(bb1, entry.value().getUsing(valueA)); } mapChecks(); @@ -1392,9 +1409,10 @@ public class CHMUseCasesTest { map.put(key2, value2); assertEquals(value2, map.get(key2)); - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } // TODO review -- the previous version of this block: // acquiring for value1, comparing value2 -- as intended? @@ -1402,55 +1420,64 @@ public class CHMUseCasesTest { // assertTrue(rc.present()); // assertEquals(22, value2.getValue()); // } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue()); } key1.setValue(3); - try (MapKeyContext rc = map.context(key1)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + assertNotNull(c.absentEntry()); } key2.setValue(4); - try (MapKeyContext rc = map.context(key2)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + assertNotNull(c.absentEntry()); } - try (MapKeyContext wc = map.acquireContext(key1, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value1)) { assertEquals(0, value1.getValue()); value1.addValue(123); assertEquals(123, value1.getValue()); } - try (MapKeyContext wc = map.acquireContext(key1, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value2)) { assertEquals(123, value2.getValue()); value2.addValue(1230 - 123); assertEquals(1230, value2.getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(1230, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(1230, entry.value().get().getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value2)) { assertEquals(0, value2.getValue()); value2.addValue(123); assertEquals(123, value2.getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value1)) { assertEquals(123, value1.getValue()); value1.addValue(1230 - 123); assertEquals(1230, value1.getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(1230, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(1230, entry.value().get().getValue()); } mapChecks(); @@ -1512,64 +1539,82 @@ public class CHMUseCasesTest { map.put(key2, value2); assertEquals(value2, map.get(key2)); - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue()); + try (ExternalMapQueryContext c = + map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } // TODO review suspicious block // try (ReadContext rc = map.getUsingLocked(key2, value1)) { // assertTrue(rc.present()); // assertEquals(22, value2.getValue()); // } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue()); + try (ExternalMapQueryContext c = + map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue()); + try (ExternalMapQueryContext c = + map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue()); + try (ExternalMapQueryContext c = + map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue()); } key1.setValue(3); - try (MapKeyContext rc = map.context(key1)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = + map.queryContext(key1)) { + assertNotNull(c.absentEntry()); } key2.setValue(4); - try (MapKeyContext rc = map.context(key2)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = + map.queryContext(key2)) { + assertNotNull(c.absentEntry()); } - try (MapKeyContext wc = map.acquireContext(key1, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value1)) { assertEquals(0, value1.getValue()); value1.addValue(123); assertEquals(123, value1.getValue()); } - try (MapKeyContext wc = map.acquireContext(key1, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value2)) { assertEquals(123, value2.getValue()); value2.addValue(1230 - 123); assertEquals(1230, value2.getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(1230, rc.get().getValue()); + try (ExternalMapQueryContext c = + map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(1230, entry.value().get().getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value2)) { assertEquals(0, value2.getValue()); value2.addValue(123); assertEquals(123, value2.getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value1)) { assertEquals(123, value1.getValue()); value1.addValue(1230 - 123); assertEquals(1230, value1.getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(1230, rc.get().getValue()); + try (ExternalMapQueryContext c = + map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(1230, entry.value().get().getValue()); } mapChecks(); } @@ -1609,64 +1654,76 @@ public class CHMUseCasesTest { map.put(key2, value2); assertEquals(value2, map.get(key2)); - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } // TODO the same as above. // try (ReadContext rc = map.getUsingLocked(key2, value1)) { // assertTrue(rc.present()); // assertEquals(22, value2.getValue()); // } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue()); } key1.setValue(3); - try (MapKeyContext rc = map.context(key1)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + assertNotNull(c.absentEntry()); } key2.setValue(4); - try (MapKeyContext rc = map.context(key2)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + assertNotNull(c.absentEntry()); } - try (MapKeyContext wc = map.acquireContext(key1, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value1)) { assertEquals(0, value1.getValue()); value1.addValue((short) 123); assertEquals(123, value1.getValue()); } - try (MapKeyContext wc = map.acquireContext(key1, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value2)) { assertEquals(123, value2.getValue()); value2.addValue((short) (1230 - 123)); assertEquals(1230, value2.getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(1230, rc.get().getValue()); + try (ExternalMapQueryContext c = + map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(1230, entry.value().get().getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value2)) { assertEquals(0, value2.getValue()); value2.addValue((short) 123); assertEquals(123, value2.getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value1)) { assertEquals(123, value1.getValue()); value1.addValue((short) (1230 - 123)); assertEquals(1230, value1.getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(1230, rc.get().getValue()); + try (ExternalMapQueryContext c = + map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(1230, entry.value().get().getValue()); } mapChecks(); } @@ -1706,64 +1763,75 @@ public class CHMUseCasesTest { map.put(key2, value2); assertEquals(value2, map.get(key2)); - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } // TODO the same as above. // try (ReadContext rc = map.getUsingLocked(key2, value1)) { // assertTrue(rc.present()); // assertEquals(22, value2.getValue()); // } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue()); } key1.setValue(3); - try (MapKeyContext rc = map.context(key1)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + assertNotNull(c.absentEntry()); } key2.setValue(4); - try (MapKeyContext rc = map.context(key2)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + assertNotNull(c.absentEntry()); } - try (MapKeyContext wc = map.acquireContext(key1, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value1)) { assertEquals(0, value1.getValue()); value1.addValue(123); assertEquals(123, value1.getValue()); } - try (MapKeyContext wc = map.acquireContext(key1, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value2)) { assertEquals(123, value2.getValue()); value2.addValue(1230 - 123); assertEquals(1230, value2.getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(1230, rc.get().getValue()); + try (ExternalMapQueryContext c = + map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(1230, entry.value().get().getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value2)) { assertEquals(0, value2.getValue()); value2.addValue(123); assertEquals(123, value2.getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value1)) { assertEquals(123, value1.getValue()); value1.addValue(1230 - 123); assertEquals(1230, value1.getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(1230, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(1230, entry.value().get().getValue()); } mapChecks(); } @@ -1800,64 +1868,73 @@ public class CHMUseCasesTest { map.put(key2, value2); assertEquals(value2, map.get(key2)); - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } // TODO The same as above // try (ReadContext rc = map.getUsingLocked(key2, value1)) { // assertTrue(rc.present()); // assertEquals(22, value2.getValue()); // } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue()); } key1.setValue(3); - try (MapKeyContext rc = map.context(key1)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + assertNotNull(c.absentEntry()); } key2.setValue(4); - try (MapKeyContext rc = map.context(key2)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + assertNotNull(c.absentEntry()); } - try (MapKeyContext wc = map.acquireContext(key1, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value1)) { assertEquals('\0', value1.getValue()); value1.setValue('@'); assertEquals('@', value1.getValue()); } - try (MapKeyContext wc = map.acquireContext(key1, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = map.acquireContext(key1, value2)) { assertEquals('@', value2.getValue()); value2.setValue('#'); assertEquals('#', value2.getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals('#', rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals('#', entry.value().get().getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value2)) { assertEquals('\0', value2.getValue()); value2.setValue(';'); assertEquals(';', value2.getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value1)) { assertEquals(';', value1.getValue()); value1.setValue('['); assertEquals('[', value1.getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals('[', rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals('[', entry.value().get().getValue()); } } } @@ -1898,64 +1975,74 @@ public class CHMUseCasesTest { map.put(key2, value2); assertEquals(value2, map.get(key2)); - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } // TODO the same as above // try (ReadContext rc = map.getUsingLocked(key2, value1)) { // assertTrue(rc.present()); // assertEquals(22, value2.getValue()); // } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue()); } key1.setValue(3); - try (MapKeyContext rc = map.context(key1)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + assertNotNull(c.absentEntry()); } key2.setValue(4); - try (MapKeyContext rc = map.context(key2)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + assertNotNull(c.absentEntry()); } - try (MapKeyContext wc = map.acquireContext(key1, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value1)) { assertEquals(0, value1.getValue()); value1.addValue(234); assertEquals(234, value1.getValue()); } - try (MapKeyContext wc = map.acquireContext(key1, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value2)) { assertEquals(234, value2.getValue()); value2.addValue(-100); assertEquals(134, value2.getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(134, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(134, entry.value().get().getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value2)) { assertEquals(0, value2.getValue()); value2.addValue((byte) 123); assertEquals(123, value2.getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value1)) { assertEquals(123, value1.getValue()); value1.addValue((byte) -111); assertEquals(12, value1.getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(12, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(12, entry.value().get().getValue()); } mapChecks(); } @@ -1994,64 +2081,74 @@ public class CHMUseCasesTest { map.put(key2, value2); assertEquals(value2, map.get(key2)); - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(true, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(true, entry.value().get().getValue()); } // TODO the same as above. copy paste, copy paste, copy-paste... // try (ReadContext rc = map.getUsingLocked(key2, value1)) { // assertTrue(rc.present()); // assertEquals(false, value2.getValue()); // } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(false, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(false, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(true, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(true, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(false, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(false, entry.value().get().getValue()); } key1.setValue(3); - try (MapKeyContext rc = map.context(key1)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + assertNotNull(c.absentEntry()); } key2.setValue(4); - try (MapKeyContext rc = map.context(key2)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + assertNotNull(c.absentEntry()); } - try (MapKeyContext wc = map.acquireContext(key1, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value1)) { assertEquals(false, value1.getValue()); value1.setValue(true); assertEquals(true, value1.getValue()); } - try (MapKeyContext wc = map.acquireContext(key1, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value2)) { assertEquals(true, value2.getValue()); value2.setValue(false); assertEquals(false, value2.getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(false, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(false, entry.value().get().getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value2)) { assertEquals(false, value2.getValue()); value2.setValue(true); assertEquals(true, value2.getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value1)) { assertEquals(true, value1.getValue()); value1.setValue(false); assertEquals(false, value1.getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(false, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(false, entry.value().get().getValue()); } mapChecks(); } @@ -2090,64 +2187,74 @@ public class CHMUseCasesTest { map.put(key2, value2); assertEquals(value2, map.get(key2)); - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue(), 0); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue(), 0); } // TODO see above // try (ReadContext rc = map.getUsingLocked(key2, value1)) { // assertTrue(rc.present()); // assertEquals(22, value2.getValue(), 0); // } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue(), 0); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue(), 0); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue(), 0); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue(), 0); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue(), 0); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue(), 0); } key1.setValue(3); - try (MapKeyContext rc = map.context(key1)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + assertNotNull(c.absentEntry()); } key2.setValue(4); - try (MapKeyContext rc = map.context(key2)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + assertNotNull(c.absentEntry()); } - try (MapKeyContext wc = map.acquireContext(key1, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value1)) { assertEquals(0, value1.getValue(), 0); value1.addValue(123); assertEquals(123, value1.getValue(), 0); } - try (MapKeyContext wc = map.acquireContext(key1, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value2)) { assertEquals(123, value2.getValue(), 0); value2.addValue(1230 - 123); assertEquals(1230, value2.getValue(), 0); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(1230, rc.get().getValue(), 0); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(1230, entry.value().get().getValue(), 0); } - try (MapKeyContext wc = map.acquireContext(key2, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value2)) { assertEquals(0, value2.getValue(), 0); value2.addValue(123); assertEquals(123, value2.getValue(), 0); } - try (MapKeyContext wc = map.acquireContext(key2, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value1)) { assertEquals(123, value1.getValue(), 0); value1.addValue(1230 - 123); assertEquals(1230, value1.getValue(), 0); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(1230, rc.get().getValue(), 0); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(1230, entry.value().get().getValue(), 0); } mapChecks(); } @@ -2191,63 +2298,73 @@ public class CHMUseCasesTest { map.put(key2, value2); assertEquals(value2, map.get(key2)); - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue(), 0); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue(), 0); } // try (ReadContext rc = map.getUsingLocked(key2, value1)) { // assertTrue(rc.present()); // assertEquals(22, value2.getValue(), 0); // } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue(), 0); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue(), 0); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue(), 0); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue(), 0); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue(), 0); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue(), 0); } key1.setValue(3); - try (MapKeyContext rc = map.context(key1)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + assertNotNull(c.absentEntry()); } key2.setValue(4); - try (MapKeyContext rc = map.context(key2)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + assertNotNull(c.absentEntry()); } - try (MapKeyContext wc = map.acquireContext(key1, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value1)) { assertEquals(0, value1.getValue(), 0); value1.addValue(123); assertEquals(123, value1.getValue(), 0); } - try (MapKeyContext wc = map.acquireContext(key1, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value2)) { assertEquals(123, value2.getValue(), 0); value2.addValue(1230 - 123); assertEquals(1230, value2.getValue(), 0); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(1230, rc.get().getValue(), 0); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(1230, entry.value().get().getValue(), 0); } - try (MapKeyContext wc = map.acquireContext(key2, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value2)) { assertEquals(0, value2.getValue(), 0); value2.addValue(123); assertEquals(123, value2.getValue(), 0); } - try (MapKeyContext wc = map.acquireContext(key2, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value1)) { assertEquals(123, value1.getValue(), 0); value1.addValue(1230 - 123); assertEquals(1230, value1.getValue(), 0); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(1230, rc.get().getValue(), 0); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(1230, entry.value().get().getValue(), 0); } mapChecks(); } @@ -2288,64 +2405,74 @@ public class CHMUseCasesTest { map.put(key2, value2); assertEquals(value2, map.get(key2)); - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } // TODO see above // try (ReadContext rc = map.getUsingLocked(key2, value1)) { // assertTrue(rc.present()); // assertEquals(22, value2.getValue()); // } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(11, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(22, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(22, entry.value().get().getValue()); } key1.setValue(3); - try (MapKeyContext rc = map.context(key1)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + assertNotNull(c.absentEntry()); } key2.setValue(4); - try (MapKeyContext rc = map.context(key2)) { - assertFalse(rc.containsKey()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + assertNotNull(c.absentEntry()); } - try (MapKeyContext wc = map.acquireContext(key1, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value1)) { assertEquals(0, value1.getValue()); value1.addValue(123); assertEquals(123, value1.getValue()); } - try (MapKeyContext wc = map.acquireContext(key1, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key1, value2)) { assertEquals(123, value2.getValue()); value2.addValue(1230 - 123); assertEquals(1230, value2.getValue()); } - try (MapKeyContext rc = map.context(key1)) { - assertTrue(rc.containsKey()); - assertEquals(1230, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key1)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(1230, entry.value().get().getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value2)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value2)) { assertEquals(0, value2.getValue()); value2.addValue(123); assertEquals(123, value2.getValue()); } - try (MapKeyContext wc = map.acquireContext(key2, value1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key2, value1)) { assertEquals(123, value1.getValue()); value1.addValue(1230 - 123); assertEquals(1230, value1.getValue()); } - try (MapKeyContext rc = map.context(key2)) { - assertTrue(rc.containsKey()); - assertEquals(1230, rc.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext(key2)) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(1230, entry.value().get().getValue()); } mapChecks(); } @@ -2374,31 +2501,35 @@ public class CHMUseCasesTest { map.put("2", asList("two-A")); List list1 = new ArrayList<>(); - try (MapKeyContext wc = map.acquireContext("1", list1)) { + try (net.openhft.chronicle.core.io.Closeable c = map.acquireContext("1", list1)) { list1.add("one"); assertEquals(asList("one"), list1); } List list2 = new ArrayList<>(); - try (MapKeyContext rc = map.context("1")) { - assertTrue(rc.containsKey()); - assertEquals(asList("one"), rc.getUsing(list2)); + try (ExternalMapQueryContext, ?> c = map.queryContext("1")) { + MapEntry> entry = c.entry(); + assertNotNull(entry); + assertEquals(asList("one"), entry.value().getUsing(list2)); } - try (MapKeyContext rc = map.context("2")) { - assertTrue(rc.containsKey()); - rc.getUsing(list2); + try (ExternalMapQueryContext, ?> c = map.queryContext("2")) { + MapEntry> entry = c.entry(); + assertNotNull(entry); + entry.value().getUsing(list2); list2.add("two-B"); // this is not written as it only a read context assertEquals(asList("two-A", "two-B"), list2); } - try (MapKeyContext wc = map.acquireContext("2", list1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext("2", list1)) { list1.add("two-C"); assertEquals(asList("two-A", "two-C"), list1); } - try (MapKeyContext rc = map.context("2")) { - assertTrue(rc.containsKey()); - assertEquals(asList("two-A", "two-C"), rc.getUsing(list2)); + try (ExternalMapQueryContext, ?> c = map.queryContext("2")) { + MapEntry> entry = c.entry(); + assertNotNull(entry); + assertEquals(asList("two-A", "two-C"), entry.value().getUsing(list2)); } } } @@ -2419,22 +2550,27 @@ public class CHMUseCasesTest { map.put("2", new LinkedHashSet(asList("one"))); Set list1 = new LinkedHashSet<>(); - try (MapKeyContext wc = map.acquireContext("1", list1)) { + try (net.openhft.chronicle.core.io.Closeable c = map.acquireContext("1", list1)) { list1.add("two"); assertEquals(new LinkedHashSet(asList("two")), list1); } Set list2 = new LinkedHashSet<>(); - try (MapKeyContext> rc = map.context("1")) { - assertTrue(rc.containsKey()); - assertEquals(new LinkedHashSet(asList("two")), rc.getUsing(list2)); + try (ExternalMapQueryContext, ?> c = map.queryContext("1")) { + MapEntry> entry = c.entry(); + assertNotNull(entry); + assertEquals(new LinkedHashSet<>(asList("two")), entry.value().getUsing(list2)); } - try (MapKeyContext wc = map.acquireContext("2", list1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext("2", list1)) { list1.add("three"); assertEquals(new LinkedHashSet(asList("one", "three")), list1); } - try (MapKeyContext> rc = map.context("2")) { - assertTrue(rc.containsKey()); - assertEquals(new LinkedHashSet(asList("one", "three")), rc.getUsing(list2)); + try (ExternalMapQueryContext, ?> c = + map.queryContext("2")) { + MapEntry> entry = c.entry(); + assertNotNull(entry); + assertEquals(new LinkedHashSet<>(asList("one", "three")), + entry.value().getUsing(list2)); } for (Map.Entry> entry : map.entrySet()) { @@ -2464,22 +2600,27 @@ public class CHMUseCasesTest { map.put("2", mapOf("one", "uni")); Map map1 = new LinkedHashMap<>(); - try (MapKeyContext wc = map.acquireContext("1", map1)) { + try (net.openhft.chronicle.core.io.Closeable c = map.acquireContext("1", map1)) { map1.put("two", "bi"); assertEquals(mapOf("two", "bi"), map1); } Map map2 = new LinkedHashMap<>(); - try (MapKeyContext> rc = map.context("1")) { - assertTrue(rc.containsKey()); - assertEquals(mapOf("two", "bi"), rc.getUsing(map2)); + try (ExternalMapQueryContext, ?> c = + map.queryContext("1")) { + MapEntry> entry = c.entry(); + assertNotNull(entry); + assertEquals(mapOf("two", "bi"), entry.value().getUsing(map2)); } - try (MapKeyContext wc = map.acquireContext("2", map1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext("2", map1)) { map1.put("three", "tri"); assertEquals(mapOf("one", "uni", "three", "tri"), map1); } - try (MapKeyContext> rc = map.context("2")) { - assertTrue(rc.containsKey()); - assertEquals(mapOf("one", "uni", "three", "tri"), rc.getUsing(map2)); + try (ExternalMapQueryContext, ?> c = + map.queryContext("2")) { + MapEntry> entry = c.entry(); + assertNotNull(entry); + assertEquals(mapOf("one", "uni", "three", "tri"), entry.value().getUsing(map2)); } mapChecks(); } @@ -2502,22 +2643,27 @@ public class CHMUseCasesTest { map.put("2", mapOf("one", 1)); Map map1 = new LinkedHashMap<>(); - try (MapKeyContext wc = map.acquireContext("1", map1)) { + try (net.openhft.chronicle.core.io.Closeable c = map.acquireContext("1", map1)) { map1.put("two", 2); assertEquals(mapOf("two", 2), map1); } Map map2 = new LinkedHashMap<>(); - try (MapKeyContext> rc = map.context("1")) { - assertTrue(rc.containsKey()); - assertEquals(mapOf("two", 2), rc.getUsing(map2)); + try (ExternalMapQueryContext, ?> c = + map.queryContext("1")) { + MapEntry> entry = c.entry(); + assertNotNull(entry); + assertEquals(mapOf("two", 2), entry.value().getUsing(map2)); } - try (MapKeyContext wc = map.acquireContext("2", map1)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext("2", map1)) { map1.put("three", 3); assertEquals(mapOf("one", 1, "three", 3), map1); } - try (MapKeyContext> rc = map.context("2")) { - assertTrue(rc.containsKey()); - assertEquals(mapOf("one", 1, "three", 3), rc.getUsing(map2)); + try (ExternalMapQueryContext, ?> c = + map.queryContext("2")) { + MapEntry> entry = c.entry(); + assertNotNull(entry); + assertEquals(mapOf("one", 1, "three", 3), entry.value().getUsing(map2)); } mapChecks(); } @@ -2558,8 +2704,7 @@ public class CHMUseCasesTest { try (ChronicleMap map = newInstance(builder)) { IBean iBean = map.newValueInstance(); - try (MapKeyContext cx = map.acquireContext("1", - iBean)) { + try (net.openhft.chronicle.core.io.Closeable c = map.acquireContext("1", iBean)) { iBean.setDouble(1.2); iBean.setLong(2); iBean.setInt(4); @@ -2712,5 +2857,4 @@ interface IBean { void setMessage(@MaxSize(20) String px); } -} - +} \ No newline at end of file diff --git a/src/test/java/net/openhft/chronicle/map/ChronicleMapImportExportTest.java b/src/test/java/net/openhft/chronicle/map/ChronicleMapImportExportTest.java index 0e51b4a3c..db607bc90 100644 --- a/src/test/java/net/openhft/chronicle/map/ChronicleMapImportExportTest.java +++ b/src/test/java/net/openhft/chronicle/map/ChronicleMapImportExportTest.java @@ -2,6 +2,7 @@ package net.openhft.chronicle.map; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; +import net.openhft.chronicle.core.io.Closeable; import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig; import net.openhft.chronicle.map.fromdocs.BondVOInterface; import net.openhft.lang.values.LongValue; @@ -257,11 +258,10 @@ public class ChronicleMapImportExportTest { LongValue value = expected.newValueInstance(); // this will add the entry - try (MapKeyContext context = expected.acquireContext("one", value)) { - assertEquals(0, context.get().getValue()); - assert value == context.get(); - LongValue value1 = context.get(); - value1.addValue(1); + try (Closeable c = + expected.acquireContext("one", value)) { + assertEquals(0, value.getValue()); + value.addValue(1); } expected.getAll(file); @@ -294,14 +294,12 @@ public class ChronicleMapImportExportTest { final BondVOInterface value = expected.newValueInstance(); // this will add the entry - try (MapKeyContext context = expected.acquireContext("one", value)) { + try (Closeable c = expected.acquireContext("one", value)) { value.setCoupon(8.98); BondVOInterface.MarketPx marketPxIntraDayHistoryAt = value.getMarketPxIntraDayHistoryAt(1); marketPxIntraDayHistoryAt.setAskPx(12.0); - - assert value == context.get(); } expected.getAll(file); diff --git a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java index f8320c822..63dc17aa8 100755 --- a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java @@ -20,6 +20,8 @@ package net.openhft.chronicle.map; import com.google.common.collect.HashBiMap; import com.google.common.primitives.Ints; +import net.openhft.chronicle.bytes.BytesStore; +import net.openhft.chronicle.hash.Data; import net.openhft.chronicle.hash.replication.SingleChronicleHashReplication; import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig; import net.openhft.lang.model.DataValueClasses; @@ -732,7 +734,8 @@ public class ChronicleMapTest { map.getUsing(key, value); } else { - try (MapKeyContext wc = map.acquireContext(key, value)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key, value)) { if (value.length() < value0.length() - 1) value.append(value0); else if (value.length() > value0.length()) @@ -824,8 +827,8 @@ public class ChronicleMapTest { map.getUsing(key, value); } else { - try (MapKeyContext wc = map.acquireContext(key, - value)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key, value)) { if (value.length() < value0.length() - 1) value.append(value0); else if (value.length() > value0.length()) @@ -923,21 +926,27 @@ public class ChronicleMapTest { long n; // 75% read if (rand.nextBoolean() || rand.nextBoolean()) { - try (MapKeyContext c = map.context(sb)) { - if (c.containsKey()) { + try (ExternalMapQueryContext c = + map.queryContext(sb)) { + MapEntry entry = c.entry(); + if (entry != null) { // Attempt to pass abstraction hierarchies - n = c.entry().readVolatileLong(c.valueOffset()) + 1; + Data v = entry.value(); + n = v.bytes().readVolatileLong(v.offset()) + 1; } else { n = 1; } } } else { - try (MapKeyContext wc = map.context(sb)) { - wc.updateLock().lock(); - if (wc.containsKey()) { - n = wc.entry().addLong(wc.valueOffset(), 1); + try (ExternalMapQueryContext c = + map.queryContext(sb)) { + c.updateLock().lock(); + MapEntry entry = c.entry(); + if (entry != null) { + Data v = entry.value(); + n = ((BytesStore) v.bytes()).addAndGetLong(v.offset(), 1); } else { - wc.put(ONE); + c.insert(c.absentEntry(), c.wrapValueAsData(ONE)); n = 1; } } @@ -1012,7 +1021,8 @@ public class ChronicleMapTest { j += independence) { key.setValue(j * factor); long n; - try (MapKeyContext wc = map.acquireContext(key, value)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key, value)) { n = value.addValue(1); } assert n > 0 && n < 1000 : "Counter corrupted " + n; @@ -1638,48 +1648,47 @@ public class ChronicleMapTest { LongValue value = nativeLongValue(); // this will add the entry - try (MapKeyContext context = map.acquireContext("one", value)) { - assertEquals(0, context.get().getValue()); - assert value == context.get(); - LongValue value1 = context.get(); - value1.addValue(1); + try (net.openhft.chronicle.core.io.Closeable c = map.acquireContext("one", value)) { + assertEquals(0, value.getValue()); + value.addValue(1); } // check that the entry was added - try (MapKeyContext context = map.context("one")) { - assertEquals(true, context.containsKey()); - LongValue v = context.getUsing(value); + try (ExternalMapQueryContext c = map.queryContext("one")) { + MapEntry entry = c.entry(); + assertNotNull(entry); + LongValue v = entry.value().getUsing(value); assert v == value; assertEquals(1, v.getValue()); } // this will remove the entry - try (MapKeyContext context = map.context("one")) { - context.remove(); + try (ExternalMapQueryContext c = map.queryContext("one")) { + c.updateLock().lock(); + c.remove(c.entry()); } // check that the entry was removed - try (MapKeyContext context = map.context("one")) { - context.updateLock().lock(); - assertEquals(false, context.containsKey()); - assertEquals(null, context.get()); + try (ExternalMapQueryContext c = map.queryContext("one")) { + c.updateLock().lock(); + assertNotNull(c.absentEntry()); } - try (MapKeyContext context = map.acquireContext("one", value)) { - assert value == context.get(); - assertEquals(0, context.get().getValue()); + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext("one", value)) { + assertEquals(0, value.getValue()); } - try (MapKeyContext context = map.acquireContext("one", value)) { - assert value == context.get(); - context.get().addValue(1); + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext("one", value)) { + value.addValue(1); } // check that the entry was removed - try (MapKeyContext context = map.context("one")) { - LongValue v = context.getUsing(value); + try (ExternalMapQueryContext c = map.queryContext("one")) { + LongValue v = c.entry().value().getUsing(value); assert value == v; - assertEquals(1, context.get().getValue()); + assertEquals(1, c.entry().value().get().getValue()); } map.close(); @@ -1733,7 +1742,7 @@ public class ChronicleMapTest { try (final ChronicleMap map = builder.create()) { // this will add the entry - try (MapKeyContext context = map.acquireContext("one", "")) { + try (net.openhft.chronicle.core.io.Closeable c = map.acquireContext("one", "")) { // do nothing } } @@ -1751,7 +1760,8 @@ public class ChronicleMapTest { .create()) { StringBuilder value = new StringBuilder(); - try (MapKeyContext context = map.acquireContext("one", value)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext("one", value)) { value.append("Hello World"); } @@ -1771,56 +1781,58 @@ public class ChronicleMapTest { LongValue value = DataValueClasses.newDirectReference(LongValue.class); - try (MapKeyContext context = map.context("one")) { - assertEquals(false, context.containsKey()); - assertEquals(null, context.get()); + try (ExternalMapQueryContext c = map.queryContext("one")) { + assertNotNull(c.absentEntry()); } - try (MapKeyContext context = map.acquireContext("one", value)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext("one", value)) { value.setValue(10); } // this will add the entry - try (MapKeyContext context = map.acquireContext("one", value)) { - LongValue value1 = context.get(); - value1.addValue(1); + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext("one", value)) { + value.addValue(1); } // check that the entry was added - try (MapKeyContext context = map.context("one")) { - assertEquals(true, context.containsKey()); - assertEquals(11, context.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext("one")) { + MapEntry entry = c.entry(); + assertNotNull(entry); + assertEquals(11, entry.value().get().getValue()); } // this will remove the entry - try (MapKeyContext context = map.context("one")) { - context.remove(); + try (ExternalMapQueryContext c = map.queryContext("one")) { + c.updateLock().lock(); + c.remove(c.entry()); } // check that the entry was removed - try (MapKeyContext context = map.context("one")) { - assertEquals(false, context.containsKey()); - assertEquals(null, context.get()); + try (ExternalMapQueryContext c = map.queryContext("one")) { + assertNotNull(c.absentEntry()); } - try (MapKeyContext context = map.acquireContext("one", value)) { - assertEquals(0, context.get().getValue()); + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext("one", value)) { + assertEquals(0, value.getValue()); } value.setValue(1); - try (MapKeyContext lockedEntry = map.context("one")) { - assertEquals(1, lockedEntry.get().getValue()); + try (ExternalMapQueryContext c = map.queryContext("one")) { + assertEquals(1, c.entry().value().get().getValue()); } - try (MapKeyContext context = map.acquireContext("one", value)) { - LongValue value1 = context.get(); - value1.addValue(1); + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext("one", value)) { + value.addValue(1); } // check that the entry was removed - try (MapKeyContext context = map.context("one")) { - LongValue value1 = context.get(); + try (ExternalMapQueryContext c = map.queryContext("one")) { + LongValue value1 = c.entry().value().get(); assertEquals(2, value1.getValue()); } diff --git a/src/test/java/net/openhft/chronicle/map/DemoChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/DemoChronicleMapTest.java index b64f9b01a..c2ad8c55b 100755 --- a/src/test/java/net/openhft/chronicle/map/DemoChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/DemoChronicleMapTest.java @@ -3,7 +3,6 @@ package net.openhft.chronicle.map; import net.openhft.lang.model.DataValueClasses; import net.openhft.lang.model.constraints.MaxSize; import net.openhft.lang.values.IntValue; -import org.junit.Ignore; import org.junit.Test; import java.io.File; @@ -74,7 +73,8 @@ public class DemoChronicleMapTest { for (int i = 0; i < maxEntries; i++) { key.setValue(i); - try (MapKeyContext wc = map.acquireContext(key, value)) { + try (net.openhft.chronicle.core.io.Closeable c = + map.acquireContext(key, value)) { value.setSymbol("IBM-" + i); value.addAtomicOrderQty(1000); } diff --git a/src/test/java/net/openhft/chronicle/map/ReplicationCheckingMap.java b/src/test/java/net/openhft/chronicle/map/ReplicationCheckingMap.java index 88413bd53..d6ff2051f 100644 --- a/src/test/java/net/openhft/chronicle/map/ReplicationCheckingMap.java +++ b/src/test/java/net/openhft/chronicle/map/ReplicationCheckingMap.java @@ -18,6 +18,7 @@ package net.openhft.chronicle.map; +import net.openhft.chronicle.core.io.Closeable; import net.openhft.chronicle.hash.function.SerializableFunction; import org.jetbrains.annotations.NotNull; import org.junit.Assert; @@ -277,12 +278,8 @@ public class ReplicationCheckingMap implements ChronicleMap { @NotNull @Override - public MapKeyContext acquireContext(@NotNull K key, @NotNull V usingValue) { - throw new UnsupportedOperationException(); - } - - @Override - public MapKeyContext context(K key) { + public Closeable acquireContext( + @NotNull K key, @NotNull V usingValue) { throw new UnsupportedOperationException(); } diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationNativeTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationNativeTest.java index 1ce65f2c6..0e3eaa7b2 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationNativeTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationNativeTest.java @@ -23,7 +23,6 @@ import net.openhft.lang.model.DataValueClasses; import net.openhft.lang.values.LongValue; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import java.io.Closeable; @@ -92,7 +91,8 @@ public class TCPSocketReplicationNativeTest { LongValue value = DataValueClasses.newDirectReference(LongValue.class); - try (MapKeyContext c = map1.acquireContext(1, value)) { + try (net.openhft.chronicle.core.io.Closeable c = + map1.acquireContext(1, value)) { value.setValue(10); } @@ -108,11 +108,13 @@ public class TCPSocketReplicationNativeTest { LongValue value = DataValueClasses.newDirectReference(LongValue.class); - try (MapKeyContext c = map1.acquireContext(1, value)) { + try (net.openhft.chronicle.core.io.Closeable c = + map1.acquireContext(1, value)) { value.setValue(10); } - try (MapKeyContext c = map1.acquireContext(1, value)) { + try (net.openhft.chronicle.core.io.Closeable c = + map1.acquireContext(1, value)) { value.setValue(20); } diff --git a/src/test/java/net/openhft/chronicle/map/TcpReplicationWithAcquireContextTest.java b/src/test/java/net/openhft/chronicle/map/TcpReplicationWithAcquireContextTest.java index d051aa8bc..10a9a61cd 100644 --- a/src/test/java/net/openhft/chronicle/map/TcpReplicationWithAcquireContextTest.java +++ b/src/test/java/net/openhft/chronicle/map/TcpReplicationWithAcquireContextTest.java @@ -3,7 +3,6 @@ package net.openhft.chronicle.map; import eg.TestInstrumentVOInterface; import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import java.net.InetSocketAddress; @@ -46,7 +45,7 @@ public class TcpReplicationWithAcquireContextTest { TestInstrumentVOInterface instrumentVOInterface = map1.newValueInstance(); - try (MapKeyContext wc = + try (net.openhft.chronicle.core.io.Closeable c = map1.acquireContext("KEY1", instrumentVOInterface)) { instrumentVOInterface.setSymbol("Flyer"); instrumentVOInterface.setCurrencyCode("USA"); diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/OpenJDKAndHashMapExamplesTest.java b/src/test/java/net/openhft/chronicle/map/fromdocs/OpenJDKAndHashMapExamplesTest.java index 73452ca9d..0fe73f457 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/OpenJDKAndHashMapExamplesTest.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/OpenJDKAndHashMapExamplesTest.java @@ -20,7 +20,7 @@ package net.openhft.chronicle.map.fromdocs; import net.openhft.chronicle.map.ChronicleMap; import net.openhft.chronicle.map.ChronicleMapBuilder; -import net.openhft.chronicle.map.MapKeyContext; +import net.openhft.chronicle.map.ExternalMapQueryContext; import org.junit.Test; import java.io.File; @@ -60,7 +60,8 @@ public class OpenJDKAndHashMapExamplesTest { .createPersistedTo(file); BondVOInterface bondVO = chm.newValueInstance(); - try (MapKeyContext wc = chm.acquireContext("369604103", bondVO)) { + try (net.openhft.chronicle.core.io.Closeable c = + chm.acquireContext("369604103", bondVO)) { bondVO.setIssueDate(parseYYYYMMDD("20130915")); bondVO.setMaturityDate(parseYYYYMMDD("20140915")); bondVO.setCoupon(5.0 / 100); // 5.0% @@ -80,8 +81,9 @@ public class OpenJDKAndHashMapExamplesTest { .entries(1000) .createPersistedTo(file); - try (MapKeyContext c = chmB.context("369604103")) { - BondVOInterface bond = c.get(); + try (ExternalMapQueryContext c = + chmB.queryContext("369604103")) { + BondVOInterface bond = c.entry().value().get(); if (bond != null) { assertEquals(5.0 / 100, bond.getCoupon(), 0.0); @@ -97,7 +99,8 @@ public class OpenJDKAndHashMapExamplesTest { BondVOInterface bond = chm.newValueInstance(); // lookup the key and give me a reference I can update in a thread safe way. - try (MapKeyContext c = chm.acquireContext("369604103", bond)) { + try (net.openhft.chronicle.core.io.Closeable c = + chm.acquireContext("369604103", bond)) { // found a key and bond has been set // get directly without touching the rest of the record. long _matDate = bond.getMaturityDate(); diff --git a/src/test/java/net/openhft/chronicle/map/jsr166/map/StatelessChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/jsr166/map/StatelessChronicleMapTest.java index 52e08b511..25eae8320 100755 --- a/src/test/java/net/openhft/chronicle/map/jsr166/map/StatelessChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/jsr166/map/StatelessChronicleMapTest.java @@ -110,9 +110,10 @@ public class StatelessChronicleMapTest extends JSR166TestCase { return d.containsValue(value); } + @NotNull @Override - public MapKeyContext context(K key) { - return d.context(key); + public net.openhft.chronicle.core.io.Closeable acquireContext(@NotNull K key, @NotNull V usingValue) { + return d.acquireContext(key, usingValue); } @NotNull @@ -180,12 +181,6 @@ public class StatelessChronicleMapTest extends JSR166TestCase { return d.acquireUsing(key, usingValue); } - @NotNull - @Override - public MapKeyContext acquireContext(@NotNull K key, @NotNull V usingValue) { - throw new UnsupportedOperationException(); - } - @Override public R getMapped(K key, @NotNull SerializableFunction function) { return d.getMapped(key, function);