mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -310,14 +310,14 @@ the ChronicleMapBuilder can also be used to return the ChronicleMap, see the exa
|
||||
ChronicleMap<Integer, CharSequence> map =
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class).create();
|
||||
```
|
||||
One way to achieve good performance is to focus on unnecessary object creation as this reduces
|
||||
One way to achieve good performance is to focus on unnecessary object creation, as this reduces
|
||||
the amount of work that has to be carried out by the Garbage Collector. As such ChronicleMap
|
||||
supports the following methods :
|
||||
|
||||
- [`V getUsing(K key, V value);`](http://openhft.github.io/Chronicle-Map/apidocs/net/openhft/chronicle/map/ChronicleMap.html#getUsing-K-V-)
|
||||
- [`V acquireUsing(K key, V value);`](http://openhft.github.io/Chronicle-Map/apidocs/net/openhft/chronicle/map/ChronicleMap.html#acquireUsing-K-V-)
|
||||
- ReadContext<K, V> getUsingLocked(@NotNull K key, @NotNull V usingValue);
|
||||
- WriteContext<K, V> acquireUsingLocked(@NotNull K key, @NotNull V usingValue);
|
||||
- [`ReadContext<K, V> getUsingLocked(@NotNull K key, @NotNull V usingValue);`] (https://github.com/OpenHFT/Chronicle-Map#off-heap-storage-and-how-using-a-proxy-object-can-improve-performance)
|
||||
- [`WriteContext<K, V> acquireUsingLocked(@NotNull K key, @NotNull V usingValue);`] (https://github.com/OpenHFT/Chronicle-Map#acquireusinglocked)
|
||||
|
||||
|
||||
These methods let you provide the object which the data will be written to, even if the object is
|
||||
@@ -364,7 +364,6 @@ that entry has to be deserialised onto the java heap so that you can use its val
|
||||
``` java
|
||||
for(int i=1;i<=10;i++) {
|
||||
Value v = get(key)
|
||||
|
||||
}
|
||||
```
|
||||
this would create 10 separate instances of the value. As each time get() is called the map has to
|
||||
|
||||
@@ -136,7 +136,7 @@ public abstract class AbstractChronicleMapBuilder<K, V,
|
||||
private MapEventListener<K, V, ChronicleMap<K, V>> eventListener =
|
||||
MapEventListeners.nop();
|
||||
private V defaultValue = null;
|
||||
private DefaultValueProvider<K, V> defaultValueProvider = NullValueProvider.INSTANCE;
|
||||
private DefaultValueProvider<K, V> defaultValueProvider = null;
|
||||
private PrepareValueBytes<K, V> prepareValueBytes = null;
|
||||
|
||||
private SingleChronicleHashReplication singleHashReplication = null;
|
||||
|
||||
@@ -237,12 +237,7 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable {
|
||||
if (closeables != null)
|
||||
closeables.closeQuietly();
|
||||
closeables = null;
|
||||
try {
|
||||
// give time to close
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
//
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -399,7 +394,7 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable {
|
||||
}
|
||||
|
||||
|
||||
public synchronized V acquireUsing(@NotNull K key, V usingValue) {
|
||||
public synchronized V acquireUsing(@NotNull K key, V usingValue) {
|
||||
throw new UnsupportedOperationException("acquireUsing() is not supported for stateless " +
|
||||
"clients");
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ public class DemoChronicleMapTest {
|
||||
File file = File.createTempFile("DummyOrders", ".test");
|
||||
file.deleteOnExit();
|
||||
int maxEntries = 1000;
|
||||
// ChronicleMap<IntValue, DemoOrderVOInterface> map = ChronicleMapBuilder
|
||||
ChronicleMap<IntValue, DemoOrderVOInterface> map = OffHeapUpdatableChronicleMapBuilder
|
||||
.of(IntValue.class, DemoOrderVOInterface.class)
|
||||
.putReturnsNull(true)
|
||||
@@ -37,7 +36,6 @@ public class DemoChronicleMapTest {
|
||||
|
||||
map.acquireUsing(key, value);
|
||||
|
||||
// TODO Shouldn't throw an NPE, because acquire should set the value.
|
||||
value.setSymbol("IBM-" + i);
|
||||
value.addAtomicOrderQty(1000);
|
||||
|
||||
@@ -61,7 +59,6 @@ public class DemoChronicleMapTest {
|
||||
File file = File.createTempFile("DummyOrders", ".test");
|
||||
file.deleteOnExit();
|
||||
int maxEntries = 1000;
|
||||
// ChronicleMap<IntValue, DemoOrderVOInterface> map = ChronicleMapBuilder
|
||||
ChronicleMap<IntValue, DemoOrderVOInterface> map = OffHeapUpdatableChronicleMapBuilder
|
||||
.of(IntValue.class, DemoOrderVOInterface.class)
|
||||
.putReturnsNull(true)
|
||||
@@ -80,7 +77,6 @@ public class DemoChronicleMapTest {
|
||||
key.setValue(i);
|
||||
|
||||
try (WriteContext wc = map.acquireUsingLocked(key, value)) {
|
||||
// TODO Shouldn't throw an NPE, because acquire should set the value.
|
||||
value.setSymbol("IBM-" + i);
|
||||
value.addAtomicOrderQty(1000);
|
||||
}
|
||||
|
||||
@@ -82,12 +82,12 @@ public class TCPSocketReplication3VoidValueTest {
|
||||
assertEquals(null, map1.put(2, null));
|
||||
|
||||
assertEquals(null, map2.put(5, null));
|
||||
assertEquals(null, map2.put(6,null));
|
||||
assertEquals(null, map2.put(6, null));
|
||||
|
||||
map1.remove(2);
|
||||
map2.remove(3);
|
||||
map1.remove(3);
|
||||
map2.put(5,null);
|
||||
map2.put(5, null);
|
||||
|
||||
// allow time for the recompilation to resolve
|
||||
assertTrue(waitTillEqual(5000));
|
||||
@@ -102,7 +102,7 @@ public class TCPSocketReplication3VoidValueTest {
|
||||
public void testClear() throws IOException, InterruptedException {
|
||||
|
||||
assertEquals(null, map1.put(1, null));
|
||||
assertEquals(null, map1.put(2,null));
|
||||
assertEquals(null, map1.put(2, null));
|
||||
|
||||
assertEquals(null, map2.put(5, null));
|
||||
assertEquals(null, map2.put(6, null));
|
||||
@@ -123,7 +123,8 @@ public class TCPSocketReplication3VoidValueTest {
|
||||
int t = 0;
|
||||
for (; t < timeOutMs; t++) {
|
||||
if (map1.equals(map2) &&
|
||||
map1.equals(map3))
|
||||
map1.equals(map3) &&
|
||||
map2.equals(map3))
|
||||
return true;
|
||||
Thread.sleep(1);
|
||||
}
|
||||
|
||||
+2
-1
@@ -145,7 +145,8 @@ public class TCPSocketReplication3wayPutReturnsNullTest {
|
||||
int t = 0;
|
||||
for (; t < timeOutMs; t++) {
|
||||
if (map1.equals(map2) &&
|
||||
map1.equals(map3))
|
||||
map1.equals(map3)
|
||||
&& map2.equals(map3))
|
||||
break;
|
||||
Thread.sleep(1);
|
||||
}
|
||||
|
||||
@@ -154,7 +154,8 @@ public class TCPSocketReplication3wayTest {
|
||||
int t = 0;
|
||||
for (; t < timeOutMs; t++) {
|
||||
if (map1.equals(map2) &&
|
||||
map1.equals(map3))
|
||||
map1.equals(map3)
|
||||
&& map2.equals(map3))
|
||||
break;
|
||||
Thread.sleep(1);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,8 @@ public class SetForTCPSocketReplication3wayTest {
|
||||
int t = 0;
|
||||
for (; t < timeOutMs; t++) {
|
||||
if (set1.equals(set2) &&
|
||||
set1.equals(set3))
|
||||
set1.equals(set3) &&
|
||||
set2.equals(set3))
|
||||
break;
|
||||
Thread.sleep(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user