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:
@@ -821,7 +821,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
|
||||
case "chronicle-key":
|
||||
|
||||
if (kClass.getCanonicalName().startsWith("net.openhft.lang.values")) {
|
||||
return toNative(reader, vClass);
|
||||
return to$$Native(reader, vClass, true);
|
||||
} else {
|
||||
long keySize = keySizeMarshaller.readSize(buffer);
|
||||
ThreadLocalCopies copies = keyReaderProvider.getCopies(null);
|
||||
@@ -831,7 +831,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
|
||||
case "chronicle-value":
|
||||
|
||||
if (vClass.getCanonicalName().startsWith("net.openhft.lang.values")) {
|
||||
return toNative(reader, vClass);
|
||||
return to$$Native(reader, vClass, false);
|
||||
} else {
|
||||
long valueSize = valueSizeMarshaller.readSize(buffer);
|
||||
ThreadLocalCopies copies = valueReaderProvider.getCopies(null);
|
||||
@@ -859,9 +859,9 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
|
||||
} else return (E) unmarshallingContext.convertAnother(null, clazz);
|
||||
}
|
||||
|
||||
private Object toNative(HierarchicalStreamReader reader, final Class aClass) {
|
||||
private Object to$$Native(HierarchicalStreamReader reader, final Class aClass, final boolean isKey) {
|
||||
|
||||
Object o = DataValueClasses.newDirectInstance(aClass);
|
||||
final Object o = isKey ? newKeyInstance() : newValueInstance();
|
||||
try {
|
||||
for (Method $$nativeMethod : o.getClass().getMethods()) {
|
||||
if ($$nativeMethod.getName().equals("setValue") && $$nativeMethod.getParameterTypes()
|
||||
@@ -870,17 +870,28 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
|
||||
Class<?> parameterType = $$nativeMethod.getParameterTypes()[0];
|
||||
String value = reader.getValue();
|
||||
|
||||
if (parameterType.isPrimitive()) {
|
||||
String name = parameterType.getSimpleName();
|
||||
|
||||
String properName = "java.lang." + Character.toString(name
|
||||
.charAt(0)).toUpperCase()
|
||||
+ name.substring(1);
|
||||
parameterType = Class.forName(properName);
|
||||
if (parameterType.isPrimitive()) {
|
||||
|
||||
// convert the primitive to their boxed type
|
||||
|
||||
if (parameterType == int.class)
|
||||
parameterType = Integer.class;
|
||||
else if (parameterType == char.class)
|
||||
parameterType = Character.class;
|
||||
else {
|
||||
final String name = parameterType.getSimpleName();
|
||||
|
||||
final String properName = "java.lang." + Character.toString
|
||||
(name.charAt(0)).toUpperCase()
|
||||
+ name.substring(1);
|
||||
parameterType = Class.forName(properName);
|
||||
}
|
||||
}
|
||||
|
||||
Method valueOf = parameterType.getMethod("valueOf", String.class);
|
||||
Object invoke = valueOf.invoke(null, value);
|
||||
|
||||
final Method valueOf = parameterType.getMethod("valueOf", String.class);
|
||||
final Object invoke = valueOf.invoke(null, value);
|
||||
$$nativeMethod.invoke(o, invoke);
|
||||
return o;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class CHMUseCasesTest {
|
||||
|
||||
|
||||
private static class PrefixStingFunction implements Function<String, String> {
|
||||
private String prefix;
|
||||
private final String prefix;
|
||||
|
||||
public PrefixStingFunction(@NotNull String prefix) {
|
||||
this.prefix = prefix;
|
||||
@@ -74,6 +74,17 @@ public class CHMUseCasesTest {
|
||||
public String apply(String s) {
|
||||
return prefix + s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof PrefixStingFunction &&
|
||||
prefix.equals(((PrefixStingFunction) obj).prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return prefix;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +109,6 @@ public class CHMUseCasesTest {
|
||||
}
|
||||
|
||||
|
||||
@Ignore("HCOLL-257 Object serialization is failing when calling writeObject() / readObject()")
|
||||
@Test
|
||||
public void testPrefixStingFunctionSerialization() throws ExecutionException,
|
||||
InterruptedException, IOException {
|
||||
@@ -114,7 +124,6 @@ public class CHMUseCasesTest {
|
||||
|
||||
}
|
||||
|
||||
@Ignore("HCOLL-257 Object serialization is failing when calling writeObject() / readObject()")
|
||||
@Test
|
||||
public void testStringStringMap() throws ExecutionException, InterruptedException, IOException {
|
||||
|
||||
|
||||
@@ -735,8 +735,7 @@ public class ChronicleMapTest {
|
||||
.of(LongValue.class, LongValue.class)
|
||||
.entries(entries)
|
||||
.entryAndValueAlignment(OF_8_BYTES)
|
||||
.actualSegments(8 * 1024)
|
||||
.entrySize(16);
|
||||
.actualSegments(8 * 1024);
|
||||
|
||||
File tmpFile = File.createTempFile("testAcquirePerf", ".deleteme");
|
||||
tmpFile.deleteOnExit();
|
||||
|
||||
@@ -60,6 +60,7 @@ public class EntryCountMapTest {
|
||||
return mapBuilder.createPersistedTo(getPersistenceFile());
|
||||
}
|
||||
|
||||
@Ignore("HCOLL-251 Investigate test failure of net.openhft.chronicle.map.EntryCountMapTest")
|
||||
@Test
|
||||
public void testVerySmall() throws Exception {
|
||||
for (int t = 0; t < 5; t++) {
|
||||
@@ -108,6 +109,7 @@ public class EntryCountMapTest {
|
||||
System.out.printf("Score: %.2f%n", scoreCount / score);
|
||||
}
|
||||
|
||||
@Ignore("HCOLL-251 Investigate test failure of net.openhft.chronicle.map.EntryCountMapTest")
|
||||
@Test
|
||||
public void testSmall() throws Exception {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
|
||||
Reference in New Issue
Block a user