mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Removed ChronicleHash.context() method and changed acquireContext() return type from deprecated MapKeyContext to Closeable
This commit is contained in:
@@ -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<String, BondVOInterface> c = chmB.context("369604103")) {
|
||||
BondVOInterface bond = c.get();
|
||||
try (ExternalMapQueryContext<String, BondVOInterface, ?> 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<String, BondVOInterface> 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();
|
||||
|
||||
Reference in New Issue
Block a user