这是我的一段代码
MyValue sampleValue = Values.newHeapInstance(MyValue.class);
// subsequently set the couple of floats and int i have defined in MyValue interface
ChronicleMap<MyKey, MyValue> cache = ChronicleMapBuilder.of(MyKey.class, MyValue.class)
.entries(100)
.averageValue(sampleValue)
.create();
当我这样做时,我得到了错误
java.lang.IllegalArgumentException:使用 BytesMarshallable 和 net.openhft.chronicle.map.ChronicleMapBuilder.averageValue(ChronicleMapBuilder.java:660) 不支持的接口值类型
有人可以帮我理解这种使用模式是否不正确吗?
如果我更改为通过实现一个具体类来创建 MyValue 然后按如下方式对其进行新的操作:
MyValue sampleValue = new MyValueImpl();
// subsequently set the couple of floats and int i have defined in MyValue interface
ChronicleMap<MyKey, MyValue> cache = ChronicleMapBuilder.of(MyKey.class, MyValue.class)
.entries(100)
.averageValue(sampleValue)
.create();