我在Utils类中有以下可用方法:
protected <U> U withTx(Function<OrientGraph, U> fc) {
// do something with the function
}
protected void withTx(Consumer<OrientGraph> consumer) {
withTx(g -> {
consumer.accept(g);
return null;
});
}
Run Code Online (Sandbox Code Playgroud)
在myClass我的方法中:
withTx(g -> anotherMethod(g));
Run Code Online (Sandbox Code Playgroud)
第二段代码有一个编译错误:
The method withTx(Function<OrientGraph, Object>) is ambiguous for the type myClass
我想这来自编译器,它无法确定lambda是a Consumer还是a Function.是否有一种消除歧视这种情况的高尚方式?
无论方法anotherMethod返回什么(void,Object什么),我都不想使用这个返回值.
一种解决方案是:
withTx(g -> { anotherMethod(g); });
Run Code Online (Sandbox Code Playgroud)
但我想知道是否有更好的东西,因为这会触发SonarLint.
是否可以将显示的时间存储@time在变量中?
例如下面的代码
for i in 1:10
@time my_function(i)
end
Run Code Online (Sandbox Code Playgroud)
显示我的函数的墙时间my_function,但我想将毫秒数存储在一个数组中,以便将其显示在一个图中,显示关于参数的执行时间的演变i。
我正在使用 Hamcrest 对 REST API 进行单元测试。
当我发送请求时,我经常检查这样的200状态代码:
public void myTest() {
url = "route/to/my/rest/api/";
secured().when().get(url).then().statusCode(200);
}
Run Code Online (Sandbox Code Playgroud)
但是当我得到错误的代码状态时,我只会得到一个断言错误。当状态代码不匹配时,有没有办法自动转储响应正文(其中包含错误)?
该secured()方法:
public RequestSpecification secured() {
return given().header("Authorization", "Bearer " + getAuth());
}
Run Code Online (Sandbox Code Playgroud) 使用这个效果很好
@ResponseStatus(value = HttpStatus.NOT_FOUND)
@ExceptionHandler(value = IoTException.class)
public void IoTError() {
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试转换为另一个自制异常时
@ExceptionHandler(value = IoTException.class)
public void IoTError() {
throw new IoTConnectionException();
}
Run Code Online (Sandbox Code Playgroud)
异常处理程序被忽略,即IoTException发送到视图而不转换为IoTConnectionException. 但是放置断点让我进入了该IoTError方法。知道为什么吗?谢谢 :)
我有一个名为docker的镜像my_image,它启动命令并关闭。
使用命令在容器中运行映像时docker run --rm my_image,是否可以测量容器的执行时间?
编辑:
容器执行后,我需要查看这些计时信息,因此无法使用time命令。
我以某种方式希望找到由docker保留的一些容器执行历史,即使--rm使用过也是如此。但是,如果它不存在,那么@tgogos的答案是合适的。
目的是比较几个图像的执行时间,以得出关于所使用的不同工具的结论。
我正在尝试在本地托管一个 Spark 独立集群。我有两台连接在 LAN 上的异构计算机。下面列出的架构的每个部分都在 docker 上运行。我有以下配置
我使用一个测试应用程序来打开一个文件并计算其行数。当文件复制到所有工作人员上并且我使用时,该应用程序可以工作SparkContext.readText()
但是,当我在工作人员上访问该文件时,该文件仅存在于SparkContext.parallelize()工作人员上时,我会显示以下内容:
INFO StandaloneSchedulerBackend: Granted executor ID app-20180116210619-0007/4 on hostPort 172.17.0.3:6598 with 4 cores, 1024.0 MB RAM
INFO StandaloneAppClient$ClientEndpoint: Executor updated: app-20180116210619-0007/4 is now RUNNING
INFO StandaloneAppClient$ClientEndpoint: Executor updated: app-20180116210619-0007/4 is now EXITED (Command exited with code 1)
INFO StandaloneSchedulerBackend: Executor app-20180116210619-0007/4 removed: Command exited with code 1
INFO StandaloneAppClient$ClientEndpoint: Executor added: app-20180116210619-0007/5 on worker-20180116205132-172.17.0.3-6598 (172.17.0.3:6598) with 4 …Run Code Online (Sandbox Code Playgroud) 我正在使用 Junit 5 注释@TestFactory生成多个测试,如下所示:
@TestFactory
public Collection<DynamicTest> myTest() throws IOException {
return fetchSomeTests().stream()
.map(test -> {
return dynamicTest(test.get("testDescription"), () -> doMyTest(test));
}).collect(Collectors.toList());
}
Run Code Online (Sandbox Code Playgroud)
是否可以将生成的测试分组,就像使用不同类时一样@Test?
我有以下代码
using Plots
function test()::nothing
A::Array{Float64,1} = rand(Float64,100)
plot(A)
end
Run Code Online (Sandbox Code Playgroud)
我像这样在朱莉娅中运行
julia> include("main.jl")
test (generic function with 1 method)
julia> test()
ERROR: MethodError: First argument to `convert` must be a Type, got nothing
Stacktrace:
[1] test() at /path/to/main.jl:85
[2] top-level scope at REPL[2]:1
Run Code Online (Sandbox Code Playgroud)
为什么我会收到错误消息First argument to convert must be a Type, got nothing?
java ×2
julia ×2
apache-spark ×1
docker ×1
hamcrest ×1
java-8 ×1
julia-plots ×1
junit ×1
junit5 ×1
lambda ×1
rest ×1
rest-assured ×1
spark-submit ×1
spring ×1
spring-boot ×1
testing ×1
time ×1
unit-testing ×1