Hi,
I need chronicle map key to be a collection of integers and strings(datatypes defined at runtime)
I referred following for ByteArray implementation in Chronicle Maps:
Similarly, I created an object array
public interface IObjectArray {
public void setObjectAt(@MaxSize(12) int index, Object obj);
public Object getObjectAt(int index);
}
I created the chronicle map as follows:
ChronicleMapBuilder<IObjectArray, IntValue> builder = ChronicleMapBuilder
.of(IObjectArray.class,IntValue.class).entries(1000000);
ChronicleMap<IObjectArray, IntValue> hashMap = builder.create();
IObjectArray key = DataValueClasses.newDirectInstance(IObjectArray.class);//hashMap.newKeyInstance();
Object obj1 = DataValueClasses.newDirectInstance(IntValue.class);
Object obj2 = DataValueClasses.newDirectInstance(IntValue.class);
IntValue value = hashMap.newValueInstance();
I set the records in map as follows:
for (int i = 0; i < max; i++) {
((IntValue) obj1).setValue(i*10);
key4.setObjectAt(0, obj1);
((IntValue) obj2).setValue(i*20);
key4.setObjectAt(1, obj2);
if (!(hashMap.containsKey(key))) {
value.setValue(i);
hashMap.put(key, value);
} else {
hashMap.acquireUsing(key, value);
value.addAtomicValue(10);
}
}
I get following error:
Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: type must be an interface, was class java.lang.Object
at net.openhft.lang.model.DataValueClassCache.newDirectReference(DataValueClassCache.java:41)
at net.openhft.lang.model.DataValueClasses.newDirectReference(DataValueClasses.java:40)
at net.openhft.lang.model.DataValueClasses.newDirectInstance(DataValueClasses.java:44)
at tests.AggregationTests.main(AggregationTests.java:116)
Caused by: java.lang.IllegalArgumentException: type must be an interface, was class java.lang.Object
at net.openhft.lang.model.DataValueModelImpl.<init>(DataValueModelImpl.java:64)
at net.openhft.lang.model.DataValueModelImpl.<init>(DataValueModelImpl.java:217)
at net.openhft.lang.model.DataValueModels.acquireModel(DataValueModels.java:44)
at net.openhft.lang.model.DataValueGenerator.acquireNativeClass(DataValueGenerator.java:783)
at net.openhft.lang.model.DataValueClassCache.directClassFor(DataValueClassCache.java:50)
at net.openhft.lang.model.DataValueClassCache.newDirectReference(DataValueClassCache.java:39)
... 3 more
Any help would be appreciated.
Thanks,
Sayali