我在debian jessie上安装elasticsearch 1.7.3.它使用默认配置文件并正常工作.但是当我调用sudo /usr/share/elasticsearch/bin/plugin它时会返回一个错误:
Exception in thread "main" org.elasticsearch.env.FailedToResolveConfigException: Failed to resolve config path ["/usr/share/elasticsearch/config/elasticsearch.yml"], tried file path ["/usr/share/elasticsearch/config/elasticsearch.yml"], path file ["/usr/share/elasticsearch/config"/"/usr/share/elasticsearch/config/elasticsearch.yml"], and classpath
at org.elasticsearch.env.Environment.resolveConfig(Environment.java:291)
at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareSettings(InternalSettingsPreparer.java:95)
at org.elasticsearch.plugins.PluginManager.main(PluginManager.java:396)
Run Code Online (Sandbox Code Playgroud)
文件/usr/share/elasticsearch/config/elasticsearch.yml存在,我可以用nano打开他.
有/ etc/default/elasticsearch文件:
# Start Elasticsearch automatically
START_DAEMON=true
# Run Elasticsearch as this user ID and group ID
#ES_USER=elasticsearch
#ES_GROUP=elasticsearch
# Heap Size (defaults to 256m min, 1g max)
#ES_HEAP_SIZE=2g
# Heap new generation
#ES_HEAP_NEWSIZE=
# max direct memory
#ES_DIRECT_SIZE=
# Maximum number of open files, …Run Code Online (Sandbox Code Playgroud) Postgresql 9.4具有数组函数.其中之一是array_length(anyarray, int).得到两个论点.
第二个论点是什么?在所有例子中它都有价值1.但是没有地方说它是什么.
我已经打印了一些文字println!.现在我需要清除终端并写新文本.如何清除终端中的所有当前文本?
我试过这段代码.但它只清除了当前的行,并且1在输出中很明显.
fn main() {
println!("1");
print!("2");
print!("\r");
}
Run Code Online (Sandbox Code Playgroud) 我有一个成功编译的简单图表:
use std::collections::HashMap;
type Key = usize;
type Weight = usize;
#[derive(Debug)]
pub struct Node<T> {
key: Key,
value: T,
}
impl<T> Node<T> {
fn new(key: Key, value: T) -> Self {
Node {
key: key,
value: value,
}
}
}
#[derive(Debug)]
pub struct Graph<T> {
map: HashMap<Key, HashMap<Key, Weight>>,
list: HashMap<Key, Node<T>>,
next_key: Key,
}
impl<T> Graph<T> {
pub fn new() -> Self {
Graph {
map: HashMap::new(),
list: HashMap::new(),
next_key: 0,
}
}
pub fn add_node(&mut self, value: …Run Code Online (Sandbox Code Playgroud) 我不明白 Rust 如何处理字符串。我创建了一个带有两个字符串字段和一个方法的简单结构。此方法连接两个字段和参数中的字符串。我的代码:
fn main() {
let obj = MyStruct {
field_1: "first".to_string(),
field_2: "second".to_string(),
};
let data = obj.get_data("myWord");
println!("{}",data);
}
struct MyStruct {
field_1: String,
field_2: String,
}
impl MyStruct {
fn get_data<'a>(&'a self, word: &'a str) -> &'a str {
let sx = &self.field_1 + &self.field_2 + word;
&* sx
}
}
Run Code Online (Sandbox Code Playgroud)
运行时出现错误:
src\main.rs:18:18: 18:31 error: binary operation `+` cannot be applied to type `&collections::string::String` [E0369]
src\main.rs:18 let sx = &self.field_1 + &self.field_2 + word;
^~~~~~~~~~~~~
src\main.rs:19:10: …Run Code Online (Sandbox Code Playgroud) 如何获得指向函数的指针u32?
我有一个函数,指向函数的指针:
fn getter_of_functions<T>(pointer: T) {
// ...
/*
This code don't compile ...
let fun_ptr: u32 = unsafe {
mem::transmute::<T, u32>(callback)
};
*/
}
fn function() {
println!("hello ...");
}
getter_of_functions(function);
Run Code Online (Sandbox Code Playgroud)
如何获得它(我必须有一个通用的功能)?我经常犯的错误是:
cannot transmute to or from a type that contains unsubstituted type parameters
Run Code Online (Sandbox Code Playgroud)