小编inj*_*cto的帖子

具有Java 8的Avro日期为逻辑类型

最新的Avro编译器(1.8.2)使用基于Joda-Time的实现为日期逻辑类型生成java源.如何配置Avro编译器以生成使用Java 8日期时间API的源?

java avro java-8

15
推荐指数
2
解决办法
4920
查看次数

如何出于开发目的禁用Spring Cloud Stream绑定?

我需要禁用事件的发布和订阅才能进行开发,但是我无法为此找到一些配置属性/其他解决方案。我怎样才能做到这一点?

可能的解决方案:使用@EnableBinding某些属性集创建自动配置,并在禁用的情况下,用生成的无操作存根替换所有绑定接口。但是也许存在更简单的解决方案?

spring-boot spring-cloud-stream

6
推荐指数
1
解决办法
2753
查看次数

OptaPlanner的神话评分腐败

我为我的模型使用增量分数计算器.在"完全断言"模式下优化几小时/几天后,抛出了分数损坏异常:

java.lang.IllegalStateException: Score corruption: the workingScore (-86591/-2765/-422/-591) is not the uncorruptedScore (-86591/-2873/-422/-591) after completedAction [...]:
Uncorrupted: Score calculator 3718238 [schedule=Schedule6422-2015-04-16T09:47:36.932[-86591/-2873/-422/-591], prioritiesScore=-422, timelineGapsScore=-2873, requirementGapsScore=-86591, timelineVersionsScore=-591]
Corrupted: Score calculator 3717237 [schedule=Schedule6422-2015-04-16T09:47:36.932[-86591/-2873/-422/-591], prioritiesScore=-422, timelineGapsScore=-2873, requirementGapsScore=-86591, timelineVersionsScore=-591]
Run Code Online (Sandbox Code Playgroud)

这个分数在参数上有所不同timelineGapsScore.分数实例从分数计算对象字段创建的prioritiesScore,timelineGapsScore,requirementGapsScoretimelineVersionsScore.按日志记录,这两个分数的实例在这些字段中是等效的,但是optaplanner引擎找到差异(-86591/-2765/-422/-591)vs(-86591/-2873/-422/-591).怎么可能?

我怀疑解决方案克隆上的引用泄漏(它是特定的实现并进行深度复制),但仔细的代码检查不会显示此类错误.

UPD:我忘了提及:optaplanner以守护进程模式运行,模型能够实时更改事实.所以我怀疑模型中的竞争条件.但我不知道如何在optaplanner的引擎盖下实现注入变化(文档中的信息不够).

java optimization optaplanner

5
推荐指数
1
解决办法
691
查看次数

第三方库中的通用方法限制规避

我使用cqengine进行集合索引:

Attribute<UtilizationEntry, LocalDate> startDateAttr = new SimpleAttribute<UtilizationEntry, LocalDate>() {
    @Override
    public LocalDate getValue(UtilizationEntry object, QueryOptions queryOptions) {
        return object.getStartDate();
    }
};
IndexedCollection<UtilizationEntry> entries = new ConcurrentIndexedCollection<>();
entries.addIndex(NavigableIndex.onAttribute(startDateAttr)); // compilation error in this line
Run Code Online (Sandbox Code Playgroud)

此代码未编译,因为:

Error:(61, 70) java: no suitable method found for onAttribute(com.googlecode.cqengine.attribute.Attribute<entities.UtilizationEntry,java.time.LocalDate>)
method com.googlecode.cqengine.index.navigable.NavigableIndex.<A,O>onAttribute(com.googlecode.cqengine.attribute.Attribute<O,A>) is not applicable
  (inferred type does not conform to equality constraint(s)
    inferred: java.time.chrono.ChronoLocalDate
    equality constraints(s): java.time.chrono.ChronoLocalDate,java.time.LocalDate)
method com.googlecode.cqengine.index.navigable.NavigableIndex.<A,O>onAttribute(com.googlecode.cqengine.index.support.Factory<java.util.concurrent.ConcurrentNavigableMap<A,com.googlecode.cqengine.resultset.stored.StoredResultSet<O>>>,com.googlecode.cqengine.index.support.Factory<com.googlecode.cqengine.resultset.stored.StoredResultSet<O>>,com.googlecode.cqengine.attribute.Attribute<O,A>) is not applicable
  (cannot infer type-variable(s) A,O
    (actual and formal argument lists differ in length)) …
Run Code Online (Sandbox Code Playgroud)

java generics java-8 cqengine

3
推荐指数
1
解决办法
180
查看次数