小编Phi*_*ßen的帖子

如何使用OSRM计算单源最短路径?

我最近一直在玩OSRM路由库.它似乎在解决最短路径问题方面非常有效.但是,我没有看到如何用它计算单源最短路径.更确切地说,给定固定的起始点,计算到达给定距离限制内可达到的所有位置的最短距离(例如,可在30分钟内到达).

OSRM在内部使用收缩层次结构.根据我的理解,当计算真实世界数据中两个位置之间的距离时,这种技术优于Dijkstra算法.但是,对于我的问题,Dijkstra的算法似乎更合适,不是吗?

OSRM是否提供API来计算单源最短路径问题(距离限制)?是否有其他免费路由库更适合此类问题?最好是对OpenStreetMap数据有良好支持的.

algorithm dijkstra openstreetmap graph-algorithm osrm

8
推荐指数
1
解决办法
1764
查看次数

IDEA中是否有@NonNullByDefault注释?

Eclipse具有@NonNullByDefault注释,它将所有值视为@NonNull除非您明确地将它们注释为@Nullable.

IntelliJ IDEA中是否有等效选项,或者您是否必须始终使用@Nonnull

java null static-analysis intellij-idea

8
推荐指数
2
解决办法
2622
查看次数

如何在测试中启用Spring的自动配置报告?

我刚刚发现Spring有一个调试模式,它可以提供有关自动配置的见解.对于服务器,可以通过--debug作为应用程序参数传递来启用它.

有没有办法为测试启用调试模式(用它执行SpringJUnit4ClassRunner)?


如果自动配置报告正在运行,它应该打印一些输出,如下所示:

=========================
AUTO-CONFIGURATION REPORT
=========================


Positive matches:
-----------------

   ConfigServiceBootstrapConfiguration#configServicePropertySource matched
      - matched (OnPropertyCondition)

   ConfigurationPropertiesRebinderAutoConfiguration matched
      - @ConditionalOnBean (types: org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor; SearchStrategy: all) found the following [org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor] (OnBeanCondition)

   ConfigurationPropertiesRebinderAutoConfiguration#configurationPropertiesBeans matched
      - @ConditionalOnMissingBean (types: org.springframework.cloud.context.properties.ConfigurationPropertiesBeans; SearchStrategy: current) found no beans (OnBeanCondition)

   ConfigurationPropertiesRebinderAutoConfiguration#configurationPropertiesRebinder matched
      - @ConditionalOnMissingBean (types: org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder; SearchStrategy: current) found no beans (OnBeanCondition)

   EncryptionBootstrapConfiguration matched
      - @ConditionalOnClass classes found: org.springframework.security.crypto.encrypt.TextEncryptor (OnClassCondition)

   PropertyPlaceholderAutoConfiguration#propertySourcesPlaceholderConfigurer matched
      - @ConditionalOnMissingBean (types: org.springframework.context.support.PropertySourcesPlaceholderConfigurer; SearchStrategy: current) found no beans (OnBeanCondition)


Negative matches:
-----------------

   ConfigServiceBootstrapConfiguration.RetryConfiguration …
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot

8
推荐指数
1
解决办法
9089
查看次数

GRPC微服务架构实现

在微服务架构中,是否建议集中收集原型文件,并将其作为客户端和服务器的依赖项?或每个客户端和服务器只有1个原型文件?

architecture protocol-buffers node.js microservices grpc

8
推荐指数
1
解决办法
508
查看次数

当-std = c ++ 11选项被删除时,clang ++仅使用boost :: format编译C++ 11程序

请查看以下C++ 11片段:

#include <boost/format.hpp>

int main(int argc, char** argv)
{
  auto s = boost::format("");
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我用clang编译它时,-std=c++11我得到以下错误:

$ clang++ -std=c++11 -o main main.cpp
In file included from main.cpp:1:
In file included from /usr/include/boost/format.hpp:19:
In file included from /usr/include/boost/detail/workaround.hpp:41:
In file included from /usr/include/boost/config.hpp:40:
In file included from /usr/include/boost/config/select_stdlib_config.hpp:18:
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/cstddef:51:11: error: 
      no member named 'max_align_t' in the global namespace
  using ::max_align_t;
        ~~^
1 error generated.
Run Code Online (Sandbox Code Playgroud)

没有-std=c++11一切编译好,但clang打印警告:

$ clang++ -o main main.cpp
main.cpp:5:3: warning: 'auto' type specifier …
Run Code Online (Sandbox Code Playgroud)

c++ gcc boost clang c++11

7
推荐指数
1
解决办法
1822
查看次数

我什么时候应该在 Spring 中使用 TypeExcludeFilters?

最近,Spring Boot 添加了TypeExcludeFilters。一个突出的用例是SpringBootApplication注释。

Spring Boot 1.4 之前:

// ...
@ComponentScan
public @interface SpringBootApplication {
// ...
Run Code Online (Sandbox Code Playgroud)

从 Spring Boot 1.4 开始:

// ...
@ComponentScan(excludeFilters = @Filter(type = FilterType.CUSTOM, 
   classes = TypeExcludeFilter.class))
public @interface SpringBootApplication {
// ...
Run Code Online (Sandbox Code Playgroud)

主要动机似乎是改进 Spring 中的测试支持,但我无法直观地理解它的作用以及它在什么情况下可以带来好处。

有人可以用一个简单的例子说明如何使用这个新概念吗?


背景:更改发生在 Spring 1.4.0 中,提交为 513dec718fd3e7449ec76b6a916f4696d1942d5d

添加一个新的 TypeFilter 专门用于排除候选组件。该过滤器应用于@SpringBootApplication并允许测试动态贡献排除过滤器,以便可以排除特定类别的组件。

参见gh-5295
参见gh-4901

java spring spring-test spring-boot

7
推荐指数
1
解决办法
5548
查看次数

AWS是否支持加权负载均衡?

AWS本身是否支持加权负载平衡?

从我看来,ELB仅支持循环负载平衡(没有任何可配置的权重)。不过,我还没有找到可靠的文档。


我想到的最简单的方法是在其前面放置一个负载均衡器,例如Nginx,例如:

upstream backend  {
  server backend1.example.com weight=1;
  server backend2.example.com weight=2;
  server backend3.example.com weight=4;
}
Run Code Online (Sandbox Code Playgroud)

在这里,在七个请求中,一个将转到后端1,两个将转到后端2,四个将转到后端4。

它可以工作,但这也意味着您必须为此使用Nginx设置服务器。如果AWS直接支持加权负载平衡,则设置起来会容易得多。

load-balancing amazon-web-services amazon-elb elastic-load-balancer

7
推荐指数
2
解决办法
5864
查看次数

std :: tuple和boost :: tuple之间的转换

鉴于boost::tuplestd::tuple,你如何在他们之间转换?

换句话说,您将如何实现以下两个功能?

template <typename... T> boost::tuple<T...> asBoostTuple(  std::tuple<T...> stdTuple);
template <typename... T>   std::tuple<T...> asStdTuple  (boost::tuple<T...> boostTuple);
Run Code Online (Sandbox Code Playgroud)

似乎是一件简单的事情,但我找不到任何好的解决方案.


我尝试了什么?

我最终用模板编程来解决它.它似乎适用于我的具体设置,但它感觉不对(太冗长),我甚至不确定它是否真的适用于所有情况(我稍后会谈到这一点).

无论如何,这是有趣的部分:

template<int offset, typename... T>
struct CopyStdTupleHelper
{
    static void copy(boost::tuple<T...> source, std::tuple<T...>& target) {
        std::get<offset>(target) = std::move(boost::get<offset>(source));
        CopyStdTupleHelper<offset - 1, T...>::copy(source, target);
    }

    static void copy(std::tuple<T...> source, boost::tuple<T...>& target) {
        boost::get<offset>(target) = std::move(std::get<offset>(source));
        CopyStdTupleHelper<offset - 1, T...>::copy(source, target);
    }
};

template<typename... T>
struct CopyStdTupleHelper<-1, T...>
{
    static void copy(boost::tuple<T...> source, std::tuple<T...>& target)
      { /* nothing to …
Run Code Online (Sandbox Code Playgroud)

c++ boost tuples variadic-templates c++14

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

在混合Java/Kotlin项目中使用Dagger 2的Maven配置

在混合Java/Kotlin项目中使用Dagger 2的推荐Maven设置是什么?

我找到了一个使用Gradle的示例项目:https://github.com/damianpetla/kotlin-dagger-example 与Maven类似的东西会非常有用.


更新:我尝试了什么?

我用从科特林配置kotlinlang.org/docs/reference/using-maven.html 和匕首配置google.github.io/dagger.我还使用了build-helper-maven-plugin插件来集成IDEA中的注释处理.

我的主要问题是我遇到了编译周期.我的配置混合了Kotlin的编译并调用了注释处理器,它生成了Dagger2类.我没有系统地尝试将两个阶段分开但缺乏更深入的Maven理解以使其工作.

java maven kotlin dagger-2

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

核心连通组件算法

对于无向图,我有4,000,000,000(40亿)个边.它们在大型文本文件中表示为节点ID对.我想计算此图的连接组件.不幸的是,一旦你将带有边缘的节点ID加载到内存中,这就需要超过128GB的RAM.

是否有一个用于查找相对简单的连接组件的核心算法?或者甚至更好,它可以与Unix命令工具和现有(python)库拼凑在一起吗?

algorithm graph space-complexity

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