mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Standard code formatting
This commit is contained in:
@@ -76,16 +76,6 @@ public class HashQueryContextExamples {
|
||||
returnValue.returnValue(q.entry().value());
|
||||
}
|
||||
|
||||
interface Point {
|
||||
double getX();
|
||||
void setX(double x);
|
||||
double addX(double xAdd);
|
||||
|
||||
double getY();
|
||||
void setY(double y);
|
||||
double addY(double yAdd);
|
||||
}
|
||||
|
||||
<K> Point movePoint(ChronicleMap<K, Point> map, K key, double xMove, double yMove,
|
||||
Point using) {
|
||||
// Moves existing point by [xMove, yMove], if absent - assumes the default point is [0, 0].
|
||||
@@ -107,4 +97,18 @@ public class HashQueryContextExamples {
|
||||
return offHeapPoint;
|
||||
}
|
||||
}
|
||||
|
||||
interface Point {
|
||||
double getX();
|
||||
|
||||
void setX(double x);
|
||||
|
||||
double addX(double xAdd);
|
||||
|
||||
double getY();
|
||||
|
||||
void setY(double y);
|
||||
|
||||
double addY(double yAdd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,13 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
interface MyFloats {
|
||||
@Array(length = 6)
|
||||
public void setValueAt(int index, float f);
|
||||
|
||||
public float getValueAt(int index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by peter.lawrey on 19/12/14.
|
||||
*/
|
||||
@@ -82,7 +89,7 @@ public class LotsOfEntriesMain {
|
||||
else
|
||||
map.getUsing(sb, mf);
|
||||
} catch (Exception e) {
|
||||
System.out.println("map.size: "+map.size());
|
||||
System.out.println("map.size: " + map.size());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -99,10 +106,3 @@ public class LotsOfEntriesMain {
|
||||
map.close();
|
||||
}
|
||||
}
|
||||
|
||||
interface MyFloats {
|
||||
@Array(length = 6)
|
||||
public void setValueAt(int index, float f);
|
||||
|
||||
public float getValueAt(int index);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,8 @@ public class PointListSerializationTest {
|
||||
EnumMarshallable<AMarshaller> {
|
||||
public static final AMarshaller INSTANCE = new AMarshaller();
|
||||
|
||||
private AMarshaller() {}
|
||||
private AMarshaller() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Bytes out, @NotNull A toWrite) {
|
||||
|
||||
+27
-25
@@ -29,17 +29,39 @@ import static net.openhft.chronicle.map.example.SimpleMapOperationsListeningTest
|
||||
|
||||
public class SimpleMapOperationsListeningTest {
|
||||
|
||||
@Test
|
||||
public void simpleLoggingTest() {
|
||||
ChronicleMap<Integer, IntValue> map = ChronicleMapBuilder
|
||||
.of(Integer.class, IntValue.class)
|
||||
.entries(100)
|
||||
.entryOperations(simpleLoggingMapEntryOperations())
|
||||
.defaultValueProvider(simpleLoggingDefaultValueProvider())
|
||||
.create();
|
||||
|
||||
IntValue value = Values.newHeapInstance(IntValue.class);
|
||||
value.setValue(2);
|
||||
map.put(1, value);
|
||||
map.remove(1);
|
||||
map.acquireUsing(3, Values.newNativeReference(IntValue.class)).addAtomicValue(1);
|
||||
IntValue value2 = Values.newHeapInstance(IntValue.class);
|
||||
value2.setValue(5);
|
||||
map.forEachEntry(e -> e.context().replaceValue(e, e.context().wrapValueAsData(value2)));
|
||||
map.forEachEntry(e -> e.context().remove(e));
|
||||
|
||||
}
|
||||
|
||||
static class SimpleLoggingMapEntryOperations<K, V> implements MapEntryOperations<K, V, Void> {
|
||||
|
||||
private static final SimpleLoggingMapEntryOperations INSTANCE =
|
||||
new SimpleLoggingMapEntryOperations();
|
||||
|
||||
private SimpleLoggingMapEntryOperations() {
|
||||
}
|
||||
|
||||
public static <K, V> MapEntryOperations<K, V, Void> simpleLoggingMapEntryOperations() {
|
||||
return SimpleLoggingMapEntryOperations.INSTANCE;
|
||||
}
|
||||
|
||||
private SimpleLoggingMapEntryOperations() {}
|
||||
|
||||
@Override
|
||||
public Void remove(@NotNull MapEntry<K, V> entry) {
|
||||
System.out.println("remove " + entry.key() + ": " + entry.value());
|
||||
@@ -67,12 +89,13 @@ public class SimpleMapOperationsListeningTest {
|
||||
private static final SimpleLoggingDefaultValueProvider INSTANCE =
|
||||
new SimpleLoggingDefaultValueProvider();
|
||||
|
||||
private SimpleLoggingDefaultValueProvider() {
|
||||
}
|
||||
|
||||
public static <K, V> DefaultValueProvider<K, V> simpleLoggingDefaultValueProvider() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private SimpleLoggingDefaultValueProvider() {}
|
||||
|
||||
@Override
|
||||
public Data<V> defaultValue(@NotNull MapAbsentEntry<K, V> absentEntry) {
|
||||
Data<V> defaultValue = absentEntry.defaultValue();
|
||||
@@ -80,25 +103,4 @@ public class SimpleMapOperationsListeningTest {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleLoggingTest() {
|
||||
ChronicleMap<Integer, IntValue> map = ChronicleMapBuilder
|
||||
.of(Integer.class, IntValue.class)
|
||||
.entries(100)
|
||||
.entryOperations(simpleLoggingMapEntryOperations())
|
||||
.defaultValueProvider(simpleLoggingDefaultValueProvider())
|
||||
.create();
|
||||
|
||||
IntValue value = Values.newHeapInstance(IntValue.class);
|
||||
value.setValue(2);
|
||||
map.put(1, value);
|
||||
map.remove(1);
|
||||
map.acquireUsing(3, Values.newNativeReference(IntValue.class)).addAtomicValue(1);
|
||||
IntValue value2 = Values.newHeapInstance(IntValue.class);
|
||||
value2.setValue(5);
|
||||
map.forEachEntry(e -> e.context().replaceValue(e, e.context().wrapValueAsData(value2)));
|
||||
map.forEachEntry(e -> e.context().remove(e));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user