本文整理汇总了Java中org.elasticsearch.common.collect.Iterables类的典型用法代码示例。如果您正苦于以下问题:Java Iterables类的具体用法?Java Iterables怎么用?Java Iterables使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Iterables类属于org.elasticsearch.common.collect包,在下文中一共展示了Iterables类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: index
import org.elasticsearch.common.collect.Iterables; //导入依赖的package包/类
/**
* Add the record to the index.
*/
@Override
public void index(Record record) {
if (this.client == null) {
this.init();
}
String id = null;
Map<String, Object> json = new HashMap<String, Object>();
for (String propname : record.getProperties()) {
Property prop = config.getPropertyByName(propname);
if (prop == null) {
throw new DukeConfigException("Record has property " + propname
+ " for which there is no configuration");
}
if (prop.isIdProperty()) {
id = record.getValue(propname);
} else {
Collection<String> values = record.getValues(propname);
if (values != null && !values.isEmpty()) {
if (values.size() == 1) {
json.put(propname, Iterables.get(values, 0));
} else {
json.put(propname, values);
}
}
}
}
this.addToIndex(id, json);
}
示例2: ensureValidKeyNames
import org.elasticsearch.common.collect.Iterables; //导入依赖的package包/类
private void ensureValidKeyNames()
{
assertThat(Iterables.any(statsdMockServer.content, containsPattern("\\.\\.")), is(false));
assertThat(Iterables.any(statsdMockServer.content, containsPattern("\\[")), is(false));
assertThat(Iterables.any(statsdMockServer.content, containsPattern("\\]")), is(false));
assertThat(Iterables.any(statsdMockServer.content, containsPattern("\\(")), is(false));
assertThat(Iterables.any(statsdMockServer.content, containsPattern("\\)")), is(false));
}
示例3: getAllStashProjectKeys
import org.elasticsearch.common.collect.Iterables; //导入依赖的package包/类
private Iterable<String> getAllStashProjectKeys() {
String url = baseUrl + "/projects" + "?" + ALL;
String response = stashRestClient.performGetRequest(url);
List<StashProject> projects = parser.extractStashProjects(response);
return Iterables.transform(projects, new Function<StashProject, String>() {
@Override
public String apply(StashProject stashProject) {
return stashProject.getKey();
}
});
}
示例4: ensureValidKeyNames
import org.elasticsearch.common.collect.Iterables; //导入依赖的package包/类
private void ensureValidKeyNames() {
assertThat(Iterables.any(graphiteMockServer.content, containsPattern("\\.\\.")), is(false));
assertThat(Iterables.any(graphiteMockServer.content, containsPattern("\\[")), is(false));
assertThat(Iterables.any(graphiteMockServer.content, containsPattern("\\]")), is(false));
assertThat(Iterables.any(graphiteMockServer.content, containsPattern("\\(")), is(false));
assertThat(Iterables.any(graphiteMockServer.content, containsPattern("\\)")), is(false));
}
示例5: init
import org.elasticsearch.common.collect.Iterables; //导入依赖的package包/类
private void init() {
this.setupConnection();
// Create index if it does not already exist
IndicesExistsResponse response = client.admin().indices()
.exists(new IndicesExistsRequest(indexName)).actionGet();
boolean forceCreate = false;
if (response.isExists() && !this.overwrite) {
client.admin().indices().prepareDelete(this.indexName).execute()
.actionGet();
forceCreate = true;
}
if (!response.isExists() || forceCreate) {
CreateIndexResponse create = client.admin().indices()
.prepareCreate(indexName).execute().actionGet();
try {
Thread.sleep(200);
} catch (InterruptedException e) {
throw new RuntimeException(
"Interrupted while waiting for index to settle in", e);
}
if (!create.isAcknowledged()) {
throw new IllegalArgumentException("Could not create index: "
+ indexName);
}
// create mapping
// XContentBuilder builder = null;
// try {
// builder =
// XContentFactory.jsonBuilder().startObject().startObject(this.indexType).startObject("properties");
// for (Property p : config.getProperties()) {
// if (!p.isIdProperty()) {
// // TODO: experiment similarity OKAPY BM25 for short
// // fields
// //
// (http://info.elasticsearch.com/rs/elasticsearch/images/What's%20new%20in%200.90%205-3-12.pdf)
// builder.startObject(p.getName()).field("type",
// "string").field("store", "yes").field("index", "analyzed")
// .endObject();
// }
// }
// builder.endObject().endObject().endObject();
// } catch (IOException e) {
// e.printStackTrace();
// }
// PutMappingResponse pmrb =
// client.admin().indices().preparePutMapping(this.indexName).setType(this.indexType).setSource(builder)
// .execute().actionGet();
}
// find id property
Collection<Property> identityProperties = this.config
.getIdentityProperties();
if (identityProperties == null || identityProperties.size() != 1) {
throw new java.lang.IllegalStateException(
"Unable to handle entities without single id");
}
this.idProperty = Iterables.get(identityProperties, 0);
// disable index refresh interval to improve indexing performance
// this is enabled back in commit()
ImmutableSettings.Builder indexSettings = ImmutableSettings
.settingsBuilder();
indexSettings.put("refresh_interval", -1);
this.client.admin().indices().prepareUpdateSettings(this.indexName)
.setSettings(indexSettings).execute().actionGet();
this.bulkRequest = this.client.prepareBulk();
}
示例6: assertStatsdMetricIsContained
import org.elasticsearch.common.collect.Iterables; //导入依赖的package包/类
private void assertStatsdMetricIsContained(final String id)
{
assertThat(Iterables.any(statsdMockServer.content, containsPattern(id)), is(true));
}
示例7: assertGraphiteMetricIsContained
import org.elasticsearch.common.collect.Iterables; //导入依赖的package包/类
private void assertGraphiteMetricIsContained(final String id) {
assertThat(Iterables.any(graphiteMockServer.content, containsPattern(id)), is(true));
}
示例8: assertGraphiteMetricIsNotContained
import org.elasticsearch.common.collect.Iterables; //导入依赖的package包/类
private void assertGraphiteMetricIsNotContained(final String id) {
assertThat(Iterables.any(graphiteMockServer.content, containsPattern(id)), is(false));
}