我正在尝试创建一个从适配器执行仿函数的线程类.代码显示了我的尝试.
#include <iostream>
struct null_t { };
typedef void (*thread_func_t)();
typedef void (*thread_func_2_t)(int);
template <typename F, typename P = null_t>
class adapter
{
public:
adapter(F f, P p = null_t()) : _f(f), _p(p) {}
void operator ()()
{
_f(_p);
}
private:
F _f;
P _p;
};
template <typename T>
class thread
{
public:
explicit thread(T f) : _f(f) { }
void run()
{
_f();
}
private:
T _f;
};
void show_hello()
{
std::cout << "hello" << std::endl;
}
void show_num(int …Run Code Online (Sandbox Code Playgroud) 安装模块后,我的脚本在原始版本的 Ubuntu 10.10 上成功运行lxml。(蟒蛇2.6.6)
所以我手动编译并安装了 pyhton2.7 (来自源代码)。我的脚本不再起作用:
Error: ImportError: No module named lxml
Run Code Online (Sandbox Code Playgroud)
我已经返回到python2.6.7(从源代码),但错误仍然发生。调用正确的 python 版本 (2.6.7)。
注意:python-lxml错误发生后我多次删除并重新安装该软件包。错误依然存在:
sudo aptitude install pyhton-lxml
Run Code Online (Sandbox Code Playgroud)
我是否必须执行某种神奇的脚本才能让 python 找到模块?
下面是命令的输出:(strace ./RunScriptPython.py带有python -v)
$ strace ./RunScriptPython.sh
execve("./RunScriptPython.sh", ["./RunScriptPython.sh"], [/* 38 vars */]) = 0
brk(0) = 0x9be3000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb770c000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下代码从Kafka主题获取JSON:
public class FlinkMain {
public static void main(String[] args) throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
// parse user parameters
ParameterTool parameterTool = ParameterTool.fromArgs(args);
DataStream messageStream = env.addSource(
new FlinkKafkaConsumer09<>(parameterTool.getRequired("topic")
, new JSONKeyValueDeserializationSchema(false), parameterTool.getProperties()));
messageStream.map(new MapFunction<String, String>() {
private static final long serialVersionUID = -6867736771747690202L;
@Override
public String map(String value) throws Exception {
return "Kafka and Flink says: " + value;
}
});
env.execute();
}
}
Run Code Online (Sandbox Code Playgroud)
}
问题是:
1)此程序未运行到期
Exception in thread "main" org.apache.flink.api.common.functions.InvalidTypesException: The return type of function …Run Code Online (Sandbox Code Playgroud)